feat: 长文本组件的对接调试
This commit is contained in:
@@ -76,8 +76,7 @@
|
||||
>
|
||||
<AnswerComponent
|
||||
v-if="item.componentName === CompName.longTextCard"
|
||||
:text="item.componentMsg || item.msg"
|
||||
:title="item.title"
|
||||
:longTextData="item.longTextData"
|
||||
:finish="item.finish"
|
||||
/>
|
||||
<QuickBookingComponent
|
||||
@@ -258,6 +257,10 @@ import {
|
||||
} from "@/request/api/ConversationApi";
|
||||
import WebSocketManager from "@/utils/WebSocketManager";
|
||||
import { IdUtils } from "@/utils";
|
||||
import {
|
||||
appendLongTextChunk,
|
||||
createLongTextData,
|
||||
} from "@/utils/longTextCard";
|
||||
import { checkToken } from "@/hooks/useGoLogin";
|
||||
import { useAppStore } from "@/store";
|
||||
import { getAccessToken } from "@/constant/token";
|
||||
@@ -781,7 +784,7 @@ const handleWebSocketMessage = (data) => {
|
||||
messageId: currentSessionMessageId,
|
||||
replyMessageId: data.replyMessageId || "",
|
||||
componentName: "",
|
||||
title: "",
|
||||
longTextData: null,
|
||||
finish: false,
|
||||
};
|
||||
chatMsgList.value.push(aiMsg);
|
||||
@@ -803,7 +806,7 @@ const handleWebSocketMessage = (data) => {
|
||||
messageId: currentSessionMessageId,
|
||||
replyMessageId: data.replyMessageId || "",
|
||||
componentName: "",
|
||||
title: "",
|
||||
longTextData: null,
|
||||
finish: false,
|
||||
};
|
||||
chatMsgList.value.push(aiMsg);
|
||||
@@ -842,13 +845,30 @@ const handleWebSocketMessage = (data) => {
|
||||
if (data.componentName) {
|
||||
aiItem.componentName = data.componentName;
|
||||
if (data.componentName === CompName.longTextCard) {
|
||||
aiItem.longTextData = aiItem.longTextData || createLongTextData();
|
||||
if (aiItem.msg && aiItem.msg.length > 0) {
|
||||
aiItem.componentMsg = (aiItem.componentMsg || "") + aiItem.msg;
|
||||
if (!aiItem.isLoading) {
|
||||
aiItem.componentMsg = (aiItem.componentMsg || "") + aiItem.msg;
|
||||
}
|
||||
aiItem.msg = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const isLongText =
|
||||
aiItem.componentName === CompName.longTextCard ||
|
||||
data.componentName === CompName.longTextCard;
|
||||
|
||||
if (isLongText && data.contentKey) {
|
||||
aiItem.longTextData = aiItem.longTextData || createLongTextData();
|
||||
appendLongTextChunk(aiItem.longTextData, data);
|
||||
if (aiItem.isLoading) {
|
||||
aiItem.msg = "";
|
||||
aiItem.isLoading = false;
|
||||
}
|
||||
nextTick(() => scrollToBottom());
|
||||
}
|
||||
|
||||
// 确保消息内容是字符串类型
|
||||
if (data.content && typeof data.content !== "string") {
|
||||
try {
|
||||
@@ -861,9 +881,6 @@ const handleWebSocketMessage = (data) => {
|
||||
// 直接拼接内容到对应 AI 消息
|
||||
if (data.content) {
|
||||
// 如果该条消息属于 longTextCard,使用 componentMsg 存储内容并保持 ChatCardAI 的 text 为空
|
||||
const isLongText =
|
||||
aiItem.componentName === CompName.longTextCard ||
|
||||
data.componentName === CompName.longTextCard;
|
||||
if (isLongText) {
|
||||
if (aiItem.isLoading) {
|
||||
aiItem.componentMsg = (aiItem.componentMsg || "") + data.content;
|
||||
@@ -900,7 +917,6 @@ const handleWebSocketMessage = (data) => {
|
||||
|
||||
// 处理组件调用
|
||||
if (data.componentName) {
|
||||
chatMsgList.value[aiMsgIndex].title = data.content;
|
||||
chatMsgList.value[aiMsgIndex].componentName = data.componentName;
|
||||
}
|
||||
|
||||
@@ -1173,7 +1189,7 @@ const sendChat = async (message, isInstruct = false) => {
|
||||
messageId: currentSessionMessageId,
|
||||
replyMessageId: "",
|
||||
componentName: "",
|
||||
title: "",
|
||||
longTextData: null,
|
||||
finish: false,
|
||||
};
|
||||
chatMsgList.value.push(aiMsg);
|
||||
|
||||
Reference in New Issue
Block a user