|
54 | 54 | watchEffect(async () => { |
55 | 55 | if (currentRoute.value.name === REDIRECT_NAME) return; |
56 | 56 | const menus = await getMenus(); |
| 57 | +
|
57 | 58 | const routeMatched = currentRoute.value.matched; |
58 | 59 | const cur = routeMatched?.[routeMatched.length - 1]; |
59 | 60 | let path = currentRoute.value.path; |
|
63 | 64 | } |
64 | 65 |
|
65 | 66 | const parent = getAllParentPath(menus, path); |
66 | | -
|
67 | 67 | const filterMenus = menus.filter((item) => item.path === parent[0]); |
68 | | -
|
69 | 68 | const matched = getMatched(filterMenus, parent) as any; |
70 | 69 |
|
71 | 70 | if (!matched || matched.length === 0) return; |
72 | 71 |
|
73 | | - let breadcrumbList = filterItem(matched); |
74 | | -
|
75 | | - const filterBreadcrumbList = breadcrumbList.filter( |
76 | | - (item) => item.path !== PageEnum.BASE_HOME |
77 | | - ); |
| 72 | + const breadcrumbList = filterItem(matched); |
78 | 73 |
|
79 | 74 | if (currentRoute.value.meta?.currentActiveMenu) { |
80 | | - filterBreadcrumbList.push(({ |
| 75 | + breadcrumbList.push(({ |
81 | 76 | ...currentRoute.value, |
82 | 77 | name: currentRoute.value.meta?.title || currentRoute.value.name, |
83 | 78 | } as unknown) as RouteLocationMatched); |
84 | 79 | } |
85 | | - routes.value = filterBreadcrumbList; |
| 80 | + routes.value = breadcrumbList; |
86 | 81 | }); |
87 | 82 |
|
88 | 83 | function getMatched(menus: Menu[], parent: string[]) { |
|
103 | 98 |
|
104 | 99 | function filterItem(list: RouteLocationMatched[]) { |
105 | 100 | let resultList = filter(list, (item) => { |
106 | | - const { meta } = item; |
107 | | -
|
| 101 | + const { meta, name } = item; |
108 | 102 | if (!meta) { |
109 | | - return false; |
| 103 | + return !!name; |
110 | 104 | } |
111 | | -
|
112 | 105 | const { title, hideBreadcrumb, hideMenu } = meta; |
113 | 106 | if (!title || hideBreadcrumb || hideMenu) { |
114 | 107 | return false; |
|
0 commit comments