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

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

上级 db5be199
...@@ -17,15 +17,18 @@ const createMenu = async (configure) => { ...@@ -17,15 +17,18 @@ const createMenu = async (configure) => {
} }
if (configure.children) { if (configure.children) {
for (const child of configure.children) { for (const child of configure.children) {
if (child) {
menu.children.push(await createMenu(child)); menu.children.push(await createMenu(child));
} }
} }
}
if (configure.modules) { if (configure.modules) {
for (const module of configure.modules) { for (const module of configure.modules) {
let info = module; let info = module;
if (isString(module)) { if (isString(module)) {
info = await getModuleInfo(module); info = await getModuleInfo(module);
} }
if (info) {
menu.children.push({ menu.children.push({
name: info.name, name: info.name,
icon: info.icon, icon: info.icon,
...@@ -33,15 +36,20 @@ const createMenu = async (configure) => { ...@@ -33,15 +36,20 @@ const createMenu = async (configure) => {
}); });
} }
} }
}
return menu; return menu;
}; };
const makeIcon = (menu) => { const makeIcon = (menu) => {
const children = menu.children; const children = menu.children;
if (!children || children.length === 0) { if (!children || children.length === 0) {
if (!menu.icon) {
menu.icon = 'file'; // eslint-disable-line no-param-reassign menu.icon = 'file'; // eslint-disable-line no-param-reassign
}
} else { } else {
if (!menu.icon) {
menu.icon = 'folder'; // eslint-disable-line no-param-reassign 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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论