feat(build): 优化路由配置并添加 404 页面

- 在主路由中添加 mainEntry组件作为主入口
- 在主入口下添加所有扫描路由作为子路由
- 添加 404 页面作为未匹配路由的处理- 修改 mainEntry 组件,使用 router-view 替代动态组件
This commit is contained in:
aixianling
2024-12-23 10:45:38 +08:00
parent 4684952973
commit 9ff89c19f3
2 changed files with 7 additions and 3 deletions

View File

@@ -51,14 +51,18 @@ const createRoutes = (config = {}) => {
{path: "/login", name: "登录", component: () => import('${signPage}')},
{path: '/dv', name: '数据大屏入口', component: () => import('../views/dvIndex')},
{path: '/v', name: 'Home', component: () => import('../views/home'), children: [
${routes.map(e => {
{path:'/',name:'mainEntry', component:()=>import('../views/mainEntry'),children:[
${routes.map(e => {
// 解构每个路由的属性,用于生成路由配置
const {name, label, esm} = e
// 生成单个路由配置的字符串表示
return `{name:"${name}",label:"${label}",path:"${name}",component:()=>import("../${esm}")}`
}).join(',\n')}
}).join(',\n')},
{path: '*',name: '404',component: ()=>import('../views/building')},
]}
]},
{path: '/', name: "init"},
]`)
// 扫描完毕使用chalkTag标记任务完成
chalkTag.done("扫描完毕")