From b0ff73285f416ded6eef44c57a3d45fb2fd33032 Mon Sep 17 00:00:00 2001 From: xingyu Date: Thu, 9 Nov 2023 11:49:20 +0800 Subject: [PATCH] feat(MultipleTab): add tabs auto collapse --- src/hooks/setting/useMultipleTabSetting.ts | 3 + src/layouts/default/header/MultipleHeader.vue | 32 ++++++++--- src/layouts/default/index.vue | 57 ++++++++++++++++--- src/layouts/default/setting/SettingDrawer.tsx | 8 ++- src/layouts/default/setting/enum.ts | 1 + src/layouts/default/setting/handler.ts | 3 + src/layouts/default/tabs/index.less | 22 +++++++ src/layouts/default/tabs/index.vue | 6 ++ src/locales/lang/en/layout.json | 1 + src/locales/lang/zh-CN/layout.json | 1 + src/settings/designSetting.ts | 2 + src/settings/projectSetting.ts | 1 + src/types/config.d.ts | 1 + 13 files changed, 121 insertions(+), 17 deletions(-) diff --git a/src/hooks/setting/useMultipleTabSetting.ts b/src/hooks/setting/useMultipleTabSetting.ts index f19a8caf..8550fa47 100644 --- a/src/hooks/setting/useMultipleTabSetting.ts +++ b/src/hooks/setting/useMultipleTabSetting.ts @@ -16,6 +16,8 @@ export function useMultipleTabSetting() { const getShowFold = computed(() => appStore.getMultiTabsSetting.showFold) + const getAutoCollapse = computed(() => appStore.getMultiTabsSetting.autoCollapse) + function setMultipleTabSetting(multiTabsSetting: Partial) { appStore.setProjectConfig({ multiTabsSetting }) } @@ -26,5 +28,6 @@ export function useMultipleTabSetting() { getShowQuick, getShowRedo, getShowFold, + getAutoCollapse, } } diff --git a/src/layouts/default/header/MultipleHeader.vue b/src/layouts/default/header/MultipleHeader.vue index 104125fe..477586a0 100644 --- a/src/layouts/default/header/MultipleHeader.vue +++ b/src/layouts/default/header/MultipleHeader.vue @@ -24,13 +24,13 @@ const { setHeaderHeight } = useLayoutHeight() const tabStore = useMultipleTabStore() const { prefixCls } = useDesign('layout-multiple-header') -const { getCalcContentWidth, getSplit } = useMenuSetting() +const { getCalcContentWidth, getSplit, getShowMenu } = useMenuSetting() const { getIsMobile } = useAppInject() const { getFixed, getShowInsetHeaderRef, getShowFullHeaderRef, getHeaderTheme, getShowHeader } = useHeaderSetting() const { getFullContent } = useFullContent() -const { getShowMultipleTab } = useMultipleTabSetting() +const { getShowMultipleTab, getAutoCollapse } = useMultipleTabSetting() const getShowTabs = computed(() => { return unref(getShowMultipleTab) && !unref(getFullContent) @@ -40,6 +40,8 @@ const getIsShowPlaceholderDom = computed(() => { return unref(getFixed) || unref(getShowFullHeaderRef) }) +const getIsUnFold = computed(() => !unref(getShowMenu) && !unref(getShowHeader)) + const getWrapStyle = computed((): CSSProperties => { const style: CSSProperties = {} if (unref(getFixed)) @@ -57,13 +59,19 @@ const getIsFixed = computed(() => { const getPlaceholderDomStyle = computed((): CSSProperties => { let height = 0 - if ((unref(getShowFullHeaderRef) || !unref(getSplit)) && unref(getShowHeader) && !unref(getFullContent)) - height += HEADER_HEIGHT + if (!(unref(getAutoCollapse) && unref(getIsUnFold))) { + if ( + (unref(getShowFullHeaderRef) || !unref(getSplit)) + && unref(getShowHeader) + && !unref(getFullContent) + ) + height += HEADER_HEIGHT - if (unref(getShowMultipleTab) && !unref(getFullContent)) - height += TABS_HEIGHT + if (unref(getShowMultipleTab) && !unref(getFullContent)) + height += TABS_HEIGHT - setHeaderHeight(height) + setHeaderHeight(height) + } return { height: `${height}px`, } @@ -75,7 +83,11 @@ const getClass = computed(() => {