Browse Source

chore[litemall-admin]: 权限校验支持超级权限*

Junling Bu 6 years ago
parent
commit
d9895619aa

+ 9 - 3
litemall-admin/src/directive/permission/permission.js

@@ -9,9 +9,15 @@ export default{
     if (value && value instanceof Array && value.length > 0) {
       const permissions = value
 
-      const hasPermission = perms.some(perm => {
-        return permissions.includes(perm)
-      })
+      var hasPermission = false
+
+      if (perms.indexOf('*') >= 0) {
+        hasPermission = true
+      } else {
+        hasPermission = perms.some(perm => {
+          return permissions.includes(perm)
+        })
+      }
 
       if (!hasPermission) {
         el.parentNode && el.parentNode.removeChild(el)

+ 9 - 3
litemall-admin/src/utils/permission.js

@@ -10,9 +10,15 @@ export default function checkPermission(value) {
     const perms = store.getters && store.getters.perms
     const permissions = value
 
-    const hasPermission = perms.some(perm => {
-      return permissions.includes(perm)
-    })
+    var hasPermission = false
+
+    if (perms.indexOf('*') >= 0) {
+      hasPermission = true
+    } else {
+      hasPermission = perms.some(perm => {
+        return permissions.includes(perm)
+      })
+    }
 
     if (!hasPermission) {
       return false