Fix: Chinese input method "Enter" issue

中文输入法里打英文,直接按下Enter会直接发送出去,修复这个错误。

但如果[通过 `e.isComposing` 去判断](https://github.com/Yidadaa/ChatGPT-Next-Web/pull/328/files),在 Safari 上并不兼容,因此直接全局阻止在中文输入法状态下的 Enter 的事件就可以了。
这样做没有任何副作用,因为无论是什么输入法,在输入状态 Enter 本来就不应与页面发生交互。

参考在另一个 ChatGPT 项目  :https://github.com/lencx/ChatGPT/issues/369#issuecomment-1429313208
This commit is contained in:
Call White 2023-04-01 22:39:26 +08:00 committed by GitHub
parent 0385f6ede9
commit 87c02f88d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -341,6 +341,15 @@ export function Chat(props: {
}, 500);
});
// Fix Chinese input method "Enter" issue
document.addEventListener(
"keydown",
(e) => {
if (e.keyCode == 229) e.stopPropagation();
},
true,
);
return (
<div className={styles.chat} key={session.id}>
<div className={styles["window-header"]}>