diff --git a/apps/web-antd/src/views/_core/profile/components/base-setting.vue b/apps/web-antd/src/views/_core/profile/components/base-setting.vue index 197e9b39..1801b232 100644 --- a/apps/web-antd/src/views/_core/profile/components/base-setting.vue +++ b/apps/web-antd/src/views/_core/profile/components/base-setting.vue @@ -15,9 +15,9 @@ import { userProfileUpdate } from '#/api/system/profile'; import { useAuthStore } from '#/store'; import { getDictOptions } from '#/utils/dict'; -const props = defineProps<{ profile: UserProfile }>(); +import { emitter } from '../mitt'; -const emit = defineEmits<{ reload: [] }>(); +const props = defineProps<{ profile: UserProfile }>(); const userStore = useUserStore(); const authStore = useAuthStore(); @@ -93,7 +93,7 @@ async function handleSubmit(values: Recordable) { const userInfo = await authStore.fetchUserInfo(); userStore.setUserInfo(userInfo); // 左边reload - emit('reload'); + emitter.emit('updateProfile'); } catch (error) { console.error(error); } finally { @@ -109,9 +109,7 @@ onMounted(() => { 'phonenumber', 'sex', ]); - for (const key in data) { - formApi.setFieldValue(key, data[key as keyof typeof data]); - } + formApi.setValues(data); }); diff --git a/apps/web-antd/src/views/_core/profile/index.vue b/apps/web-antd/src/views/_core/profile/index.vue index b27d62df..7d437cf5 100644 --- a/apps/web-antd/src/views/_core/profile/index.vue +++ b/apps/web-antd/src/views/_core/profile/index.vue @@ -9,6 +9,7 @@ import { useUserStore } from '@vben/stores'; import { userProfile } from '#/api/system/profile'; import { useAuthStore } from '#/store'; +import { emitter } from './mitt'; import ProfilePanel from './profile-panel.vue'; import SettingPanel from './setting-panel.vue'; @@ -32,6 +33,8 @@ async function handleUploadFinish() { const userInfo = await authStore.fetchUserInfo(); userStore.setUserInfo(userInfo); } + +emitter.on('updateProfile', loadProfile);