From 8703f7ddda1cbdbee1cefc4c8f9a31ea97272494 Mon Sep 17 00:00:00 2001
From: wujingjing <gersonwu@qq.com>
Date: 星期一, 18 十一月 2024 14:24:50 +0800
Subject: [PATCH] 打包优化: 1)使用 lodash-es 2)element-plus按需导入

---
 src/components/chat/hooks/useScrollToBottom.ts |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/src/components/chat/hooks/useScrollToBottom.ts b/src/components/chat/hooks/useScrollToBottom.ts
index f7484b2..42bd49f 100644
--- a/src/components/chat/hooks/useScrollToBottom.ts
+++ b/src/components/chat/hooks/useScrollToBottom.ts
@@ -13,12 +13,15 @@
 
 	const scrollToBottom = () => {
 		nextTick(() => {
-			if (!chatListDom.value) return;
-			const parent = chatListDom.value.parentElement;
-			if (!parent) return;
-			if (parent.scrollHeight > parent.clientHeight) {
-				parent.scrollTop = parent.scrollHeight - parent.clientHeight;
+			if (chatListDom.value.scrollHeight > chatListDom.value.clientHeight) {
+				chatListDom.value.scrollTop = chatListDom.value.scrollHeight - chatListDom.value.clientHeight;
 			}
+		});
+	};
+
+	const scrollToTop = () => {
+		nextTick(() => {
+			chatListDom.value.scrollTop = 0;
 		});
 	};
 	const debounceAmisScroll = debounce(({ instance }) => {
@@ -37,5 +40,6 @@
 
 	return {
 		scrollToBottom,
+		scrollToTop,
 	};
 };

--
Gitblit v1.9.3