diff --git a/packages/@core/base/design/src/design-tokens/default.css b/packages/@core/base/design/src/design-tokens/default.css index 64679f85..4ce7ff95 100644 --- a/packages/@core/base/design/src/design-tokens/default.css +++ b/packages/@core/base/design/src/design-tokens/default.css @@ -93,6 +93,7 @@ /* 基本文字大小 */ --font-size-base: 16px; + --menu-font-size: calc(var(--font-size-base) * 0.875); /* =============component & UI============= */ diff --git a/packages/@core/preferences/src/preferences.ts b/packages/@core/preferences/src/preferences.ts index 23c5f8be..f43bf39e 100644 --- a/packages/@core/preferences/src/preferences.ts +++ b/packages/@core/preferences/src/preferences.ts @@ -141,7 +141,10 @@ class PreferenceManager { private handleUpdates(updates: DeepPartial) { const themeUpdates = updates.theme || {}; const appUpdates = updates.app || {}; - if (themeUpdates && Object.keys(themeUpdates).length > 0) { + if ( + (themeUpdates && Object.keys(themeUpdates).length > 0) || + Reflect.has(themeUpdates, 'fontSize') + ) { updateCSSVariables(this.state); } diff --git a/packages/@core/preferences/src/update-css-variables.ts b/packages/@core/preferences/src/update-css-variables.ts index b00be782..6ee5f748 100644 --- a/packages/@core/preferences/src/update-css-variables.ts +++ b/packages/@core/preferences/src/update-css-variables.ts @@ -69,9 +69,14 @@ function updateCSSVariables(preferences: Preferences) { // 更新字体大小 if (Reflect.has(theme, 'fontSize')) { + const fontSize = theme.fontSize; document.documentElement.style.setProperty( '--font-size-base', - `${theme.fontSize}px`, + `${fontSize}px`, + ); + document.documentElement.style.setProperty( + '--menu-font-size', + `calc(${fontSize}px * 0.875)`, ); } } diff --git a/packages/@core/ui-kit/menu-ui/src/components/menu.vue b/packages/@core/ui-kit/menu-ui/src/components/menu.vue index 624be291..237aff00 100644 --- a/packages/@core/ui-kit/menu-ui/src/components/menu.vue +++ b/packages/@core/ui-kit/menu-ui/src/components/menu.vue @@ -388,7 +388,7 @@ $namespace: vben; padding: var(--menu-item-padding-y) var(--menu-item-padding-x); margin: 0 var(--menu-item-margin-x) var(--menu-item-margin-y) var(--menu-item-margin-x); - font-size: var(--menu-font-size); + font-size: var(--menu-font-size) !important; color: var(--menu-item-color); white-space: nowrap; text-decoration: none; @@ -433,6 +433,7 @@ $namespace: vben; max-width: var(--menu-title-width); overflow: hidden; text-overflow: ellipsis; + font-size: var(--menu-font-size) !important; white-space: nowrap; opacity: 1; } @@ -458,7 +459,6 @@ $namespace: vben; --menu-item-collapse-margin-x: 0px; --menu-item-radius: 0px; --menu-item-indent: 16px; - --menu-font-size: calc(var(--font-size-base, 16px) * 0.875); &.is-dark { --menu-background-color: hsl(var(--menu)); @@ -785,7 +785,7 @@ $namespace: vben; width: 100%; height: 100%; padding: 0 var(--menu-item-padding-x); - font-size: var(--menu-font-size); + font-size: var(--menu-font-size) !important; line-height: var(--menu-item-height); } } @@ -812,9 +812,14 @@ $namespace: vben; .#{$namespace}-sub-menu-content { height: var(--menu-item-height); + font-size: var(--menu-font-size) !important; @include menu-item; + * { + font-size: inherit !important; + } + &__icon-arrow { position: absolute; top: 50%;