import type { RouteMeta, RouteLocationNormalizedLoaded } from 'vue-router'
|
import { pathResolve } from '@/utils/routerHelper'
|
|
export const filterAffixTags = (routes: AppRouteRecordRaw[], parentPath = '') => {
|
let tags: RouteLocationNormalizedLoaded[] = []
|
routes.forEach((route) => {
|
const meta = route.meta as RouteMeta
|
const tagPath = pathResolve(parentPath, route.path)
|
if (meta?.affix) {
|
tags.push({ ...route, path: tagPath, fullPath: tagPath } as RouteLocationNormalizedLoaded)
|
}
|
if (route.children) {
|
const tempTags: RouteLocationNormalizedLoaded[] = filterAffixTags(route.children, tagPath)
|
if (tempTags.length >= 1) {
|
tags = [...tags, ...tempTags]
|
}
|
}
|
})
|
|
return tags
|
}
|