From 9d0acfb65c80c4948c305ca01338f894b87346a0 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期一, 08 四月 2024 09:44:37 +0800
Subject: [PATCH] Merge branch 'Four-Way-Rack' of http://47.97.1.152:5880/r/zy-asrs-master into Four-Way-Rack

---
 zy-asrs-flow/src/services/route.js |   72 ++++++++++++++++++++++++++++--------
 1 files changed, 56 insertions(+), 16 deletions(-)

diff --git a/zy-asrs-flow/src/services/route.js b/zy-asrs-flow/src/services/route.js
index 34cbd68..398ea8a 100644
--- a/zy-asrs-flow/src/services/route.js
+++ b/zy-asrs-flow/src/services/route.js
@@ -62,22 +62,36 @@
             break;
         }
     }
+
+    const rootMenu = { routes: [], children: [] }
+    addMapMenu(remoteMenu)
+    addHomeMenu(remoteMenu);
     addUserSettingMenu(remoteMenu);
-    patchRouteItems(proLayout, remoteMenu);
+    patchRouteItems(rootMenu, remoteMenu);
+
+    proLayout.children = proLayout.children.concat(rootMenu.children);
+    proLayout.routes = proLayout.routes.concat(rootMenu.routes);
 }
 
 function patchRouteItems(parent, children) {
     for (const menu of children) {
         if (menu.component !== null && menu.component !== undefined) {
             // children
-            const Component = require(`@/pages${menu.path}/index.jsx`).default
-            const newRoute = {
-                name: menu.name,
-                path: menu.path,
-                element: <Component />,
+            let Component;
+            try {
+                Component = require(`@/pages${menu.path}/index.jsx`).default
+            } catch (error) {
+                console.error('An error has occurred: ', error);
             }
-            parent.children.push(newRoute);
-            parent.routes.push(newRoute);
+            if (Component) {
+                const newRoute = {
+                    name: menu.name,
+                    path: menu.path,
+                    element: <Component />,
+                }
+                parent.routes.push(newRoute);
+                parent.children.push(newRoute);
+            }
         } else {
             // parent
             const newRoute = {
@@ -87,6 +101,7 @@
                 children: [],
             }
             parent.routes.push(newRoute);
+            parent.children.push(newRoute);
             if (menu.routes && menu.routes.length > 0) {
                 for (const route of menu.routes) {
                     patchRouteItems(newRoute, [route]);
@@ -97,17 +112,42 @@
     }
 }
 
+function addMapMenu(remoteMenu) {
+    remoteMenu.unshift({
+        name: "鍦板浘鐩戞帶",
+        path: "/map",
+        component: "/map",
+        icon: createIcon('HeatMapOutlined')
+    })
+}
+
+function addHomeMenu(remoteMenu) {
+    remoteMenu.unshift({
+        name: "棣栭〉",
+        path: "/home",
+        component: "/home",
+        icon: createIcon('HomeOutlined')
+    })
+}
+
 function addUserSettingMenu(remoteMenu) {
-    const settingRoute = {
-        name: "涓汉璁剧疆",
-        path: "/account/setting",
-        component: "/account/setting"
-    }
+    // const settingRoute = {
+    //     name: "涓汉璁剧疆",
+    //     path: "/account/setting",
+    //     component: "/account/setting"
+    // }
+    // remoteMenu.push({
+    //     name: "涓汉涓績",
+    //     path: "/account",
+    //     component: null,
+    //     routes: [settingRoute],
+    //     icon: createIcon('UserOutlined')
+    // })
+
     remoteMenu.push({
         name: "涓汉涓績",
-        path: "/account",
-        component: null,
-        routes: [settingRoute],
+        path: "/account/setting",
+        component: "/account/setting",
         icon: createIcon('UserOutlined')
     })
 }
\ No newline at end of file

--
Gitblit v1.9.1