fix: 🐛 修复修改头像后没有显示最新的头像

- 移除在 permission.ts 中的冗余用户信息检查

- 刷新页面确保获取最新的用户信息

- 更新 profile 页面中用户头像的显示逻辑

- 在头像上传成功后同步更新用户信息

#ICRONO
This commit is contained in:
zimo493
2025-08-07 12:26:13 +08:00
parent 0c2dff802a
commit 79521c4807
2 changed files with 9 additions and 8 deletions

View File

@@ -6,7 +6,7 @@
<el-card class="user-card">
<div class="user-info">
<div class="avatar-wrapper">
<el-avatar :src="userProfile.avatar" :size="100" />
<el-avatar :src="userStore.userInfo.avatar" :size="100" />
<el-button
type="info"
class="avatar-edit-btn"
@@ -227,9 +227,12 @@ import UserAPI, {
} from "@/api/system/user.api";
import FileAPI from "@/api/file.api";
import { useUserStoreHook } from "@/store";
import { Camera } from "@element-plus/icons-vue";
const userStore = useUserStoreHook();
const userProfile = ref<UserProfileVO>({});
const enum DialogType {
@@ -443,12 +446,12 @@ const handleFileChange = async (event: Event) => {
// 调用文件上传API
try {
const data = await FileAPI.uploadFile(file);
// 更新用户头像
userProfile.value.avatar = data.url;
// 更新用户信息
await UserAPI.updateProfile({
avatar: data.url,
});
// 更新用户头像
userStore.userInfo.avatar = data.url;
} catch (error) {
console.error("头像上传失败:" + error);
ElMessage.error("头像上传失败");