diff --git a/src/router/modules/remaining.ts b/src/router/modules/remaining.ts index ef79752f..bf2ba2bb 100644 --- a/src/router/modules/remaining.ts +++ b/src/router/modules/remaining.ts @@ -593,6 +593,16 @@ const remainingRouter: AppRouteRecordRaw[] = [ } } ] + }, + { + path: '/:pathMatch(.*)*', + component: () => import('@/views/Error/404.vue'), + name: '', + meta: { + title: '404', + hidden: true, + breadcrumb: false + } } ] diff --git a/src/store/modules/permission.ts b/src/store/modules/permission.ts index 5e3287a7..fc927f42 100644 --- a/src/store/modules/permission.ts +++ b/src/store/modules/permission.ts @@ -40,10 +40,12 @@ export const usePermissionStore = defineStore('permission', { } const routerMap: AppRouteRecordRaw[] = generateRoute(res) // 动态路由,404一定要放到最后面 + // preschooler:vue-router@4以后已支持静态404路由,此处可不再追加 this.addRouters = routerMap.concat([ { path: '/:path(.*)*', - redirect: '/404', + // redirect: '/404', + component: () => import('@/views/Error/404.vue'), name: '404Page', meta: { hidden: true,