Bladeren bron

按钮权限修改

魏熙美 5 jaren geleden
bovenliggende
commit
1c3894b662
1 gewijzigde bestanden met toevoegingen van 13 en 2 verwijderingen
  1. 13
    2
      src/components/AuthButton/index.jsx

+ 13
- 2
src/components/AuthButton/index.jsx Bestand weergeven

@@ -6,12 +6,23 @@ let current = [];
6 6
 const AuthButton = ({ children, name, noRight }) => {
7 7
   const btn = allBtns.filter(x => x.code === name)[0]
8 8
 
9
+  console.log('allBtns: ', allBtns)
10
+  console.log('btn: ', btn)
11
+  console.log('current: ', current)
12
+
9 13
   // 没维护的按钮, 或者不需要权限的按钮直接通过
10
-  if (!btn || !btn.roles || !btn.roles.length) {
14
+  // if (!btn || !btn.roles || !btn.roles.length) {
15
+  //   return <>{children}</>
16
+  // }
17
+
18
+  // const hasRight = btn.roles.some(x => current.some(y => x === y))
19
+
20
+  if (!btn || !btn.rolesList || !btn.rolesList.length) {
11 21
     return <>{children}</>
12 22
   }
13 23
 
14
-  const hasRight = btn.roles.some(x => current.some(y => x === y))
24
+  const hasRight = btn.rolesList.some(x => current.some(y => x.roleId === y))
25
+  console.log('hasRight: ', hasRight)
15 26
   return hasRight ? <>{children}</> : <>{noRight}</>
16 27
 }
17 28