优化用户数据初始化时机

This commit is contained in:
2025-11-18 19:16:24 +08:00
parent 5b1dae6e6c
commit fa6a4e5121
19 changed files with 52 additions and 52 deletions

View File

@@ -12,14 +12,12 @@ export type ProfileActions = {
refreshProfile: () => Promise<void>
}
export const createProfileStore = (init: User | null) => {
return createStore<ProfileStore>()(setState => ({
profile: init,
export const createProfileStore = () => {
return createStore<ProfileStore>()(set => ({
profile: null,
refreshProfile: async () => {
const profile = await getProfile()
setState({
profile: profile.success ? profile.data : null,
})
const result = await getProfile()
set({profile: result.success ? result.data : null})
},
}))
}