From 2417a769bbefa6e205ef528bcb30d6707d62b475 Mon Sep 17 00:00:00 2001 From: MT-Fire <798521692@qq.com> Date: Thu, 12 Mar 2026 11:11:41 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=87=AA=E5=8A=A8=E9=87=8D=E5=91=BD?= =?UTF-8?q?=E5=90=8D=E4=BC=9A=E8=AF=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/chat/ChatMain.vue | 15 +++++++++++++-- src/stores/chat.ts | 4 ++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/components/chat/ChatMain.vue b/src/components/chat/ChatMain.vue index a8d0248..3c2bfba 100644 --- a/src/components/chat/ChatMain.vue +++ b/src/components/chat/ChatMain.vue @@ -181,6 +181,7 @@ async function handleSend( deepThinking?: boolean; systemPrompt?: string; skipUserMessage?: boolean; + conversationTitle?: string; }, ) { // 检查认证状态 @@ -221,7 +222,13 @@ async function handleSend( // 如果没有当前对话,创建新对话 if (!currentConversation.value) { - await chatStore.createConversation(); + await chatStore.createConversation(options?.conversationTitle || text); + } else if (currentConversation.value.title === "新对话") { + // 如果当前对话是"新对话",用传入的标题或用户输入重命名 + chatStore.renameConversation( + currentConversation.value.id, + options?.conversationTitle || text + ); } // 获取系统提示词(优先使用传入的,否则使用会话设置) @@ -488,7 +495,11 @@ function handleRegenerate(messageId: string) { } function handleSuggestion(suggestion: Suggestion) { - handleSend(suggestion.text, [], { systemPrompt: suggestion.systemPrompt, skipUserMessage: true }); + handleSend(suggestion.text, [], { + systemPrompt: suggestion.systemPrompt, + skipUserMessage: true, + conversationTitle: suggestion.text, + }); } function focusInput() { diff --git a/src/stores/chat.ts b/src/stores/chat.ts index 06efcf5..766fbae 100644 --- a/src/stores/chat.ts +++ b/src/stores/chat.ts @@ -79,10 +79,10 @@ export const useChatStore = defineStore("chat", () => { } // 创建对话 - async function createConversation(): Promise { + async function createConversation(title?: string): Promise { const newConversation: Conversation = { id: generateId(), - title: "新对话", + title: title || "新对话", messages: [], createdAt: Date.now(), updatedAt: Date.now(),