fix(chat): keybinds and composer ui

main
sp mac bookpro 2605 2026-05-29 14:55:03 +08:00
parent 4a2578121a
commit bd8a494cb2
2 changed files with 40 additions and 9 deletions

View File

@ -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() {
/>
<Upload
className="chat-upload"
multiple
beforeUpload={(_f, files) => {
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"
>
<Button type="text" icon={<PaperClipOutlined style={{ fontSize: 18 }} />} />
<Button type="text" className="chat-tool-button" icon={<PaperClipOutlined style={{ fontSize: 18 }} />} />
</Upload>
<Button type="text" icon={<BookOutlined style={{ fontSize: 18 }} />} onClick={() => setTplDrawerOpen(true)} />
<Button
type="text"
className="chat-tool-button"
icon={<BookOutlined style={{ fontSize: 18 }} />}
onClick={() => setTplDrawerOpen(true)}
/>
</div>
{sending ? (

View File

@ -556,11 +556,6 @@ body {
box-shadow: var(--shadow-sm);
}
.chat-input-card:focus-within {
border-color: var(--color-border-focus);
box-shadow: var(--shadow-focus);
}
.chat-input-stack {
display: flex;
flex-direction: column;
@ -614,6 +609,20 @@ body {
color: var(--color-text-tertiary);
}
.chat-tool-button {
position: relative;
z-index: 1;
}
.chat-upload {
flex: 0 0 auto;
display: inline-flex;
}
.chat-upload .ant-upload {
display: inline-flex;
}
.chat-send-button {
width: 40px;
height: 40px;