feat: user-bar 修改
This commit is contained in:
@@ -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) {
|
||||
// 明确声明忽略权限访问权限,则可以访问
|
||||
|
||||
Reference in New Issue
Block a user