luxiaotao1123
2024-04-08 9d0acfb65c80c4948c305ca01338f894b87346a0
zy-asrs-flow/src/services/route.js
@@ -63,12 +63,13 @@
        }
    }
    const rootMenu = { routes: [] }
    const rootMenu = { routes: [], children: [] }
    addMapMenu(remoteMenu)
    addHomeMenu(remoteMenu);
    addUserSettingMenu(remoteMenu);
    patchRouteItems(rootMenu, remoteMenu);
    proLayout.children = proLayout.children.concat(rootMenu.routes);
    proLayout.children = proLayout.children.concat(rootMenu.children);
    proLayout.routes = proLayout.routes.concat(rootMenu.routes);
}
@@ -76,13 +77,21 @@
    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.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 = {
@@ -92,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]);
@@ -102,6 +112,15 @@
    }
}
function addMapMenu(remoteMenu) {
    remoteMenu.unshift({
        name: "地图监控",
        path: "/map",
        component: "/map",
        icon: createIcon('HeatMapOutlined')
    })
}
function addHomeMenu(remoteMenu) {
    remoteMenu.unshift({
        name: "首页",