From 5e5764f8bfec48095fe31afe69845b9e8c0de630 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E8=9F=91=E8=9E=82?= Date: Sun, 29 Mar 2026 15:26:03 +0800 Subject: [PATCH] =?UTF-8?q?fix(profile):=20=E4=BF=AE=E5=A4=8D=E5=A4=B4?= =?UTF-8?q?=E5=83=8F=E9=A2=84=E8=A7=88=20-=20=E6=94=B9=E7=94=A8=20@change?= =?UTF-8?q?=20=E6=9B=BF=E4=BB=A3=20before-upload?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit before-upload 的 async 返回值处理在某些场景下不生效,改为 @change 事件直接处理 --- .../src/views/system/profile/index.vue | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/system/profile/index.vue b/ecom-dmb-frontend/apps/web-antd/src/views/system/profile/index.vue index 6dcf49c3..a0dac205 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/views/system/profile/index.vue +++ b/ecom-dmb-frontend/apps/web-antd/src/views/system/profile/index.vue @@ -61,22 +61,22 @@ async function fetchUserInfo() { } } -async function handleAvatarChange(info: any) { - const file = info.file.originFileObj || info.file; - if (!file) return false; +function handleAvatarChange({ file }: { file: any }) { + // 获取实际文件对象 + const actualFile = file.originFileObj || file; + if (!actualFile) return; - if (!file.type.startsWith('image/')) { + if (!actualFile.type.startsWith('image/')) { message.error('只能上传图片文件'); - return false; + return; } - if (file.size > 2 * 1024 * 1024) { + if (actualFile.size > 2 * 1024 * 1024) { message.error('图片大小不能超过 2MB'); - return false; + return; } // 缓存头像文件,预览由 computed avatarSrc 自动处理 - pendingAvatarFile.value = file; - return false; // 阻止默认上传 + pendingAvatarFile.value = actualFile; } async function handleSubmit() { @@ -153,7 +153,7 @@ fetchUserInfo();