From 9a552e21711626af15ff36b298bcbe4422021f02 Mon Sep 17 00:00:00 2001 From: gerson <1405270578@qq.com> Date: 星期五, 24 一月 2025 10:20:19 +0800 Subject: [PATCH] 完成loading 显示 --- src/components/chat/Chat.vue | 30 +++++++++++++++++------------- src/components/chat/model/types.ts | 3 +++ src/components/chat/assistant/index.vue | 4 ++-- 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/src/components/chat/Chat.vue b/src/components/chat/Chat.vue index 808f898..0c39d36 100644 --- a/src/components/chat/Chat.vue +++ b/src/components/chat/Chat.vue @@ -21,7 +21,7 @@ <!-- 杈撳叆鍖哄煙 --> <template #input-area> - <div class="w-full "> + <div class="w-full"> <PlayBar ref="playBarRef" v-model:voicePageIsShow="voicePageIsShow" @@ -50,7 +50,7 @@ import axios from 'axios'; import { orderBy } from 'lodash-es'; import moment from 'moment'; -import { computed, onActivated, onMounted, ref } from 'vue'; +import { computed, nextTick, onActivated, onMounted, ref } from 'vue'; import { loadAmisSource } from '../amis/load'; import { useScrollLoad } from './hooks/useScrollLoad'; import type { ChatContent } from './model/types'; @@ -59,7 +59,7 @@ import PlayBar from '/@/components/chat/components/playBar/PlayBar.vue'; import CustomDrawer from '/@/components/drawer/CustomDrawer.vue'; import { Logger } from '/@/model/logger/Logger'; - +import { triggerRef } from 'vue'; import { ElMessage } from 'element-plus'; import ChatContainer from './components/ChatContainer.vue'; import ShareLinkDlg from './components/shareLink/index.vue'; @@ -164,15 +164,15 @@ if (chunkRes.mode === 'result') { lastIsResult = true; const res = chunkRes.value; - if (checkReportEmpty()) { const resReport = getResReport(); resReport.reports.push(res); questionRes = resReport; + // resReport.reports = resReport.reports.concat([]); resolve(resReport); } else { const lastMsg = computedMessageList.value.at(-1); - + // lastMsg.content.values = lastMsg.content.values.concat([]); // 宸茬粡瑙f瀽杩囦竴娆� reports lastMsg.content.values.push({ content: parseContent(res, true, { @@ -271,14 +271,18 @@ // 鏆傛椂涓嶈�冭檻澶氫釜 report鎯呭喌 - // if (lastIsResult && chunkRes.mode !== 'finish') { - // // 寮�濮嬪鍔犳柊鐨� stepGroup - // computedMessageList.value.at(-1).stepGroup.push({ - // value: [], - // isShow: true, - // }); - // lastIsResult = false; - // } + if (lastIsResult && chunkRes.mode !== 'finish') { + const lastTow = computedMessageList.value.at(-1); + lastTow.stepGroup.at(-1).value.at(-1).finishLoading = true; + // lastTow.content.values = lastTow.content.values.concat([]); + + // 寮�濮嬪鍔犳柊鐨� stepGroup + computedMessageList.value.at(-1).stepGroup.push({ + value: [], + isShow: true, + }); + lastIsResult = false; + } const lastGroup = computedMessageList.value.at(-1).stepGroup.at(-1); const stepList = lastGroup?.value ?? []; const currentTimeStamp = new Date().getTime(); diff --git a/src/components/chat/assistant/index.vue b/src/components/chat/assistant/index.vue index 8ae6578..37481ef 100644 --- a/src/components/chat/assistant/index.vue +++ b/src/components/chat/assistant/index.vue @@ -51,7 +51,7 @@ :title="subItem.title" :status="stepEnumMap[subItem.status]" > - <template #icon v-if="stepIndex + 1 === msg?.stepGroup?.[index].value.length && isTalking && isLast"> + <template #icon v-if="stepIndex + 1 === msg?.stepGroup?.[index].value.length && isTalking && isLast&&(subItem.finishLoading===false || subItem.finishLoading===undefined)"> <span class="ywifont ywicon-loading1 animate-spin !text-[24px]"></span> </template> <template #title> @@ -87,7 +87,7 @@ 涓轰簡瑙e喅杩欎釜闂锛岀瓑鍒� msg.historyId 瀛樺湪鏃讹紝鍐嶆覆鏌� recordSetTable --> <component - v-if="msg.content?.values?.[index] && msg.historyId && msg.content?.errCode !== ErrorCode.Message" + v-if="msg.content?.values?.[index] && msg.content?.errCode !== ErrorCode.Message" :reportIndex="index" :conclusion="msg.content.values[index].conclusion" :is="answerTypeMapCom[msg.content.values[index].content.type]" diff --git a/src/components/chat/model/types.ts b/src/components/chat/model/types.ts index 6c7afb4..45dc32f 100644 --- a/src/components/chat/model/types.ts +++ b/src/components/chat/model/types.ts @@ -100,4 +100,7 @@ // 娑堣�楁椂闂� ms?: string | number; subStep?: SubStep[]; + // isLoading?:boolean; + /** @description 涓存椂浣跨敤锛屾帶鍒跺己鍒朵笉鏄剧ず loading */ + finishLoading?:boolean; }; -- Gitblit v1.9.3