Skip to content

Commit

Permalink
feat: restore the breadcrumb display icon function
Browse files Browse the repository at this point in the history
  • Loading branch information
anncwb committed Oct 27, 2020
1 parent a2c413a commit f65bed7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- 新增`pwa`功能,可在`.env.production`开启
- Button 组件扩展 `preIcon``postIcon`属性用于在文本前后添加图标
- 恢复面包屑显示图标功能

### 🎫 Chores

Expand Down
25 changes: 23 additions & 2 deletions src/layouts/default/LayoutBreadcrumb.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { AppRouteRecordRaw } from '/@/router/types';
import type { RouteLocationMatched } from 'vue-router';
import type { PropType } from 'vue';

import { defineComponent, TransitionGroup, unref, watch, ref } from 'vue';
import Breadcrumb from '/@/components/Breadcrumb/Breadcrumb.vue';
Expand All @@ -10,10 +11,17 @@ import { PageEnum } from '/@/enums/pageEnum';
import { isBoolean } from '/@/utils/is';

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

export default defineComponent({
name: 'BasicBreadcrumb',
setup() {
props: {
showIcon: {
type: Boolean as PropType<boolean>,
default: false,
},
},
setup(props) {
const itemList = ref<AppRouteRecordRaw[]>([]);

const { currentRoute, push } = useRouter();
Expand Down Expand Up @@ -82,7 +90,20 @@ export default defineComponent({
isLink={isLink}
onClick={handleItemClick.bind(null, item)}
>
{() => item.meta.title}
{() => (
<>
{props.showIcon && item.meta.icon && item.meta.icon.trim() !== '' && (
<Icon
icon={item.meta.icon}
class="icon mr-1 "
style={{
marginBottom: '2px',
}}
/>
)}
{item.meta.title}
</>
)}
</BreadcrumbItem>
);
});
Expand Down

0 comments on commit f65bed7

Please sign in to comment.