feat: support multiple custom schemes

This commit is contained in:
Erzbir
2026-08-17 23:09:11 +08:00
parent 2a9da1e8f8
commit ff27f72a33
3 changed files with 145 additions and 16 deletions
+90 -14
View File
@@ -151,6 +151,14 @@ spec:
value: "studio" value: "studio"
- label: "vanilla" - label: "vanilla"
value: "vanilla" value: "vanilla"
- $formkit: text
name: custom_dark_scheme
if: "$get(dark_color_scheme).value === 'custom'"
label: 自定义深色配色
help: 填写下方自定义配色的 ID
validation: "required"
- $formkit: select - $formkit: select
name: light_color_scheme name: light_color_scheme
id: light_color_scheme id: light_color_scheme
@@ -184,6 +192,88 @@ spec:
value: "studio" value: "studio"
- label: "vanilla" - label: "vanilla"
value: "vanilla" value: "vanilla"
- $formkit: text
name: custom_light_scheme
if: "$get(light_color_scheme).value === 'custom'"
label: 自定义浅色配色
help: 填写下方自定义配色的 ID
validation: "required"
- $formkit: array
name: custom_color_schemes
label: 自定义配色
value: [ ]
itemLabels:
- type: "text"
label: "$value.id"
children:
- $formkit: text
name: id
label: 配色 ID
validation: "required"
- $formkit: color
name: background
label: 背景色
validation: "required"
- $formkit: color
name: foreground
label: 前景色
validation: "required"
- $formkit: color
name: accent
label: 强调色
validation: "required"
- $formkit: checkbox
name: advanced
label: 高级颜色设置
value: false
help: 开启后可以单独设置标签, 标题, 元信息, 链接和代码等颜色
- $formkit: color
if: "$value.advanced === true"
name: foreground_muted
label: 次要前景色
- $formkit: color
if: "$value.advanced === true"
name: muted
label: 弱化文字颜色
- $formkit: color
if: "$value.advanced === true"
name: tag
label: 标签颜色
- $formkit: color
if: "$value.advanced === true"
name: title
label: 标题颜色
- $formkit: color
if: "$value.advanced === true"
name: meta
label: 元信息颜色
- $formkit: color
if: "$value.advanced === true"
name: framed
label: 强调框颜色
- $formkit: color
if: "$value.advanced === true"
name: menu
label: 菜单颜色
- $formkit: color
if: "$value.advanced === true"
name: header
label: 页头颜色
- $formkit: color
if: "$value.advanced === true"
name: link
label: 链接颜色
- $formkit: color
if: "$value.advanced === true"
name: code_text
label: 代码文字颜色
- $formkit: color
if: "$value.advanced === true"
name: code_background
label: 代码背景颜色
- $formkit: select - $formkit: select
label: 无序列表标记 label: 无序列表标记
name: list_marker name: list_marker
@@ -288,20 +378,6 @@ spec:
min: 0 min: 0
help: 访客手动选择的模式, 配色和像素风格过期后会在下次访问时恢复默认值, 设为 0 表示永久保存 help: 访客手动选择的模式, 配色和像素风格过期后会在下次访问时恢复默认值, 设为 0 表示永久保存
- $formkit: text
name: custom_dark
if: "$get(dark_color_scheme).value === 'custom'"
value: ""
help: 填写自定义深色配色方案的名称
validation: "required"
- $formkit: text
name: custom_light
if: "$get(light_color_scheme).value === 'custom'"
value: ""
help: 填写自定义浅色配色方案的名称
validation: "required"
- $formkit: text - $formkit: text
label: 正文区域最大宽度 label: 正文区域最大宽度
name: max_width name: max_width
+53
View File
@@ -81,6 +81,59 @@
<script data-no-pjax> <script data-no-pjax>
window.TerminalTheme?.applyCustomCss?.(); window.TerminalTheme?.applyCustomCss?.();
</script> </script>
<style th:inline="css">
[# th:each="scheme : ${theme.config.style.custom_color_schemes}"]
html[data-theme-color-scheme="[(${scheme.id})]"] {
--color-theme-background: [(${scheme.background})];
--color-theme-foreground: [(${scheme.foreground})];
--color-theme-accent: [(${scheme.accent})];
[# th:if="${not #strings.isEmpty(scheme.tag)}"]
--color-theme-tag: [(${scheme.tag})];
[/]
[# th:if="${not #strings.isEmpty(scheme.title)}"]
--color-theme-title: [(${scheme.title})];
[/]
[# th:if="${not #strings.isEmpty(scheme.meta)}"]
--color-theme-meta: [(${scheme.meta})];
[/]
[# th:if="${not #strings.isEmpty(scheme.framed)}"]
--color-theme-framed: [(${scheme.framed})];
[/]
[# th:if="${not #strings.isEmpty(scheme.menu)}"]
--color-theme-menu: [(${scheme.menu})];
[/]
[# th:if="${not #strings.isEmpty(scheme.header)}"]
--color-theme-header: [(${scheme.header})];
[/]
[# th:if="${not #strings.isEmpty(scheme.foreground_muted)}"]
--color-theme-foreground-muted: [(${scheme.foreground_muted})];
[/]
[# th:if="${not #strings.isEmpty(scheme.link)}"]
--color-theme-link: [(${scheme.link})];
[/]
[# th:if="${not #strings.isEmpty(scheme.muted)}"]
--color-theme-muted: [(${scheme.muted})];
[/]
[# th:if="${not #strings.isEmpty(scheme.code_text)}"]
--color-theme-code-text: [(${scheme.code_text})];
[/]
[# th:if="${not #strings.isEmpty(scheme.code_background)}"]
--color-theme-code-background: [(${scheme.code_background})];
[/]
}
[/]
</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 not theme.config?.style?.system_font_enable
+2 -2
View File
@@ -4,8 +4,8 @@
systemFontEnabled: /*[[${theme.config.style.system_font_enable}]]*/ false, 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}]]*/ "", customDarkTheme: /*[[${theme.config.style.custom_dark_scheme}]]*/ "",
customLightTheme: /*[[${theme.config.style.custom_light}]]*/ "", customLightTheme: /*[[${theme.config.style.custom_light_scheme}]]*/ "",
defaultMode: /*[[${theme.config.style.default_scheme_mode}]]*/ "system", defaultMode: /*[[${theme.config.style.default_scheme_mode}]]*/ "system",
preferTTL: /*[[${theme.config.style.prefer_ttl ?: 24}]]*/ 24, preferTTL: /*[[${theme.config.style.prefer_ttl ?: 24}]]*/ 24,
pixelStyle: /*[[${theme.config.style.pixel_style}]]*/ false, pixelStyle: /*[[${theme.config.style.pixel_style}]]*/ false,