From 2a59dbfbb37f87757d4179c405f47380d97d0781 Mon Sep 17 00:00:00 2001 From: RuoYi <yzz_ivy@163.com> Date: 星期二, 05 十一月 2024 12:50:44 +0800 Subject: [PATCH] 校检文件名是否包含特殊字符 --- src/components/ImageUpload/index.vue | 8 +++++--- src/components/FileUpload/index.vue | 7 ++++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/components/FileUpload/index.vue b/src/components/FileUpload/index.vue index ad67460..0d19c5e 100644 --- a/src/components/FileUpload/index.vue +++ b/src/components/FileUpload/index.vue @@ -104,10 +104,15 @@ 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('鏂囦欢鍚嶄笉姝g‘锛屼笉鑳藉寘鍚嫳鏂囬�楀彿!'); + return false; + } // 鏍℃鏂囦欢澶у皬 if (props.fileSize) { const isLt = file.size / 1024 / 1024 < props.fileSize; diff --git a/src/components/ImageUpload/index.vue b/src/components/ImageUpload/index.vue index d232da6..90999e1 100644 --- a/src/components/ImageUpload/index.vue +++ b/src/components/ImageUpload/index.vue @@ -125,9 +125,11 @@ 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('鏂囦欢鍚嶄笉姝g‘锛屼笉鑳藉寘鍚嫳鏂囬�楀彿!'); return false; } if (props.fileSize) { -- Gitblit v1.9.3