#
Junjie
2025-02-14 ac4341ea6b66ae02427d39d35f41d42d78b2eb2e
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')
    })
}