Jelajahi Sumber

[Fix 0000] 解决菜单生成循环的问题

houzekong 2 bulan lalu
induk
melakukan
554e488e7f
2 mengubah file dengan 20 tambahan dan 5 penghapusan
  1. 12 0
      public/js/global.js
  2. 8 5
      src/api/sys/menu.ts

+ 12 - 0
public/js/global.js

@@ -132,6 +132,18 @@ const __STATIC_ROUTES__ = [
         },
         name: 'basicinfo-closed-statistics',
       },
+      {
+        path: '/basicinfo/problem-report',
+        component: 'dashboard/basicInfo/problemReport',
+        meta: {
+          keepAlive: true,
+          internalOrExternal: false,
+          icon: '',
+          componentName: 'index',
+          title: '密闭墙问题反馈',
+        },
+        name: 'basicinfo-problem-report',
+      },
     ],
     meta: {
       keepAlive: false,

+ 8 - 5
src/api/sys/menu.ts

@@ -23,6 +23,7 @@ const generateStaticSealedMonitorRoute = (route: AppRouteRecordRaw, items: MineD
   return items.reduce((arr: AppRouteRecordRaw[], item) => {
     const [__, ___, LEAF_LEVEL_ORG] = item.memoDesc;
 
+    // 菜单生成到叶节点为止,不包括叶节点
     if (item.orgType === LEAF_LEVEL_ORG) return arr;
 
     const res: AppRouteRecordRaw = {
@@ -50,10 +51,6 @@ const processStaticRoutes = (routes: AppRouteRecordRaw[], mineStore: any) => {
   return routes.reduce((arr: AppRouteRecordRaw[], route) => {
     // 首先处理子菜单,因为子菜单的权限和父菜单是独立的,避免子菜单还有内容的情况下被父菜单过滤
     if (route.children && route.children.length) {
-      // 如果是生成式动态菜单,优先处理
-      if (route.meta.generation) {
-        route.children = generateStaticSealedMonitorRoute(route, mineStore.getDepartTree);
-      }
       // 如果子菜单有内容,则递归处理
       route.children = processStaticRoutes(route.children, mineStore);
     }
@@ -78,7 +75,13 @@ export const getMenuList: () => Promise<getMenuListResultModel> = () => {
       auth: res.auth || [],
       codeList: res.codeList || [],
       // menu: __STATIC_ROUTES__,
-      menu: processStaticRoutes(__STATIC_ROUTES__, mineStore),
+      menu: processStaticRoutes(__STATIC_ROUTES__, mineStore).map((route) => {
+        if (route.meta?.generation && route.children && route.children.length) {
+          const template = route.children[0];
+          route.children = generateStaticSealedMonitorRoute(template, mineStore.getDepartTree);
+        }
+        return route;
+      }),
     };
   });
 };