style: 优化字体栈设置与选择器匹配逻辑
This commit is contained in:
15
js/script.js
15
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;
|
||||
});
|
||||
|
||||
// 字号选择器 - 密码锁式滚轮
|
||||
|
||||
Reference in New Issue
Block a user