提交 | 用户 | 时间
|
cb6cd2
|
1 |
import type { RouteMeta, RouteLocationNormalizedLoaded } from 'vue-router' |
H |
2 |
import { pathResolve } from '@/utils/routerHelper' |
|
3 |
|
|
4 |
export const filterAffixTags = (routes: AppRouteRecordRaw[], parentPath = '') => { |
|
5 |
let tags: RouteLocationNormalizedLoaded[] = [] |
|
6 |
routes.forEach((route) => { |
|
7 |
const meta = route.meta as RouteMeta |
|
8 |
const tagPath = pathResolve(parentPath, route.path) |
|
9 |
if (meta?.affix) { |
|
10 |
tags.push({ ...route, path: tagPath, fullPath: tagPath } as RouteLocationNormalizedLoaded) |
|
11 |
} |
|
12 |
if (route.children) { |
|
13 |
const tempTags: RouteLocationNormalizedLoaded[] = filterAffixTags(route.children, tagPath) |
|
14 |
if (tempTags.length >= 1) { |
|
15 |
tags = [...tags, ...tempTags] |
|
16 |
} |
|
17 |
} |
|
18 |
}) |
|
19 |
|
|
20 |
return tags |
|
21 |
} |