feat(idiom): disable answer button after question is solved

This commit is contained in:
pllx
2026-04-28 23:53:05 +08:00
parent 3973b7770c
commit cd1621f497
+21
View File
@@ -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);