wujingjing
2025-04-02 5fb58c10b2bb44b3f2d3bdab4d7a6619271e2bbf
src/components/chat/hooks/useScroll.ts
@@ -10,11 +10,19 @@
export const useScroll = (option: UseScrollOption) => {
   const { chatListDom } = option;
   const scrollStepToBottom = () => {
      const allStepList = document.querySelectorAll('.step-list');
      const lastStepList = allStepList[allStepList.length - 1];
      if (!lastStepList) return;
      lastStepList.scrollTop = lastStepList.scrollHeight - lastStepList.clientHeight;
   };
   const scrollToBottom = () => {
      nextTick(() => {
         if (chatListDom.value.scrollHeight > chatListDom.value.clientHeight) {
            chatListDom.value.scrollTop = chatListDom.value.scrollHeight - chatListDom.value.clientHeight;
            nextTick(() => {
               scrollStepToBottom();
            });
         }
      });
   };
@@ -24,7 +32,6 @@
         chatListDom.value.scrollTop = 0;
      });
   };
   const checkIsBottom = () => {
      // 误差 2像素
@@ -36,7 +43,7 @@
   });
   onUnmounted(() => {
      chatListDom.value.removeEventListener('scrollend', checkIsBottom);
      chatListDom.value?.removeEventListener('scrollend', checkIsBottom);
   });
   // emitter.on('amis.page.ready', debounceAmisScroll);