From 507dd44465e481ef7530562e31b7f905d1e2aef5 Mon Sep 17 00:00:00 2001 From: ssongliu Date: Mon, 6 Mar 2023 18:25:21 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=96=87=E4=BB=B6=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E5=A4=87=E4=BB=BD=E5=A2=9E=E5=8A=A0=E6=A0=BC=E5=BC=8F=E5=8F=8A?= =?UTF-8?q?=E5=A4=A7=E5=B0=8F=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/components/upload/index.vue | 27 +++++++++++------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/frontend/src/components/upload/index.vue b/frontend/src/components/upload/index.vue index 8a9a9f83c..ec1725f57 100644 --- a/frontend/src/components/upload/index.vue +++ b/frontend/src/components/upload/index.vue @@ -5,14 +5,7 @@
- +
{{ $t('database.dropHelper') }} @@ -81,7 +74,7 @@ import { computeSize } from '@/utils/util'; import { useDeleteData } from '@/hooks/use-delete-data'; import { handleRecoverByUpload } from '@/api/modules/setting'; import i18n from '@/lang'; -import { UploadFile, UploadFiles, UploadInstance, UploadProps } from 'element-plus'; +import { UploadFile, UploadFiles, UploadInstance } from 'element-plus'; import { File } from '@/api/interface/file'; import DrawerHeader from '@/components/drawer-header/index.vue'; import { BatchDeleteFile, GetUploadList, UploadFileData } from '@/api/modules/files'; @@ -159,9 +152,9 @@ const onRecover = async (row: File.File) => { const uploaderFiles = ref([]); const uploadRef = ref(); -const beforeAvatarUpload: UploadProps['beforeUpload'] = (rawFile) => { +const beforeAvatarUpload = (rawFile) => { if (type.value === 'app' || type.value === 'website') { - if (rawFile.name.endsWith('.tar.gz')) { + if (!rawFile.name.endsWith('.tar.gz')) { MsgError(i18n.global.t('database.unSupportType')); return false; } else if (rawFile.size / 1024 / 1024 > 50) { @@ -171,10 +164,10 @@ const beforeAvatarUpload: UploadProps['beforeUpload'] = (rawFile) => { return true; } if ( - rawFile.name.endsWith('.sql') || - rawFile.name.endsWith('.gz') || - rawFile.name.endsWith('.zip') || - rawFile.name.endsWith('.tgz') + !rawFile.name.endsWith('.sql') || + !rawFile.name.endsWith('.gz') || + !rawFile.name.endsWith('.zip') || + !rawFile.name.endsWith('.tgz') ) { MsgError(i18n.global.t('database.unSupportType')); return false; @@ -203,6 +196,10 @@ const onSubmit = () => { if (uploaderFiles.value[0]!.raw != undefined) { formData.append('file', uploaderFiles.value[0]!.raw); } + let isOk = beforeAvatarUpload(uploaderFiles.value[0]!.raw); + if (!isOk) { + return; + } formData.append('path', baseDir.value); loading.value = true; UploadFileData(formData, {})