yangjie #22

Merged
yangqiang merged 99 commits from yangjie into master 2024-10-22 16:11:46 +08:00
2 changed files with 23 additions and 7 deletions
Showing only changes of commit 58facc62ea - Show all commits

View File

@ -1,18 +1,22 @@
import styles from '@/page/Meeting/ChatSmallWindow/index.module.scss'
import { Input } from 'antd';
import { useEffect, useState } from "react";
import { storage } from '@/utils';
const ChatSmallWindow: React.FC = () => {
const [inputValue, setInputValue] = useState<string>('')
const [chatLists, setChatLists] = useState<any>([])
const userInfo = JSON.parse(storage.getItem('user') as string)
const channel = new BroadcastChannel('meeting_channel');
useEffect(() => {
let time: NodeJS.Timeout;
time = setInterval(() => {
setChatLists((res: any) => {
return res.length ? res.slice(0, -1) : res
})
}, 10000)
channel.onmessage = function (event) {
const { type, chatList } = event.data;
const { type, chatListIten } = event.data;
switch (type) {
case 'chatList':
setChatLists(chatList.reverse())
case 'chatListIten':
setChatLists((newChatList: any) => [chatListIten, ...newChatList])
setTimeout(() => {
const chatSmallWindowView = document.getElementById('chatSmallWindowView') as HTMLElement;
if (chatSmallWindowView) {
@ -22,6 +26,9 @@ const ChatSmallWindow: React.FC = () => {
break;
}
}
return () => {
clearTimeout(time)
}
}, []);

View File

@ -509,6 +509,10 @@ const Meeting: React.FC = () => {
setNoViewChatList(storageNoViewChatList)
}
setChatList((newChatList: any) => [...newChatList, item])
channel.postMessage({
type: 'chatListIten',
chatListIten: item,
});
setStatusList((res: any) => {
if (!res.userChatList) {
api.open({
@ -1673,12 +1677,17 @@ const Meeting: React.FC = () => {
roomNum: state.channelId,
msg: msg,
})
setChatList((newChatList: any) => [...newChatList, {
let item = {
uid: userInfo.uid,
userName: userInfo.userName,
message: msg,
timestamp: +new Date()
}])
}
setChatList((newChatList: any) => [...newChatList, item])
channel.postMessage({
type: 'chatListIten',
chatListIten: item,
});
setTextMsg('');
chatScrollBotton()
} else {