权限相关,通过角色限制菜单,未起到作用
chaihao opened this issue · 2 comments
chaihao commented
在路由配置角色验证
{
path: 'demo',
name: '演示页',
meta: {
icon: 'file-ppt',
authority: {
role: 'test',
}
},
component: () => import('@/pages/demo')
}
加载菜单仍然会显示,经过筛查,发现 hasPermission方法权限验证通过了,由于 route.meta.pAuthorities 给了 * 的权限,现在想用角色来实现菜单权限控制有什么好的解决办法? 我目前想到的解决办法是在 routerUtil.js文件中在给pAuthorities 赋值时判断 authority 中是否存在 role 限制, 如果存在赋值 pAuthorities 下 permission 值为空字符串,目前测试可以实现预期效果,请问是否有其他方式解决这个问题
wangyaoyong-wyy commented
我是按照官网里面的东西进行调整了的
路由:
role: {
name: '角色管理',
path: 'role_manage',
component: () => import('@/pages/system/role_manage')
}
后端返回菜单:
{
"router":"role",
"authority":{
"permission":"role"
}
}
后端返回权限:
{
"id":"role",
"operation":[
"query",
"delete",
"edit",
"add"
]
}
basic原来的校验js稍微改动了下
然后再用的v-auth
我不是写前端的,不知道你们写前端的是不是这样的,我是现在能和官网说的那样子实现粒度级权限控制
Frankiness commented
我是通过修改源码,把读取路由变成读取localStorage的role数据来鉴权