Skip to content

Commit 144fde8

Browse files
committed
fix: fix abnormal breadcrumb status
1 parent f75425d commit 144fde8

File tree

1 file changed

+16
-26
lines changed

1 file changed

+16
-26
lines changed

src/layouts/default/LayoutBreadcrumb.tsx

+16-26
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,23 @@ import { PageEnum } from '/@/enums/pageEnum';
1010
import { isBoolean } from '/@/utils/is';
1111

1212
import { compile } from 'path-to-regexp';
13-
import Icon from '/@/components/Icon';
1413

1514
export default defineComponent({
1615
name: 'BasicBreadcrumb',
17-
props: {
18-
showIcon: {
19-
type: Boolean,
20-
default: false,
21-
},
22-
},
23-
setup(props) {
16+
setup() {
2417
const itemList = ref<AppRouteRecordRaw[]>([]);
18+
2519
const { currentRoute, push } = useRouter();
2620

21+
watch(
22+
() => currentRoute.value,
23+
() => {
24+
if (unref(currentRoute).name === 'Redirect') return;
25+
getBreadcrumb();
26+
},
27+
{ immediate: true }
28+
);
29+
2730
function getBreadcrumb() {
2831
const { matched } = unref(currentRoute);
2932
const matchedList = matched.filter((item) => item.meta && item.meta.title).slice(1);
@@ -63,36 +66,23 @@ export default defineComponent({
6366
return push(pathCompile(path));
6467
}
6568

66-
watch(
67-
() => currentRoute.value,
68-
() => {
69-
if (unref(currentRoute).name === 'Redirect') return;
70-
getBreadcrumb();
71-
},
72-
{ immediate: true }
73-
);
74-
7569
return () => (
7670
<Breadcrumb class="layout-breadcrumb">
7771
{() => (
7872
<TransitionGroup name="breadcrumb">
7973
{() => {
8074
return unref(itemList).map((item) => {
81-
const isLink = !!item.redirect && !item.meta.disabledRedirect;
75+
const isLink =
76+
(!!item.redirect && !item.meta.disabledRedirect) ||
77+
!item.children ||
78+
item.children.length === 0;
8279
return (
8380
<BreadcrumbItem
8481
key={item.path}
8582
isLink={isLink}
8683
onClick={handleItemClick.bind(null, item)}
8784
>
88-
{() => (
89-
<>
90-
{props.showIcon && item.meta.icon && item.meta.icon.trim() !== '' && (
91-
<Icon icon={item.meta.icon} class="icon mr-1 mb-1" />
92-
)}
93-
{item.meta.title}
94-
</>
95-
)}
85+
{() => item.meta.title}
9686
</BreadcrumbItem>
9787
);
9888
});

0 commit comments

Comments
 (0)