Merge pull request #103 from yanbowe/main

feat(tabs): 多页签增加关闭所有
This commit is contained in:
Soybean 2022-06-16 12:06:28 +08:00 committed by GitHub
commit c6ed9b1558
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 3 deletions

View File

@ -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>

View File

@ -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')
}
]);
@ -119,6 +124,12 @@ const actionMap = new Map<DropdownKey, () => void>([
() => {
tab.clearRightTab(props.currentPath);
}
],
[
'close-all',
() => {
tab.clearAllTab();
}
]
]);

View File

@ -155,6 +155,10 @@ export const useTabStore = defineStore('tab-store', {
this.clearTab(excludes);
}
},
/** 清除所有多页签 */
clearAllTab() {
this.clearTab();
},
/**
* tab
* @param fullPath - fullPath

View File

@ -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';
@ -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 }) });
}
/**
@ -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 }) });
}