mirror of
https://github.com/m-xlsea/ruoyi-plus-soybean.git
synced 2025-09-24 07:49:47 +08:00
feat(projects): new router system [新的路由系统]
This commit is contained in:
@ -1,35 +0,0 @@
|
||||
import type { Component } from 'vue';
|
||||
import { BasicLayout, BlankLayout } from '@/layouts';
|
||||
import { views } from '@/views';
|
||||
|
||||
type LayoutComponent = Record<EnumType.LayoutComponentName, () => Promise<Component>>;
|
||||
|
||||
/**
|
||||
* 获取页面导入的vue文件(懒加载的方式)
|
||||
* @param layoutType - 布局类型
|
||||
*/
|
||||
export function getLayoutComponent(layoutType: EnumType.LayoutComponentName) {
|
||||
const layoutComponent: LayoutComponent = {
|
||||
basic: BasicLayout,
|
||||
blank: BlankLayout
|
||||
};
|
||||
return layoutComponent[layoutType];
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取页面导入的vue文件(懒加载的方式)
|
||||
* @param routeKey - 路由key
|
||||
*/
|
||||
export function getViewComponent(routeKey: AuthRoute.RouteKey) {
|
||||
if (!views[routeKey]) {
|
||||
window.console.error(`路由“${routeKey}”没有对应的组件文件!`);
|
||||
}
|
||||
return () => setViewComponentName(views[routeKey], routeKey) as Promise<Component>;
|
||||
}
|
||||
|
||||
/** 给页面组件设置名称 */
|
||||
async function setViewComponentName(asyncComponent: () => Promise<Component>, name: string) {
|
||||
const component = (await asyncComponent()) as { default: Component };
|
||||
Object.assign(component.default, { name });
|
||||
return component;
|
||||
}
|
Reference in New Issue
Block a user