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 { useAuthStore } from '#/store';
|
||||||
import { getDictOptions } from '#/utils/dict';
|
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 userStore = useUserStore();
|
||||||
const authStore = useAuthStore();
|
const authStore = useAuthStore();
|
||||||
@ -93,7 +93,7 @@ async function handleSubmit(values: Recordable<any>) {
|
|||||||
const userInfo = await authStore.fetchUserInfo();
|
const userInfo = await authStore.fetchUserInfo();
|
||||||
userStore.setUserInfo(userInfo);
|
userStore.setUserInfo(userInfo);
|
||||||
// 左边reload
|
// 左边reload
|
||||||
emit('reload');
|
emitter.emit('updateProfile');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
} finally {
|
} finally {
|
||||||
@ -109,9 +109,7 @@ onMounted(() => {
|
|||||||
'phonenumber',
|
'phonenumber',
|
||||||
'sex',
|
'sex',
|
||||||
]);
|
]);
|
||||||
for (const key in data) {
|
formApi.setValues(data);
|
||||||
formApi.setFieldValue(key, data[key as keyof typeof data]);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ import { useUserStore } from '@vben/stores';
|
|||||||
import { userProfile } from '#/api/system/profile';
|
import { userProfile } from '#/api/system/profile';
|
||||||
import { useAuthStore } from '#/store';
|
import { useAuthStore } from '#/store';
|
||||||
|
|
||||||
|
import { emitter } from './mitt';
|
||||||
import ProfilePanel from './profile-panel.vue';
|
import ProfilePanel from './profile-panel.vue';
|
||||||
import SettingPanel from './setting-panel.vue';
|
import SettingPanel from './setting-panel.vue';
|
||||||
|
|
||||||
@ -32,6 +33,8 @@ async function handleUploadFinish() {
|
|||||||
const userInfo = await authStore.fetchUserInfo();
|
const userInfo = await authStore.fetchUserInfo();
|
||||||
userStore.setUserInfo(userInfo);
|
userStore.setUserInfo(userInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
emitter.on('updateProfile', loadProfile);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@ -44,7 +47,6 @@ async function handleUploadFinish() {
|
|||||||
v-if="profile"
|
v-if="profile"
|
||||||
:profile="profile"
|
:profile="profile"
|
||||||
class="flex-1 overflow-hidden"
|
class="flex-1 overflow-hidden"
|
||||||
@reload="loadProfile"
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</Page>
|
</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