Compare commits

...

2 Commits

2 changed files with 41 additions and 3 deletions
@@ -687,19 +687,39 @@
}
});
// ── 发送消息(Enter 发送 ───────────────────────
document.getElementById('content').addEventListener('keydown', function(e) {
// ── 发送消息(Enter 发送,防 IME 输入法重复触发)────────
// 用 isComposing 标记中文输入法的组词状态,组词期间过滤掉 Enter
let _imeComposing = false;
const _contentInput = document.getElementById('content');
// 中文/日文等 IME 组词开始
_contentInput.addEventListener('compositionstart', () => {
_imeComposing = true;
});
// 组词结束(确认候选词完成),给 10ms 缓冲让 keydown 先被过滤掉
_contentInput.addEventListener('compositionend', () => {
setTimeout(() => {
_imeComposing = false;
}, 10);
});
_contentInput.addEventListener('keydown', function(e) {
if (e.key === 'Enter' && !e.shiftKey) {
e.preventDefault();
// IME 正在组词时(如选候选汉字),不触发发送
if (_imeComposing) return;
sendMessage(e);
}
});
/**
* 发送聊天消息
* 发送聊天消息(内带防重入锁,避免快速连按 Enter 重复提交)
*/
let _isSending = false; // 发送中防重入标记
async function sendMessage(e) {
if (e) e.preventDefault();
if (_isSending) return; // 上一次还没结束,忽略
_isSending = true;
// 前端禁言检查
if (isMutedUntil > Date.now()) {
@@ -763,6 +783,7 @@
console.error(error);
} finally {
submitBtn.disabled = false;
_isSending = false; // 释放发送锁,允许下次发送
}
}
+17
View File
@@ -372,6 +372,23 @@
</div>
@endif
</div>
{{-- 推荐浏览器提示 --}}
<div
style="margin-top: 14px; padding: 7px 10px; background: #fffbea; border: 1px solid #f0d060; border-radius: 4px; font-size: 11px; color: #7a5f00; text-align: center; line-height: 1.7;">
🌐 <b>推荐使用</b>
<a href="https://www.microsoft.com/zh-cn/edge/download" target="_blank"
style="color: #1565c0; font-weight: bold; text-decoration: none;" title="下载 Microsoft Edge">
Microsoft Edge
</a>
<a href="https://www.google.com/chrome/" target="_blank"
style="color: #e53935; font-weight: bold; text-decoration: none;" title="下载 Google Chrome">
Google Chrome
</a>
浏览器,以获得最佳聊天体验<br>
<span style="color: #999; font-size: 10px;">IE / 旧版浏览器不支持 WebSocket,将无法正常使用</span>
</div>
</div>
{{-- 右侧:房间列表 --}}