From ac4341ea6b66ae02427d39d35f41d42d78b2eb2e Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期五, 14 二月 2025 10:08:32 +0800
Subject: [PATCH] #

---
 zy-asrs-flow/src/services/route.js |   46 +++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 41 insertions(+), 5 deletions(-)

diff --git a/zy-asrs-flow/src/services/route.js b/zy-asrs-flow/src/services/route.js
index 3daa1bd..1221444 100644
--- a/zy-asrs-flow/src/services/route.js
+++ b/zy-asrs-flow/src/services/route.js
@@ -14,7 +14,6 @@
 
 export async function getUserInfo(options) {
     return request('/api/auth/user', {
-        baseURL: 'http://localhost:9090/wcs',
         method: 'GET',
         ...(options || {}),
     });
@@ -22,7 +21,6 @@
 
 export async function getRouters() {
     return request('/api/auth/menu', {
-        baseURL: 'http://localhost:9090/wcs'
     });
 }
 
@@ -64,12 +62,19 @@
             break;
         }
     }
-    patchRouteItems(proLayout, remoteMenu);
+
+    const rootMenu = { routes: [], children: [] }
+    addHomeMenu(remoteMenu);
+    addUserSettingMenu(remoteMenu);
+    patchRouteItems(rootMenu, remoteMenu);
+
+    proLayout.children = proLayout.children.concat(rootMenu.routes);
+    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 = {
@@ -77,8 +82,8 @@
                 path: menu.path,
                 element: <Component />,
             }
-            parent.children.push(newRoute);
             parent.routes.push(newRoute);
+            parent.children.push(newRoute);
         } else {
             // parent
             const newRoute = {
@@ -88,6 +93,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]);
@@ -96,5 +102,35 @@
             }
         }
     }
+}
 
+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