| | |
| | | |
| | | export async function getRoutersInfo() { |
| | | return getRouters().then((res) => { |
| | | console.log(res); |
| | | if (res.code === 200) { |
| | | // return res.data; |
| | | const routersInfo = convertCompatRouters(res.data); |
| | |
| | | for (const menu of children) { |
| | | if (menu.component !== null && menu.component !== undefined) { |
| | | // children |
| | | const Component = require(`@/pages${menu.path}/index.jsx`).default |
| | | const newRoute = { |
| | | name: menu.name, |
| | | path: menu.path, |
| | | element: <Component />, |
| | | let Component; |
| | | try { |
| | | Component = require(`@/pages${menu.path}/index.jsx`).default |
| | | } catch (error) { |
| | | console.error('An error has occurred: ', error); |
| | | } |
| | | parent.routes.push(newRoute); |
| | | parent.children.push(newRoute); |
| | | if (Component) { |
| | | const newRoute = { |
| | | name: menu.name, |
| | | path: menu.path, |
| | | element: <Component />, |
| | | } |
| | | parent.routes.push(newRoute); |
| | | parent.children.push(newRoute); |
| | | } |
| | | } else { |
| | | // parent |
| | | const newRoute = { |