From b779099bcf5648fd4976b85cd0a32b3345bc0ad9 Mon Sep 17 00:00:00 2001 From: wonder Date: Fri, 26 Jun 2026 17:14:17 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=80=89=E4=B8=AD=E5=AD=90=E6=A0=87?= =?UTF-8?q?=E7=AD=BE=E9=80=89=E9=A1=B9=E6=97=B6=E5=90=8C=E6=AD=A5=E5=8B=BE?= =?UTF-8?q?=E9=80=89=E7=88=B6=E6=A0=87=E7=AD=BE=E5=A4=8D=E9=80=89=E6=A1=86?= =?UTF-8?q?=EF=BC=8C=E5=B9=B6=E6=94=AF=E6=8C=81=E5=86=8D=E6=AC=A1=E7=82=B9?= =?UTF-8?q?=E5=87=BB=E5=8F=96=E6=B6=88=E9=80=89=E6=8B=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将 radio 的 onchange 改为 onclick,支持点击已选中的 radio 触发取消 - selectTagOption 中增加父复选框 DOM 同步逻辑 - 再次点击已选中的 radio 时取消选择并重建 DOM 状态 --- frontend/index.html | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/frontend/index.html b/frontend/index.html index 4f22ce4..93d33f7 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -214,7 +214,7 @@ const checked = selectedTags[tag.id] !== undefined; const optionsHtml = tag.options.map(o => ` `).join(''); @@ -255,7 +255,18 @@ } function selectTagOption(tagId, optionId) { - selectedTags[tagId] = optionId; + if (selectedTags[tagId] === optionId) { + // 再次点击已选中的选项 → 取消选择(需要 renderTags 重建 DOM 以取消 radio 的 checked 状态) + delete selectedTags[tagId]; + renderTags(); + } else { + selectedTags[tagId] = optionId; + // 同步勾选父标签复选框 + const checkbox = document.querySelector(`#tag-options-${tagId}`) + ?.closest('.mb-2') + ?.querySelector('input[type="checkbox"]'); + if (checkbox) checkbox.checked = true; + } updatePreview(); }