let n = 0; const generateMenuTree = (menus) => { const arr = []; for (let i = 0; i < menus.length; i++) { const menu = menus[i]; if (menu.subMenu.length) { const children = generateMenuTree(menu.subMenu) arr.push({ index: menu.value + '_' + n++, name: menu.label, path: menu.value, children }) } else { arr.push({ name: menu.label, value: 'dzsys-' + menu.value, path: '/business/dzsys/' + menu.value, isDz: true, icon: "el-icon-document", children: [] }) } } return arr; } export const getDzSysMenu = () => { const menuStr = window.sessionStorage.getItem('menu') if (!menuStr) { return null; } const menusConfig = JSON.parse(menuStr); // menusConfig.unshift( { id: null, label: "登陆", value: "login", subMenu: [] } ) return { name: '电证系统', index: 'dzsys', path: 'dzsys', children: generateMenuTree(menusConfig) } }