fix:前端上传头像名称取值错误以及用户保存个人信息时还使用的是旧的头像数据

This commit is contained in:
sunjianfeng
2025-09-12 01:05:07 +08:00
parent 7ddbf8712c
commit 9c8abbc341
3 changed files with 33 additions and 5 deletions

View File

@@ -49,18 +49,31 @@
<script lang="ts" setup>
import { formatDate } from '@/utils/formatTime'
import UserAvatar from './UserAvatar.vue'
import { useUserStore } from '@/store/modules/user'
import { getUserProfile, ProfileVO } from '@/api/system/user/profile'
defineOptions({ name: 'ProfileUser' })
const { t } = useI18n()
const userStore = useUserStore()
const userInfo = ref({} as ProfileVO)
const getUserInfo = async () => {
const users = await getUserProfile()
userInfo.value = users
}
// 监听 userStore 中头像的变化,同步更新本地 userInfo
watch(
() => userStore.getUser.avatar,
(newAvatar) => {
if (newAvatar && userInfo.value) {
userInfo.value.avatar = newAvatar
}
}
)
// 暴露刷新方法
defineExpose({
refresh: getUserInfo