Browse Source

修改权限不足情况处理

zhaoke 1 year ago
parent
commit
300d023a3a
1 changed files with 16 additions and 12 deletions
  1. 16 12
      src/getMenu.js

+ 16 - 12
src/getMenu.js

@@ -49,18 +49,22 @@ router.beforeEach(async (to, from, next) => {
       } else {
         try {
           const treeData = await store.dispatch('user/getMenuInfo')
-          if (Array.isArray(treeData) && treeData.length) {
-            const ndOrder = _.orderBy(treeData, ['displaynumber'])
-            const nd = ndOrder.filter(item => item.pageconfigurationid)
-            store.dispatch('auth/changeAuthArrs', nd)
-            // const typeData = setType(treeData, 'up_auth_id', 'auth_id')
-            const menusArray = parseMenuItem(nd)
-            const treeMenu = listToTree(menusArray, 'up_auth_id', 'auth_id')
-            const dataMenu = _.unionBy(treeMenu, 'auth_id')
-            const menus = parseMenu(dataMenu)
-            store.dispatch('permission/setRoutes', menus)
-            router.addRoutes(menus)
-            next({ ...to, replace: true })
+          if (Array.isArray(treeData)) {
+            if (treeData.length) {
+              const ndOrder = _.orderBy(treeData, ['displaynumber'])
+              const nd = ndOrder.filter(item => item.pageconfigurationid)
+              store.dispatch('auth/changeAuthArrs', nd)
+              const menusArray = parseMenuItem(nd)
+              const treeMenu = listToTree(menusArray, 'up_auth_id', 'auth_id')
+              const dataMenu = _.unionBy(treeMenu, 'auth_id')
+              const menus = parseMenu(dataMenu)
+              store.dispatch('permission/setRoutes', menus)
+              router.addRoutes(menus)
+              next({ ...to, replace: true })
+            } else {
+              next({ path: '/' })
+              NProgress.done()
+            }
           } else {
             await store.dispatch('user/resetToken')
             Message.error(error || 'Has Error')