fix:个人中心修改信息后,左侧没变化

This commit is contained in:
YunaiV 2025-05-12 21:15:26 +08:00
parent 02d284bced
commit 2b44f1d6dc
3 changed files with 22 additions and 2 deletions

View File

@ -7,13 +7,13 @@
<span>{{ t('profile.user.title') }}</span>
</div>
</template>
<ProfileUser />
<ProfileUser ref="profileUserRef" />
</el-card>
<el-card class="user ml-3 w-2/3" shadow="hover">
<div>
<el-tabs v-model="activeName" class="profile-tabs" style="height: 400px" tab-position="top">
<el-tab-pane :label="t('profile.info.basicInfo')" name="basicInfo">
<BasicInfo />
<BasicInfo @success="handleBasicInfoSuccess" />
</el-tab-pane>
<el-tab-pane :label="t('profile.info.resetPwd')" name="resetPwd">
<ResetPwd />
@ -32,6 +32,12 @@ import { BasicInfo, ProfileUser, ResetPwd, UserSocial } from './components'
const { t } = useI18n()
defineOptions({ name: 'Profile' })
const activeName = ref('basicInfo')
const profileUserRef = ref()
//
const handleBasicInfoSuccess = async () => {
await profileUserRef.value?.refresh()
}
</script>
<style scoped>
.user {

View File

@ -28,6 +28,12 @@ defineOptions({ name: 'BasicInfo' })
const { t } = useI18n()
const message = useMessage() //
const userStore = useUserStore()
//
const emit = defineEmits<{
(e: 'success'): void
}>()
//
const rules = reactive<FormRules>({
nickname: [{ required: true, message: t('profile.rules.nickname'), trigger: 'blur' }],
@ -82,6 +88,8 @@ const submit = () => {
message.success(t('common.updateSuccess'))
const profile = await init()
userStore.setUserNicknameAction(profile.nickname)
//
emit('success')
}
})
}

View File

@ -60,6 +60,12 @@ const getUserInfo = async () => {
const users = await getUserProfile()
userInfo.value = users
}
//
defineExpose({
refresh: getUserInfo
})
onMounted(async () => {
await getUserInfo()
})