feat: 发送消息的处理
This commit is contained in:
@@ -45,7 +45,7 @@
|
||||
shadow-[0_1px_0_rgba(0,0,0,0.03)]
|
||||
p-[18px] mt-[8px] flex flex-col justify-between">
|
||||
<textarea rows="2" placeholder="给我发布或者布置任务" class="flex-1 resize-none outline-none text-sm"
|
||||
v-model="inputMessage" @keyup.enter="sendMessageAction" />
|
||||
v-model="inputMessage" @keydown.enter="handleKeydownEnter" />
|
||||
|
||||
<div class="flex justify-between items-end">
|
||||
<button @click="addAttachmentAction()">
|
||||
@@ -193,14 +193,27 @@ const sendMessageAction = () => {
|
||||
return;
|
||||
}
|
||||
|
||||
console.log("输入消息:", inputMessage.value);
|
||||
if (!inputMessage.value.trim()) return;
|
||||
const raw = inputMessage.value || '';
|
||||
// 去除尾部多余的换行,保留中间换行(例如 Shift+Enter)
|
||||
const sendText = raw.replace(/\n+$/, '');
|
||||
console.log("输入消息:", sendText);
|
||||
if (!sendText.trim()) return;
|
||||
// 重置消息状态,准备接收新的AI回复
|
||||
resetMessageState();
|
||||
sendMessage(inputMessage.value);
|
||||
sendMessage(sendText);
|
||||
setTimeoutScrollToBottom();
|
||||
};
|
||||
|
||||
// 处理在 textarea 中按 Enter:Shift+Enter 保留换行,单按 Enter 发送并阻止默认换行行为
|
||||
const handleKeydownEnter = (e: KeyboardEvent) => {
|
||||
if ((e as KeyboardEvent).shiftKey) {
|
||||
// 允许插入换行
|
||||
return;
|
||||
}
|
||||
e.preventDefault();
|
||||
sendMessageAction();
|
||||
};
|
||||
|
||||
// 停止发送消息事件
|
||||
const sendStopAction = () => {
|
||||
console.log("停止发送消息");
|
||||
|
||||
Reference in New Issue
Block a user