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();