Commit f65bed72ac8c63aaed640d59703f73e83de80da5

Authored by vben
1 parent a2c413a8

feat: restore the breadcrumb display icon function

CHANGELOG.zh_CN.md
... ... @@ -4,6 +4,7 @@
4 4  
5 5 - 新增`pwa`功能,可在`.env.production`开启
6 6 - Button 组件扩展 `preIcon`和`postIcon`属性用于在文本前后添加图标
  7 +- 恢复面包屑显示图标功能
7 8  
8 9 ### 🎫 Chores
9 10  
... ...
src/layouts/default/LayoutBreadcrumb.tsx
1 1 import type { AppRouteRecordRaw } from '/@/router/types';
2 2 import type { RouteLocationMatched } from 'vue-router';
  3 +import type { PropType } from 'vue';
3 4  
4 5 import { defineComponent, TransitionGroup, unref, watch, ref } from 'vue';
5 6 import Breadcrumb from '/@/components/Breadcrumb/Breadcrumb.vue';
... ... @@ -10,10 +11,17 @@ import { PageEnum } from '/@/enums/pageEnum';
10 11 import { isBoolean } from '/@/utils/is';
11 12  
12 13 import { compile } from 'path-to-regexp';
  14 +import Icon from '/@/components/Icon';
13 15  
14 16 export default defineComponent({
15 17 name: 'BasicBreadcrumb',
16   - setup() {
  18 + props: {
  19 + showIcon: {
  20 + type: Boolean as PropType<boolean>,
  21 + default: false,
  22 + },
  23 + },
  24 + setup(props) {
17 25 const itemList = ref<AppRouteRecordRaw[]>([]);
18 26  
19 27 const { currentRoute, push } = useRouter();
... ... @@ -82,7 +90,20 @@ export default defineComponent({
82 90 isLink={isLink}
83 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 107 </BreadcrumbItem>
87 108 );
88 109 });
... ...