Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

权限相关,通过角色限制菜单,未起到作用 #297

Open
chaihao opened this issue Mar 30, 2022 · 2 comments
Open

权限相关,通过角色限制菜单,未起到作用 #297

chaihao opened this issue Mar 30, 2022 · 2 comments

Comments

@chaihao
Copy link

chaihao commented Mar 30, 2022

在路由配置角色验证

   {
      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
Copy link

我是按照官网里面的东西进行调整了的

路由:
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
Copy link

我是通过修改源码,把读取路由变成读取localStorage的role数据来鉴权

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants