mo 2 年之前
父节点
当前提交
42bb62337e
共有 1 个文件被更改,包括 7 次插入2 次删除
  1. 7 2
      src/store/modules/permission.js

+ 7 - 2
src/store/modules/permission.js

@@ -3,6 +3,7 @@ import router from "@/router";
 import { getSilder } from "@/api/silder";
 import store from "@/store";
 import { Message } from "element-ui";
+import {  removeToken } from "@/utils/auth";
 // import { stat } from 'fs'
 // import { removeToken } from '@/utils/auth'
 // import Layout from '@/layout'
@@ -109,7 +110,7 @@ function checkPathUrl(path) {
 // 递归遍历数组
 function recursionRouter(arr) {
   // 这里来了
-  if (arr.length > 0) {
+  if (arr&&arr.length > 0) {
     let newArr = [];
     for (let i = 0; i < arr.length; i++) {
       if (arr[i].type == 1) {
@@ -142,6 +143,8 @@ function recursionRouter(arr) {
       newArr.push(obj);
     }
     return newArr;
+  }else{
+    return []
   }
 }
 
@@ -1299,6 +1302,7 @@ const actions = {
       getSilder().then(async res => {
         if (res.code == 200) {
           let result = addTopMenu(res.data);
+          console.log('获取异步菜单',res.data)
           if (res.data?.length < 1) {
             // 一条权限都没有
             //退出 跳到登录页 提示'该账号无任何权限'
@@ -1307,9 +1311,10 @@ const actions = {
             localStorage.removeItem("firstMenuUrl");
             // await this.$store.dispatch("permission/removePermission")
             Message.error("该用户无访问权限");
+            removeToken()
             router.push(`/login`);
 
-            // window.location.reload();
+            window.location.reload();
           }
           let newData = recursionRouter(result);
           newData = getFirstMenu(newData);