优化聊天

This commit is contained in:
yj 2024-10-22 12:28:58 +08:00
parent a4589d9f6f
commit 8e65fdf520
2 changed files with 12 additions and 12 deletions

View File

@ -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 (
<>

View File

@ -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)