fix ctrl enter state

This commit is contained in:
2023-03-16 10:39:52 +08:00
parent 2422f2d2c9
commit 7747bfa1ac

View File

@@ -200,7 +200,8 @@ export function App() {
}; };
// when user click the "send" button or ctrl+Enter in the textarea // when user click the "send" button or ctrl+Enter in the textarea
const send = async () => { const send = async (msg = "") => {
const inputMsg = msg;
if (!inputMsg) { if (!inputMsg) {
console.log("empty message"); console.log("empty message");
return; return;
@@ -418,7 +419,7 @@ export function App() {
onKeyPress={(event: any) => { onKeyPress={(event: any) => {
console.log(event); console.log(event);
if (event.ctrlKey && event.code === "Enter") { if (event.ctrlKey && event.code === "Enter") {
send(); send(event.target.value);
setInputMsg(""); setInputMsg("");
return; return;
} }
@@ -431,7 +432,7 @@ export function App() {
className="disabled:line-through disabled:bg-slate-500 rounded m-1 p-1 border-2 bg-cyan-400 hover:bg-cyan-600" className="disabled:line-through disabled:bg-slate-500 rounded m-1 p-1 border-2 bg-cyan-400 hover:bg-cyan-600"
disabled={showGenerating || !chatStore.apiKey} disabled={showGenerating || !chatStore.apiKey}
onClick={() => { onClick={() => {
send(); send(inputMsg);
}} }}
> >
Send Send