feat: allow temporary intranet no-login mode

This commit is contained in:
2026-08-04 16:22:29 +08:00
parent 5ff58ac4d6
commit 1042b48102
6 changed files with 70 additions and 8 deletions
+12 -1
View File
@@ -50,8 +50,19 @@ const router = createRouter({
routes,
})
// 路由守卫:检查登录
// 默认运行在内网免登录模式;需要 Casdoor 时构建时设置 VITE_AUTH_ENABLED=true。
const authEnabled = import.meta.env.VITE_AUTH_ENABLED === 'true'
router.beforeEach((to, from, next) => {
if (!authEnabled) {
if (to.name === 'Login') {
next({ name: 'Dashboard' })
} else {
next()
}
return
}
const token = localStorage.getItem('token')
if (to.name !== 'Login' && !token) {
next({ name: 'Login' })