mirror of
https://github.com/Ed1s0nZ/CyberStrikeAI.git
synced 2026-08-05 18:38:52 +02:00
Add files via upload
This commit is contained in:
+15
-3
@@ -56,6 +56,7 @@ const mentionState = {
|
|||||||
|
|
||||||
// IME输入法状态跟踪
|
// IME输入法状态跟踪
|
||||||
let isComposing = false;
|
let isComposing = false;
|
||||||
|
let compositionEndTimer = null;
|
||||||
|
|
||||||
// 输入框草稿保存相关
|
// 输入框草稿保存相关
|
||||||
const DRAFT_STORAGE_KEY = 'cyberstrike-chat-draft';
|
const DRAFT_STORAGE_KEY = 'cyberstrike-chat-draft';
|
||||||
@@ -1576,8 +1577,9 @@ function handleChatInputClick(event) {
|
|||||||
|
|
||||||
function handleChatInputKeydown(event) {
|
function handleChatInputKeydown(event) {
|
||||||
// 如果正在使用输入法输入(IME),回车键应该用于确认候选词,而不是发送消息
|
// 如果正在使用输入法输入(IME),回车键应该用于确认候选词,而不是发送消息
|
||||||
// 使用 event.isComposing 或 isComposing 标志来判断
|
// Safari 可能在确认候选词时先触发 compositionend,再触发 Enter keydown,
|
||||||
if (event.isComposing || isComposing) {
|
// 因此这里同时使用全局状态和 keyCode 229 兜底。
|
||||||
|
if (event.isComposing || isComposing || event.keyCode === 229) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2923,10 +2925,20 @@ if (chatInput) {
|
|||||||
chatInput.addEventListener('focus', handleChatInputClick);
|
chatInput.addEventListener('focus', handleChatInputClick);
|
||||||
// IME输入法事件监听,用于跟踪输入法状态
|
// IME输入法事件监听,用于跟踪输入法状态
|
||||||
chatInput.addEventListener('compositionstart', () => {
|
chatInput.addEventListener('compositionstart', () => {
|
||||||
|
if (compositionEndTimer) {
|
||||||
|
clearTimeout(compositionEndTimer);
|
||||||
|
compositionEndTimer = null;
|
||||||
|
}
|
||||||
isComposing = true;
|
isComposing = true;
|
||||||
});
|
});
|
||||||
chatInput.addEventListener('compositionend', () => {
|
chatInput.addEventListener('compositionend', () => {
|
||||||
isComposing = false;
|
if (compositionEndTimer) {
|
||||||
|
clearTimeout(compositionEndTimer);
|
||||||
|
}
|
||||||
|
compositionEndTimer = setTimeout(() => {
|
||||||
|
isComposing = false;
|
||||||
|
compositionEndTimer = null;
|
||||||
|
}, 0);
|
||||||
});
|
});
|
||||||
chatInput.addEventListener('blur', () => {
|
chatInput.addEventListener('blur', () => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user