From f996c7437b0a7d4e7bafeb7c71b7c86b7170c8bd Mon Sep 17 00:00:00 2001
From: wujingjing <gersonwu@qq.com>
Date: 星期四, 27 二月 2025 17:15:13 +0800
Subject: [PATCH] 地图图标展示

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

diff --git a/src/components/chat/Chat.vue b/src/components/chat/Chat.vue
index 011c915..caccc96 100644
--- a/src/components/chat/Chat.vue
+++ b/src/components/chat/Chat.vue
@@ -60,7 +60,7 @@
 import CustomDrawer from '/@/components/drawer/CustomDrawer.vue';
 import { Logger } from '/@/model/logger/Logger';
 import { triggerRef } from 'vue';
-import { ElMessage } from 'element-plus';
+import { ElLoadingService, ElMessage } from 'element-plus';
 import ChatContainer from './components/ChatContainer.vue';
 import ShareLinkDlg from './components/shareLink/index.vue';
 import router from '/@/router';
@@ -85,7 +85,7 @@
 const scrollToBottom = () => {
 	containerRef.value?.scrollToBottom();
 };
-const { loadReplyData, parseContent, parseExtraContent, convertProcessItem, convertProcessToStep, formatShowTimeYear } = useLoadData();
+const { loadReplyData, parseContent, parseExtraContent, convertProcessItem, convertProcessToStep, formatShowTimeYear, getStepGroupList } = useLoadData();
 const voicePageIsShow = ref(false);
 let isTalking = ref(false);
 const chatWidth = computed(() => containerRef.value?.chatWidth);
@@ -115,6 +115,8 @@
 	});
 };
 
+let streamOutputIsStart = false;
+let position: Position = null;
 const questionAi = async (text) => {
 	let judgeParams = null;
 	if (!preQuestion.value) {
@@ -131,7 +133,17 @@
 		raw_mode: roomConfig.value?.[currentRouteId]?.isAnswerByLLM ?? false,
 		...judgeParams,
 	} as any;
-	// const position = await getCurrentPosition();
+
+	// if (!position) {
+	// 	const loadingInstance = ElLoadingService({
+	// 		text: '鑾峰彇浣嶇疆涓�...',
+	// 		target: '.layout-parent',
+	// 		fullscreen:false,
+	// 	});
+	// 	position = await getCurrentPosition().finally(() => {
+	// 		loadingInstance.close();
+	// 	});
+	// }
 
 	// if (position) {
 	// 	const { latitude, longitude } = position;
@@ -169,7 +181,6 @@
 			params,
 			(chunkRes) => {
 				Logger.info('chunk response锛歕n\n' + JSON.stringify(chunkRes));
-
 				if (chunkRes.mode === 'result') {
 					lastIsResult = true;
 					const res = chunkRes.value;
@@ -297,29 +308,42 @@
 					});
 					lastIsResult = false;
 				}
-				const lastGroup = computedMessageList.value.at(-1).stepGroup[0];
+				const lastGroup = getLastGroup();
 				const stepList = lastGroup?.value ?? [];
 				const currentTimeStamp = new Date().getTime();
-				const ms = toMyFixed(currentTimeStamp - lastTimestamp, 2) + ' ms';
 				if (chunkRes.mode === 'finish') {
+					const ms = toMyFixed(currentTimeStamp - lastTimestamp, 2) + ' ms';
 					stepList.at(-1).ms = ms;
 					isTalking.value = false;
+					streamOutputIsStart = false;
 					return;
 				}
 
-				if (stepList?.length >= 1) {
-					stepList.at(-1).ms = ms;
-				} else {
-					const stepGroup = computedMessageList.value.at(-1).stepGroup;
-					if (stepGroup.length > 1) {
-						const lastStepList = stepGroup.at(-2).value;
-						lastStepList.at(-1).ms = ms;
-					}
-				}
-				lastTimestamp = currentTimeStamp;
-				const stepItem = convertProcessItem(chunkRes);
+				if (stepList?.length >= 1 && !streamOutputIsStart) {
+					const ms = toMyFixed(currentTimeStamp - lastTimestamp, 2) + ' ms';
 
-				stepList.push(stepItem);
+					stepList.at(-1).ms = ms;
+				} 
+
+				if (!streamOutputIsStart) {
+					lastTimestamp = currentTimeStamp;
+				}
+				if (!streamOutputIsStart) {
+					const stepItem = convertProcessItem(chunkRes);
+					stepList.push(stepItem);
+				} else {
+					const lastItem = stepList.at(-1);
+					lastItem.title += chunkRes.value ?? '';
+				}
+
+				if (chunkRes.mode === 'begin_stream') {
+					streamOutputIsStart = true;
+					lastTimestamp = currentTimeStamp;
+				}
+				if (chunkRes.mode === 'end_stream') {
+					streamOutputIsStart = false;
+				}
+
 				// 寮哄埗瑙﹀彂鏇存柊
 
 				scrollToBottom();
@@ -509,10 +533,8 @@
 		historyId: msgValue.history_id,
 		role: RoleEnum.assistant,
 		content: parseContent(msgValue),
-		stepGroup: (msgValue?.reports ?? []).map((item) => ({
-			value: convertProcessToStep(item?.exec_process),
-			isShow: false,
-		})),
+		stepGroup: getStepGroupList(msgValue?.reports ?? []),
+
 		isStopMsg: false,
 
 		conclusion: msgValue.conclusion ?? [],

--
Gitblit v1.9.3