From 6789050c488dc2c41fa02f7b664df9f08dac8f7a Mon Sep 17 00:00:00 2001
From: wujingjing <gersonwu@qq.com>
Date: 星期二, 18 二月 2025 14:23:11 +0800
Subject: [PATCH] var

---
 src/components/chat/Chat.vue |   23 +++++++++++++----------
 1 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/src/components/chat/Chat.vue b/src/components/chat/Chat.vue
index 617c4cd..0b727ce 100644
--- a/src/components/chat/Chat.vue
+++ b/src/components/chat/Chat.vue
@@ -17,7 +17,7 @@
 							srcset=""
 						/>
 						<div class="flex-auto flex" :class="{ 'justify-end': item.role === RoleEnum.user }">
-							<div class="inline-flex flex-col" :class="{ 'w-full': item.role === RoleEnum.assistant }">
+							<div class="inline-flex flex-col w-full" :class="{ 'w-full': item.role === RoleEnum.assistant }">
 								<div class="w-full" v-if="item.content?.values">
 									<div
 										class="text-sm rounded-[6px] p-4 leading-relaxed"
@@ -119,7 +119,7 @@
 									</div>
 								</div>
 
-								<Loading v-if="isTalking && index === messageList.length - 1" class="w-fit" />
+								<Loading v-if="isTalking && index === computedMessageList.length - 1" class="w-fit my-auto" />
 							</div>
 						</div>
 					</div>
@@ -139,7 +139,7 @@
 				</div>
 			</div>
 
-			<div class="sticky bottom-0 w-full pb-3 flex justify-center">
+			<div class="sticky bottom-0 w-full py-6 flex justify-center">
 				<PlayBar
 					v-model:voicePageIsShow="voicePageIsShow"
 					:isTalking="isTalking"
@@ -167,11 +167,10 @@
 import { GetHistoryAnswer, extCallQuery } from '/@/api/ai/chat';
 import PlayBar from '/@/components/chat/components/playBar/PlayBar.vue';
 import { ErrorCode } from '/@/utils/request';
-
-
+import { CancelTokenSource } from 'axios';
 
 const props = defineProps({
-	questionApi: Function as PropType<(...params: any[]) => any>,
+	questionApi: Function as PropType<(text: string, sourceObj: { source: CancelTokenSource }) => any>,
 });
 
 const chatWidth = '100%';
@@ -194,7 +193,6 @@
 		type: AnswerType.Text,
 		values: '瑙f瀽澶辫触锛�',
 	};
-
 	switch (res.answer_type) {
 		case AnswerType.RecordSet:
 			content = {
@@ -249,8 +247,13 @@
 };
 
 let questionRes = null;
+// 浣滀负鍙傛暟浼犺繘鍘伙紝鎼哄甫鍙傛暟鍑烘潵
+let lastSourceObj: { source: CancelTokenSource } = {
+	source:null
+};
+
 const questionAi = async (text) => {
-	const res = await props.questionApi(text);
+	const res = await props.questionApi(text, lastSourceObj);
 	questionRes = res?.values;
 	const content = parseContent(res?.values);
 	return content;
@@ -267,7 +270,6 @@
 		history_id: historyId,
 	});
 };
-
 const sendChatMessage = async (content: ChatContent = messageContent.value, cb?: any, isCallExtParams?: any) => {
 	if (!content?.values || isTalking.value) return;
 	const isNewChat = messageList.value.length === 0;
@@ -326,6 +328,7 @@
 };
 
 const clearContent = () => {
+	lastSourceObj.source?.cancel();
 	messageList.value = [];
 	// 娓呯┖杈撳叆妗�
 	clearMessageContent();
@@ -333,7 +336,7 @@
 
 defineExpose({
 	autoSend,
-	clear:clearContent
+	clear: clearContent,
 });
 
 //#region ====================== 鍏宠仈鏌ヨ ======================

--
Gitblit v1.9.3