From b6e84de616b0c6b172a51b4481cba88bd93d2151 Mon Sep 17 00:00:00 2001 From: Erzbir Date: Mon, 17 Aug 2026 00:41:25 +0800 Subject: [PATCH] refactor: normalize custom data attributes --- README.md | 12 ++++----- src/libs/pjax.js | 24 +++++++++--------- src/module/color-scheme-picker.js | 2 +- src/module/header-actions.js | 13 +++------- src/styles/icons.scss | 4 +-- src/styles/main.scss | 4 +-- src/styles/scheme.scss | 4 +-- src/utils/theme-preferences.js | 2 -- templates/layout.html | 32 ++++++++++++------------ templates/modules/theme-preferences.html | 20 +++++++-------- 10 files changed, 54 insertions(+), 63 deletions(-) diff --git a/README.md b/README.md index ee5337a..d3d9d7e 100644 --- a/README.md +++ b/README.md @@ -99,7 +99,7 @@ | 自定义深色名称 | `style.custom_dark` | 深色配色选择 `custom` 时填写 | | 自定义浅色名称 | `style.custom_light` | 浅色配色选择 `custom` 时填写 | -访客配色列表会从页面样式表中自动发现 `html[theme-color-scheme='name']` 选择器, 列表中的 `default` 用于清除访客选择并恢复主题设置, +访客配色列表会从页面样式表中自动发现 `html[data-theme-color-scheme='name']` 选择器, 列表中的 `default` 用于清除访客选择并恢复主题设置, 因此不要将 `default` 用作自定义配色名称 ### 页面设置 @@ -163,7 +163,7 @@ 下面的示例增加名为 `forest` 的配色: ```css -html[theme-color-scheme='forest'] { +html[-data-theme-color-scheme='forest'] { --color-theme-background: #0f1a14; --color-theme-foreground: #c7d8cc; --color-theme-accent: #68d391; @@ -187,7 +187,7 @@ html[theme-color-scheme='forest'] { 直接使用内置配色名称即可覆盖对应变量: ```css -html[theme-color-scheme='matrix'] { +html[-data-theme-color-scheme='matrix'] { --color-theme-background: #07130b; --color-theme-foreground: #7dff9b; --color-theme-accent: #39ff68; @@ -252,7 +252,7 @@ html[theme-color-scheme='matrix'] { 修改特定配色下的字体: ```css -html[theme-color-scheme='matrix'] { +html[-data-theme-color-scheme='matrix'] { --family-theme-font: system-ui; } ``` @@ -293,11 +293,11 @@ OR: 如果要注入 ` - + - - - - - - - - - - - - - - -