优化:禁言/解禁通知路由到被禁言者的包厢窗口(say2)

- 被禁言者在 say2 看到禁言/解禁提示
- 其他人在 say1(公聊)看到禁言通知
This commit is contained in:
2026-02-26 23:15:27 +08:00
parent 2d45e52591
commit 065e82f8b7

View File

@@ -462,16 +462,21 @@
now.getMinutes().toString().padStart(2, '0') + ':' +
now.getSeconds().toString().padStart(2, '0');
// 在聊天窗口显示禁言通知
const isMe = d.username === window.chatContext.username;
// 禁言通知:自己被禁言显示在包厢(say2),其他人显示在公聊(say1)
const div = document.createElement('div');
div.className = 'msg-line';
div.innerHTML =
`<span style="color: #c00; font-weight: bold;">【系统】${d.message}</span><span class="msg-time">(${timeStr})</span>`;
container.appendChild(div);
if (autoScroll) container.scrollTop = container.scrollHeight;
const targetContainer = isMe ? document.getElementById('say2') : container;
if (targetContainer) {
targetContainer.appendChild(div);
targetContainer.scrollTop = targetContainer.scrollHeight;
}
// 如果是自己被禁言,设置本地禁言计时
if (d.username === window.chatContext.username && d.mute_time > 0) {
if (isMe && d.mute_time > 0) {
isMutedUntil = Date.now() + d.mute_time * 60 * 1000;
const contentInput = document.getElementById('content');
const operatorName = d.operator || '管理员';
@@ -487,8 +492,12 @@
unmuteDiv.className = 'msg-line';
unmuteDiv.innerHTML =
'<span style="color: #16a34a; font-weight: bold;">【系统】您的禁言已解除,可以继续发言了。</span>';
container.appendChild(unmuteDiv);
if (autoScroll) container.scrollTop = container.scrollHeight;
// 解禁提示也显示在包厢窗口
const say2 = document.getElementById('say2');
if (say2) {
say2.appendChild(unmuteDiv);
say2.scrollTop = say2.scrollHeight;
}
}, d.mute_time * 60 * 1000);
}
}