优化用户信息展示和权限显示逻辑

This commit is contained in:
jxxghp
2025-06-11 12:56:10 +08:00
parent 052d6edd13
commit 3c051b8698
8 changed files with 251 additions and 166 deletions
+4 -1
View File
@@ -224,15 +224,18 @@ function abortAllControllers() {
}
// 路由导航守卫
router.beforeEach((to: any, from: any, next: any) => {
router.beforeEach(async (to: any, from: any, next: any) => {
// 认证 Store
const authStore = useAuthStore()
// 总是记录非login路由
if (to.fullPath != '/login') authStore.originalPath = to.fullPath
const isAuthenticated = authStore.token !== null
if (to.meta.requiresAuth && !isAuthenticated) {
// 用户未登录,重定向到登录页
next('/login')
} else {
// 清理所有中止控制器
abortAllControllers()
next()
}