提交 3fb538df authored 作者: vipcxj's avatar vipcxj

fix: 左侧菜单生成时内部报错

上级 db5be199
...@@ -17,7 +17,9 @@ const createMenu = async (configure) => { ...@@ -17,7 +17,9 @@ const createMenu = async (configure) => {
} }
if (configure.children) { if (configure.children) {
for (const child of configure.children) { for (const child of configure.children) {
menu.children.push(await createMenu(child)); if (child) {
menu.children.push(await createMenu(child));
}
} }
} }
if (configure.modules) { if (configure.modules) {
...@@ -26,11 +28,13 @@ const createMenu = async (configure) => { ...@@ -26,11 +28,13 @@ const createMenu = async (configure) => {
if (isString(module)) { if (isString(module)) {
info = await getModuleInfo(module); info = await getModuleInfo(module);
} }
menu.children.push({ if (info) {
name: info.name, menu.children.push({
icon: info.icon, name: info.name,
text: info.showName, icon: info.icon,
}); text: info.showName,
});
}
} }
} }
return menu; return menu;
...@@ -39,9 +43,13 @@ const createMenu = async (configure) => { ...@@ -39,9 +43,13 @@ const createMenu = async (configure) => {
const makeIcon = (menu) => { const makeIcon = (menu) => {
const children = menu.children; const children = menu.children;
if (!children || children.length === 0) { if (!children || children.length === 0) {
menu.icon = 'file'; // eslint-disable-line no-param-reassign if (!menu.icon) {
menu.icon = 'file'; // eslint-disable-line no-param-reassign
}
} else { } else {
menu.icon = 'folder'; // eslint-disable-line no-param-reassign if (!menu.icon) {
menu.icon = 'folder'; // eslint-disable-line no-param-reassign
}
for (const child of children) { for (const child of children) {
makeIcon(child); makeIcon(child);
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论