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: "/login", name: "登录", component: () => import('${signPage}')},
|
||||||
{path: '/dv', name: '数据大屏入口', component: () => import('../views/dvIndex')},
|
{path: '/dv', name: '数据大屏入口', component: () => import('../views/dvIndex')},
|
||||||
{path: '/v', name: 'Home', component: () => import('../views/home'), children: [
|
{path: '/v', name: 'Home', component: () => import('../views/home'), children: [
|
||||||
|
{path:'/',name:'mainEntry', component:()=>import('../views/mainEntry'),children:[
|
||||||
${routes.map(e => {
|
${routes.map(e => {
|
||||||
// 解构每个路由的属性,用于生成路由配置
|
// 解构每个路由的属性,用于生成路由配置
|
||||||
const {name, label, esm} = e
|
const {name, label, esm} = e
|
||||||
// 生成单个路由配置的字符串表示
|
// 生成单个路由配置的字符串表示
|
||||||
return `{name:"${name}",label:"${label}",path:"${name}",component:()=>import("../${esm}")}`
|
return `{name:"${name}",label:"${label}",path:"${name}",component:()=>import("../${esm}")}`
|
||||||
}).join(',\n')}
|
}).join(',\n')},
|
||||||
|
{path: '*',name: '404',component: ()=>import('../views/building')},
|
||||||
|
]}
|
||||||
]},
|
]},
|
||||||
{path: '/', name: "init"},
|
{path: '/', name: "init"},
|
||||||
|
|
||||||
]`)
|
]`)
|
||||||
// 扫描完毕,使用chalkTag标记任务完成
|
// 扫描完毕,使用chalkTag标记任务完成
|
||||||
chalkTag.done("扫描完毕")
|
chalkTag.done("扫描完毕")
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<ai-intro :id="currentApp.guideId" :instance="$request" @start="handleStartUse"/>
|
<ai-intro :id="currentApp.guideId" :instance="$request" @start="handleStartUse"/>
|
||||||
</template>
|
</template>
|
||||||
</ai-detail>
|
</ai-detail>
|
||||||
<component v-else :is="app" :instance="$request" :dict="$dict" :permissions="$permissions" :menuName="currentApp.name"/>
|
<router-view v-else :instance="$request" :dict="$dict" :permissions="$permissions" :menuName="currentApp.name"/>
|
||||||
</section>
|
</section>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user