From 578928d66720a75e6d06611324532dcb711e079c Mon Sep 17 00:00:00 2001
From: gerson <1405270578@qq.com>
Date: 星期三, 22 一月 2025 10:36:16 +0800
Subject: [PATCH] 统计重复问题

---
 src/components/chat/Chat.vue |   55 +++++++++++++++++++++++++++++++++++--------------------
 1 files changed, 35 insertions(+), 20 deletions(-)

diff --git a/src/components/chat/Chat.vue b/src/components/chat/Chat.vue
index 5d55abb..808f898 100644
--- a/src/components/chat/Chat.vue
+++ b/src/components/chat/Chat.vue
@@ -21,17 +21,20 @@
 
 		<!-- 杈撳叆鍖哄煙 -->
 		<template #input-area>
-			<PlayBar
-				ref="playBarRef"
-				v-model:voicePageIsShow="voicePageIsShow"
-				:isTalking="isTalking"
-				:isHome="false"
-				:msgList="computedMessageList"
-				v-model="messageContent.values"
-				@sendClick="sendClick"
-				@stopGenClick="stopGenClick"
-				:style="{ width: chatWidth }"
-			/>
+			<div class="w-full ">
+				<PlayBar
+					ref="playBarRef"
+					v-model:voicePageIsShow="voicePageIsShow"
+					:isTalking="isTalking"
+					:isHome="false"
+					:msgList="computedMessageList"
+					v-model="messageContent.values"
+					@sendClick="sendClick"
+					@stopGenClick="stopGenClick"
+					:style="{ width: chatWidth }"
+					class="mx-auto"
+				/>
+			</div>
 		</template>
 
 		<!-- 鎶藉眽 -->
@@ -49,7 +52,7 @@
 import moment from 'moment';
 import { computed, onActivated, onMounted, ref } from 'vue';
 import { loadAmisSource } from '../amis/load';
-import {   useScrollLoad } from './hooks/useScrollLoad';
+import { useScrollLoad } from './hooks/useScrollLoad';
 import type { ChatContent } from './model/types';
 import { AnswerState, AnswerType, RoleEnum, type ChatMessage } from './model/types';
 import { getShareChatJsonByPost, questionStreamByPost } from '/@/api/ai/chat';
@@ -75,9 +78,12 @@
 import { useCompRef } from '/@/utils/types';
 import { toMyFixed } from '/@/utils/util';
 import { useLoadData } from './hooks/useLoadData';
+import { useSyncMsg } from './hooks/useSyncMsg';
 const containerRef = useCompRef(ChatContainer);
 const chatListDom = computed(() => containerRef.value?.chatListDom);
-
+const scrollToBottom = () => {
+	containerRef.value?.scrollToBottom();
+};
 const { loadReplyData, parseContent, parseExtraContent, convertProcessItem, convertProcessToStep, formatShowTimeYear } = useLoadData();
 const voicePageIsShow = ref(false);
 let isTalking = ref(false);
@@ -395,15 +401,15 @@
 
 	try {
 		const [userItem, assistantItem] = addChatItem(content);
-
 		resMsgContent = await questionAi(content.values);
-
 		updateLoadIndex();
 
 		userItem.historyId = questionRes?.history_id;
+		const current = moment().format('YYYY-MM-DD HH:mm:ss');
+		userItem.createTime = current;
 		userItem.content.values = questionRes?.question ?? userItem.content.values;
 		assistantItem.historyId = questionRes?.history_id;
-		const currentTime = formatShowTimeYear(moment().format('YYYY-MM-DD HH:mm:ss'));
+		const currentTime = formatShowTimeYear(current);
 		assistantItem.createTime = currentTime;
 		assistantItem.content = resMsgContent;
 		setTimeout(() => {
@@ -423,7 +429,19 @@
 	messageList,
 	loadReplyData,
 });
-
+useSyncMsg({
+	msgList: messageList,
+	updateLoadIndex,
+	historyGroupId: currentRouteId,
+	checkCanSync: (data) => {
+		return !isTalking.value && !moreIsLoading.value;
+	},
+	showTip: (data) => {
+		playBarRef.value.showSyncTip(data);
+	},
+	loadReplyData,
+	scrollToBottom,
+});
 const chatListLoading = ref(true);
 
 onActivated(() => {
@@ -436,9 +454,6 @@
 		values: activeChatRoom.value?.title,
 	};
 	sendChatMessage();
-};
-const scrollToBottom = () => {
-	containerRef.value?.scrollToBottom();
 };
 
 const initHistoryChat = () => {

--
Gitblit v1.9.3