mirror of
https://github.com/vbenjs/gf-vben-admin.git
synced 2025-02-02 19:08:40 +08:00
style: some format adjustments
This commit is contained in:
parent
bdce84537a
commit
e2333642c4
@ -23,12 +23,14 @@
|
||||
},
|
||||
},
|
||||
setup(props) {
|
||||
const showRef = ref<boolean>(!!props.showTitle);
|
||||
const { globSetting } = useSetting();
|
||||
const go = useGo();
|
||||
|
||||
function handleGoHome() {
|
||||
go(PageEnum.BASE_HOME);
|
||||
}
|
||||
const showRef = ref<boolean>(!!props.showTitle);
|
||||
|
||||
watch(
|
||||
() => props.showTitle,
|
||||
(show: boolean) => {
|
||||
@ -41,6 +43,7 @@
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
return {
|
||||
handleGoHome,
|
||||
globSetting,
|
||||
@ -55,7 +58,6 @@
|
||||
|
||||
.app-logo {
|
||||
display: flex;
|
||||
// justify-content: center;
|
||||
align-items: center;
|
||||
cursor: pointer;
|
||||
|
||||
|
@ -1,11 +1,12 @@
|
||||
import type { AppRouteRecordRaw } from '/@/router/types';
|
||||
|
||||
import { computed, toRaw, unref } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import router from '/@/router';
|
||||
|
||||
import { tabStore } from '/@/store/modules/tab';
|
||||
import { appStore } from '/@/store/modules/app';
|
||||
|
||||
import { AppRouteRecordRaw } from '/@/router/types';
|
||||
import { useRouter } from 'vue-router';
|
||||
import router from '/@/router';
|
||||
import { unique } from '/@/utils';
|
||||
|
||||
export function useFrameKeepAlive() {
|
||||
|
@ -1,19 +1,17 @@
|
||||
import { computed, defineComponent, unref, Transition, KeepAlive, toRaw } from 'vue';
|
||||
|
||||
import { appStore } from '/@/store/modules/app';
|
||||
|
||||
import { useTransition } from './useTransition';
|
||||
|
||||
import { RouterView, RouteLocation } from 'vue-router';
|
||||
import { tabStore } from '/@/store/modules/tab';
|
||||
|
||||
import FrameLayout from '/@/layouts/iframe/index.vue';
|
||||
|
||||
import { useTransition } from './useTransition';
|
||||
import { useSetting } from '/@/hooks/core/useSetting';
|
||||
// import { useRouter } from 'vue-router';
|
||||
|
||||
import { tabStore } from '/@/store/modules/tab';
|
||||
import { appStore } from '/@/store/modules/app';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'PageLayout',
|
||||
setup() {
|
||||
// const { currentRoute } = useRouter();
|
||||
const getProjectConfigRef = computed(() => {
|
||||
return appStore.getProjectConfig;
|
||||
});
|
||||
|
@ -22,6 +22,7 @@ export const PAGE_NOT_FOUND_ROUTE: AppRouteRecordRaw = {
|
||||
hideBreadcrumb: true,
|
||||
},
|
||||
};
|
||||
|
||||
export const REDIRECT_ROUTE: AppRouteRecordRaw = {
|
||||
path: '/redirect/:path(.*)*',
|
||||
name: 'Redirect',
|
||||
@ -31,16 +32,3 @@ export const REDIRECT_ROUTE: AppRouteRecordRaw = {
|
||||
hideBreadcrumb: true,
|
||||
},
|
||||
};
|
||||
|
||||
// Whole site 404
|
||||
// export const FULL_PAGE_NOT_FOUND_ROUTE: AppRouteRecordRaw = {
|
||||
// path: '/:path(.*)*',
|
||||
// name: 'FullErrorPage',
|
||||
// component: EXCEPTION_COMPONENT,
|
||||
// props: {
|
||||
// full: true,
|
||||
// },
|
||||
// meta: {
|
||||
// title: 'FullErrorPage',
|
||||
// },
|
||||
// };
|
||||
|
@ -1,13 +1,16 @@
|
||||
import type { Router } from 'vue-router';
|
||||
|
||||
import { Modal, notification } from 'ant-design-vue';
|
||||
import { AxiosCanceler } from '/@/utils/http/axios/axiosCancel';
|
||||
|
||||
import { createProgressGuard } from './progressGuard';
|
||||
import { createPermissionGuard } from './permissionGuard';
|
||||
import { createPageLoadingGuard } from './pageLoadingGuard';
|
||||
|
||||
import { useSetting } from '/@/hooks/core/useSetting';
|
||||
|
||||
import { getIsOpenTab, setCurrentTo } from '/@/utils/helper/routeHelper';
|
||||
import { setTitle } from '/@/utils/browser';
|
||||
import { AxiosCanceler } from '/@/utils/http/axios/axiosCancel';
|
||||
|
||||
const { projectSetting, globSetting } = useSetting();
|
||||
export function createGuard(router: Router) {
|
||||
@ -36,10 +39,7 @@ export function createGuard(router: Router) {
|
||||
|
||||
router.afterEach((to) => {
|
||||
// change html title
|
||||
|
||||
setTimeout(() => {
|
||||
setTitle(to.meta.title, globSetting.title);
|
||||
}, 0);
|
||||
setTitle(to.meta.title, globSetting.title);
|
||||
});
|
||||
|
||||
openNProgress && createProgressGuard(router);
|
||||
|
@ -2,12 +2,11 @@ import type { Router, RouteRecordRaw } from 'vue-router';
|
||||
|
||||
import { userStore } from '/@/store/modules/user';
|
||||
import { permissionStore } from '/@/store/modules/permission';
|
||||
|
||||
import { PageEnum } from '/@/enums/pageEnum';
|
||||
import { getToken } from '/@/utils/auth';
|
||||
import {
|
||||
// FULL_PAGE_NOT_FOUND_ROUTE,
|
||||
PAGE_NOT_FOUND_ROUTE,
|
||||
} from '/@/router/constant';
|
||||
|
||||
import { PAGE_NOT_FOUND_ROUTE } from '/@/router/constant';
|
||||
import { RootRoute } from '../routes/index';
|
||||
|
||||
const LOGIN_PATH = PageEnum.BASE_LOGIN;
|
||||
@ -60,6 +59,7 @@ export function createPermissionGuard(router: Router) {
|
||||
permissionStore.commitDynamicAddedRouteState(true);
|
||||
next(nextData);
|
||||
});
|
||||
|
||||
router.afterEach((to) => {
|
||||
// Just enter the login page and clear the authentication information
|
||||
if (to.path === LOGIN_PATH) {
|
||||
|
@ -11,6 +11,7 @@ export function createProgressGuard(router: Router) {
|
||||
!to.meta.inTab && NProgress.start();
|
||||
return true;
|
||||
});
|
||||
|
||||
router.afterEach(async (to) => {
|
||||
!to.meta.inTab && NProgress.done();
|
||||
return true;
|
||||
|
@ -2,6 +2,7 @@ import type { RouteRecordRaw } from 'vue-router';
|
||||
import type { App } from 'vue';
|
||||
|
||||
import { createRouter, createWebHashHistory } from 'vue-router';
|
||||
|
||||
import { scrollWaiter } from '../utils/scrollWaiter';
|
||||
|
||||
import { createGuard } from './guard/';
|
||||
@ -24,6 +25,7 @@ const router = createRouter({
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
// reset router
|
||||
export function resetRouter() {
|
||||
const resetWhiteNameList = [
|
||||
@ -45,21 +47,4 @@ export function setupRouter(app: App<Element>) {
|
||||
createGuard(router);
|
||||
}
|
||||
|
||||
// // hmr
|
||||
// if (import.meta.hot) {
|
||||
// let removeRoutes: (() => void)[] = [];
|
||||
|
||||
// for (let route of routes) {
|
||||
// removeRoutes.push(router.addRoute(route as RouteRecordRaw));
|
||||
// }
|
||||
|
||||
// import.meta.hot?.acceptDeps('./routes.ts', ({ routes }) => {
|
||||
// for (let removeRoute of removeRoutes) removeRoute();
|
||||
// removeRoutes = [];
|
||||
// for (let route of routes) {
|
||||
// removeRoutes.push(router.addRoute(route));
|
||||
// }
|
||||
// router.replace('');
|
||||
// });
|
||||
// }
|
||||
export default router;
|
||||
|
@ -9,33 +9,7 @@ import { PermissionModeEnum } from '/@/enums/appEnum';
|
||||
import { pathToRegexp } from 'path-to-regexp';
|
||||
import modules from 'globby!/@/router/menus/modules/**/*.@(ts)';
|
||||
|
||||
// ===========================
|
||||
// ==========module import====
|
||||
// ===========================
|
||||
// import dashboard from './modules/dashboard';
|
||||
|
||||
// import exceptionDemo from './modules/demo/exception';
|
||||
// import iframeDemo from './modules/demo/iframe';
|
||||
// import compDemo from './modules/demo/comp';
|
||||
// import permissionDemo from './modules/demo/permission';
|
||||
// import featDemo from './modules/demo/feat';
|
||||
// import chartsDemo from './modules/demo/charts';
|
||||
// import tableDemo from './modules/demo/table';
|
||||
// import formDemo from './modules/demo/form';
|
||||
// import treeDemo from './modules/demo/tree';
|
||||
|
||||
const menuModules: MenuModule[] = [
|
||||
// dashboard,
|
||||
// featDemo,
|
||||
// exceptionDemo,
|
||||
// iframeDemo,
|
||||
// compDemo,
|
||||
// permissionDemo,
|
||||
// chartsDemo,
|
||||
// tableDemo,
|
||||
// formDemo,
|
||||
// treeDemo,
|
||||
];
|
||||
const menuModules: MenuModule[] = [];
|
||||
|
||||
Object.keys(modules).forEach((key) => {
|
||||
menuModules.push(modules[key]);
|
||||
|
@ -4,30 +4,7 @@ import { DEFAULT_LAYOUT_COMPONENT, PAGE_NOT_FOUND_ROUTE, REDIRECT_ROUTE } from '
|
||||
import { genRouteModule } from '/@/utils/helper/routeHelper';
|
||||
import modules from 'globby!/@/router/routes/modules/**/*.@(ts)';
|
||||
|
||||
// import dashboard from './modules/dashboard';
|
||||
// demo
|
||||
// import exceptionDemo from './modules/demo/exception';
|
||||
// import iframeDemo from './modules/demo/iframe';
|
||||
// import compDemo from './modules/demo/comp';
|
||||
// import permissionDemo from './modules/demo/permission';
|
||||
// import featDemo from './modules/demo/feat';
|
||||
// import chartsDemo from './modules/demo/charts';
|
||||
// import tableDemo from './modules/demo/table';
|
||||
// import formDemo from './modules/demo/form';
|
||||
// import treeDemo from './modules/demo/tree';
|
||||
|
||||
const routeModuleList: AppRouteModule[] = [
|
||||
// exceptionDemo,
|
||||
// dashboard,
|
||||
// iframeDemo,
|
||||
// compDemo,
|
||||
// featDemo,
|
||||
// permissionDemo,
|
||||
// chartsDemo,
|
||||
// tableDemo,
|
||||
// formDemo,
|
||||
// treeDemo,
|
||||
];
|
||||
const routeModuleList: AppRouteModule[] = [];
|
||||
|
||||
Object.keys(modules).forEach((key) => {
|
||||
routeModuleList.push(modules[key]);
|
||||
@ -38,6 +15,7 @@ export const asyncRoutes = [
|
||||
PAGE_NOT_FOUND_ROUTE,
|
||||
...genRouteModule(routeModuleList),
|
||||
];
|
||||
|
||||
// 主框架根路由
|
||||
export const RootRoute: AppRouteRecordRaw = {
|
||||
path: '/',
|
||||
|
@ -66,25 +66,23 @@ export function scriptErrorHandler(
|
||||
if (event === 'Script error.' && !source) {
|
||||
return false;
|
||||
}
|
||||
setTimeout(function () {
|
||||
const errorInfo: Partial<ErrorInfo> = {};
|
||||
colno = colno || (window.event && (window.event as any).errorCharacter) || 0;
|
||||
errorInfo.message = event as string;
|
||||
if (error && error.stack) {
|
||||
errorInfo.stack = error.stack;
|
||||
} else {
|
||||
errorInfo.stack = '';
|
||||
}
|
||||
const name = source ? source.substr(source.lastIndexOf('/') + 1) : 'script';
|
||||
errorStore.commitErrorInfoState({
|
||||
type: ErrorTypeEnum.SCRIPT,
|
||||
name: name,
|
||||
file: source as string,
|
||||
detail: 'lineno' + lineno,
|
||||
url: window.location.href,
|
||||
...(errorInfo as Pick<ErrorInfo, 'message' | 'stack'>),
|
||||
});
|
||||
}, 0);
|
||||
const errorInfo: Partial<ErrorInfo> = {};
|
||||
colno = colno || (window.event && (window.event as any).errorCharacter) || 0;
|
||||
errorInfo.message = event as string;
|
||||
if (error && error.stack) {
|
||||
errorInfo.stack = error.stack;
|
||||
} else {
|
||||
errorInfo.stack = '';
|
||||
}
|
||||
const name = source ? source.substr(source.lastIndexOf('/') + 1) : 'script';
|
||||
errorStore.commitErrorInfoState({
|
||||
type: ErrorTypeEnum.SCRIPT,
|
||||
name: name,
|
||||
file: source as string,
|
||||
detail: 'lineno' + lineno,
|
||||
url: window.location.href,
|
||||
...(errorInfo as Pick<ErrorInfo, 'message' | 'stack'>),
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,9 @@ const store = createStore({
|
||||
strict: isDev,
|
||||
// plugins,
|
||||
});
|
||||
|
||||
export function setupStore(app: App<Element>) {
|
||||
app.use(store);
|
||||
}
|
||||
|
||||
export default store;
|
||||
|
@ -1,13 +1,14 @@
|
||||
import store from '/@/store';
|
||||
import { hotModuleUnregisterModule } from '/@/utils/helper/vuexHelper';
|
||||
import type { ProjectConfig } from '/@/types/config';
|
||||
|
||||
import { VuexModule, getModule, Module, Mutation, Action } from 'vuex-module-decorators';
|
||||
import store from '/@/store';
|
||||
|
||||
import { PROJ_CFG_KEY, LOCK_INFO_KEY } from '/@/enums/cacheEnum';
|
||||
import { ProjectConfig } from '/@/types/config';
|
||||
|
||||
// import { userStore } from './user';
|
||||
import { hotModuleUnregisterModule } from '/@/utils/helper/vuexHelper';
|
||||
import { setLocal, getLocal, removeLocal } from '/@/utils/helper/persistent';
|
||||
import { deepMerge } from '/@/utils';
|
||||
|
||||
import { userStore } from './user';
|
||||
|
||||
export interface LockInfo {
|
||||
@ -20,12 +21,16 @@ const NAME = 'app';
|
||||
hotModuleUnregisterModule(NAME);
|
||||
@Module({ dynamic: true, namespaced: true, store, name: NAME })
|
||||
class App extends VuexModule {
|
||||
// Page loading status
|
||||
private pageLoadingState = false;
|
||||
|
||||
// project config
|
||||
private projectConfigState: ProjectConfig | null = getLocal(PROJ_CFG_KEY);
|
||||
|
||||
// lock info
|
||||
private lockInfoState: LockInfo | null = getLocal(LOCK_INFO_KEY);
|
||||
|
||||
// set main overflow hidden
|
||||
private lockMainScrollState = false;
|
||||
|
||||
get getPageLoading() {
|
||||
@ -87,7 +92,7 @@ class App extends VuexModule {
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @description: 解锁
|
||||
// * @description: unlock page
|
||||
// */
|
||||
@Action
|
||||
public async unLockAction({ password, valid = true }: { password: string; valid?: boolean }) {
|
||||
|
@ -25,7 +25,10 @@ const NAME = 'error';
|
||||
hotModuleUnregisterModule(NAME);
|
||||
@Module({ dynamic: true, namespaced: true, store, name: NAME })
|
||||
class Error extends VuexModule implements ErrorState {
|
||||
// error log list
|
||||
errorInfoState: ErrorInfo[] = [];
|
||||
|
||||
// error log count
|
||||
errorListCountState = 0;
|
||||
|
||||
get getErrorInfoState() {
|
||||
|
@ -26,16 +26,16 @@ const NAME = 'permission';
|
||||
hotModuleUnregisterModule(NAME);
|
||||
@Module({ dynamic: true, namespaced: true, store, name: NAME })
|
||||
class Permission extends VuexModule {
|
||||
// private routesState: AppRouteRecordRaw[] = [];
|
||||
|
||||
// 权限编码列表
|
||||
// Permission code list
|
||||
private permCodeListState: string[] = [];
|
||||
|
||||
// Whether the route has been dynamically added
|
||||
private isDynamicAddedRouteState = false;
|
||||
|
||||
// To trigger a menu update
|
||||
private lastBuildMenuTimeState = 0;
|
||||
|
||||
// Backstage menu list
|
||||
private backMenuListState: Menu[] = [];
|
||||
|
||||
get getPermCodeListState() {
|
||||
@ -50,10 +50,6 @@ class Permission extends VuexModule {
|
||||
return this.lastBuildMenuTimeState;
|
||||
}
|
||||
|
||||
// get getRoutesState() {
|
||||
// return this.routesState;
|
||||
// }
|
||||
|
||||
get getIsDynamicAddedRouteState() {
|
||||
return this.isDynamicAddedRouteState;
|
||||
}
|
||||
@ -73,11 +69,6 @@ class Permission extends VuexModule {
|
||||
this.lastBuildMenuTimeState = new Date().getTime();
|
||||
}
|
||||
|
||||
// @Mutation
|
||||
// commitRoutesState(routes: AppRouteRecordRaw[]): void {
|
||||
// this.routesState = routes;
|
||||
// }
|
||||
|
||||
@Mutation
|
||||
commitDynamicAddedRouteState(added: boolean): void {
|
||||
this.isDynamicAddedRouteState = added;
|
||||
|
@ -34,18 +34,15 @@ const getOpenKeepAliveRef = computed(() => appStore.getProjectConfig.openKeepAli
|
||||
|
||||
@Module({ namespaced: true, name: NAME, dynamic: true, store })
|
||||
class Tab extends VuexModule {
|
||||
// tab列表
|
||||
// tab list
|
||||
tabsState: TabItem[] = [];
|
||||
// 缓存列表
|
||||
// tab cache list
|
||||
keepAliveTabsState: CacheName[] = [];
|
||||
|
||||
currentContextMenuIndexState = -1;
|
||||
|
||||
currentContextMenuState: TabItem | null = null;
|
||||
|
||||
/**
|
||||
* @description: 获取tabs
|
||||
*/
|
||||
get getTabsState() {
|
||||
return this.tabsState;
|
||||
}
|
||||
@ -58,9 +55,6 @@ class Tab extends VuexModule {
|
||||
return this.currentContextMenuState;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 获取缓存的tab列表
|
||||
*/
|
||||
get getKeepAliveTabsState() {
|
||||
return this.keepAliveTabsState;
|
||||
}
|
||||
|
@ -58,7 +58,6 @@ class User extends VuexModule {
|
||||
this.userInfoState = null;
|
||||
this.tokenState = '';
|
||||
this.roleListState = [];
|
||||
// permissionStore.commitReset();
|
||||
}
|
||||
|
||||
@Mutation
|
||||
@ -136,7 +135,6 @@ class User extends VuexModule {
|
||||
resetRouter();
|
||||
clearSession();
|
||||
clearLocal();
|
||||
// router.addRoute(FULL_PAGE_NOT_FOUND_ROUTE as RouteRecordRaw);
|
||||
permissionStore.commitResetState();
|
||||
tabStore.commitResetState();
|
||||
this.resetState();
|
||||
|
10
src/types/config.d.ts
vendored
10
src/types/config.d.ts
vendored
@ -70,7 +70,6 @@ export interface ProjectConfig {
|
||||
headerSetting: HeaderSetting;
|
||||
// 菜单类型
|
||||
// menuType: MenuTypeEnum;
|
||||
|
||||
menuSetting: MenuSetting;
|
||||
|
||||
messageSetting: MessageSetting;
|
||||
@ -88,15 +87,12 @@ export interface ProjectConfig {
|
||||
showBreadCrumbIcon: boolean;
|
||||
// 使用error-handler-plugin
|
||||
useErrorHandle: boolean;
|
||||
|
||||
// 开启页面切换动画
|
||||
openRouterTransition: boolean;
|
||||
// 路由切换动画
|
||||
routerTransition: RouterTransitionEnum;
|
||||
|
||||
// 是否开启登录安全校验
|
||||
openLoginVerify: boolean;
|
||||
|
||||
// 是否监听网络变化
|
||||
listenNetWork: boolean;
|
||||
// 是否开启页面切换loading
|
||||
@ -116,23 +112,17 @@ export interface ProjectConfig {
|
||||
export interface GlobConfig {
|
||||
// 网站标题
|
||||
title: string;
|
||||
|
||||
// 项目路径
|
||||
apiUrl: string;
|
||||
|
||||
urlPrefix?: string;
|
||||
|
||||
shortName: string;
|
||||
}
|
||||
export interface GlobEnvConfig {
|
||||
// 网站标题
|
||||
VITE_GLOB_APP_TITLE: string;
|
||||
|
||||
// 项目路径
|
||||
VITE_GLOB_API_URL: string;
|
||||
|
||||
VITE_GLOB_API_URL_PREFIX?: string;
|
||||
|
||||
VITE_GLOB_APP_SHORT_NAME: string;
|
||||
}
|
||||
|
||||
|
2
src/types/global.d.ts
vendored
2
src/types/global.d.ts
vendored
@ -9,6 +9,7 @@ declare interface IObj<T = any> {
|
||||
}
|
||||
|
||||
declare function parseInt(s: string | number, radix?: number): number;
|
||||
|
||||
declare function parseFloat(string: string | number): number;
|
||||
|
||||
declare type Dictionary<T> = Record<string, T>;
|
||||
@ -26,6 +27,7 @@ declare type CustomizedHTMLElement<T> = HTMLElement & T;
|
||||
declare type Indexable<T = any> = {
|
||||
[key: string]: T;
|
||||
};
|
||||
|
||||
declare type Hash<T> = Indexable<T>;
|
||||
|
||||
declare type DeepPartial<T> = {
|
||||
|
3
src/types/module.d.ts
vendored
3
src/types/module.d.ts
vendored
@ -1,4 +1,7 @@
|
||||
declare module 'ant-design-vue/es/locale/zh_CN';
|
||||
|
||||
declare module 'globby!/@/router/routes/modules/**/*.@(ts)';
|
||||
|
||||
declare module 'globby!/@/router/menus/modules/**/*.@(ts)';
|
||||
|
||||
declare const React: string;
|
||||
|
6
src/types/shim-tsx.d.ts
vendored
6
src/types/shim-tsx.d.ts
vendored
@ -1,12 +1,8 @@
|
||||
// 文件: `shim-tsx.d.ts`
|
||||
import Vue, { VNode } from 'vue';
|
||||
import type { ComponentRenderProxy } from '@vue/composition-api';
|
||||
import type { ComponentRenderProxy, VNode } from 'vue';
|
||||
|
||||
declare module '*.tsx' {
|
||||
import { defineComponent } from 'vue';
|
||||
const component: ReturnType<defineComponent>;
|
||||
// import { ComponentOptions } from 'vue';
|
||||
// const component: ReturnType<ComponentOptions>;
|
||||
export default component;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user