@@ -10,20 +10,23 @@ import { PageEnum } from '/@/enums/pageEnum';
10
10
import { isBoolean } from '/@/utils/is' ;
11
11
12
12
import { compile } from 'path-to-regexp' ;
13
- import Icon from '/@/components/Icon' ;
14
13
15
14
export default defineComponent ( {
16
15
name : 'BasicBreadcrumb' ,
17
- props : {
18
- showIcon : {
19
- type : Boolean ,
20
- default : false ,
21
- } ,
22
- } ,
23
- setup ( props ) {
16
+ setup ( ) {
24
17
const itemList = ref < AppRouteRecordRaw [ ] > ( [ ] ) ;
18
+
25
19
const { currentRoute, push } = useRouter ( ) ;
26
20
21
+ watch (
22
+ ( ) => currentRoute . value ,
23
+ ( ) => {
24
+ if ( unref ( currentRoute ) . name === 'Redirect' ) return ;
25
+ getBreadcrumb ( ) ;
26
+ } ,
27
+ { immediate : true }
28
+ ) ;
29
+
27
30
function getBreadcrumb ( ) {
28
31
const { matched } = unref ( currentRoute ) ;
29
32
const matchedList = matched . filter ( ( item ) => item . meta && item . meta . title ) . slice ( 1 ) ;
@@ -63,36 +66,23 @@ export default defineComponent({
63
66
return push ( pathCompile ( path ) ) ;
64
67
}
65
68
66
- watch (
67
- ( ) => currentRoute . value ,
68
- ( ) => {
69
- if ( unref ( currentRoute ) . name === 'Redirect' ) return ;
70
- getBreadcrumb ( ) ;
71
- } ,
72
- { immediate : true }
73
- ) ;
74
-
75
69
return ( ) => (
76
70
< Breadcrumb class = "layout-breadcrumb" >
77
71
{ ( ) => (
78
72
< TransitionGroup name = "breadcrumb" >
79
73
{ ( ) => {
80
74
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 ;
82
79
return (
83
80
< BreadcrumbItem
84
81
key = { item . path }
85
82
isLink = { isLink }
86
83
onClick = { handleItemClick . bind ( null , item ) }
87
84
>
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 }
96
86
</ BreadcrumbItem >
97
87
) ;
98
88
} ) ;
0 commit comments