This commit is contained in:
zlwu committed 2026-06-04 12:57:59 +08:00
1 parent afd517ce10
commit eec61cb5dd
82 files changed
+16585 -9026

No files matched your search

+6 -3
View File
@@ -24,6 +24,7 @@ import { StorageConfig } from '@/utils/storage/storage-config'
import { fetchLogout } from '@/api/auth'
import { RoutesAlias } from '@/router/routesAlias'
import { resolveSafeRedirectTarget } from '@/utils/router'
import { pickUserAvatarRaw } from '@/utils/user-avatar'
/**
* 用户状态管理
@@ -57,11 +58,13 @@ export const useUserStore = defineStore(
* @param newInfo 新的用户信息
*/
const setUserInfo = (newInfo: Partial<Api.Auth.UserInfo> & Record<string, any>) => {
const merged = { ...(info.value || {}), ...(newInfo || {}) }
const avatarRaw = pickUserAvatarRaw(newInfo) || pickUserAvatarRaw(merged)
info.value = {
...(info.value || {}),
...(newInfo || {}),
...merged,
buttons: newInfo?.buttons ?? info.value?.buttons ?? [],
userName: newInfo?.userName ?? newInfo?.username ?? info.value?.userName ?? ''
userName: newInfo?.userName ?? newInfo?.username ?? info.value?.userName ?? '',
avatarUrl: avatarRaw || undefined
} as Api.Auth.UserInfo
}