feat(projects): 迁移多页签

This commit is contained in:
Soybean
2022-01-20 00:56:59 +08:00
parent cc290accc2
commit 28efbdbc70
26 changed files with 868 additions and 20 deletions

View File

@ -0,0 +1,33 @@
import type { RouteRecordNormalized, RouteLocationNormalizedLoaded } from 'vue-router';
import type { GlobalTabRoute } from '@/interface';
/**
* 根据vue路由获取tab路由
* @param route
*/
export function getTabRouteByVueRoute(route: RouteRecordNormalized | RouteLocationNormalizedLoaded) {
const tabRoute: GlobalTabRoute = {
name: route.name,
path: route.path,
meta: route.meta
};
return tabRoute;
}
/**
* 获取该页签在多页签数据中的索引
* @param tabs - 多页签数据
* @param path - 该页签的路径
*/
export function getIndexInTabRoutes(tabs: GlobalTabRoute[], path: string) {
return tabs.findIndex(tab => tab.path === path);
}
/**
* 判断该页签是否在多页签数据中
* @param tabs - 多页签数据
* @param path - 该页签的路径
*/
export function isInTabRoutes(tabs: GlobalTabRoute[], path: string) {
return getIndexInTabRoutes(tabs, path) > -1;
}