diff --git a/src/pages/ChatPage.tsx b/src/pages/ChatPage.tsx index e6baa89..6db8a78 100644 --- a/src/pages/ChatPage.tsx +++ b/src/pages/ChatPage.tsx @@ -632,8 +632,24 @@ export default function ChatPage() { onChange={(e) => setInput(e.target.value)} placeholder="问我任何问题..." autoSize={{ minRows: 3, maxRows: 10 }} - onPressEnter={(e) => { - if (!e.shiftKey) { + onKeyDown={(e) => { + if (e.key !== 'Enter') return; + if ((e as any).isComposing) return; + + if (e.metaKey || e.ctrlKey) { + e.preventDefault(); + const el = e.currentTarget; + const start = el.selectionStart ?? input.length; + const end = el.selectionEnd ?? input.length; + const next = input.slice(0, start) + '\n' + input.slice(end); + setInput(next); + requestAnimationFrame(() => { + el.selectionStart = el.selectionEnd = start + 1; + }); + return; + } + + if (!e.shiftKey && !e.altKey) { e.preventDefault(); handleSend(); } @@ -655,6 +671,7 @@ export default function ChatPage() { /> { handleAttach(files as File[]); @@ -663,9 +680,14 @@ export default function ChatPage() { showUploadList={false} accept=".txt,.md,.markdown,.json,.csv,.pdf,.docx,.html,.htm,image/png,image/jpeg,image/webp,image/gif" > -