简体   繁体   English

Reactjs中如何实现基于组件的角色和权限?

[英]How to implement roles and permission base on component in Reactjs?

Here I want to know how to implement roles and permissions for users with multi roles.这里想了解如何实现多角色用户的角色和权限。

Rules like this:像这样的规则:

Note : R = Read, W = Write, D = Delete注意:R = 读取,W = 写入,D = 删除

Role角色 Feature 1特点 1 Feature 2特征2 Feature 3特色三
Super Admin超级管理员 RWD后驱 RWD后驱 RWD后驱
Marketing营销 - - R R RW读写器
Customer Service客户服务 - - RW读写器 R R

Please give me example with React Hook for implement this role and permission.请给我示例 React Hook 以实现此角色和权限。 Thank you!谢谢!

really you dont need to do anything crazy for storing roles...真的,你不需要为存储角色做任何疯狂的事情......

const roles = [
  { role: 'superAdmin', display: 'Super Admin', feature1: 'RWD', feature2: 'RWD', feature3: 'RWD' },
  { role: 'marketing', display: 'Marketing', feature1: null, feature2: 'R', feature3: 'RW' },
  { role: 'customerService', display: 'Customer Service', feature1: null, feature2: 'RW', feature3: 'R' }
]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM