From d1cf7860de651a77f4e0d4bd6aa8b89ca51451c2 Mon Sep 17 00:00:00 2001 From: zihanjian Date: Mon, 30 Jun 2025 16:59:16 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A2=9C=E8=89=B2=E6=98=A0=E5=B0=84=20-=20?= =?UTF-8?q?=E5=88=9D=E5=A7=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/ColorSystemPanel.tsx | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/components/ColorSystemPanel.tsx b/src/components/ColorSystemPanel.tsx index 5ef2c16..a29272d 100644 --- a/src/components/ColorSystemPanel.tsx +++ b/src/components/ColorSystemPanel.tsx @@ -214,12 +214,23 @@ const ColorSystemPanel: React.FC = ({ return colorKey !== '-'; }) ); + + // 检查色板是否真的改变了 + const paletteChanged = validColors.size !== tempCustomPalette.size; + setTempCustomPalette(validColors); - // 使用 setTimeout 确保状态更新后再触发画布刷新 - setTimeout(() => { - onSettingsChange?.(); - }, 50); + // 只有在色板内容真的改变时才触发重新生成 + if (paletteChanged) { + // 保存到 localStorage + localStorage.setItem('customPalette', JSON.stringify(Array.from(validColors))); + onCustomPaletteChange(validColors); + + // 使用 setTimeout 确保状态更新后再触发画布刷新 + setTimeout(() => { + onSettingsChange?.(); + }, 50); + } setShowColorSystemDropdown(false); }}