Skip to content

Commit b6ac310

Browse files
Azir-11honghuangdc
authored andcommitted
feat(projects)!: optimize layout mode, split horizontal mix component into two layouts, and rename the component.
1 parent d37ce04 commit b6ac310

File tree

20 files changed

+113
-112
lines changed

20 files changed

+113
-112
lines changed

packages/materials/src/libs/admin-layout/index.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ function handleClickMask() {
127127
:class="[
128128
style['layout-header'],
129129
commonClass,
130-
headerClass,
131130
headerLeftGapClass,
132131
{ 'absolute top-0 left-0 w-full': fixedHeaderAndTab }
133132
]"

packages/materials/src/types/index.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@ interface AdminLayoutHeaderConfig {
66
* @default true
77
*/
88
headerVisible?: boolean;
9-
/**
10-
* Header class
11-
*
12-
* @default ''
13-
*/
14-
headerClass?: string;
159
/**
1610
* Header height
1711
*

src/constants/app.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ export const themeLayoutModeRecord: Record<UnionKey.ThemeLayoutMode, App.I18n.I1
2424
vertical: 'theme.layout.layoutMode.vertical',
2525
'vertical-mix': 'theme.layout.layoutMode.vertical-mix',
2626
horizontal: 'theme.layout.layoutMode.horizontal',
27-
'horizontal-mix': 'theme.layout.layoutMode.horizontal-mix'
27+
'top-hybrid-sidebar-first': 'theme.layout.layoutMode.top-hybrid-sidebar-first',
28+
'top-hybrid-header-first': 'theme.layout.layoutMode.top-hybrid-header-first'
2829
};
2930

3031
export const themeLayoutModeOptions = transformRecordToOption(themeLayoutModeRecord);

src/layouts/base-layout/index.vue

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const layoutMode = computed(() => {
2929
});
3030
3131
const headerProps = computed(() => {
32-
const { mode, reverseHorizontalMix } = themeStore.layout;
32+
const { mode } = themeStore.layout;
3333
3434
const headerPropsConfig: Record<UnionKey.ThemeLayoutMode, App.Global.HeaderProps> = {
3535
vertical: {
@@ -47,10 +47,15 @@ const headerProps = computed(() => {
4747
showMenu: true,
4848
showMenuToggler: false
4949
},
50-
'horizontal-mix': {
50+
'top-hybrid-sidebar-first': {
5151
showLogo: true,
5252
showMenu: true,
53-
showMenuToggler: reverseHorizontalMix && isActiveFirstLevelMenuHasChildren.value
53+
showMenuToggler: false
54+
},
55+
'top-hybrid-header-first': {
56+
showLogo: true,
57+
showMenu: true,
58+
showMenuToggler: isActiveFirstLevelMenuHasChildren.value
5459
}
5560
};
5661
@@ -61,21 +66,22 @@ const siderVisible = computed(() => themeStore.layout.mode !== 'horizontal');
6166
6267
const isVerticalMix = computed(() => themeStore.layout.mode === 'vertical-mix');
6368
64-
const isHorizontalMix = computed(() => themeStore.layout.mode === 'horizontal-mix');
69+
const isTopHybridSidebarFirst = computed(() => themeStore.layout.mode === 'top-hybrid-sidebar-first');
70+
71+
const isTopHybridHeaderFirst = computed(() => themeStore.layout.mode === 'top-hybrid-header-first');
6572
6673
const siderWidth = computed(() => getSiderWidth());
6774
6875
const siderCollapsedWidth = computed(() => getSiderCollapsedWidth());
6976
7077
function getSiderWidth() {
71-
const { reverseHorizontalMix } = themeStore.layout;
7278
const { width, mixWidth, mixChildMenuWidth } = themeStore.sider;
7379
74-
if (isHorizontalMix.value && reverseHorizontalMix) {
80+
if (isTopHybridHeaderFirst.value) {
7581
return isActiveFirstLevelMenuHasChildren.value ? width : 0;
7682
}
7783
78-
let w = isVerticalMix.value || isHorizontalMix.value ? mixWidth : width;
84+
let w = isVerticalMix.value || isTopHybridSidebarFirst.value ? mixWidth : width;
7985
8086
if (isVerticalMix.value && appStore.mixSiderFixed && childLevelMenus.value.length) {
8187
w += mixChildMenuWidth;
@@ -85,14 +91,13 @@ function getSiderWidth() {
8591
}
8692
8793
function getSiderCollapsedWidth() {
88-
const { reverseHorizontalMix } = themeStore.layout;
8994
const { collapsedWidth, mixCollapsedWidth, mixChildMenuWidth } = themeStore.sider;
9095
91-
if (isHorizontalMix.value && reverseHorizontalMix) {
96+
if (isTopHybridHeaderFirst.value) {
9297
return isActiveFirstLevelMenuHasChildren.value ? collapsedWidth : 0;
9398
}
9499
95-
let w = isVerticalMix.value || isHorizontalMix.value ? mixCollapsedWidth : collapsedWidth;
100+
let w = isVerticalMix.value || isTopHybridSidebarFirst.value ? mixCollapsedWidth : collapsedWidth;
96101
97102
if (isVerticalMix.value && appStore.mixSiderFixed && childLevelMenus.value.length) {
98103
w += mixChildMenuWidth;

src/layouts/modules/global-menu/index.vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import { useThemeStore } from '@/store/modules/theme';
66
import VerticalMenu from './modules/vertical-menu.vue';
77
import VerticalMixMenu from './modules/vertical-mix-menu.vue';
88
import HorizontalMenu from './modules/horizontal-menu.vue';
9-
import HorizontalMixMenu from './modules/horizontal-mix-menu.vue';
10-
import ReversedHorizontalMixMenu from './modules/reversed-horizontal-mix-menu.vue';
9+
import TopHybridSidebarFirst from './modules/top-hybrid-sidebar-first.vue';
10+
import TopHybridHeaderFirst from './modules/top-hybrid-header-first.vue';
1111
1212
defineOptions({
1313
name: 'GlobalMenu'
@@ -21,7 +21,8 @@ const activeMenu = computed(() => {
2121
vertical: VerticalMenu,
2222
'vertical-mix': VerticalMixMenu,
2323
horizontal: HorizontalMenu,
24-
'horizontal-mix': themeStore.layout.reverseHorizontalMix ? ReversedHorizontalMixMenu : HorizontalMixMenu
24+
'top-hybrid-sidebar-first': TopHybridSidebarFirst,
25+
'top-hybrid-header-first': TopHybridHeaderFirst
2526
};
2627
2728
return menuMap[themeStore.layout.mode];

src/layouts/modules/global-sider/index.vue

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,15 @@ const appStore = useAppStore();
1313
const themeStore = useThemeStore();
1414
1515
const isVerticalMix = computed(() => themeStore.layout.mode === 'vertical-mix');
16-
const isHorizontalMix = computed(() => themeStore.layout.mode === 'horizontal-mix');
17-
const darkMenu = computed(() => !themeStore.darkMode && !isHorizontalMix.value && themeStore.sider.inverted);
18-
const showLogo = computed(() => !isVerticalMix.value && !isHorizontalMix.value);
16+
const isTopHybridSidebarFirst = computed(() => themeStore.layout.mode === 'top-hybrid-sidebar-first');
17+
const isTopHybridHeaderFirst = computed(() => themeStore.layout.mode === 'top-hybrid-header-first');
18+
const darkMenu = computed(
19+
() =>
20+
!themeStore.darkMode && !isTopHybridSidebarFirst.value && !isTopHybridHeaderFirst.value && themeStore.sider.inverted
21+
);
22+
const showLogo = computed(
23+
() => !isVerticalMix.value && !isTopHybridSidebarFirst.value && !isTopHybridHeaderFirst.value
24+
);
1925
const menuWrapperClass = computed(() => (showLogo.value ? 'flex-1-hidden' : 'h-full'));
2026
</script>
2127

src/layouts/modules/theme-drawer/components/layout-mode-card.vue

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ type LayoutConfig = Record<
2727
UnionKey.ThemeLayoutMode,
2828
{
2929
placement: PopoverPlacement;
30-
headerClass: string;
3130
menuClass: string;
3231
mainClass: string;
3332
}
@@ -36,25 +35,26 @@ type LayoutConfig = Record<
3635
const layoutConfig: LayoutConfig = {
3736
vertical: {
3837
placement: 'bottom',
39-
headerClass: '',
4038
menuClass: 'w-1/3 h-full',
4139
mainClass: 'w-2/3 h-3/4'
4240
},
4341
'vertical-mix': {
4442
placement: 'bottom',
45-
headerClass: '',
4643
menuClass: 'w-1/4 h-full',
4744
mainClass: 'w-2/3 h-3/4'
4845
},
4946
horizontal: {
5047
placement: 'bottom',
51-
headerClass: '',
5248
menuClass: 'w-full h-1/4',
5349
mainClass: 'w-full h-3/4'
5450
},
55-
'horizontal-mix': {
51+
'top-hybrid-sidebar-first': {
52+
placement: 'bottom',
53+
menuClass: 'w-full h-1/4',
54+
mainClass: 'w-2/3 h-3/4'
55+
},
56+
'top-hybrid-header-first': {
5657
placement: 'bottom',
57-
headerClass: '',
5858
menuClass: 'w-full h-1/4',
5959
mainClass: 'w-2/3 h-3/4'
6060
}
@@ -68,25 +68,27 @@ function handleChangeMode(mode: UnionKey.ThemeLayoutMode) {
6868
</script>
6969

7070
<template>
71-
<div class="grid grid-cols-3 gap-x-32px gap-y-16px">
71+
<div class="grid grid-cols-2 gap-x-16px gap-y-12px md:grid-cols-3">
7272
<div
7373
v-for="(item, key) in layoutConfig"
7474
:key="key"
75-
class="flex-center cursor-pointer border-2px rounded-6px hover:border-primary"
76-
:class="[mode === key ? 'border-primary' : 'border-transparent']"
75+
class="flex-col-center cursor-pointer"
7776
@click="handleChangeMode(key)"
7877
>
7978
<NTooltip :placement="item.placement">
8079
<template #trigger>
8180
<div
82-
class="h-64px w-96px gap-6px rd-4px p-6px shadow dark:shadow-coolGray-5"
83-
:class="[key.includes('vertical') ? 'flex' : 'flex-col']"
81+
class="h-64px w-96px gap-6px rd-4px p-6px shadow ring-2 ring-transparent transition-all hover:ring-primary"
82+
:class="{ '!ring-primary': mode === key }"
8483
>
85-
<slot :name="key"></slot>
84+
<div class="h-full w-full gap-1" :class="[key.includes('vertical') ? 'flex' : 'flex-col']">
85+
<slot :name="key"></slot>
86+
</div>
8687
</div>
8788
</template>
88-
{{ $t(themeLayoutModeRecord[key]) }}
89+
{{ $t(`theme.layout.layoutMode.${key}_detail`) }}
8990
</NTooltip>
91+
<p class="mt-8px text-12px">{{ $t(themeLayoutModeRecord[key]) }}</p>
9092
</div>
9193
</div>
9294
</template>

src/layouts/modules/theme-drawer/modules/layout/index.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<script setup lang="ts">
2+
import { useThemeStore } from '@/store/modules/theme';
23
import LayoutMode from './modules/layout-mode.vue';
34
import TabSettings from './modules/tab-settings.vue';
45
import HeaderSettings from './modules/header-settings.vue';
@@ -9,14 +10,17 @@ import ContentSettings from './modules/content-settings.vue';
910
defineOptions({
1011
name: 'LayoutSettings'
1112
});
13+
14+
const themeStore = useThemeStore();
1215
</script>
1316

1417
<template>
1518
<div class="flex-col-stretch gap-16px">
1619
<LayoutMode />
1720
<TabSettings />
1821
<HeaderSettings />
19-
<SiderSettings />
22+
<!-- The top menu mode does not have a sidebar -->
23+
<SiderSettings v-if="themeStore.layout.mode !== 'horizontal'" />
2024
<FooterSettings />
2125
<ContentSettings />
2226
</div>

0 commit comments

Comments
 (0)