refactor(projects): 路由文件夹重构

This commit is contained in:
Soybean
2021-10-21 11:59:55 +08:00
parent b80c224664
commit b2854d57e8
28 changed files with 150 additions and 197 deletions

View File

@@ -1,23 +1,3 @@
import type { Component } from 'vue';
import { EnumRoutePath } from '@/enum';
import type { RoutePathKey } from '@/interface';
import { router } from '@/router';
/** 获取路由name map */
export function getRouteNameMap() {
return new Map<RoutePathKey, RoutePathKey>((Object.keys(EnumRoutePath) as RoutePathKey[]).map(v => [v, v]));
}
/** 给需要缓存的页面组件设置名称 */
export function setRouterCacheName(component: Component, name?: string) {
if (name) {
Object.assign(component, { name });
}
}
// 获取登录后的重定向地址
export function getLoginRedirectUrl() {
const path = router.currentRoute.value.fullPath as EnumRoutePath;
const redirectUrl = path === EnumRoutePath.root ? undefined : path;
return redirectUrl;
}
export { ROUTE_NAME_MAP, setRouterCacheName, getLoginRedirectUrl, setSingleRoute } from './helpers';
export { default as getCacheRoutes } from './cache';
export { default as transformRouteToMenu } from './menus';