From 425d6e00ebf0c0cce2e7e16f9ea57e6e847786f9 Mon Sep 17 00:00:00 2001 From: insistence <3055204202@qq.com> Date: Fri, 8 Nov 2024 17:10:54 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E6=A0=A1=E6=A3=80=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=90=8D=E6=98=AF=E5=90=A6=E5=8C=85=E5=90=AB=E7=89=B9=E6=AE=8A?= =?UTF-8?q?=E5=AD=97=E7=AC=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/FileUpload/index.vue | 7 ++++++- .../src/components/ImageUpload/index.vue | 8 +++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/ruoyi-fastapi-frontend/src/components/FileUpload/index.vue b/ruoyi-fastapi-frontend/src/components/FileUpload/index.vue index 2af9672..a860a40 100644 --- a/ruoyi-fastapi-frontend/src/components/FileUpload/index.vue +++ b/ruoyi-fastapi-frontend/src/components/FileUpload/index.vue @@ -104,10 +104,15 @@ function handleBeforeUpload(file) { const fileExt = fileName[fileName.length - 1]; const isTypeOk = props.fileType.indexOf(fileExt) >= 0; if (!isTypeOk) { - proxy.$modal.msgError(`文件格式不正确, 请上传${props.fileType.join("/")}格式文件!`); + proxy.$modal.msgError(`文件格式不正确,请上传${props.fileType.join("/")}格式文件!`); return false; } } + // 校检文件名是否包含特殊字符 + if (file.name.includes(',')) { + proxy.$modal.msgError('文件名不正确,不能包含英文逗号!'); + return false; + } // 校检文件大小 if (props.fileSize) { const isLt = file.size / 1024 / 1024 < props.fileSize; diff --git a/ruoyi-fastapi-frontend/src/components/ImageUpload/index.vue b/ruoyi-fastapi-frontend/src/components/ImageUpload/index.vue index 9d0e048..4d19693 100644 --- a/ruoyi-fastapi-frontend/src/components/ImageUpload/index.vue +++ b/ruoyi-fastapi-frontend/src/components/ImageUpload/index.vue @@ -125,9 +125,11 @@ function handleBeforeUpload(file) { isImg = file.type.indexOf("image") > -1; } if (!isImg) { - proxy.$modal.msgError( - `文件格式不正确, 请上传${props.fileType.join("/")}图片格式文件!` - ); + proxy.$modal.msgError(`文件格式不正确,请上传${props.fileType.join("/")}图片格式文件!`); + return false; + } + if (file.name.includes(',')) { + proxy.$modal.msgError('文件名不正确,不能包含英文逗号!'); return false; } if (props.fileSize) {