From 088a2bb308858a8beec512c80c39d0e0aeff2f74 Mon Sep 17 00:00:00 2001 From: "pikachu1995@126.com" Date: Tue, 20 Oct 2026 19:07:35 +0800 Subject: [PATCH] =?UTF-8?q?feat(oss):=20=E4=BC=98=E5=8C=96=E7=B4=A0?= =?UTF-8?q?=E6=9D=90=E5=BA=93=E4=B8=8A=E4=BC=A0=E6=A0=BC=E5=BC=8F=E9=99=90?= =?UTF-8?q?=E5=88=B6=E5=8F=8A=E7=BB=84=E4=BB=B6=E6=A8=A1=E5=BC=8F=E4=B8=8B?= =?UTF-8?q?=E7=9A=84=20Tab=20=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/sys/oss-manage/ossManage.vue | 27 +++++++++++++++---- seller/src/views/sys/oss-manage/ossManage.vue | 24 ++++++++++++++--- 2 files changed, 43 insertions(+), 8 deletions(-) diff --git a/manager/src/views/sys/oss-manage/ossManage.vue b/manager/src/views/sys/oss-manage/ossManage.vue index 4be43024f..c9834ddb4 100644 --- a/manager/src/views/sys/oss-manage/ossManage.vue +++ b/manager/src/views/sys/oss-manage/ossManage.vue @@ -137,7 +137,7 @@ - + @@ -191,6 +191,7 @@ v-if="canUploadImages" ref="upRef" :action="managerApiUrl + '/manager/common/upload/file'" + :accept="uploadAccept" :data="uploadData" :headers="accessToken" :before-upload="beforeUpload" @@ -930,13 +931,16 @@ const canShowGroups = computed(() => { return activeRoleTab.value === "MANAGER"; }); const canUploadImages = computed(() => { - return activeRoleTab.value === "MANAGER"; + return activeRoleTab.value === "MANAGER" && activeCategoryTab.value !== "FILE"; +}); +const uploadAccept = computed(() => { + if (activeCategoryTab.value === "VIDEO") return "video/*"; + return "image/*"; }); const uploadButtonText = computed(() => { const textMap = { IMAGE: "上传图片", VIDEO: "上传视频", - FILE: "上传文件", }; return textMap[activeCategoryTab.value] || "上传图片"; }); @@ -954,9 +958,22 @@ const uploadData = computed(() => { function beforeUpload(file) { if (!canUploadImages.value) { - ElMessage.warning("仅管理员模块支持上传图片"); + ElMessage.warning("当前模块不支持上传"); return false; } + if (activeCategoryTab.value === "IMAGE") { + const isImg = (file?.type && file.type.startsWith("image/")) || /\.(jpg|jpeg|png|gif|webp|bmp|svg)$/i.test(file?.name || ""); + if (!isImg) { + ElMessage.warning("请上传图片格式文件"); + return false; + } + } else if (activeCategoryTab.value === "VIDEO") { + const isVid = (file?.type && file.type.startsWith("video/")) || /\.(mp4|webm|ogg|mov|avi|mkv)$/i.test(file?.name || ""); + if (!isVid) { + ElMessage.warning("请上传视频格式文件"); + return false; + } + } const maxSize = 20480 * 1024; if (file && file.size > maxSize) { handleMaxSize(file); @@ -1388,7 +1405,7 @@ function changeFileType() { const categoryMap = { pic: "IMAGE", video: "VIDEO", - file: "FILE", + file: props.isComponent ? "IMAGE" : "FILE", all: "IMAGE", }; const category = categoryMap[fileType.value] || "IMAGE"; diff --git a/seller/src/views/sys/oss-manage/ossManage.vue b/seller/src/views/sys/oss-manage/ossManage.vue index 943ad7299..3262d1e7c 100644 --- a/seller/src/views/sys/oss-manage/ossManage.vue +++ b/seller/src/views/sys/oss-manage/ossManage.vue @@ -122,6 +122,7 @@ @click="handleCategoryTabChange('VIDEO')" >视频
{ return activeRoleTab.value === "STORE"; }); -// 商家端允许上传图片/视频/文件 +// 商家端允许上传图片/视频(文件仅在发票上传业务中使用) const canUploadImages = computed(() => { - return activeRoleTab.value === "STORE"; + return activeRoleTab.value === "STORE" && activeCategoryTab.value !== "FILE"; +}); +const uploadAccept = computed(() => { + if (activeCategoryTab.value === "VIDEO") return "video/*"; + return "image/*"; }); const uploadButtonText = computed(() => { const textMap = { IMAGE: "上传图片", VIDEO: "上传视频", - FILE: "上传文件", }; return textMap[activeCategoryTab.value] || "上传图片"; }); @@ -563,6 +568,19 @@ function beforeUpload(file) { ElMessage.warning("当前模块不支持上传"); return false; } + if (activeCategoryTab.value === "IMAGE") { + const isImg = (file?.type && file.type.startsWith("image/")) || /\.(jpg|jpeg|png|gif|webp|bmp|svg)$/i.test(file?.name || ""); + if (!isImg) { + ElMessage.warning("请上传图片格式文件"); + return false; + } + } else if (activeCategoryTab.value === "VIDEO") { + const isVid = (file?.type && file.type.startsWith("video/")) || /\.(mp4|webm|ogg|mov|avi|mkv)$/i.test(file?.name || ""); + if (!isVid) { + ElMessage.warning("请上传视频格式文件"); + return false; + } + } const maxSize = 20480 * 1024; if (file && file.size > maxSize) { handleMaxSize(file);