From 68994735dddb8d2be65149aa605ec0ac12e8775a Mon Sep 17 00:00:00 2001 From: wujingjing <gersonwu@qq.com> Date: 星期二, 10 九月 2024 15:26:59 +0800 Subject: [PATCH] 未滑动到底部 bug;多次点开对话测试 bug;数据对接SQL为选项之一 --- src/components/chat/Chat.vue | 21 ++++++++++++--------- 1 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/components/chat/Chat.vue b/src/components/chat/Chat.vue index 617c4cd..5ad202e 100644 --- a/src/components/chat/Chat.vue +++ b/src/components/chat/Chat.vue @@ -119,7 +119,7 @@ </div> </div> - <Loading v-if="isTalking && index === messageList.length - 1" class="w-fit" /> + <Loading v-if="isTalking && index === messageList.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