Преглед на файлове

fix: showLink is false,children menu still showing

xiaoxian521 преди 3 години
родител
ревизия
c8e90b4bd7
променени са 1 файла, в които са добавени 10 реда и са изтрити 2 реда
  1. 10 2
      src/store/modules/permission.ts

+ 10 - 2
src/store/modules/permission.ts

@@ -13,9 +13,17 @@ export const usePermissionStore = defineStore({
   }),
   actions: {
     asyncActionRoutes(routes) {
+      const filterTree = data => {
+        const newTree = data.filter(v => v.meta.showLink);
+        newTree.forEach(
+          v => v.children && (v.children = filterTree(v.children))
+        );
+        return newTree;
+      };
+
       if (this.wholeRoutes.length > 0) return;
-      this.wholeRoutes = ascending(this.constantRoutes.concat(routes)).filter(
-        v => v.meta.showLink
+      this.wholeRoutes = filterTree(
+        ascending(this.constantRoutes.concat(routes))
       );
 
       const getButtonAuth = (arrRoutes: Array<string>) => {