mirror of
https://github.com/YuleBest/FontMM.git
synced 2026-12-04 03:11:48 +08:00
fix(webui): 恢复应用按钮可用状态
重构时丢失 renderSlots 中 applyBtn.disabled = applying 一行, 按钮停留在 HTML 初始 disabled 状态无法点击。恢复共享 applying 标志, 选中字体后按钮启用, 应用过程中禁用
This commit is contained in:
1 parent
471bc2051a
commit
d0f5b49a0d
2 files changed
+11
-4
No files matched your search
+3
-3
@@ -1,5 +1,5 @@
|
||||
import { exec, shellQuote, toast } from './ksu';
|
||||
import { copyFont, pickWghtRange, renderSlots, slots } from './slots';
|
||||
import { copyFont, pickWghtRange, renderSlots, setApplying, slots } from './slots';
|
||||
import { applyWghtOverride, getSelectedWghtMode, writeWghtMode } from './wght';
|
||||
import { invalidateTestFonts } from './testFonts';
|
||||
import { applyBtn } from './dom';
|
||||
@@ -14,7 +14,7 @@ document.getElementById('log-close')?.addEventListener('click', () => {
|
||||
|
||||
async function apply() {
|
||||
if (!slots.hans.path) return;
|
||||
applyBtn.disabled = true;
|
||||
setApplying(true);
|
||||
renderSlots();
|
||||
try {
|
||||
// 字重范围覆写: 用 UI 当前模式 (持久化到 FONTS/wght-mode.txt), 仅当存在可变字体且模式非 0 时处理
|
||||
@@ -76,7 +76,7 @@ async function apply() {
|
||||
} catch (e) {
|
||||
toast(`应用失败: ${String(e)}`);
|
||||
} finally {
|
||||
applyBtn.disabled = false;
|
||||
setApplying(false);
|
||||
renderSlots();
|
||||
}
|
||||
}
|
||||
|
||||
+8
-1
@@ -49,6 +49,12 @@ const wghtModeSub = document.getElementById('wght-mode-sub');
|
||||
|
||||
let pickingKey: SlotKey = 'hans';
|
||||
|
||||
// 应用流程进行中: renderSlots 据此禁用/启用应用按钮
|
||||
export let applying = false;
|
||||
export function setApplying(v: boolean): void {
|
||||
applying = v;
|
||||
}
|
||||
|
||||
const picker = new FontFilePicker((path, name) => {
|
||||
const slot = slots[pickingKey];
|
||||
slot.path = path;
|
||||
@@ -140,8 +146,9 @@ export function renderSlots() {
|
||||
});
|
||||
|
||||
if (applyBtn) {
|
||||
// 未选择简体字体时直接隐藏按钮 (不做半透明禁用)
|
||||
// 未选择简体字体时直接隐藏按钮 (不做半透明禁用); 应用过程中禁用
|
||||
applyBtn.style.display = !slots.hans.path ? 'none' : '';
|
||||
applyBtn.disabled = applying;
|
||||
}
|
||||
updateWghtModeDisabled();
|
||||
// 通知其他模块 (如字重映射预览) 槽位已变化
|
||||
|
||||
Reference in new issue
Block a user