Skip to content

Commit

Permalink
Merge pull request #103 from yanbowe/main
Browse files Browse the repository at this point in the history
feat(tabs): 多页签增加关闭所有
  • Loading branch information
honghuangdc authored Jun 16, 2022
2 parents 65c2181 + 0523f08 commit c6ed9b1
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/components/custom/SvgIcon.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<svg aria-hidden="true" width="1em" height="1em" class="inline-block">
<svg aria-hidden="true" width="1em" height="1em">
<use :xlink:href="symbolId" fill="currentColor" />
</svg>
</template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ const options = computed<Option[]>(() => [
label: '关闭右侧',
key: 'close-right',
icon: iconifyRender('mdi:format-horizontal-align-right')
},
{
label: '关闭所有',
key: 'close-all',
icon: iconifyRender('ant-design:line-outlined')
}
]);
Expand Down Expand Up @@ -119,6 +124,12 @@ const actionMap = new Map<DropdownKey, () => void>([
() => {
tab.clearRightTab(props.currentPath);
}
],
[
'close-all',
() => {
tab.clearAllTab();
}
]
]);
Expand Down
4 changes: 4 additions & 0 deletions src/store/modules/tab/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ export const useTabStore = defineStore('tab-store', {
this.clearTab(excludes);
}
},
/** 清除所有多页签 */
clearAllTab() {
this.clearTab();
},
/**
* 点击单个tab
* @param fullPath - 路由fullPath
Expand Down
5 changes: 3 additions & 2 deletions src/utils/common/icon.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { h } from 'vue';
import { NIcon } from 'naive-ui';
import { Icon } from '@iconify/vue';
import SvgIcon from '@/components/custom/SvgIcon.vue';

Expand All @@ -16,7 +17,7 @@ export function iconifyRender(icon: string, color?: string, size?: number) {
if (size) {
style.size = `${size}px`;
}
return () => h(Icon, { icon, style });
return () => h(NIcon, null, { default: () => h(Icon, { icon, style }) });
}

/**
Expand All @@ -34,5 +35,5 @@ export function customIconRender(icon: string, color?: string, size?: number) {
style.size = `${size}px`;
}

return () => h(SvgIcon, { icon, style });
return () => h(NIcon, null, { default: () => h(SvgIcon, { icon, style }) });
}

1 comment on commit c6ed9b1

@vercel
Copy link

@vercel vercel bot commented on c6ed9b1 Jun 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.