Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(breadcrumb): support showIcon #48

Merged
merged 1 commit into from
Oct 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions src/layouts/default/LayoutBreadcrumb.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,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,
default: false,
},
},
setup(props) {
const itemList = ref<AppRouteRecordRaw[]>([]);
const { currentRoute, push } = useRouter();

Expand Down Expand Up @@ -78,7 +85,14 @@ 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 mb-1" />
)}
{item.meta.title}
</>
)}
</BreadcrumbItem>
);
});
Expand Down
3 changes: 2 additions & 1 deletion src/layouts/default/LayoutHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export default defineComponent({
},
menuSetting: { mode, type: menuType, split: splitMenu, topMenuAlign },
showBreadCrumb,
showBreadCrumbIcon,
} = getProjectConfig;

const isSidebarType = menuType === MenuTypeEnum.SIDEBAR;
Expand All @@ -106,7 +107,7 @@ export default defineComponent({
{showLogo && !isSidebarType && <Logo class={`layout-header__logo`} />}

{mode !== MenuModeEnum.HORIZONTAL && showBreadCrumb && !splitMenu && (
<LayoutBreadcrumb />
<LayoutBreadcrumb showIcon={showBreadCrumbIcon} />
)}
{unref(showTopMenu) && (
<div
Expand Down
13 changes: 13 additions & 0 deletions src/layouts/default/setting/SettingDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ export default defineComponent({
menuSetting: { show: showMenu },
multiTabsSetting: { show: showMultiple, showQuick, showIcon: showTabIcon },
showBreadCrumb,
showBreadCrumbIcon,
} = unref(getProjectConfigRef);
return [
renderSwitchItem('面包屑', {
Expand All @@ -352,6 +353,13 @@ export default defineComponent({
def: showBreadCrumb,
disabled: !unref(getShowHeaderRef),
}),
renderSwitchItem('面包屑图标', {
handler: (e) => {
baseHandler('showBreadCrumbIcon', e);
},
def: showBreadCrumbIcon,
disabled: !unref(getShowHeaderRef),
}),
renderSwitchItem('标签页', {
handler: (e) => {
baseHandler('showMultiple', e);
Expand Down Expand Up @@ -449,6 +457,11 @@ export default defineComponent({
showBreadCrumb: value,
};
}
if (event === 'showBreadCrumbIcon') {
config = {
showBreadCrumbIcon: value,
};
}
if (event === 'collapsed') {
config = {
menuSetting: {
Expand Down
2 changes: 2 additions & 0 deletions src/settings/projectSetting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ const setting: ProjectConfig = {
lockTime: 0,
// 显示面包屑
showBreadCrumb: true,
// 显示面包屑图标
showBreadCrumbIcon: false,

// 使用error-handler-plugin
useErrorHandle: isProdMode(),
Expand Down
2 changes: 2 additions & 0 deletions src/types/config.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ export interface ProjectConfig {
lockTime: number;
// 显示面包屑
showBreadCrumb: boolean;
// 显示面包屑图标
showBreadCrumbIcon: boolean;
// 使用error-handler-plugin
useErrorHandle: boolean;

Expand Down