From b6ac3106ce5ccd10a3a9708b654fd421002061c0 Mon Sep 17 00:00:00 2001 From: Azir <2075125282@qq.com> Date: Fri, 4 Jul 2025 02:59:22 +0800 Subject: [PATCH] feat(projects)!: optimize layout mode, split horizontal mix component into two layouts, and rename the component. --- .../materials/src/libs/admin-layout/index.vue | 1 - packages/materials/src/types/index.ts | 6 --- src/constants/app.ts | 3 +- src/layouts/base-layout/index.vue | 25 ++++++++----- src/layouts/modules/global-menu/index.vue | 7 ++-- ...x-menu.vue => top-hybrid-header-first.vue} | 0 ...-menu.vue => top-hybrid-sidebar-first.vue} | 0 src/layouts/modules/global-sider/index.vue | 12 ++++-- .../components/layout-mode-card.vue | 28 +++++++------- .../theme-drawer/modules/layout/index.vue | 6 ++- .../layout/modules/footer-settings.vue | 5 ++- .../modules/layout/modules/layout-mode.vue | 37 ++++++++----------- .../modules/layout/modules/sider-settings.vue | 2 +- src/locales/langs/en-us.ts | 18 ++++++--- src/locales/langs/zh-cn.ts | 9 ++++- src/store/modules/theme/index.ts | 9 ----- src/theme/settings.ts | 3 +- src/typings/app.d.ts | 24 ++++++------ src/typings/components.d.ts | 20 ---------- src/typings/union-key.d.ts | 10 ++++- 20 files changed, 113 insertions(+), 112 deletions(-) rename src/layouts/modules/global-menu/modules/{reversed-horizontal-mix-menu.vue => top-hybrid-header-first.vue} (100%) rename src/layouts/modules/global-menu/modules/{horizontal-mix-menu.vue => top-hybrid-sidebar-first.vue} (100%) diff --git a/packages/materials/src/libs/admin-layout/index.vue b/packages/materials/src/libs/admin-layout/index.vue index 543f7dc0..8bbc5526 100644 --- a/packages/materials/src/libs/admin-layout/index.vue +++ b/packages/materials/src/libs/admin-layout/index.vue @@ -127,7 +127,6 @@ function handleClickMask() { :class="[ style['layout-header'], commonClass, - headerClass, headerLeftGapClass, { 'absolute top-0 left-0 w-full': fixedHeaderAndTab } ]" diff --git a/packages/materials/src/types/index.ts b/packages/materials/src/types/index.ts index bbcfb9d6..583f0907 100644 --- a/packages/materials/src/types/index.ts +++ b/packages/materials/src/types/index.ts @@ -6,12 +6,6 @@ interface AdminLayoutHeaderConfig { * @default true */ headerVisible?: boolean; - /** - * Header class - * - * @default '' - */ - headerClass?: string; /** * Header height * diff --git a/src/constants/app.ts b/src/constants/app.ts index 0c8ba5ac..269ff960 100644 --- a/src/constants/app.ts +++ b/src/constants/app.ts @@ -24,7 +24,8 @@ export const themeLayoutModeRecord: Record { }); const headerProps = computed(() => { - const { mode, reverseHorizontalMix } = themeStore.layout; + const { mode } = themeStore.layout; const headerPropsConfig: Record = { vertical: { @@ -47,10 +47,15 @@ const headerProps = computed(() => { showMenu: true, showMenuToggler: false }, - 'horizontal-mix': { + 'top-hybrid-sidebar-first': { showLogo: true, showMenu: true, - showMenuToggler: reverseHorizontalMix && isActiveFirstLevelMenuHasChildren.value + showMenuToggler: false + }, + 'top-hybrid-header-first': { + showLogo: true, + showMenu: true, + showMenuToggler: isActiveFirstLevelMenuHasChildren.value } }; @@ -61,21 +66,22 @@ const siderVisible = computed(() => themeStore.layout.mode !== 'horizontal'); const isVerticalMix = computed(() => themeStore.layout.mode === 'vertical-mix'); -const isHorizontalMix = computed(() => themeStore.layout.mode === 'horizontal-mix'); +const isTopHybridSidebarFirst = computed(() => themeStore.layout.mode === 'top-hybrid-sidebar-first'); + +const isTopHybridHeaderFirst = computed(() => themeStore.layout.mode === 'top-hybrid-header-first'); const siderWidth = computed(() => getSiderWidth()); const siderCollapsedWidth = computed(() => getSiderCollapsedWidth()); function getSiderWidth() { - const { reverseHorizontalMix } = themeStore.layout; const { width, mixWidth, mixChildMenuWidth } = themeStore.sider; - if (isHorizontalMix.value && reverseHorizontalMix) { + if (isTopHybridHeaderFirst.value) { return isActiveFirstLevelMenuHasChildren.value ? width : 0; } - let w = isVerticalMix.value || isHorizontalMix.value ? mixWidth : width; + let w = isVerticalMix.value || isTopHybridSidebarFirst.value ? mixWidth : width; if (isVerticalMix.value && appStore.mixSiderFixed && childLevelMenus.value.length) { w += mixChildMenuWidth; @@ -85,14 +91,13 @@ function getSiderWidth() { } function getSiderCollapsedWidth() { - const { reverseHorizontalMix } = themeStore.layout; const { collapsedWidth, mixCollapsedWidth, mixChildMenuWidth } = themeStore.sider; - if (isHorizontalMix.value && reverseHorizontalMix) { + if (isTopHybridHeaderFirst.value) { return isActiveFirstLevelMenuHasChildren.value ? collapsedWidth : 0; } - let w = isVerticalMix.value || isHorizontalMix.value ? mixCollapsedWidth : collapsedWidth; + let w = isVerticalMix.value || isTopHybridSidebarFirst.value ? mixCollapsedWidth : collapsedWidth; if (isVerticalMix.value && appStore.mixSiderFixed && childLevelMenus.value.length) { w += mixChildMenuWidth; diff --git a/src/layouts/modules/global-menu/index.vue b/src/layouts/modules/global-menu/index.vue index 45434d92..cc3a0a32 100644 --- a/src/layouts/modules/global-menu/index.vue +++ b/src/layouts/modules/global-menu/index.vue @@ -6,8 +6,8 @@ import { useThemeStore } from '@/store/modules/theme'; import VerticalMenu from './modules/vertical-menu.vue'; import VerticalMixMenu from './modules/vertical-mix-menu.vue'; import HorizontalMenu from './modules/horizontal-menu.vue'; -import HorizontalMixMenu from './modules/horizontal-mix-menu.vue'; -import ReversedHorizontalMixMenu from './modules/reversed-horizontal-mix-menu.vue'; +import TopHybridSidebarFirst from './modules/top-hybrid-sidebar-first.vue'; +import TopHybridHeaderFirst from './modules/top-hybrid-header-first.vue'; defineOptions({ name: 'GlobalMenu' @@ -21,7 +21,8 @@ const activeMenu = computed(() => { vertical: VerticalMenu, 'vertical-mix': VerticalMixMenu, horizontal: HorizontalMenu, - 'horizontal-mix': themeStore.layout.reverseHorizontalMix ? ReversedHorizontalMixMenu : HorizontalMixMenu + 'top-hybrid-sidebar-first': TopHybridSidebarFirst, + 'top-hybrid-header-first': TopHybridHeaderFirst }; return menuMap[themeStore.layout.mode]; diff --git a/src/layouts/modules/global-menu/modules/reversed-horizontal-mix-menu.vue b/src/layouts/modules/global-menu/modules/top-hybrid-header-first.vue similarity index 100% rename from src/layouts/modules/global-menu/modules/reversed-horizontal-mix-menu.vue rename to src/layouts/modules/global-menu/modules/top-hybrid-header-first.vue diff --git a/src/layouts/modules/global-menu/modules/horizontal-mix-menu.vue b/src/layouts/modules/global-menu/modules/top-hybrid-sidebar-first.vue similarity index 100% rename from src/layouts/modules/global-menu/modules/horizontal-mix-menu.vue rename to src/layouts/modules/global-menu/modules/top-hybrid-sidebar-first.vue diff --git a/src/layouts/modules/global-sider/index.vue b/src/layouts/modules/global-sider/index.vue index bb62c185..2b5bfca2 100644 --- a/src/layouts/modules/global-sider/index.vue +++ b/src/layouts/modules/global-sider/index.vue @@ -13,9 +13,15 @@ const appStore = useAppStore(); const themeStore = useThemeStore(); const isVerticalMix = computed(() => themeStore.layout.mode === 'vertical-mix'); -const isHorizontalMix = computed(() => themeStore.layout.mode === 'horizontal-mix'); -const darkMenu = computed(() => !themeStore.darkMode && !isHorizontalMix.value && themeStore.sider.inverted); -const showLogo = computed(() => !isVerticalMix.value && !isHorizontalMix.value); +const isTopHybridSidebarFirst = computed(() => themeStore.layout.mode === 'top-hybrid-sidebar-first'); +const isTopHybridHeaderFirst = computed(() => themeStore.layout.mode === 'top-hybrid-header-first'); +const darkMenu = computed( + () => + !themeStore.darkMode && !isTopHybridSidebarFirst.value && !isTopHybridHeaderFirst.value && themeStore.sider.inverted +); +const showLogo = computed( + () => !isVerticalMix.value && !isTopHybridSidebarFirst.value && !isTopHybridHeaderFirst.value +); const menuWrapperClass = computed(() => (showLogo.value ? 'flex-1-hidden' : 'h-full')); diff --git a/src/layouts/modules/theme-drawer/components/layout-mode-card.vue b/src/layouts/modules/theme-drawer/components/layout-mode-card.vue index b430fd01..c9cedc72 100644 --- a/src/layouts/modules/theme-drawer/components/layout-mode-card.vue +++ b/src/layouts/modules/theme-drawer/components/layout-mode-card.vue @@ -27,7 +27,6 @@ type LayoutConfig = Record< UnionKey.ThemeLayoutMode, { placement: PopoverPlacement; - headerClass: string; menuClass: string; mainClass: string; } @@ -36,25 +35,26 @@ type LayoutConfig = Record< const layoutConfig: LayoutConfig = { vertical: { placement: 'bottom', - headerClass: '', menuClass: 'w-1/3 h-full', mainClass: 'w-2/3 h-3/4' }, 'vertical-mix': { placement: 'bottom', - headerClass: '', menuClass: 'w-1/4 h-full', mainClass: 'w-2/3 h-3/4' }, horizontal: { placement: 'bottom', - headerClass: '', menuClass: 'w-full h-1/4', mainClass: 'w-full h-3/4' }, - 'horizontal-mix': { + 'top-hybrid-sidebar-first': { + placement: 'bottom', + menuClass: 'w-full h-1/4', + mainClass: 'w-2/3 h-3/4' + }, + 'top-hybrid-header-first': { placement: 'bottom', - headerClass: '', menuClass: 'w-full h-1/4', mainClass: 'w-2/3 h-3/4' } @@ -68,25 +68,27 @@ function handleChangeMode(mode: UnionKey.ThemeLayoutMode) { diff --git a/src/layouts/modules/theme-drawer/modules/layout/index.vue b/src/layouts/modules/theme-drawer/modules/layout/index.vue index f82a2dd3..c842af09 100644 --- a/src/layouts/modules/theme-drawer/modules/layout/index.vue +++ b/src/layouts/modules/theme-drawer/modules/layout/index.vue @@ -1,4 +1,5 @@