chore: 个人中心
This commit is contained in:
parent
23c548ac3d
commit
71d005bd48
@ -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<any>) {
|
||||
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);
|
||||
});
|
||||
</script>
|
||||
|
||||
|
@ -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);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@ -44,7 +47,6 @@ async function handleUploadFinish() {
|
||||
v-if="profile"
|
||||
:profile="profile"
|
||||
class="flex-1 overflow-hidden"
|
||||
@reload="loadProfile"
|
||||
/>
|
||||
</div>
|
||||
</Page>
|
||||
|
7
apps/web-antd/src/views/_core/profile/mitt.ts
Normal file
7
apps/web-antd/src/views/_core/profile/mitt.ts
Normal file
@ -0,0 +1,7 @@
|
||||
import { mitt } from '@vben/utils';
|
||||
|
||||
type Events = {
|
||||
updateProfile: void;
|
||||
};
|
||||
|
||||
export const emitter = mitt<Events>();
|
Loading…
Reference in New Issue
Block a user