Browse Source

chore: exception

master
wangxiang 2 years ago
parent
commit
25175b6bd6
No known key found for this signature in database
GPG Key ID: 1BA7946AB6B232E4
  1. 4
      src/router/routes/basic.ts
  2. 10
      src/store/modules/app.ts

4
src/router/routes/basic.ts

@ -8,6 +8,7 @@ @@ -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 = { @@ -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,

10
src/store/modules/app.ts

@ -21,6 +21,7 @@ import { Persistent } from '/@/utils/cache/persistent'; @@ -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 { @@ -31,6 +32,8 @@ interface AppState {
projectConfig: ProjectConfig | null;
// 当窗口收缩时,记住一些状态,在窗口恢复时恢复这些状态
beforeMiniInfo: BeforeMiniState;
// 页面异常状态
pageException: ExceptionEnum;
}
let timeId: TimeoutHandle;
@ -41,11 +44,15 @@ export const useAppStore = defineStore({ @@ -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({ @@ -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);

Loading…
Cancel
Save