diff --git a/src/pages/home/components/ChatMainList/index.vue b/src/pages/home/components/ChatMainList/index.vue index 3e1dc04..72448f2 100644 --- a/src/pages/home/components/ChatMainList/index.vue +++ b/src/pages/home/components/ChatMainList/index.vue @@ -5,116 +5,122 @@ -
- -
-
- -
-
- +
+
+ +
+
+ +
+
+ +
-
- -
+ +
- -
+ +
- -
+ +
-
- - + - +
@@ -181,6 +187,7 @@ const appStore = useAppStore(); /// 输入框组件引用 const inputAreaRef = ref(null); +const mainScrollRef = ref(null); const topNavBarRef = ref(); const notitceConent = ref(null); @@ -331,10 +338,17 @@ const handleScroll = (e) => { hideKeyboardByScroll(); } - const detail = e.detail; - topNavBarRef.value.show = parseInt(detail.scrollTop) > welcomeHeight.value; - - const currentScrollTop = detail.scrollTop; + const currentScrollTop = Number(e?.detail?.scrollTop ?? e?.target?.scrollTop ?? 0); + const scrollEl = e?.target; + if (topNavBarRef.value) { + topNavBarRef.value.show = currentScrollTop > welcomeHeight.value; + } + if ( + scrollEl && + scrollEl.scrollHeight - currentScrollTop - scrollEl.clientHeight < 8 + ) { + isAutoScroll.value = true; + } // 如果向上滚动 (当前位置小于上一次记录的位置) if (currentScrollTop < lastScrollTop - 2) { // 增加 2px 阈值防止抖动 @@ -361,6 +375,12 @@ const scrollToBottom = (force = false) => { // 使用更大的值确保滚动到真正的底部 const targetScrollTop = 99999 + Math.random(); scrollTop.value = targetScrollTop; + if (mainScrollRef.value && typeof mainScrollRef.value.scrollTo === "function") { + mainScrollRef.value.scrollTo({ + top: mainScrollRef.value.scrollHeight, + behavior: "smooth", + }); + } }); }; diff --git a/src/pages/home/components/Discovery/components/CardSwiper/index.vue b/src/pages/home/components/Discovery/components/CardSwiper/index.vue index 993804a..61ae448 100644 --- a/src/pages/home/components/Discovery/components/CardSwiper/index.vue +++ b/src/pages/home/components/Discovery/components/CardSwiper/index.vue @@ -1,5 +1,5 @@