feat(build): 优化路由配置并添加 404 页面
- 在主路由中添加 mainEntry组件作为主入口 - 在主入口下添加所有扫描路由作为子路由 - 添加 404 页面作为未匹配路由的处理- 修改 mainEntry 组件,使用 router-view 替代动态组件
This commit is contained in:
@@ -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("扫描完毕")
|
||||
|
||||
Reference in New Issue
Block a user