From 9c81ad77ea847ab2f6fcc5a6257dda9abb200a1e Mon Sep 17 00:00:00 2001
From: wujingjing <gersonwu@qq.com>
Date: 星期二, 22 十月 2024 12:07:06 +0800
Subject: [PATCH] 同步后台管理组件

---
 src/components/chat/hooks/useScrollLoad.ts |   28 ++++++++++++++++------------
 1 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/src/components/chat/hooks/useScrollLoad.ts b/src/components/chat/hooks/useScrollLoad.ts
index c8fc721..457bfc1 100644
--- a/src/components/chat/hooks/useScrollLoad.ts
+++ b/src/components/chat/hooks/useScrollLoad.ts
@@ -1,11 +1,11 @@
-import { Ref, ShallowRef, nextTick, onBeforeUnmount, ref } from 'vue';
+import { Ref, ShallowRef, nextTick, onBeforeUnmount, ref, unref } from 'vue';
 import { LOAD_CHAT_LIMIT } from '../constants';
 import { AnswerType, ChatContent, ChatMessage, RoleEnum } from '../model/types';
 import { GetHistoryAnswer, QueryHistoryDetail } from '/@/api/ai/chat';
 
 type UseScrollLoadOption = {
 	container: ShallowRef<HTMLDivElement>;
-	historyGroupId: string;
+	historyGroupId: string | Ref<string>;
 	messageList: Ref<ChatMessage[]>;
 	parseAnswerContent: (res: any) => ChatContent;
 };
@@ -79,7 +79,7 @@
 	 */
 	const loadRangeData = async (lastEnd = nextUserMsgEndIndex.value) => {
 		const res = await QueryHistoryDetail({
-			history_group_id: historyGroupId,
+			history_group_id: unref(historyGroupId),
 			last_end: lastEnd,
 			last_count: LOAD_CHAT_LIMIT,
 		});
@@ -97,7 +97,6 @@
 	//婊氬姩鐩戝惉
 	async function onChatListScroll() {
 		if (container.value.scrollTop == 0) {
-			console.log('婊氬姩鍒伴《閮ㄤ簡');
 
 			// 鏇村鏁版嵁姝e湪鍔犺浇鏃�
 			if (moreIsLoading.value) {
@@ -114,15 +113,20 @@
 				moreIsLoading.value = false;
 			});
 			//鏇存柊鍚庯紝绛夊緟椤甸潰娓叉煋瀹屾瘯鍐嶅幓鎷縮crollHeight,鍚﹀垯鎷垮埌鐨勬槸涔嬪墠鐨�
-			nextTick(() => {
-				let h2 = container.value.scrollHeight;
+			nextTick(()=>{
+				nextTick(()=>{
+					nextTick(()=>{
+						let h2 = container.value.scrollHeight;
+						container.value.scrollTo({
+							//椤堕儴鍦ㄥ師鍏堝熀纭�涓婂線涓嬫粴鍔�50px锛岄湶鍑烘柊鍔犺浇鏁版嵁鐨勪竴鐐�
+							// top: h2 - h1 - 50,
+							top: h2 - h1,
+							behavior: 'instant', //auto-鑷姩婊氬姩 instant-鐬棿婊氬姩 smooth-骞虫粦婊氬姩
+						});
+					})
+				})
+			})
 
-				//椤堕儴鍦ㄥ師鍏堝熀纭�涓婂線涓嬫粴鍔�50px锛岄湶鍑烘柊鍔犺浇鏁版嵁鐨勪竴鐐�
-				container.value.scrollTo({
-					top: h2 - h1 - 50,
-					behavior: 'instant', //auto-鑷姩婊氬姩 instant-鐬棿婊氬姩 smooth-骞虫粦婊氬姩
-				});
-			});
 		}
 	}
 

--
Gitblit v1.9.3