Merge remote-tracking branch 'upstream/main'

This commit is contained in:
huangjunsen0406
2025-04-01 00:45:43 +08:00
21 changed files with 2891 additions and 256 deletions
+18
View File
@@ -76,4 +76,22 @@ const router = new VueRouter({
routes
})
// 需要登录才能访问的路由
const protectedRoutes = ['home', 'RoleConfig', 'DeviceManagement', 'UserManagement', 'ModelConfig']
// 路由守卫
router.beforeEach((to, from, next) => {
// 检查是否是需要保护的路由
if (protectedRoutes.includes(to.name)) {
// 从localStorage获取token
const token = localStorage.getItem('token')
if (!token) {
// 未登录,跳转到登录页
next({ name: 'login', query: { redirect: to.fullPath } })
return
}
}
next()
})
export default router