fix: 修复未登录的消息发送bug

This commit is contained in:
何嘉悦 2025-06-02 17:40:05 +08:00
parent ac8c09d53a
commit 9ba37ea876

View File

@ -81,7 +81,7 @@ watch(
function handleDataChunk(chunk: AnyObject) { function handleDataChunk(chunk: AnyObject) {
try { try {
// console.log('New chunk:', chunk); // console.log('New chunk:', chunk);
const reasoningChunk = chunk.choices[0].delta.reasoning_content; const reasoningChunk = chunk.choices?.[0].delta.reasoning_content;
if (reasoningChunk) { if (reasoningChunk) {
// //
bubbleItems.value[bubbleItems.value.length - 1].thinkingStatus = 'thinking'; bubbleItems.value[bubbleItems.value.length - 1].thinkingStatus = 'thinking';
@ -91,7 +91,7 @@ function handleDataChunk(chunk: AnyObject) {
} }
} }
const parsedChunk = chunk.choices[0].delta.content; const parsedChunk = chunk.choices?.[0].delta.content;
if (parsedChunk) { if (parsedChunk) {
// //
bubbleItems.value[bubbleItems.value.length - 1].thinkingStatus = 'end'; bubbleItems.value[bubbleItems.value.length - 1].thinkingStatus = 'end';
@ -132,7 +132,7 @@ async function startSSE(chatContent: string) {
role: item.role, role: item.role,
content: item.content, content: item.content,
})), })),
sessionId: String(route.params?.id), sessionId: route.params?.id !== 'not_login' ? String(route.params?.id) : undefined,
userId: userStore.userInfo?.userId, userId: userStore.userInfo?.userId,
model: modelStore.currentModelInfo.modelName ?? '', model: modelStore.currentModelInfo.modelName ?? '',
}); });