This commit is contained in:
ygx
2026-03-28 15:44:57 +08:00
parent 1020699b8c
commit 877e3115c4
11 changed files with 497 additions and 167 deletions

View File

@@ -4,6 +4,9 @@ import type { LocationQueryRaw, Router } from 'vue-router'
import { useUserStore } from '@/store'
import { isLogin } from '@/utils/auth'
// 不需要登录验证的路由名称
const whiteList = ['login', 'home']
export default function setupUserLoginInfoGuard(router: Router) {
router.beforeEach(async (to, from, next) => {
NProgress.start()
@@ -27,7 +30,8 @@ export default function setupUserLoginInfoGuard(router: Router) {
}
}
} else {
if (to.name === 'login') {
// 在白名单中的路由不需要登录验证
if (whiteList.includes(to.name as string)) {
next()
return
}