feat: header menu align support (#5256)

* feat: header menu align support

* fix: typo
This commit is contained in:
Netfan
2024-12-28 16:16:48 +08:00
committed by GitHub
parent 15fe82c62f
commit ec2c6eff6f
10 changed files with 73 additions and 4 deletions

View File

@@ -38,6 +38,7 @@ type BuiltinThemeType =
type ContentCompactType = 'compact' | 'wide';
type LayoutHeaderModeType = 'auto' | 'auto-scroll' | 'fixed' | 'static';
type LayoutHeaderMenuAlignType = 'center' | 'end' | 'start';
/**
* 登录过期模式
@@ -95,6 +96,7 @@ export type {
BreadcrumbStyleType,
BuiltinThemeType,
ContentCompactType,
LayoutHeaderMenuAlignType,
LayoutHeaderModeType,
LayoutType,
LoginExpiredModeType,

View File

@@ -46,6 +46,7 @@ exports[`defaultPreferences immutability test > should not modify the config obj
"header": {
"enable": true,
"hidden": false,
"menuAlign": "start",
"mode": "fixed",
},
"logo": {

View File

@@ -46,6 +46,7 @@ const defaultPreferences: Preferences = {
header: {
enable: true,
hidden: false,
menuAlign: 'start',
mode: 'fixed',
},
logo: {

View File

@@ -5,6 +5,7 @@ import type {
BuiltinThemeType,
ContentCompactType,
DeepPartial,
LayoutHeaderMenuAlignType,
LayoutHeaderModeType,
LayoutType,
LoginExpiredModeType,
@@ -104,6 +105,8 @@ interface HeaderPreferences {
enable: boolean;
/** 顶栏是否隐藏,css-隐藏 */
hidden: boolean;
/** 顶栏菜单位置 */
menuAlign: LayoutHeaderMenuAlignType;
/** header显示模式 */
mode: LayoutHeaderModeType;
}

View File

@@ -332,6 +332,7 @@ function removeMenuItem(item: MenuItemRegistered) {
is(theme, true),
is('rounded', rounded),
is('collapse', collapse),
is('menu-align', mode === 'horizontal'),
]"
:style="menuStyle"
role="menu"
@@ -423,6 +424,10 @@ $namespace: vben;
opacity: 1;
}
.is-menu-align {
justify-content: var(--menu-align, start);
}
.#{$namespace}-menu__popup-container,
.#{$namespace}-menu {
--menu-title-width: 140px;