refactor(projects): 重构路由类型和路由元数据类型,重构多级菜单路由写法

This commit is contained in:
Soybean
2021-11-28 12:17:48 +08:00
parent 9fb641f71e
commit d683894beb
20 changed files with 144 additions and 115 deletions

View File

@ -1,6 +1,13 @@
import type { Component } from 'vue';
import type { RouteRecordRaw } from 'vue-router';
/** 给需要缓存的页面组件设置名称 */
function setComponentName(component?: Component, name?: string) {
if (component && name) {
Object.assign(component, { name });
}
}
function getCacheName(route: RouteRecordRaw, isCache: boolean) {
const cacheNames: string[] = [];
const hasChild = hasChildren(route);
@ -26,13 +33,6 @@ function hasChildren(route: RouteRecordRaw) {
return Boolean(route.children && route.children.length);
}
/** 给需要缓存的页面组件设置名称 */
export function setComponentName(component?: Component, name?: string) {
if (component && name) {
Object.assign(component, { name });
}
}
/** 获取被缓存的路由 */
export function getCacheRoutes(routes: RouteRecordRaw[]) {
const cacheNames: string[] = [];