mirror of
https://github.com/m-xlsea/ruoyi-plus-soybean.git
synced 2025-09-24 07:49:47 +08:00
feat(projects): 迁移多页签
This commit is contained in:
33
src/store/modules/tab/helpers.ts
Normal file
33
src/store/modules/tab/helpers.ts
Normal 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;
|
||||
}
|
Reference in New Issue
Block a user