Commit f65bed72ac8c63aaed640d59703f73e83de80da5
1 parent
a2c413a8
feat: restore the breadcrumb display icon function
Showing
2 changed files
with
24 additions
and
2 deletions
CHANGELOG.zh_CN.md
src/layouts/default/LayoutBreadcrumb.tsx
1 | import type { AppRouteRecordRaw } from '/@/router/types'; | 1 | import type { AppRouteRecordRaw } from '/@/router/types'; |
2 | import type { RouteLocationMatched } from 'vue-router'; | 2 | import type { RouteLocationMatched } from 'vue-router'; |
3 | +import type { PropType } from 'vue'; | ||
3 | 4 | ||
4 | import { defineComponent, TransitionGroup, unref, watch, ref } from 'vue'; | 5 | import { defineComponent, TransitionGroup, unref, watch, ref } from 'vue'; |
5 | import Breadcrumb from '/@/components/Breadcrumb/Breadcrumb.vue'; | 6 | import Breadcrumb from '/@/components/Breadcrumb/Breadcrumb.vue'; |
@@ -10,10 +11,17 @@ import { PageEnum } from '/@/enums/pageEnum'; | @@ -10,10 +11,17 @@ import { PageEnum } from '/@/enums/pageEnum'; | ||
10 | import { isBoolean } from '/@/utils/is'; | 11 | import { isBoolean } from '/@/utils/is'; |
11 | 12 | ||
12 | import { compile } from 'path-to-regexp'; | 13 | import { compile } from 'path-to-regexp'; |
14 | +import Icon from '/@/components/Icon'; | ||
13 | 15 | ||
14 | export default defineComponent({ | 16 | export default defineComponent({ |
15 | name: 'BasicBreadcrumb', | 17 | name: 'BasicBreadcrumb', |
16 | - setup() { | 18 | + props: { |
19 | + showIcon: { | ||
20 | + type: Boolean as PropType<boolean>, | ||
21 | + default: false, | ||
22 | + }, | ||
23 | + }, | ||
24 | + setup(props) { | ||
17 | const itemList = ref<AppRouteRecordRaw[]>([]); | 25 | const itemList = ref<AppRouteRecordRaw[]>([]); |
18 | 26 | ||
19 | const { currentRoute, push } = useRouter(); | 27 | const { currentRoute, push } = useRouter(); |
@@ -82,7 +90,20 @@ export default defineComponent({ | @@ -82,7 +90,20 @@ export default defineComponent({ | ||
82 | isLink={isLink} | 90 | isLink={isLink} |
83 | onClick={handleItemClick.bind(null, item)} | 91 | onClick={handleItemClick.bind(null, item)} |
84 | > | 92 | > |
85 | - {() => item.meta.title} | 93 | + {() => ( |
94 | + <> | ||
95 | + {props.showIcon && item.meta.icon && item.meta.icon.trim() !== '' && ( | ||
96 | + <Icon | ||
97 | + icon={item.meta.icon} | ||
98 | + class="icon mr-1 " | ||
99 | + style={{ | ||
100 | + marginBottom: '2px', | ||
101 | + }} | ||
102 | + /> | ||
103 | + )} | ||
104 | + {item.meta.title} | ||
105 | + </> | ||
106 | + )} | ||
86 | </BreadcrumbItem> | 107 | </BreadcrumbItem> |
87 | ); | 108 | ); |
88 | }); | 109 | }); |