优化新建会话逻辑

This commit is contained in:
2026-08-05 17:31:48 +08:00
parent 2fff814c79
commit 941070a2ee
3 changed files with 54 additions and 50 deletions

View File

@@ -725,7 +725,10 @@ import { openFile as openFileNative, downloadAndOpen } from '@/utils/fileOpener.
return
}
closeNewChatModal();
takeUserConversations();
await takeUserConversations();
// 切换到新创建的会话
currentSessionId.value = conversationId;
uni.setStorageSync('currentSessionId', conversationId);
} catch (error) {
// ❌ 统一捕获异步错误,防止崩溃
@@ -785,8 +788,9 @@ import { openFile as openFileNative, downloadAndOpen } from '@/utils/fileOpener.
}
// 刷新会话列表
await takeUserConversations()
// 切换到新创建的会话
// 切换到新创建的会话并持久化
currentSessionId.value = result.conversation_id
uni.setStorageSync('currentSessionId', result.conversation_id)
uni.hideLoading()
uni.showToast({ title: `已创建「${result.title || agent.title}」会话`, icon: 'success' })
} catch (error) {