|
@@ -1,4 +1,4 @@
|
|
|
-import { nextTick } from 'vue';
|
|
|
|
|
|
|
+import { nextTick, onBeforeUnmount } from 'vue';
|
|
|
import type ChatMessages from '/@/views/ventAI/manageAssistent/components/chat/ChatMessages.vue';
|
|
import type ChatMessages from '/@/views/ventAI/manageAssistent/components/chat/ChatMessages.vue';
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -30,5 +30,18 @@ export const useChatScroll = (getChatMessages: () => InstanceType<typeof ChatMes
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+ // [审计-第四轮 R4-8] 卸载时取消挂起的 rAF。
|
|
|
|
|
+ // 原行为:scrollRafId 仅在重入时 cancel 自身,组件卸载后不 cancel,残留回调会在卸载后
|
|
|
|
|
+ // 再执行一次(内部全 optional chaining,无崩溃、无累积,但无意义)。
|
|
|
|
|
+ // 现行为:onBeforeUnmount 里若有挂起 rAF 则 cancel 并复位。
|
|
|
|
|
+ // 为什么:定时器/动画帧挂摘对称,消除卸载后的空转回调。
|
|
|
|
|
+ // 注:本 composable 仅在组件 setup 内调用(AiAssistantModal),onBeforeUnmount 注册到该组件上。
|
|
|
|
|
+ onBeforeUnmount(() => {
|
|
|
|
|
+ if (scrollRafId !== null) {
|
|
|
|
|
+ cancelAnimationFrame(scrollRafId);
|
|
|
|
|
+ scrollRafId = null;
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
return { scrollToBottom, scrollToBottomThrottled };
|
|
return { scrollToBottom, scrollToBottomThrottled };
|
|
|
};
|
|
};
|