fix: prevent unnecessary route changes and trim input field on change

This commit is contained in:
kangfenmao 2025-01-20 09:52:48 +08:00
parent 725f81c165
commit b01aca9066
2 changed files with 2 additions and 2 deletions

View File

@ -59,7 +59,7 @@ const HomeWindow: FC = () => {
if (e.key === 'Enter') { if (e.key === 'Enter') {
e.preventDefault() e.preventDefault()
if (text.trim() === '') { if (textRef.current.trim() === '') {
return return
} }
setRoute('chat') setRoute('chat')

View File

@ -24,7 +24,7 @@ const InputBar: FC<InputBarProps> = ({ text, model, placeholder, handleKeyDown,
bordered={false} bordered={false}
autoFocus autoFocus
onKeyDown={handleKeyDown} onKeyDown={handleKeyDown}
onChange={(e) => setText(e.target.value.trim())} onChange={(e) => setText(e.target.value)}
disabled={generating} disabled={generating}
/> />
</InputWrapper> </InputWrapper>