2025-10-30 19:34:04 +08:00
|
|
|
import fs from 'fs';
|
|
|
|
|
import _ from 'lodash';
|
|
|
|
|
import {menuList, ScopeApp, ScopeRoute} from './function.mjs';
|
|
|
|
|
import {appMap, navMap, pageMap} from './moduleMap.mjs';
|
|
|
|
|
|
|
|
|
|
const menuData = [
|
|
|
|
|
{
|
|
|
|
|
path: '/home',
|
|
|
|
|
name: 'staticRoutes.home',
|
|
|
|
|
meta: {
|
|
|
|
|
icon: 'mdi mdi-home',
|
|
|
|
|
isKeepAlive: true,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
const formatSubApps = (subApps) => {
|
|
|
|
|
if (subApps && subApps.length > 0) {
|
|
|
|
|
return subApps.map((item) => {
|
|
|
|
|
const firstPage = pageMap[appMap[item]?.pages?.[0]?.name];
|
|
|
|
|
return {
|
|
|
|
|
name: `${ScopeApp}.${item}`,
|
|
|
|
|
path: firstPage?.path || '',
|
|
|
|
|
meta: firstPage?.meta || {},
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
for (const item of menuList) {
|
|
|
|
|
const appName = item.appName;
|
|
|
|
|
const appData = appMap[appName];
|
|
|
|
|
const navName = item.navName;
|
|
|
|
|
const navData = navMap[navName];
|
|
|
|
|
let itemMenu;
|
|
|
|
|
if (appName && appData) {
|
|
|
|
|
const firstPage = pageMap[appData.pages[0]?.name];
|
|
|
|
|
itemMenu = {
|
|
|
|
|
name: appData.name,
|
|
|
|
|
path: firstPage.path,
|
2025-11-25 19:08:59 +08:00
|
|
|
meta: {
|
|
|
|
|
...firstPage.meta,
|
|
|
|
|
...appData.meta,
|
|
|
|
|
},
|
2025-10-30 19:34:04 +08:00
|
|
|
};
|
|
|
|
|
if (itemMenu.name === `${ScopeApp}.task`) {
|
|
|
|
|
itemMenu.children = appData.pages.map((item) => pageMap[item.name]);
|
|
|
|
|
}
|
2025-11-03 10:35:36 +08:00
|
|
|
if ([
|
|
|
|
|
`${ScopeApp}.spdmProject`,
|
|
|
|
|
`${ScopeApp}.spdmTask`,
|
|
|
|
|
`${ScopeApp}.spdmData`,
|
|
|
|
|
`${ScopeApp}.spdmSimulation`,
|
|
|
|
|
`${ScopeApp}.spdmCompetenceCenter`,
|
|
|
|
|
`${ScopeApp}.spdmSystem`
|
|
|
|
|
].includes(itemMenu.name)) {
|
|
|
|
|
itemMenu.children = appData.pages.map((item) => pageMap[item.name]);
|
|
|
|
|
}
|
2025-10-30 19:34:04 +08:00
|
|
|
if (item.subApps && item.subApps.length > 0) {
|
|
|
|
|
itemMenu.children = [];
|
|
|
|
|
if (firstPage) {
|
|
|
|
|
itemMenu.children.push(firstPage);
|
|
|
|
|
}
|
|
|
|
|
itemMenu.children = itemMenu.children.concat(formatSubApps(item.subApps));
|
|
|
|
|
}
|
|
|
|
|
} else if (navName && navData) {
|
|
|
|
|
itemMenu = {
|
|
|
|
|
name: navData.name,
|
|
|
|
|
path: navName,
|
|
|
|
|
meta: navData.meta,
|
|
|
|
|
children: formatSubApps(navData.subApps),
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
if (itemMenu) {
|
|
|
|
|
menuData.push(itemMenu);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
fs.writeFileSync(`./moduleMenu.ts`, `export default ${JSON.stringify(menuData, null, 2)}`);
|
|
|
|
|
console.log(`file written successfully :>> moduleMenu.ts\n`);
|
|
|
|
|
} catch (err) {
|
|
|
|
|
console.error(err);
|
|
|
|
|
}
|