From e69f71beae727b3c3577072b0a1040f8d3385ff8 Mon Sep 17 00:00:00 2001 From: huangxianhhh Date: Tue, 28 Feb 2023 10:05:05 +0800 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20=F0=9F=9A=80=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E4=B8=8A=E4=BC=A0-=E8=A7=86=E9=A2=91?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Upload/Img.vue | 15 ++++++++++++--- src/components/Upload/Imgs.vue | 14 +++++++++++--- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/components/Upload/Img.vue b/src/components/Upload/Img.vue index daadf28d..22e89ddb 100644 --- a/src/components/Upload/Img.vue +++ b/src/components/Upload/Img.vue @@ -64,7 +64,11 @@ type FileTypes = | "image/svg+xml" | "image/tiff" | "image/webp" - | "image/x-icon"; + | "image/x-icon" + | "video/mp4" + | "video/avi" + | "video/wmv" + | "video/rm"; interface UploadFileProps { imageUrl: string; // 图片地址 ==> 必传 @@ -72,7 +76,7 @@ interface UploadFileProps { drag?: boolean; // 是否支持拖拽上传 ==> 非必传(默认为 true) disabled?: boolean; // 是否禁用上传组件 ==> 非必传(默认为 false) fileSize?: number; // 图片大小限制 ==> 非必传(默认为 5M) - fileType?: FileTypes[]; // 图片类型限制 ==> 非必传(默认为 ["image/jpeg", "image/png", "image/gif"]) + fileType?: Array; // 图片类型限制 ==> 非必传(默认为 ["image/jpeg", "image/png", "image/gif"]) height?: string; // 组件高度 ==> 非必传(默认为 150px) width?: string; // 组件宽度 ==> 非必传(默认为 150px) borderRadius?: string; // 组件边框圆角 ==> 非必传(默认为 8px) @@ -150,7 +154,12 @@ const editImg = () => { const beforeUpload: UploadProps["beforeUpload"] = rawFile => { const imgSize = rawFile.size / 1024 / 1024 < props.fileSize; const imgType = props.fileType; - if (!imgType.includes(rawFile.type as FileTypes)) + + // 验证fileType传入'image/*','video/*'等参数格式 + if ( + !imgType.includes(rawFile.type as FileTypes) || + !imgType.some(_ => _.indexOf("/*") > -1 && _.split("/*")[0] === rawFile.type.split("/")[0]) + ) ElNotification({ title: "温馨提示", message: "上传图片不符合所需的格式!", diff --git a/src/components/Upload/Imgs.vue b/src/components/Upload/Imgs.vue index eadd743e..5dbcad4a 100644 --- a/src/components/Upload/Imgs.vue +++ b/src/components/Upload/Imgs.vue @@ -60,7 +60,11 @@ type FileTypes = | "image/svg+xml" | "image/tiff" | "image/webp" - | "image/x-icon"; + | "image/x-icon" + | "video/mp4" + | "video/avi" + | "video/wmv" + | "video/rm"; interface UploadFileProps { fileList: UploadUserFile[]; @@ -69,7 +73,7 @@ interface UploadFileProps { disabled?: boolean; // 是否禁用上传组件 ==> 非必传(默认为 false) limit?: number; // 最大图片上传数 ==> 非必传(默认为 5张) fileSize?: number; // 图片大小限制 ==> 非必传(默认为 5M) - fileType?: FileTypes[]; // 图片类型限制 ==> 非必传(默认为 ["image/jpeg", "image/png", "image/gif"]) + fileType?: Array; // 图片类型限制 ==> 非必传(默认为 ["image/jpeg", "image/png", "image/gif"]) height?: string; // 组件高度 ==> 非必传(默认为 150px) width?: string; // 组件宽度 ==> 非必传(默认为 150px) borderRadius?: string; // 组件边框圆角 ==> 非必传(默认为 8px) @@ -105,7 +109,11 @@ const fileList = ref(props.fileList); const beforeUpload: UploadProps["beforeUpload"] = rawFile => { const imgSize = rawFile.size / 1024 / 1024 < props.fileSize; const imgType = props.fileType; - if (!imgType.includes(rawFile.type as FileTypes)) + // 验证fileType传入'image/*','video/*'等参数格式 + if ( + !imgType.includes(rawFile.type as FileTypes) || + !imgType.some(_ => _.indexOf("/*") > -1 && _.split("/*")[0] === rawFile.type.split("/")[0]) + ) ElNotification({ title: "温馨提示", message: "上传图片不符合所需的格式!", From 0676abf58b6d87317be41d34ffdad5a8df6276e0 Mon Sep 17 00:00:00 2001 From: huangxianhhh Date: Tue, 28 Feb 2023 10:16:06 +0800 Subject: [PATCH 2/3] =?UTF-8?q?feat:=20=F0=9F=9A=80=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E4=B8=8A=E4=BC=A0-=E8=A7=86=E9=A2=91?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Upload/Img.vue | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/Upload/Img.vue b/src/components/Upload/Img.vue index 22e89ddb..e8434188 100644 --- a/src/components/Upload/Img.vue +++ b/src/components/Upload/Img.vue @@ -154,7 +154,6 @@ const editImg = () => { const beforeUpload: UploadProps["beforeUpload"] = rawFile => { const imgSize = rawFile.size / 1024 / 1024 < props.fileSize; const imgType = props.fileType; - // 验证fileType传入'image/*','video/*'等参数格式 if ( !imgType.includes(rawFile.type as FileTypes) || From a5d13d01df6dec7d2df696bb6763ad7e65e4b99b Mon Sep 17 00:00:00 2001 From: huangxianhhh Date: Wed, 1 Mar 2023 11:11:57 +0800 Subject: [PATCH 3/3] =?UTF-8?q?fix:=20=F0=9F=A7=A9=20=E9=AA=8C=E8=AF=81fil?= =?UTF-8?q?eType=E4=BC=A0=E5=85=A5=E5=8F=82=E6=95=B0=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Upload/Img.vue | 6 ++++-- src/components/Upload/Imgs.vue | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/components/Upload/Img.vue b/src/components/Upload/Img.vue index e8434188..691dcb91 100644 --- a/src/components/Upload/Img.vue +++ b/src/components/Upload/Img.vue @@ -156,8 +156,10 @@ const beforeUpload: UploadProps["beforeUpload"] = rawFile => { const imgType = props.fileType; // 验证fileType传入'image/*','video/*'等参数格式 if ( - !imgType.includes(rawFile.type as FileTypes) || - !imgType.some(_ => _.indexOf("/*") > -1 && _.split("/*")[0] === rawFile.type.split("/")[0]) + !imgType.some( + _ => + imgType.includes(rawFile.type as FileTypes) || (_.indexOf("/*") > -1 && _.split("/*")[0] === rawFile.type.split("/")[0]) + ) ) ElNotification({ title: "温馨提示", diff --git a/src/components/Upload/Imgs.vue b/src/components/Upload/Imgs.vue index 5dbcad4a..95cbcf6c 100644 --- a/src/components/Upload/Imgs.vue +++ b/src/components/Upload/Imgs.vue @@ -111,8 +111,10 @@ const beforeUpload: UploadProps["beforeUpload"] = rawFile => { const imgType = props.fileType; // 验证fileType传入'image/*','video/*'等参数格式 if ( - !imgType.includes(rawFile.type as FileTypes) || - !imgType.some(_ => _.indexOf("/*") > -1 && _.split("/*")[0] === rawFile.type.split("/")[0]) + !imgType.some( + _ => + imgType.includes(rawFile.type as FileTypes) || (_.indexOf("/*") > -1 && _.split("/*")[0] === rawFile.type.split("/")[0]) + ) ) ElNotification({ title: "温馨提示",