task-12(壳层/路由): 实现路由级错误页面(404 兜底)
新增 src/pages/error/NotFoundPage.vue(el-result + 返回首页),router 在业务路由 之后注册 :pathMatch(.*)* 兜底(无 menuKey,不参与权限门禁),保留壳层 chrome; main.css 增加 .not-found 布局。
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { createRouter, createWebHistory, type RouteRecordRaw } from 'vue-router'
|
||||
import type { AdminMenuNode } from '@/types/admin'
|
||||
import AdminLayout from '@/layout/AdminLayout.vue'
|
||||
import NotFoundPage from '@/pages/error/NotFoundPage.vue'
|
||||
import { useAdminSessionStore } from '@/stores/admin-session'
|
||||
import { APP_BASE_PATH } from '@/config/app'
|
||||
import { adminRouteRecords } from './routes'
|
||||
@@ -12,10 +13,13 @@ const router = createRouter({
|
||||
{
|
||||
path: '/',
|
||||
component: AdminLayout,
|
||||
children: adminRouteRecords.map((record) => ({
|
||||
...record,
|
||||
component: defineLazyPage(record.component as () => Promise<{ default: unknown }>),
|
||||
})) as RouteRecordRaw[],
|
||||
children: [
|
||||
...adminRouteRecords.map((record) => ({
|
||||
...record,
|
||||
component: defineLazyPage(record.component as () => Promise<{ default: unknown }>),
|
||||
})),
|
||||
{ path: ':pathMatch(.*)*', component: NotFoundPage, meta: { title: '页面不存在' } },
|
||||
] as RouteRecordRaw[],
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user