diff --git a/easyflow-ui-admin/app/src/components/upload/DragFileUpload.vue b/easyflow-ui-admin/app/src/components/upload/DragFileUpload.vue index 168cc3af..bffe3e85 100644 --- a/easyflow-ui-admin/app/src/components/upload/DragFileUpload.vue +++ b/easyflow-ui-admin/app/src/components/upload/DragFileUpload.vue @@ -4,6 +4,7 @@ import type { UploadProps } from 'element-plus'; import { ref } from 'vue'; import { useAppConfig } from '@easyflow/hooks'; +import { $t } from '@easyflow/locales'; import { useAccessStore } from '@easyflow/stores'; import { UploadFilled } from '@element-plus/icons-vue'; @@ -26,6 +27,8 @@ const props = defineProps({ }); const emit = defineEmits(['success', 'error', 'onChange']); +const MAX_FILE_SIZE_BYTES = 100 * 1024 * 1024; +const ACCEPTED_FILE_TYPES = '.txt,.pdf,.docx,.md,.pptx,.xlsx'; const accessStore = useAccessStore(); const headers = ref({ 'easyflow-token': accessStore.accessToken, @@ -51,6 +54,14 @@ const handleError: UploadProps['onError'] = (error) => { emit('error', normalizedError); }; +const beforeUpload: UploadProps['beforeUpload'] = (rawFile) => { + if (rawFile.size <= MAX_FILE_SIZE_BYTES) { + return true; + } + ElMessage.warning($t('message.upload.fileTooLarge')); + return false; +}; + // 文件状态变化回调 const handleChange: UploadProps['onChange'] = (file, fileList) => { emit('onChange', file, fileList); @@ -86,6 +97,8 @@ defineExpose({ drag :headers="headers" :action="`${apiURL}${props.action}`" + :accept="ACCEPTED_FILE_TYPES" + :before-upload="beforeUpload" :on-success="handleSuccess" :on-error="handleError" :on-change="handleChange" @@ -97,7 +110,7 @@ defineExpose({
{{ $t('message.upload.title') }} - {{ + {{ $t('message.upload.description') }}
diff --git a/easyflow-ui-admin/app/src/locales/langs/en-US/message.json b/easyflow-ui-admin/app/src/locales/langs/en-US/message.json index b9054035..2da70aef 100644 --- a/easyflow-ui-admin/app/src/locales/langs/en-US/message.json +++ b/easyflow-ui-admin/app/src/locales/langs/en-US/message.json @@ -27,7 +27,8 @@ "copyFail": "Copy fail", "upload": { "title": "Click or drag and drop files here to upload", - "description": "TXT, PDF, DOCX, MD, PPT, PPTX files are supported. Each upload allows one file only, with a maximum size of 20M per file." + "description": "TXT, PDF, DOCX, MD, PPTX, and XLSX files are supported, up to 100 MB each.", + "fileTooLarge": "Each file must not exceed 100 MB" }, "uploadFileFirst": "Please upload the file first", "deleteModelAlert": "This operation will delete the large model. Are you sure to delete it?", diff --git a/easyflow-ui-admin/app/src/locales/langs/zh-CN/message.json b/easyflow-ui-admin/app/src/locales/langs/zh-CN/message.json index 68b84921..45e9f268 100644 --- a/easyflow-ui-admin/app/src/locales/langs/zh-CN/message.json +++ b/easyflow-ui-admin/app/src/locales/langs/zh-CN/message.json @@ -27,7 +27,8 @@ "copyFail": "复制失败", "upload": { "title": "点击或将文件拖拽到这里上传", - "description": "TXT, PDF, DOCX, MD, PPT, PPTX 格式文件,单个大小不超过20M。" + "description": "支持 TXT、PDF、DOCX、MD、PPTX、XLSX,单个文件不超过 100 MB。", + "fileTooLarge": "单个文件大小不能超过 100 MB" }, "uploadFileFirst": "请先上传文件", "deleteModelAlert": "该操作会删除大模型,确定删除吗?",