mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-11-29 05:09:46 +01:00
Update index.js
权限调整
This commit is contained in:
parent
b23e31bb4b
commit
611d1a65e7
1 changed files with 1 additions and 14 deletions
|
|
@ -170,13 +170,10 @@ VueRouter.prototype.push = function push(location) {
|
||||||
// 需要登录才能访问的路由
|
// 需要登录才能访问的路由
|
||||||
const protectedRoutes = ['home', 'RoleConfig', 'DeviceManagement', 'UserManagement', 'ModelConfig']
|
const protectedRoutes = ['home', 'RoleConfig', 'DeviceManagement', 'UserManagement', 'ModelConfig']
|
||||||
|
|
||||||
// 需要管理员权限才能访问的路由
|
|
||||||
const adminRoutes = ['TemplateQuickConfig', 'AgentTemplateManagement']
|
|
||||||
|
|
||||||
// 路由守卫
|
// 路由守卫
|
||||||
router.beforeEach((to, from, next) => {
|
router.beforeEach((to, from, next) => {
|
||||||
// 检查是否是需要保护的路由
|
// 检查是否是需要保护的路由
|
||||||
if (protectedRoutes.includes(to.name) || adminRoutes.includes(to.name)) {
|
if (protectedRoutes.includes(to.name)) {
|
||||||
// 从localStorage获取token
|
// 从localStorage获取token
|
||||||
const token = localStorage.getItem('token')
|
const token = localStorage.getItem('token')
|
||||||
if (!token) {
|
if (!token) {
|
||||||
|
|
@ -184,16 +181,6 @@ router.beforeEach((to, from, next) => {
|
||||||
next({ name: 'login', query: { redirect: to.fullPath } })
|
next({ name: 'login', query: { redirect: to.fullPath } })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 对于需要管理员权限的路由,检查用户是否是超级管理员
|
|
||||||
if (adminRoutes.includes(to.name)) {
|
|
||||||
const isSuperAdmin = localStorage.getItem('isSuperAdmin') === 'true'
|
|
||||||
if (!isSuperAdmin) {
|
|
||||||
// 不是管理员,跳转到首页或显示无权限提示
|
|
||||||
next({ name: 'home' })
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
next()
|
next()
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue