@@ -6,57 +6,6 @@ import ChatMessage from './ChatMessage.vue'
66const chatGPTStore = useChatGPTStore ()
77const { messages, editingIdx, editValue, loading } = storeToRefs (chatGPTStore )
88
9- const messageListRef = useTemplateRef (' messageList' )
10- let scrollTimeoutId: number | null = null
11-
12- function scrollToBottom() {
13- // Debounce scroll operations for better performance
14- if (scrollTimeoutId ) {
15- clearTimeout (scrollTimeoutId )
16- }
17-
18- scrollTimeoutId = window .setTimeout (() => {
19- requestAnimationFrame (() => {
20- if (messageListRef .value ) {
21- let element = messageListRef .value .parentElement
22- while (element ) {
23- const style = window .getComputedStyle (element )
24- if (style .overflowY === ' auto' || style .overflowY === ' scroll' ) {
25- element .scrollTo ({
26- top: element .scrollHeight ,
27- behavior: ' smooth' ,
28- })
29- return
30- }
31- element = element .parentElement
32- }
33- }
34- })
35- }, 50 ) // 50ms debounce
36- }
37-
38- // Watch for messages changes and auto scroll - with debouncing
39- watch (() => messages .value , () => {
40- scrollToBottom ()
41- }, { deep: true , flush: ' post' })
42-
43- // Auto scroll when messages are loaded
44- onMounted (() => {
45- scrollToBottom ()
46- })
47-
48- // Clean up on unmount
49- onUnmounted (() => {
50- if (scrollTimeoutId ) {
51- clearTimeout (scrollTimeoutId )
52- }
53- })
54-
55- // Expose scroll function for parent component
56- defineExpose ({
57- scrollToBottom ,
58- })
59-
609function handleEdit(index : number ) {
6110 chatGPTStore .startEdit (index )
6211}
@@ -77,7 +26,7 @@ async function handleRegenerate(index: number) {
7726 </script >
7827
7928<template >
80- <div ref = " messageList " class =" message-list-container" >
29+ <div class =" message-list-container" >
8130 <AList
8231 class =" chatgpt-log"
8332 item-layout =" horizontal"
@@ -102,6 +51,9 @@ async function handleRegenerate(index: number) {
10251
10352<style lang="less" scoped>
10453.message-list-container {
54+ overflow-y : auto ;
55+ height : 100% ;
56+
10557 .chatgpt-log {
10658 :deep(.ant-list-item ) {
10759 padding : 0 12px ;
0 commit comments