fix(th_14_panels): 修复 ShortX 图标调色板确认后未应用颜色

This commit is contained in:
Hermes
2026-04-20 21:30:03 +08:00
parent 4ab42b274a
commit 3c8c337401

View File

@@ -904,6 +904,9 @@ FloatBallAppWM.prototype.buildButtonEditorPanelView = function() {
currentShortXIconName = name; currentShortXIconName = name;
updateShortXIconPreview(); updateShortXIconPreview();
try { if (shortxPickerState.toggleBtn) shortxPickerState.toggleBtn.setText(name || "\u9009\u62e9\u56fe\u6807"); } catch(e) {} try { if (shortxPickerState.toggleBtn) shortxPickerState.toggleBtn.setText(name || "\u9009\u62e9\u56fe\u6807"); } catch(e) {}
// # 选中 ShortX 图标后自动切换到 ShortX 图标模式,避免保存时走 file 分支导致颜色丢失
try { rbIconShortX.setChecked(true); } catch(eRb) {}
try { updateIconInputs("shortx"); } catch(eUp) {}
} }
}); });
}); });
@@ -934,17 +937,7 @@ FloatBallAppWM.prototype.buildButtonEditorPanelView = function() {
currentIconName: currentShortXIconName, currentIconName: currentShortXIconName,
onSelect: function(colorHex) { onSelect: function(colorHex) {
try { try {
var safeColor = String(colorHex || ""); applyTintSelectionFromPopup(colorHex);
// # 避免 Rhino 闭包问题:从 self.state 读取输入框引用
var tintInput = self.state._btnEditorTintInput || inputShortXIconTint;
if (tintInput && tintInput.input) {
tintInput.input.setText(safeColor);
try { tintInput.input.invalidate(); } catch(e) {}
}
// # 双保险:直接更新 targetBtn确保保存时能拿到正确值
if (safeColor) targetBtn.iconTint = safeColor;
else delete targetBtn.iconTint;
try { if (tintPaletteState.toggleBtn) tintPaletteState.toggleBtn.setText(safeColor || "\u9009\u62e9\u989c\u8272"); } catch(e) {}
} catch(eSelect) { } catch(eSelect) {
safeLog(self.L, 'e', "colorPicker callback err=" + String(eSelect)); safeLog(self.L, 'e', "colorPicker callback err=" + String(eSelect));
} }
@@ -1382,6 +1375,16 @@ FloatBallAppWM.prototype.buildButtonEditorPanelView = function() {
syncTintUiFromInput(!!pushRecent); syncTintUiFromInput(!!pushRecent);
} }
function applyTintSelectionFromPopup(colorHex) {
var safeColor = normalizeTintColorValue(colorHex, true);
if (safeColor === null) safeColor = "";
applyTintHexValue(safeColor, !!safeColor);
if (safeColor) targetBtn.iconTint = safeColor;
else delete targetBtn.iconTint;
try { if (tintPaletteState.toggleBtn) tintPaletteState.toggleBtn.setText(safeColor || "\u9009\u62e9\u989c\u8272"); } catch(eTintPopupBtn0) {}
try { updateShortXIconPreview(); } catch(eTintPopupPreview0) {}
}
function applyTintFromCurrentBase(pushRecent) { function applyTintFromCurrentBase(pushRecent) {
var baseRgb = tintPaletteState.currentBaseRgbHex || extractTintRgbHex(getThemeTintHex()); var baseRgb = tintPaletteState.currentBaseRgbHex || extractTintRgbHex(getThemeTintHex());
var alphaByte = 255; var alphaByte = 255;
@@ -1505,17 +1508,7 @@ FloatBallAppWM.prototype.buildButtonEditorPanelView = function() {
currentIconName: currentShortXIconName, currentIconName: currentShortXIconName,
onSelect: function(colorHex) { onSelect: function(colorHex) {
try { try {
var safeColor = String(colorHex || ""); applyTintSelectionFromPopup(colorHex);
// # 避免 Rhino 闭包问题:从 self.state 读取输入框引用
var tintInput = self.state._btnEditorTintInput || inputShortXIconTint;
if (tintInput && tintInput.input) {
tintInput.input.setText(safeColor);
try { tintInput.input.invalidate(); } catch(e) {}
}
// # 双保险:直接更新 targetBtn确保保存时能拿到正确值
if (safeColor) targetBtn.iconTint = safeColor;
else delete targetBtn.iconTint;
try { if (tintPaletteState.toggleBtn) tintPaletteState.toggleBtn.setText(safeColor || "\u9009\u62e9\u989c\u8272"); } catch(e) {}
} catch(eSelect) { } catch(eSelect) {
safeLog(self.L, 'e', "colorPicker callback err=" + String(eSelect)); safeLog(self.L, 'e', "colorPicker callback err=" + String(eSelect));
} }
@@ -3399,6 +3392,9 @@ try {
buttons[editIdx] = newBtn; buttons[editIdx] = newBtn;
} }
// # 立即持久化,避免 refreshPanel 重新加载时丢失keepBtnEditorState=false 会触发重新克隆)
ConfigManager.saveButtons(buttons);
self.state.editingButtonIndex = null; self.state.editingButtonIndex = null;
refreshPanel(); refreshPanel();
self.toast("已暂存,请在列表页点击保存"); self.toast("已暂存,请在列表页点击保存");