From 3c8c337401934baa66dac96f51c991395a511de9 Mon Sep 17 00:00:00 2001 From: Hermes Date: Mon, 20 Apr 2026 21:30:03 +0800 Subject: [PATCH] =?UTF-8?q?fix(th=5F14=5Fpanels):=20=E4=BF=AE=E5=A4=8D=20S?= =?UTF-8?q?hortX=20=E5=9B=BE=E6=A0=87=E8=B0=83=E8=89=B2=E6=9D=BF=E7=A1=AE?= =?UTF-8?q?=E8=AE=A4=E5=90=8E=E6=9C=AA=E5=BA=94=E7=94=A8=E9=A2=9C=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- code/th_14_panels.js | 40 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/code/th_14_panels.js b/code/th_14_panels.js index f0515d5..c601daa 100644 --- a/code/th_14_panels.js +++ b/code/th_14_panels.js @@ -904,6 +904,9 @@ FloatBallAppWM.prototype.buildButtonEditorPanelView = function() { currentShortXIconName = name; updateShortXIconPreview(); 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, onSelect: function(colorHex) { try { - var safeColor = String(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) {} + applyTintSelectionFromPopup(colorHex); } catch(eSelect) { safeLog(self.L, 'e', "colorPicker callback err=" + String(eSelect)); } @@ -1382,6 +1375,16 @@ FloatBallAppWM.prototype.buildButtonEditorPanelView = function() { 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) { var baseRgb = tintPaletteState.currentBaseRgbHex || extractTintRgbHex(getThemeTintHex()); var alphaByte = 255; @@ -1505,17 +1508,7 @@ FloatBallAppWM.prototype.buildButtonEditorPanelView = function() { currentIconName: currentShortXIconName, onSelect: function(colorHex) { try { - var safeColor = String(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) {} + applyTintSelectionFromPopup(colorHex); } catch(eSelect) { safeLog(self.L, 'e', "colorPicker callback err=" + String(eSelect)); } @@ -3399,6 +3392,9 @@ try { buttons[editIdx] = newBtn; } + // # 立即持久化,避免 refreshPanel 重新加载时丢失(keepBtnEditorState=false 会触发重新克隆) + ConfigManager.saveButtons(buttons); + self.state.editingButtonIndex = null; refreshPanel(); self.toast("已暂存,请在列表页点击保存");