From 83c548d3dba59aaed9b52b5d413c6912a87d2efc Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期日, 16 六月 2024 15:50:14 +0800
Subject: [PATCH] #

---
 zy-asrs-flow/src/services/route.js |   67 ++++++++++++++++++++++++++++-----
 1 files changed, 57 insertions(+), 10 deletions(-)

diff --git a/zy-asrs-flow/src/services/route.js b/zy-asrs-flow/src/services/route.js
index 68b572e..0b5a631 100644
--- a/zy-asrs-flow/src/services/route.js
+++ b/zy-asrs-flow/src/services/route.js
@@ -12,16 +12,15 @@
     remoteMenu = data;
 }
 
-// export async function getUserInfo(options) {
-//     return request('/api/system/user/getInfo', {
-//         method: 'GET',
-//         ...(options || {}),
-//     });
-// }
+export async function getUserInfo(options) {
+    return request('/api/auth/user', {
+        method: 'GET',
+        ...(options || {}),
+    });
+}
 
 export async function getRouters() {
     return request('/api/auth/menu', {
-        baseURL: 'http://localhost:9090/wcs'
     });
 }
 
@@ -63,12 +62,20 @@
             break;
         }
     }
-    patchRouteItems(proLayout, remoteMenu);
+
+    const rootMenu = { routes: [], children: [] }
+    addMapMenu(remoteMenu)
+    addHomeMenu(remoteMenu);
+    addUserSettingMenu(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) {
+        if (menu.component !== null && menu.component !== undefined) {
             // children
             const Component = require(`@/pages${menu.path}/index.jsx`).default
             const newRoute = {
@@ -76,8 +83,8 @@
                 path: menu.path,
                 element: <Component />,
             }
-            parent.children.push(newRoute);
             parent.routes.push(newRoute);
+            parent.children.push(newRoute);
         } else {
             // parent
             const newRoute = {
@@ -87,6 +94,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]);
@@ -95,5 +103,44 @@
             }
         }
     }
+}
 
+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"
+    // }
+    // remoteMenu.push({
+    //     name: "涓汉涓績",
+    //     path: "/account",
+    //     component: null,
+    //     routes: [settingRoute],
+    //     icon: createIcon('UserOutlined')
+    // })
+
+    remoteMenu.push({
+        name: "涓汉涓績",
+        path: "/account/setting",
+        component: "/account/setting",
+        icon: createIcon('UserOutlined')
+    })
 }
\ No newline at end of file

--
Gitblit v1.9.1