From f7ea0b4ceb05fc15e363d918bff74022efd29d53 Mon Sep 17 00:00:00 2001
From: wujingjing <gersonwu@qq.com>
Date: 星期四, 22 八月 2024 17:36:31 +0800
Subject: [PATCH] onClickOutside

---
 src/components/chat/Chat.vue |   30 ++++++++++++++++++++++--------
 1 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/src/components/chat/Chat.vue b/src/components/chat/Chat.vue
index d9328d5..25f06d7 100644
--- a/src/components/chat/Chat.vue
+++ b/src/components/chat/Chat.vue
@@ -119,7 +119,7 @@
 									</div>
 								</div>
 
-								<Loding v-else class="w-fit" :process="process" />
+								<Loding v-if="isTalking && index === messageList.length - 1" class="w-fit" :process="process" />
 							</div>
 						</div>
 					</div>
@@ -257,11 +257,23 @@
 		ElMessage.warning('鍙戦�佸け璐ワ紝鏈‘瀹氬簲鐢ㄥ満鏅紒');
 	}
 	processId.value = uuidv4();
-	const judgeParams = !preQuestion.value
-		? {}
-		: {
-				prev_question: preQuestion.value,
-		  };
+	let judgeParams = null;
+	if (!preQuestion.value) {
+		// const aiContent = computedMessageList.value.filter((item) => item.role === RoleEnum.assistant);
+		// const lastQuestion = aiContent[aiContent.length - 2]?.content?.origin?.question;
+		// judgeParams = lastQuestion
+		// 	? {
+		// 			prev_question: lastQuestion,
+		// 	  }
+		// 	: {};
+			// 姝e父鍥炵瓟鏆傛椂涓嶉噰鐢�
+		judgeParams = {};
+	} else {
+		judgeParams = {
+			prev_question: preQuestion.value,
+		};
+	}
+	
 	const params = {
 		process_id: processId.value,
 		question: text,
@@ -307,7 +319,7 @@
 };
 
 const sendChatMessage = async (content: ChatContent = messageContent.value, cb?: any, isCallExtParams?: any) => {
-	if (!content?.values) return;
+	if (!content?.values || isTalking.value) return;
 	const isNewChat = messageList.value.length === 0;
 	if (isNewChat) {
 		if (activeSampleId.value) {
@@ -350,6 +362,7 @@
 			cb?.(resMsgContent);
 		}
 		userItem.historyId = questionRes.history_id;
+		userItem.content.values = questionRes?.question ?? userItem.content.values;
 		assistantItem.historyId = questionRes.history_id;
 		appendLastMessageContent(resMsgContent);
 	} catch (error: any) {
@@ -390,9 +403,10 @@
 	currentSampleId = res?.details?.[0]?.sample_id;
 	const resList = await Promise.all((res.details ?? []).map((item) => getAnswerById(item.history_id)));
 	let i = 0;
-
 	resList.map((item, index) => {
 		const insertIndex = index + 1 + i;
+		const userMsg = messageList.value[insertIndex - 1];
+		userMsg.content.values = item?.answer?.question ??userMsg.content.values;
 		messageList.value.splice(
 			insertIndex,
 			0,

--
Gitblit v1.9.3