feat: user-bar 修改

This commit is contained in:
2026-06-22 11:19:11 +08:00
parent 7d2d6707b7
commit 349a50339f
6 changed files with 269 additions and 211 deletions

View File

@@ -20,7 +20,6 @@ function isPublicPath(path: string): boolean {
*/
function setupCommonGuard(router: Router) {
router.beforeEach(async (to) => {
return true
const accountStore = useAccountStore()
// 已登录用户访问公开路由(如登录页),直接跳转首页
@@ -28,6 +27,15 @@ function setupCommonGuard(router: Router) {
return '/'
}
// 有 token 但未加载用户信息(页面刷新后 Pinia 只持久化了 token
if (accountStore.accessToken && !accountStore.accountInfo) {
try {
await accountStore.fetchUserInfo()
} catch {
// 获取失败token 过期等),由刷新拦截器处理,此处静默
}
}
// accessToken 检查
if (!accountStore.accessToken) {
// 明确声明忽略权限访问权限,则可以访问