diff --git a/src/router/routes/basic.ts b/src/router/routes/basic.ts index 9415bc4..0efb6d3 100644 --- a/src/router/routes/basic.ts +++ b/src/router/routes/basic.ts @@ -8,6 +8,7 @@ import type { AppRouteRecordRaw } from '/@/router/types'; import { REDIRECT_NAME, LAYOUT, EXCEPTION_COMPONENT, PAGE_NOT_FOUND_NAME } from '/@/router/constant'; +import { useAppStoreWithOut } from '/@/store/modules/app'; export const PAGE_NOT_FOUND_ROUTE: AppRouteRecordRaw = { path: '/:path(.*)*', @@ -23,6 +24,9 @@ export const PAGE_NOT_FOUND_ROUTE: AppRouteRecordRaw = { path: '/:path(.*)*', name: PAGE_NOT_FOUND_NAME, component: EXCEPTION_COMPONENT, + props: () => ({ + status: useAppStoreWithOut().getPageException + }), meta: { title: 'ErrorPage', hideBreadcrumb: true, diff --git a/src/store/modules/app.ts b/src/store/modules/app.ts index 898e47a..35f6768 100644 --- a/src/store/modules/app.ts +++ b/src/store/modules/app.ts @@ -21,6 +21,7 @@ import { Persistent } from '/@/utils/cache/persistent'; import { darkMode } from '/@/settings/designSetting'; import { resetRouter } from '/@/router'; import { deepMerge } from '/@/utils'; +import { ExceptionEnum } from '/@/enums/exceptionEnum'; interface AppState { // 主题颜色 @@ -31,6 +32,8 @@ interface AppState { projectConfig: ProjectConfig | null; // 当窗口收缩时,记住一些状态,在窗口恢复时恢复这些状态 beforeMiniInfo: BeforeMiniState; + // 页面异常状态 + pageException: ExceptionEnum; } let timeId: TimeoutHandle; @@ -41,11 +44,15 @@ export const useAppStore = defineStore({ pageLoading: false, projectConfig: Persistent.getLocal(PROJ_CFG_KEY), beforeMiniInfo: {}, + pageException: ExceptionEnum.PAGE_NOT_FOUND, }), getters: { getPageLoading(): boolean { return this.pageLoading; }, + getPageException(): ExceptionEnum { + return this.pageException; + }, getDarkMode(): 'light' | 'dark' | string { return this.darkMode || darkMode; }, @@ -72,6 +79,9 @@ export const useAppStore = defineStore({ setPageLoading(loading: boolean): void { this.pageLoading = loading; }, + setPageException(exception: ExceptionEnum): void { + this.pageException = exception; + }, setDarkMode(mode: ThemeEnum): void { this.darkMode = mode; localStorage.setItem(APP_DARK_MODE_KEY, mode);