|
|
@ -54,6 +54,7 @@ |
|
|
watchEffect(async () => { |
|
|
watchEffect(async () => { |
|
|
if (currentRoute.value.name === REDIRECT_NAME) return; |
|
|
if (currentRoute.value.name === REDIRECT_NAME) return; |
|
|
const menus = await getMenus(); |
|
|
const menus = await getMenus(); |
|
|
|
|
|
|
|
|
const routeMatched = currentRoute.value.matched; |
|
|
const routeMatched = currentRoute.value.matched; |
|
|
const cur = routeMatched?.[routeMatched.length - 1]; |
|
|
const cur = routeMatched?.[routeMatched.length - 1]; |
|
|
let path = currentRoute.value.path; |
|
|
let path = currentRoute.value.path; |
|
|
@ -63,26 +64,20 @@ |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
const parent = getAllParentPath(menus, path); |
|
|
const parent = getAllParentPath(menus, path); |
|
|
|
|
|
|
|
|
const filterMenus = menus.filter((item) => item.path === parent[0]); |
|
|
const filterMenus = menus.filter((item) => item.path === parent[0]); |
|
|
|
|
|
|
|
|
const matched = getMatched(filterMenus, parent) as any; |
|
|
const matched = getMatched(filterMenus, parent) as any; |
|
|
|
|
|
|
|
|
if (!matched || matched.length === 0) return; |
|
|
if (!matched || matched.length === 0) return; |
|
|
|
|
|
|
|
|
let breadcrumbList = filterItem(matched); |
|
|
const breadcrumbList = filterItem(matched); |
|
|
|
|
|
|
|
|
const filterBreadcrumbList = breadcrumbList.filter( |
|
|
|
|
|
(item) => item.path !== PageEnum.BASE_HOME |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
if (currentRoute.value.meta?.currentActiveMenu) { |
|
|
if (currentRoute.value.meta?.currentActiveMenu) { |
|
|
filterBreadcrumbList.push(({ |
|
|
breadcrumbList.push(({ |
|
|
...currentRoute.value, |
|
|
...currentRoute.value, |
|
|
name: currentRoute.value.meta?.title || currentRoute.value.name, |
|
|
name: currentRoute.value.meta?.title || currentRoute.value.name, |
|
|
} as unknown) as RouteLocationMatched); |
|
|
} as unknown) as RouteLocationMatched); |
|
|
} |
|
|
} |
|
|
routes.value = filterBreadcrumbList; |
|
|
routes.value = breadcrumbList; |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
function getMatched(menus: Menu[], parent: string[]) { |
|
|
function getMatched(menus: Menu[], parent: string[]) { |
|
|
@ -103,12 +98,10 @@ |
|
|
|
|
|
|
|
|
function filterItem(list: RouteLocationMatched[]) { |
|
|
function filterItem(list: RouteLocationMatched[]) { |
|
|
let resultList = filter(list, (item) => { |
|
|
let resultList = filter(list, (item) => { |
|
|
const { meta } = item; |
|
|
const { meta, name } = item; |
|
|
|
|
|
|
|
|
if (!meta) { |
|
|
if (!meta) { |
|
|
return false; |
|
|
return !!name; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
const { title, hideBreadcrumb, hideMenu } = meta; |
|
|
const { title, hideBreadcrumb, hideMenu } = meta; |
|
|
if (!title || hideBreadcrumb || hideMenu) { |
|
|
if (!title || hideBreadcrumb || hideMenu) { |
|
|
return false; |
|
|
return false; |
|
|
|