From 93fe7ebcf8fc4b4d72dd83e21ef5ec5e30134064 Mon Sep 17 00:00:00 2001 From: kurihada Date: Thu, 18 Dec 2025 00:54:38 +0800 Subject: [PATCH] =?UTF-8?q?fix(ui):=20=E4=BF=AE=E5=A4=8D=E4=B8=AD=E6=96=87?= =?UTF-8?q?=E8=BE=93=E5=85=A5=E6=B3=95=E5=9B=9E=E8=BD=A6=E8=AF=AF=E5=8F=91?= =?UTF-8?q?=E9=80=81=E6=B6=88=E6=81=AF=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加 IME composition 状态检测,在输入法组合期间阻止回车发送消息 --- packages/ui/src/components/ChatInput.tsx | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/ui/src/components/ChatInput.tsx b/packages/ui/src/components/ChatInput.tsx index 8d44db8..6ec317f 100644 --- a/packages/ui/src/components/ChatInput.tsx +++ b/packages/ui/src/components/ChatInput.tsx @@ -69,6 +69,7 @@ export function ChatInput({ const [selectedCommandIndex, setSelectedCommandIndex] = useState(0); const [showSystemCommandMenu, setShowSystemCommandMenu] = useState(false); const [selectedSystemCommandIndex, setSelectedSystemCommandIndex] = useState(0); + const [isComposing, setIsComposing] = useState(false); // IME 输入法组合状态 const textareaRef = useRef(null); // 命令系统 @@ -327,12 +328,22 @@ export function ChatInput({ } // Enter 发送,Shift+Enter 换行 - if (e.key === 'Enter' && !e.shiftKey) { + // 注意:IME 组合期间不发送(中文输入法按回车确认拼音) + if (e.key === 'Enter' && !e.shiftKey && !isComposing) { e.preventDefault(); handleSubmit(); } }; + // IME 输入法组合事件处理 + const handleCompositionStart = () => { + setIsComposing(true); + }; + + const handleCompositionEnd = () => { + setIsComposing(false); + }; + return (