fix(idiom): split display - winner sees in private, others in public

This commit is contained in:
pllx
2026-04-28 23:51:16 +08:00
parent 0847877ce2
commit 3973b7770c
2 changed files with 21 additions and 9 deletions
+19 -6
View File
@@ -38,7 +38,9 @@ function handleIdiomGameAnswered(e) {
answerModal.style.display = "none";
}
// ── 全局文字提示:在聊天窗口中追加结果消息 ──
// ── 分屏文字提示 ──
// 回答者 → 包厢(chat-messages-container2
// 其他人 → 公屏(chat-messages-container
const now = new Date();
const timeStr = now.getHours().toString().padStart(2, "0") + ":" +
now.getMinutes().toString().padStart(2, "0") + ":" +
@@ -48,13 +50,24 @@ function handleIdiomGameAnswered(e) {
div.className = "msg-line";
div.innerHTML = `<span style="color:#16a34a;font-weight:bold;">🎉 恭喜 <b>${winner_username}</b> 率先答对成语「${answer}」,获得 ${reward_gold} 金币、${reward_exp} 经验!</span><span class="msg-time">(${timeStr})</span>`;
const say1 = document.getElementById("chat-messages-container");
if (say1) {
say1.appendChild(div);
say1.scrollTop = say1.scrollHeight;
const isWinner = winner_username === (window.chatContext?.username || "");
if (isWinner) {
// 回答者 → 包厢
const say2 = document.getElementById("chat-messages-container2");
if (say2) {
say2.appendChild(div.cloneNode(true));
say2.scrollTop = say2.scrollHeight;
}
} else {
// 其他人 → 公屏
const say1 = document.getElementById("chat-messages-container");
if (say1) {
say1.appendChild(div);
say1.scrollTop = say1.scrollHeight;
}
}
// ── Toast 通知(所有在线用户都能看到) ──
// ── Toast 通知(所有用户都能看到) ──
window.chatToast?.show({
title: "🧩 猜成语",
message: `<b>${winner_username}</b> 答对了「${answer}」,获得 ${reward_gold}💰 + ${reward_exp}⭐!`,