From 7866aa30bd13dab1fc0662e1baf6675d0dc1b282 Mon Sep 17 00:00:00 2001
From: wujingjing <gersonwu@qq.com>
Date: 星期三, 02 四月 2025 15:42:30 +0800
Subject: [PATCH] 修改意见

---
 src/components/chat/Chat.vue |   36 ++++++++++++++++++++++++++++++++----
 1 files changed, 32 insertions(+), 4 deletions(-)

diff --git a/src/components/chat/Chat.vue b/src/components/chat/Chat.vue
index e5a1199..771c7ab 100644
--- a/src/components/chat/Chat.vue
+++ b/src/components/chat/Chat.vue
@@ -48,7 +48,6 @@
 <script setup lang="ts">
 import type { CancelTokenSource } from 'axios';
 import axios from 'axios';
-import { orderBy } from 'lodash-es';
 import moment from 'moment';
 import { computed, nextTick, onActivated, onMounted, ref } from 'vue';
 import { loadAmisSource } from '../amis/load';
@@ -60,7 +59,7 @@
 import CustomDrawer from '/@/components/drawer/CustomDrawer.vue';
 import { Logger } from '/@/model/logger/Logger';
 import { triggerRef } from 'vue';
-import { ElLoadingService, ElMessage } from 'element-plus';
+import {  ElMessage } from 'element-plus';
 import ChatContainer from './components/ChatContainer.vue';
 import ShareLinkDlg from './components/shareLink/index.vue';
 import router from '/@/router';
@@ -80,8 +79,11 @@
 import { useLoadData } from './hooks/useLoadData';
 import { useSyncMsg } from './hooks/useSyncMsg';
 import { getCurrentPosition } from '/@/utils/brower';
+import { deepClone } from '/@/utils/other';
+import { ParentRegister } from '/@/stores/global';
 const containerRef = useCompRef(ChatContainer);
 const chatListDom = computed(() => containerRef.value?.chatListDom);
+
 const scrollToBottom = () => {
 	containerRef.value?.scrollToBottom();
 };
@@ -124,6 +126,8 @@
 	});
 };
 
+const enableCallback = ref(false);
+
 let streamOutputIsStart = false;
 let position: Position = null;
 const questionAi = async (text) => {
@@ -147,6 +151,10 @@
 		params.tables = JSON.stringify(tableList);
 	}
 
+	const metricList = attachList.value.filter((item) => item.type === 'metric').map((item) => item.model);
+	if (metricList?.length > 0) {
+		params.metrics = JSON.stringify(metricList);
+	}
 	// if (!position) {
 	// 	const loadingInstance = ElLoadingService({
 	// 		text: '鑾峰彇浣嶇疆涓�...',
@@ -225,6 +233,26 @@
 					triggerRefresh();
 					return;
 					// chunkRes.value = '鍑嗗鏁版嵁鍒嗘瀽';
+				}
+				
+				if (chunkRes.mode === 'main_frame') {
+					const jsonObj = JSON.parse(chunkRes.value);
+					if (!enableCallback.value) {
+						return;
+					}
+
+					ParentRegister.notify?.({
+						type: 'main_frame',
+						value: jsonObj,
+					});
+					return;
+				}
+
+				if (chunkRes.mode === 'create_work_order') {
+					const lastMsg = computedMessageList.value.at(-1);
+					lastMsg.modeContent = chunkRes;
+					triggerRefresh();
+					return;
 				}
 
 				if (chunkRes.mode === 'summary') {
@@ -407,7 +435,7 @@
 	lastAxiosSource?.cancel();
 	isTalking.value = false;
 	chatListLoading.value = false;
-
+	streamOutputIsStart = false;
 	computedMessageList.value.at(-1).isStopMsg = true;
 };
 
@@ -424,7 +452,7 @@
 
 const addChatItem = (content: ChatContent) => {
 	isTalking.value = true;
-	const userItem: ChatMessage = { role: RoleEnum.user, content, isChecked: false, attachList: attachList.value } as any;
+	const userItem: ChatMessage = { role: RoleEnum.user, content, isChecked: false, attachList: deepClone(attachList.value) } as any;
 	const assistantItem: ChatMessage = {
 		role: RoleEnum.assistant,
 		content: {

--
Gitblit v1.9.3