rbac-permission-interface-impl
This commit is contained in:
@@ -26,6 +26,7 @@ setTokenGetter(() => useUserStore().token)
|
||||
|
||||
// 路由守卫
|
||||
const authWhitelist = ['/login', '/register']
|
||||
const adminOnlyPaths = ['/users', '/mq-status']
|
||||
|
||||
router.beforeEach(async (to) => {
|
||||
const { useUserStore } = await import('./stores/user')
|
||||
@@ -54,6 +55,12 @@ router.beforeEach(async (to) => {
|
||||
}
|
||||
}
|
||||
|
||||
// 角色权限检查:非 admin 不能访问受限路由
|
||||
if (adminOnlyPaths.includes(to.path) && !userStore.isAdmin) {
|
||||
message.error('无权访问')
|
||||
return '/'
|
||||
}
|
||||
|
||||
return true
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user