refactor: integrate system font into default font selector

This commit is contained in:
Erzbir
2026-08-19 02:25:45 +08:00
parent 930587a542
commit fd751c14b0
5 changed files with 4 additions and 22 deletions
-1
View File
@@ -68,7 +68,6 @@
| 基础行高 | `style.line_height` | 接受 `28px`, `1.75rem` 或 `calc(...)` 等 CSS 长度 | | 基础行高 | `style.line_height` | 接受 `28px`, `1.75rem` 或 `calc(...)` 等 CSS 长度 |
| 文章段落间距 | `style.post_paragraph_spacing` | 控制文章正文段落的上下间距 | | 文章段落间距 | `style.post_paragraph_spacing` | 控制文章正文段落的上下间距 |
| 元信息分隔符 | `style.post_meta_divider` | 控制文章时间, 作者和标签等元信息之间的分隔符 | | 元信息分隔符 | `style.post_meta_divider` | 控制文章时间, 作者和标签等元信息之间的分隔符 |
| 使用系统字体 | `style.system_font_enable` | 使用访问者的 `system-ui` 字体 |
| 默认像素风格 | `style.pixel_style` | 使用像素字体和像素图标 | | 默认像素风格 | `style.pixel_style` | 使用像素字体和像素图标 |
| 自定义字体 | `style.custom_font_enable` | 上传字体文件并填写字体内部名称 | | 自定义字体 | `style.custom_font_enable` | 上传字体文件并填写字体内部名称 |
| 无序列表标记 | `style.list_marker` | 可选 `-`, `*`, `+`, `>` 或默认标记 | | 无序列表标记 | `style.list_marker` | 可选 `-`, `*`, `+`, `>` 或默认标记 |
+3 -9
View File
@@ -25,12 +25,14 @@ spec:
name: default_font name: default_font
value: "JetBrains Mono" value: "JetBrains Mono"
options: options:
- label: "系统默认"
value: "system-ui"
- label: "JetBrains Mono" - label: "JetBrains Mono"
value: "JetBrains Mono" value: "JetBrains Mono"
- label: "Hack" - label: "Hack"
value: "Hack" value: "Hack"
- label: "Fira Code" - label: "Fira Code"
value: "Fira Code" value: "Fira Code"
- $formkit: checkbox - $formkit: checkbox
label: 启用全屏布局 label: 启用全屏布局
name: fullscreen_layout name: fullscreen_layout
@@ -47,18 +49,10 @@ spec:
value: false value: false
help: 开启后将默认使用像素风格字体及图标 help: 开启后将默认使用像素风格字体及图标
- $formkit: checkbox - $formkit: checkbox
label: 使用系统字体
name: system_font_enable
id: system_font_enable
value: false
help: 开启后将优先使用访问者的系统字体
- $formkit: checkbox
if: "$get(system_font_enable).value != true"
name: custom_font_enable name: custom_font_enable
id: custom_font_enable id: custom_font_enable
label: 启用自定义字体文件 label: 启用自定义字体文件
value: false value: false
help: '如果启用 "使用系统字体", 此配置项不生效'
- $formkit: array - $formkit: array
if: "$get(custom_font_enable).value === true" if: "$get(custom_font_enable).value === true"
name: custom_fonts name: custom_fonts
-4
View File
@@ -35,10 +35,6 @@ html[data-pixel-style='true'] {
--family-theme-font: 'Fusion Pixel 12px Prop zh_hans'; --family-theme-font: 'Fusion Pixel 12px Prop zh_hans';
} }
html[data-system-font-enabled='true']:not([data-pixel-style='true']) {
--family-theme-font: system-ui;
}
* { * {
scrollbar-width: var(--width-theme-scrollbar); scrollbar-width: var(--width-theme-scrollbar);
scrollbar-color: var(--color-theme-scrollbar); scrollbar-color: var(--color-theme-scrollbar);
-1
View File
@@ -136,7 +136,6 @@
</style> </style>
<th:block <th:block
th:if="${theme.config?.style?.custom_font_enable th:if="${theme.config?.style?.custom_font_enable
and not theme.config?.style?.system_font_enable
and theme.config?.style?.custom_fonts != null and theme.config?.style?.custom_fonts != null
and not #lists.isEmpty(theme.config.style.custom_fonts)}"> and not #lists.isEmpty(theme.config.style.custom_fonts)}">
+1 -7
View File
@@ -1,7 +1,6 @@
<th:block th:fragment="theme-preferences"> <th:block th:fragment="theme-preferences">
<script data-no-pjax th:inline="javascript"> <script data-no-pjax th:inline="javascript">
window.TerminalThemeConfig = { window.TerminalThemeConfig = {
systemFontEnabled: /*[[${theme.config.style.system_font_enable}]]*/ false,
darkTheme: /*[[${theme.config.style.dark_color_scheme}]]*/ "dark", darkTheme: /*[[${theme.config.style.dark_color_scheme}]]*/ "dark",
lightTheme: /*[[${theme.config.style.light_color_scheme}]]*/ "light", lightTheme: /*[[${theme.config.style.light_color_scheme}]]*/ "light",
customDarkTheme: /*[[${theme.config.style.custom_dark_scheme}]]*/ "", customDarkTheme: /*[[${theme.config.style.custom_dark_scheme}]]*/ "",
@@ -108,11 +107,7 @@
setStoredPreference(storageKeys.colorScheme, scheme); setStoredPreference(storageKeys.colorScheme, scheme);
root.dataset.themeColorScheme = scheme; root.dataset.themeColorScheme = scheme;
} }
function syncSystemFont() {
root.dataset.systemFontEnabled = String(config.systemFontEnabled);
}
function syncPixelStyle() { function syncPixelStyle() {
root.dataset.pixelStyle = getStoredPreference(storageKeys.pixelStyle) root.dataset.pixelStyle = getStoredPreference(storageKeys.pixelStyle)
|| String(config.pixelStyle); || String(config.pixelStyle);
@@ -168,7 +163,6 @@
syncPixelStyle syncPixelStyle
}; };
syncSystemFont();
syncThemeMode(); syncThemeMode();
syncPixelStyle(); syncPixelStyle();
syncPixelFont(); syncPixelFont();