feat: Support file management page drag and drop upload (#10011)

#9307
This commit is contained in:
2025-08-15 17:37:04 +08:00 committed by GitHub
parent 18462296ae
commit 037da3a7fd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 19 additions and 2 deletions

View file

@ -1,5 +1,5 @@
<template>
<div>
<div @dragover="handleDragover" @drop="handleDrop" @dragleave="handleDragleave">
<div class="flex sm:flex-row flex-col justify-start gap-y-2 items-center gap-x-4" ref="toolRef">
<div class="flex-shrink-0 flex sm:w-min w-full items-center justify-start">
<el-tooltip :content="$t('file.back')" placement="top">
@ -1407,6 +1407,23 @@ const getHostMount = async () => {
}
};
const handleDrop = async (event: DragEvent) => {
event.preventDefault();
fileUpload.path = req.path;
if (!uploadRef.value?.open) {
await uploadRef.value?.handleDrop(event);
}
uploadRef.value.acceptParams(fileUpload);
};
const handleDragover = (event: DragEvent) => {
event.preventDefault();
};
const handleDragleave = (event: { preventDefault: () => void }) => {
event.preventDefault();
};
onMounted(() => {
if (localStorage.getItem('show-hidden') === null) {
localStorage.setItem('show-hidden', 'true');

View file

@ -448,7 +448,7 @@ const acceptParams = (props: UploadFileProps) => {
});
};
defineExpose({ acceptParams });
defineExpose({ acceptParams, handleDrop, open });
</script>
<style lang="scss" scoped>