feat(projects): 添加页面缓存、记录在tab中的缓存页面的滚动条位置

This commit is contained in:
Soybean
2022-01-21 23:59:14 +08:00
parent db3c25ea14
commit 1d63a83822
26 changed files with 343 additions and 160 deletions

View File

@ -1,4 +1,6 @@
import type { Component } from 'vue';
import { EnumLayoutComponentName } from '@/enum';
import { BasicLayout, BlankLayout } from '@/layouts';
import {
Login,
NoPermission,
@ -14,6 +16,21 @@ import {
MultiMenuFirstSecond,
MultiMenuFirstSecondNewThird
} from '@/views';
import type { LayoutComponentName } from '@/interface';
type LayoutComponent = Record<LayoutComponentName, () => Promise<Component>>;
/**
* 获取页面导入的vue文件(懒加载的方式)
* @param layoutType - 布局类型
*/
export function getLayoutComponent(layoutType: LayoutComponentName) {
const layoutComponent: LayoutComponent = {
basic: BasicLayout,
blank: BlankLayout
};
return () => setViewComponentName(layoutComponent[layoutType], EnumLayoutComponentName[layoutType]);
}
/** 需要用到自身vue组件的页面 */
type ViewComponentKey = Exclude<
@ -28,12 +45,11 @@ type ViewComponentKey = Exclude<
| 'exception'
>;
type ViewComponent = {
[key in ViewComponentKey]: () => Promise<Component>;
};
type ViewComponent = Record<ViewComponentKey, () => Promise<Component>>;
/**
* 获取页面导入的vue文件(懒加载的方式)
* @param routeKey - 路由key
*/
export function getViewComponent(routeKey: AuthRoute.RouteKey) {
const keys: ViewComponentKey[] = [