diff --git a/src/common/menu.js b/src/common/menu.js index e73b95b3609bbd8c7d61d1e57f230b3537994199..e910d7649312856bc4b4ab46565a8a3d720c5f1c 100644 --- a/src/common/menu.js +++ b/src/common/menu.js @@ -115,22 +115,16 @@ const menuData = [{ }]; function formatter(data, parentPath = '') { - const list = []; - data.forEach((item) => { + return data.map((item) => { + const result = { + ...item, + path: `${parentPath}${item.path}`, + }; if (item.children) { - list.push({ - ...item, - path: `${parentPath}${item.path}`, - children: formatter(item.children, `${parentPath}${item.path}/`), - }); - } else { - list.push({ - ...item, - path: `${parentPath}${item.path}`, - }); + result.children = formatter(item.children, `${parentPath}${item.path}/`); } + return result; }); - return list; } export const getMenuData = () => formatter(menuData);