From bb2ae9c139b359d26f3f523bb21ffc22019fa406 Mon Sep 17 00:00:00 2001 From: ZF sun <34314687@qq.com> Date: Tue, 21 Apr 2026 10:23:18 +0800 Subject: [PATCH] =?UTF-8?q?style:=20=E4=BC=98=E5=8C=96=E5=AD=97=E4=BD=93?= =?UTF-8?q?=E6=A0=88=E8=AE=BE=E7=BD=AE=E4=B8=8E=E9=80=89=E6=8B=A9=E5=99=A8?= =?UTF-8?q?=E5=8C=B9=E9=85=8D=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- css/style.css | 2 +- index.html | 9 +++++---- js/script.js | 15 ++++++++++++--- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/css/style.css b/css/style.css index c957ceb..121d0b9 100644 --- a/css/style.css +++ b/css/style.css @@ -390,7 +390,7 @@ html, body { padding: 0; font-size: 16px; color: #000; - font-family: "Microsoft YaHei", "微软雅黑", sans-serif; + font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif; background: transparent; outline: 2px solid transparent; border-radius: 4px; diff --git a/index.html b/index.html index c3c23af..a8c1d23 100644 --- a/index.html +++ b/index.html @@ -31,10 +31,11 @@
diff --git a/js/script.js b/js/script.js index 0a25178..0729ec0 100644 --- a/js/script.js +++ b/js/script.js @@ -1199,13 +1199,22 @@ // 更新颜色选择器 colorPicker.value = rgbToHex(color); - // 更新字体选择器 + // 更新字体选择器 - 匹配字体栈中的主要字体 + let matched = false; for (let option of fontPicker.options) { - if (option.value === fontFamily || fontFamily.includes(option.value)) { + const optionFonts = option.value.toLowerCase().split(',').map(f => f.trim()); + const currentFonts = fontFamily.toLowerCase().split(',').map(f => f.trim()); + // 检查是否有主要字体匹配 + if (optionFonts.some(of => currentFonts.includes(of))) { fontPicker.value = option.value; + matched = true; break; } } + // 如果没有匹配,默认选择第一个(系统默认) + if (!matched && fontPicker.options.length > 0) { + fontPicker.value = fontPicker.options[0].value; + } // 更新字号选择器 const fontSizeValueEl = fontSizePicker.querySelector('.roller-value'); @@ -1730,7 +1739,7 @@ fontPicker.addEventListener('change', () => { const targetInput = editingInput || selectedInput; if (!targetInput) return; - targetInput.style.fontFamily = fontPicker.value + ', sans-serif'; + targetInput.style.fontFamily = fontPicker.value; }); // 字号选择器 - 密码锁式滚轮