mirror of
https://gitee.com/dapppp/ruoyi-plus-vben5.git
synced 2026-03-08 07:31:09 +08:00
feat: add global font size adjustment
This commit is contained in:
@@ -100,7 +100,7 @@
|
|||||||
"node": ">=20.10.0",
|
"node": ">=20.10.0",
|
||||||
"pnpm": ">=9.12.0"
|
"pnpm": ">=9.12.0"
|
||||||
},
|
},
|
||||||
"packageManager": "pnpm@10.14.0",
|
"packageManager": "pnpm@10.21.0",
|
||||||
"pnpm": {
|
"pnpm": {
|
||||||
"peerDependencyRules": {
|
"peerDependencyRules": {
|
||||||
"allowedVersions": {
|
"allowedVersions": {
|
||||||
|
|||||||
@@ -14,8 +14,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
html {
|
html {
|
||||||
@apply text-foreground bg-background font-sans text-[100%];
|
@apply text-foreground bg-background font-sans;
|
||||||
|
|
||||||
|
font-size: var(--font-size-base, 16px);
|
||||||
font-variation-settings: normal;
|
font-variation-settings: normal;
|
||||||
line-height: 1.15;
|
line-height: 1.15;
|
||||||
text-size-adjust: 100%;
|
text-size-adjust: 100%;
|
||||||
|
|||||||
@@ -116,6 +116,7 @@ const defaultPreferences: Preferences = {
|
|||||||
colorWarning: 'hsl(42 84% 61%)',
|
colorWarning: 'hsl(42 84% 61%)',
|
||||||
mode: 'dark',
|
mode: 'dark',
|
||||||
radius: '0.5',
|
radius: '0.5',
|
||||||
|
fontSize: 16,
|
||||||
semiDarkHeader: false,
|
semiDarkHeader: false,
|
||||||
semiDarkSidebar: false,
|
semiDarkSidebar: false,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -243,6 +243,8 @@ interface ThemePreferences {
|
|||||||
mode: ThemeModeType;
|
mode: ThemeModeType;
|
||||||
/** 圆角 */
|
/** 圆角 */
|
||||||
radius: string;
|
radius: string;
|
||||||
|
/** 字体大小(单位:px) */
|
||||||
|
fontSize: number;
|
||||||
/** 是否开启半深色header(只在theme='light'时生效) */
|
/** 是否开启半深色header(只在theme='light'时生效) */
|
||||||
semiDarkHeader: boolean;
|
semiDarkHeader: boolean;
|
||||||
/** 是否开启半深色菜单(只在theme='light'时生效) */
|
/** 是否开启半深色菜单(只在theme='light'时生效) */
|
||||||
|
|||||||
@@ -66,6 +66,14 @@ function updateCSSVariables(preferences: Preferences) {
|
|||||||
if (Reflect.has(theme, 'radius')) {
|
if (Reflect.has(theme, 'radius')) {
|
||||||
document.documentElement.style.setProperty('--radius', `${radius}rem`);
|
document.documentElement.style.setProperty('--radius', `${radius}rem`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 更新字体大小
|
||||||
|
if (Reflect.has(theme, 'fontSize')) {
|
||||||
|
document.documentElement.style.setProperty(
|
||||||
|
'--font-size-base',
|
||||||
|
`${theme.fontSize}px`,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -444,7 +444,7 @@ $namespace: vben;
|
|||||||
.#{$namespace}-menu__popup-container,
|
.#{$namespace}-menu__popup-container,
|
||||||
.#{$namespace}-menu {
|
.#{$namespace}-menu {
|
||||||
--menu-title-width: 140px;
|
--menu-title-width: 140px;
|
||||||
--menu-item-icon-size: 16px;
|
--menu-item-icon-size: var(--font-size-base, 16px);
|
||||||
--menu-item-height: 38px;
|
--menu-item-height: 38px;
|
||||||
--menu-item-padding-y: 21px;
|
--menu-item-padding-y: 21px;
|
||||||
--menu-item-padding-x: 12px;
|
--menu-item-padding-x: 12px;
|
||||||
@@ -458,7 +458,7 @@ $namespace: vben;
|
|||||||
--menu-item-collapse-margin-x: 0px;
|
--menu-item-collapse-margin-x: 0px;
|
||||||
--menu-item-radius: 0px;
|
--menu-item-radius: 0px;
|
||||||
--menu-item-indent: 16px;
|
--menu-item-indent: 16px;
|
||||||
--menu-font-size: 14px;
|
--menu-font-size: calc(var(--font-size-base, 16px) * 0.875);
|
||||||
|
|
||||||
&.is-dark {
|
&.is-dark {
|
||||||
--menu-background-color: hsl(var(--menu));
|
--menu-background-color: hsl(var(--menu));
|
||||||
@@ -752,7 +752,7 @@ $namespace: vben;
|
|||||||
}
|
}
|
||||||
.#{$namespace}-menu__icon {
|
.#{$namespace}-menu__icon {
|
||||||
display: block;
|
display: block;
|
||||||
font-size: 20px !important;
|
font-size: calc(var(--font-size-base, 16px) * 1.25) !important;
|
||||||
transition: all 0.25s ease;
|
transition: all 0.25s ease;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -760,7 +760,7 @@ $namespace: vben;
|
|||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
margin-top: 8px;
|
margin-top: 8px;
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
font-size: 12px;
|
font-size: calc(var(--font-size-base, 16px) * 0.75);
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
line-height: normal;
|
line-height: normal;
|
||||||
transition: all 0.25s ease;
|
transition: all 0.25s ease;
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ $namespace: vben;
|
|||||||
}
|
}
|
||||||
|
|
||||||
.#{$namespace}-normal-menu__icon {
|
.#{$namespace}-normal-menu__icon {
|
||||||
font-size: 20px;
|
font-size: calc(var(--font-size-base, 16px) * 1.25);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,14 +146,14 @@ $namespace: vben;
|
|||||||
|
|
||||||
&__icon {
|
&__icon {
|
||||||
max-height: 20px;
|
max-height: 20px;
|
||||||
font-size: 20px;
|
font-size: calc(var(--font-size-base, 16px) * 1.25);
|
||||||
transition: all 0.25s ease;
|
transition: all 0.25s ease;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__name {
|
&__name {
|
||||||
margin-top: 8px;
|
margin-top: 8px;
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
font-size: 12px;
|
font-size: calc(var(--font-size-base, 16px) * 0.75);
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
transition: all 0.25s ease;
|
transition: all 0.25s ease;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,5 +15,6 @@ export { default as GlobalShortcutKeys } from './shortcut-keys/global.vue';
|
|||||||
export { default as SwitchItem } from './switch-item.vue';
|
export { default as SwitchItem } from './switch-item.vue';
|
||||||
export { default as BuiltinTheme } from './theme/builtin.vue';
|
export { default as BuiltinTheme } from './theme/builtin.vue';
|
||||||
export { default as ColorMode } from './theme/color-mode.vue';
|
export { default as ColorMode } from './theme/color-mode.vue';
|
||||||
|
export { default as FontSize } from './theme/font-size.vue';
|
||||||
export { default as Radius } from './theme/radius.vue';
|
export { default as Radius } from './theme/radius.vue';
|
||||||
export { default as Theme } from './theme/theme.vue';
|
export { default as Theme } from './theme/theme.vue';
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ import {
|
|||||||
Content,
|
Content,
|
||||||
Copyright,
|
Copyright,
|
||||||
Footer,
|
Footer,
|
||||||
|
FontSize,
|
||||||
General,
|
General,
|
||||||
GlobalShortcutKeys,
|
GlobalShortcutKeys,
|
||||||
Header,
|
Header,
|
||||||
@@ -85,6 +86,7 @@ const themeColorPrimary = defineModel<string>('themeColorPrimary');
|
|||||||
const themeBuiltinType = defineModel<BuiltinThemeType>('themeBuiltinType');
|
const themeBuiltinType = defineModel<BuiltinThemeType>('themeBuiltinType');
|
||||||
const themeMode = defineModel<ThemeModeType>('themeMode');
|
const themeMode = defineModel<ThemeModeType>('themeMode');
|
||||||
const themeRadius = defineModel<string>('themeRadius');
|
const themeRadius = defineModel<string>('themeRadius');
|
||||||
|
const themeFontSize = defineModel<number>('themeFontSize');
|
||||||
const themeSemiDarkSidebar = defineModel<boolean>('themeSemiDarkSidebar');
|
const themeSemiDarkSidebar = defineModel<boolean>('themeSemiDarkSidebar');
|
||||||
const themeSemiDarkHeader = defineModel<boolean>('themeSemiDarkHeader');
|
const themeSemiDarkHeader = defineModel<boolean>('themeSemiDarkHeader');
|
||||||
|
|
||||||
@@ -328,6 +330,9 @@ async function handleReset() {
|
|||||||
<Block :title="$t('preferences.theme.radius')">
|
<Block :title="$t('preferences.theme.radius')">
|
||||||
<Radius v-model="themeRadius" />
|
<Radius v-model="themeRadius" />
|
||||||
</Block>
|
</Block>
|
||||||
|
<Block :title="$t('preferences.theme.fontSize')">
|
||||||
|
<FontSize v-model="themeFontSize" />
|
||||||
|
</Block>
|
||||||
<Block :title="$t('preferences.other')">
|
<Block :title="$t('preferences.other')">
|
||||||
<ColorMode
|
<ColorMode
|
||||||
v-model:app-color-gray-mode="appColorGrayMode"
|
v-model:app-color-gray-mode="appColorGrayMode"
|
||||||
|
|||||||
@@ -120,6 +120,8 @@
|
|||||||
"theme": {
|
"theme": {
|
||||||
"title": "Theme",
|
"title": "Theme",
|
||||||
"radius": "Radius",
|
"radius": "Radius",
|
||||||
|
"fontSize": "Font Size",
|
||||||
|
"fontSizeTip": "Adjust global font size with real-time preview",
|
||||||
"light": "Light",
|
"light": "Light",
|
||||||
"dark": "Dark",
|
"dark": "Dark",
|
||||||
"darkSidebar": "Semi Dark Sidebar",
|
"darkSidebar": "Semi Dark Sidebar",
|
||||||
|
|||||||
@@ -120,6 +120,8 @@
|
|||||||
"theme": {
|
"theme": {
|
||||||
"title": "主题",
|
"title": "主题",
|
||||||
"radius": "圆角",
|
"radius": "圆角",
|
||||||
|
"fontSize": "字体大小",
|
||||||
|
"fontSizeTip": "调整全局字体大小,实时预览效果",
|
||||||
"light": "浅色",
|
"light": "浅色",
|
||||||
"dark": "深色",
|
"dark": "深色",
|
||||||
"darkSidebar": "深色侧边栏",
|
"darkSidebar": "深色侧边栏",
|
||||||
|
|||||||
Reference in New Issue
Block a user