From cd1621f49795b9e05f74c243c629980967decbd2 Mon Sep 17 00:00:00 2001 From: pllx Date: Tue, 28 Apr 2026 23:53:05 +0800 Subject: [PATCH] feat(idiom): disable answer button after question is solved --- resources/js/chat-room/idiom-quiz.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/resources/js/chat-room/idiom-quiz.js b/resources/js/chat-room/idiom-quiz.js index 97d7949..0dc532c 100644 --- a/resources/js/chat-room/idiom-quiz.js +++ b/resources/js/chat-room/idiom-quiz.js @@ -75,6 +75,15 @@ function handleIdiomGameAnswered(e) { color: "#16a34a", duration: 6000, }); + + // ── 标记所有对应 round_id 的【答题】按钮为已答 ── + document.querySelectorAll(`[data-idiom-answer-btn="${round_id}"]`).forEach((btn) => { + btn.dataset.idiomAnswered = "1"; + btn.textContent = "✅ 已答"; + btn.style.background = "#9ca3af"; + btn.style.cursor = "default"; + btn.style.opacity = "0.6"; + }); } /** @@ -227,6 +236,18 @@ export function bindIdiomQuizControls() { const btn = e.target.closest("[data-idiom-answer-btn]"); if (!btn) return; + // 已答完的按钮不可点击 + if (btn.dataset.idiomAnswered === "1") { + window.chatToast?.show({ + title: "🧩 猜成语", + message: "这道题已被答过了,等下一题吧!", + icon: "😅", + color: "#9ca3af", + duration: 3000, + }); + return; + } + const roundId = parseInt(btn.dataset.idiomAnswerBtn || "0", 10); const hint = btn.dataset.idiomHint || ""; const rewardGold = parseInt(btn.dataset.idiomGold || "0", 10);