From 7357a3709ebeb22f28c17a21f103d0c715213b34 Mon Sep 17 00:00:00 2001
From: wujingjing <gersonwu@qq.com>
Date: 星期二, 31 十二月 2024 17:50:16 +0800
Subject: [PATCH] 编号、单位等

---
 src/components/chat/hooks/useScrollToBottom.ts |   18 ++++++++++++++++--
 1 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/src/components/chat/hooks/useScrollToBottom.ts b/src/components/chat/hooks/useScrollToBottom.ts
index b23e8a4..eae8e64 100644
--- a/src/components/chat/hooks/useScrollToBottom.ts
+++ b/src/components/chat/hooks/useScrollToBottom.ts
@@ -1,6 +1,7 @@
 import type { ComputedRef, Ref } from 'vue';
-import { nextTick, onActivated, ref, watch } from 'vue';
+import { nextTick, onActivated, onUnmounted, ref, watch } from 'vue';
 import type { ChatMessage } from '../model/types';
+import emitter from '/@/utils/mitt';
 
 export type UseScrollToBottomOption = {
 	chatListDom: Ref<HTMLDivElement>;
@@ -12,8 +13,18 @@
 
     const scrollToBottom = () => {
         if (!chatListDom.value) return;
-        chatListDom.value.lastElementChild?.scrollIntoView();
+		const parent = chatListDom.value.parentElement;
+		if(!parent)return;
+		if(parent.scrollHeight>parent.clientHeight){
+			parent.scrollTop = parent.scrollHeight - parent.clientHeight;
+		}
     };
+
+	emitter.on('amis.page.ready',({instance})=>{
+		nextTick(()=>{
+			scrollToBottom();
+		})
+	})
     const forbidScroll = ref(false);
 	watch(
 		displayMessageList,
@@ -25,6 +36,9 @@
 			deep: true,
 		}
 	);
+	onUnmounted(()=>{
+		emitter.off('amis.page.ready');
+	})
 
 	onActivated(() => {
 		if (forbidScroll.value) return;

--
Gitblit v1.9.3