Commit 906a7c01 authored by tyyin lan's avatar tyyin lan

chore: 应用加载更新用户信息

parent 22edf216
...@@ -16,3 +16,7 @@ export function fetchSMSCode<T>(phoneNumber: string) { ...@@ -16,3 +16,7 @@ export function fetchSMSCode<T>(phoneNumber: string) {
export function fetchEmailCode<T>(emailAddress: string) { export function fetchEmailCode<T>(emailAddress: string) {
return request.post<T>(`/sendEmailRest/sendEmailCode.json?emailAddress=${emailAddress}`) return request.post<T>(`/sendEmailRest/sendEmailCode.json?emailAddress=${emailAddress}`)
} }
export function fetchUserDetailInfo<T>() {
return request.post<T>('/bizMemberInfoRest/getCurrentMemberInfo.json')
}
...@@ -5,8 +5,10 @@ import mitt from 'mitt' ...@@ -5,8 +5,10 @@ import mitt from 'mitt'
import { themeOverrides } from '@/config/theme-config' import { themeOverrides } from '@/config/theme-config'
import { useResizeObserver } from '@vueuse/core' import { useResizeObserver } from '@vueuse/core'
import { useDesignSettingStore } from '@/store/modules/design-setting' import { useDesignSettingStore } from '@/store/modules/design-setting'
import { useUserStore } from './store/modules/user'
const designSettingStore = useDesignSettingStore() const designSettingStore = useDesignSettingStore()
const userStore = useUserStore()
const emitter = mitt<MittEvents>() const emitter = mitt<MittEvents>()
...@@ -37,6 +39,11 @@ useResizeObserver(rootContainer, (entries) => { ...@@ -37,6 +39,11 @@ useResizeObserver(rootContainer, (entries) => {
designSettingStore.toggleSidebarDisplayStatus('expand') designSettingStore.toggleSidebarDisplayStatus('expand')
} }
}) })
;(function () {
if (userStore.isLogin) {
userStore.fetchUpdateUserInfo()
}
})()
</script> </script>
<template> <template>
......
import { defineStore } from 'pinia' import { defineStore } from 'pinia'
import { ss } from '@/utils/storage' import { ss } from '@/utils/storage'
import { type UserState, type UserInfo, UserStoreStorageKeyEnum } from '../types/user' import { type UserState, type UserInfo, UserStoreStorageKeyEnum } from '../types/user'
import { fetchUserDetailInfo } from '@/apis/user'
function createDefaultUserInfoFactory(): UserInfo { function createDefaultUserInfoFactory(): UserInfo {
return { return {
...@@ -43,5 +44,10 @@ export const useUserStore = defineStore('user-store', { ...@@ -43,5 +44,10 @@ export const useUserStore = defineStore('user-store', {
this.userInfo = userInfo this.userInfo = userInfo
ss.set(UserStoreStorageKeyEnum.userInfo, userInfo) ss.set(UserStoreStorageKeyEnum.userInfo, userInfo)
}, },
fetchUpdateUserInfo() {
fetchUserDetailInfo<UserInfo>().then((res) => {
this.userInfo = res.data
})
},
}, },
}) })
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment