From 8e65fdf520ddd0c18773b320c2f026b7a44ee1d3 Mon Sep 17 00:00:00 2001 From: yj <1336058017@qq.com> Date: Tue, 22 Oct 2024 12:28:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=81=8A=E5=A4=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/page/Meeting/ChatBigWindow/index.tsx | 12 ++++++------ src/page/Meeting/ChatSmallWindow/index.tsx | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/page/Meeting/ChatBigWindow/index.tsx b/src/page/Meeting/ChatBigWindow/index.tsx index cfe6bb2..e87418b 100644 --- a/src/page/Meeting/ChatBigWindow/index.tsx +++ b/src/page/Meeting/ChatBigWindow/index.tsx @@ -37,12 +37,6 @@ const ChatBigWindow: React.FC = () => { } window.electron.windowHandleMessageCallBack((_e: any, data: any) => { setChatLists(data.parmes.chatList) - setTimeout(() => { - const chatBigWindowView = document.getElementById('chatBigWindowView') as HTMLElement; - if (chatBigWindowView) { - chatBigWindowView.scrollTop = chatBigWindowView.scrollHeight; - } - }, 100) }) channel.postMessage({ type: 'chatBigWindowSendChannelMsg', @@ -54,6 +48,12 @@ const ChatBigWindow: React.FC = () => { channel.close(); } }, []); + useEffect(() => { + const chatBigWindowView = document.getElementById('chatBigWindowView') as HTMLElement; + if (chatBigWindowView) { + chatBigWindowView.scrollTop = chatBigWindowView.scrollHeight; + } + }, [chatLists]); return ( <> diff --git a/src/page/Meeting/ChatSmallWindow/index.tsx b/src/page/Meeting/ChatSmallWindow/index.tsx index 9df2e94..0a9da32 100644 --- a/src/page/Meeting/ChatSmallWindow/index.tsx +++ b/src/page/Meeting/ChatSmallWindow/index.tsx @@ -15,17 +15,17 @@ const ChatSmallWindow: React.FC = () => { }, 10000); return [data.parmes.chatListIten, ...newChatList] }) - setTimeout(() => { - const chatSmallWindowView = document.getElementById('chatSmallWindowView') as HTMLElement; - if (chatSmallWindowView) { - chatSmallWindowView.scrollTop = chatSmallWindowView.scrollHeight; - } - }, 100) }) return () => { channel.close(); } }, []); + useEffect(() => { + const chatBigWindowView = document.getElementById('chatBigWindowView') as HTMLElement; + if (chatBigWindowView) { + chatBigWindowView.scrollTop = chatBigWindowView.scrollHeight; + } + }, [chatLists]); const removeItemByIndex = () => { setChatLists((res: any) => { return res.slice(0, -1)