From 8237adb9c0b187911df37d6d99fd84718bc3ea8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=87=95=E5=8D=9A=E6=96=87?= <349952469@qq.com> Date: Thu, 16 Jun 2022 10:00:23 +0800 Subject: [PATCH] =?UTF-8?q?feat(tabs):=20=E5=A4=9A=E9=A1=B5=E7=AD=BE?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=85=B3=E9=97=AD=E6=89=80=E6=9C=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/TabDetail/components/ContextMenu.vue | 11 +++++++++++ src/store/modules/tab/index.ts | 4 ++++ src/utils/common/icon.ts | 3 ++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/layouts/common/GlobalTab/components/TabDetail/components/ContextMenu.vue b/src/layouts/common/GlobalTab/components/TabDetail/components/ContextMenu.vue index fed6ddc6a..e18651ffd 100644 --- a/src/layouts/common/GlobalTab/components/TabDetail/components/ContextMenu.vue +++ b/src/layouts/common/GlobalTab/components/TabDetail/components/ContextMenu.vue @@ -86,6 +86,11 @@ const options = computed(() => [ 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 void>([ () => { tab.clearRightTab(props.currentPath); } + ], + [ + 'close-all', + () => { + tab.clearAllTab(); + } ] ]); diff --git a/src/store/modules/tab/index.ts b/src/store/modules/tab/index.ts index d0be48e59..118989444 100644 --- a/src/store/modules/tab/index.ts +++ b/src/store/modules/tab/index.ts @@ -155,6 +155,10 @@ export const useTabStore = defineStore('tab-store', { this.clearTab(excludes); } }, + /** 清除所有多页签 */ + clearAllTab() { + this.clearTab(); + }, /** * 点击单个tab * @param fullPath - 路由fullPath diff --git a/src/utils/common/icon.ts b/src/utils/common/icon.ts index 69efbc16e..db225dda0 100644 --- a/src/utils/common/icon.ts +++ b/src/utils/common/icon.ts @@ -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 }) }); } /**