From fa6b85e4f56b7d8a0ec7715eaa9d0e969ba6f7ad Mon Sep 17 00:00:00 2001 From: yj <1336058017@qq.com> Date: Mon, 21 Oct 2024 14:27:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Meeting/CurrentSpeakUserWindow/index.tsx | 10 +++++ src/page/Meeting/index.tsx | 41 ++++++++++--------- 2 files changed, 31 insertions(+), 20 deletions(-) diff --git a/src/page/Meeting/CurrentSpeakUserWindow/index.tsx b/src/page/Meeting/CurrentSpeakUserWindow/index.tsx index e86c258..64fbf8a 100644 --- a/src/page/Meeting/CurrentSpeakUserWindow/index.tsx +++ b/src/page/Meeting/CurrentSpeakUserWindow/index.tsx @@ -2,7 +2,14 @@ import styles from '@/page/Meeting/CurrentSpeakUserWindow/index.module.scss' import { useEffect, useState } from "react"; const CurrentSpeakUserWindow: React.FC = () => { const [inputValue, setInputValue] = useState('') + const channel = new BroadcastChannel('meeting_channel'); useEffect(() => { + let time: NodeJS.Timeout; + time = setInterval(() => { + channel.postMessage({ + type: 'currentSpeakUserWindowGetUserName' + }) + }, 1000) window.electron.windowHandleMessageCallBack((_e: any, data: any) => { if (data.parmes.currentSpeakUser.length) { setInputValue(data.parmes.currentSpeakUser.join(';')) @@ -10,6 +17,9 @@ const CurrentSpeakUserWindow: React.FC = () => { setInputValue('') } }) + return () => { + clearInterval(time) + } }, []); return ( diff --git a/src/page/Meeting/index.tsx b/src/page/Meeting/index.tsx index c743f61..0a2d665 100644 --- a/src/page/Meeting/index.tsx +++ b/src/page/Meeting/index.tsx @@ -374,30 +374,31 @@ const Meeting: React.FC = () => { userId: noticeWindowPostRoomManager.uid }) break; + case 'currentSpeakUserWindowGetUserName': + setSpeackUid((uids: any) => { + const usernames: string[] = []; + setRoomUserList((res: any) => { + uids.forEach((uid: any) => { + const user = res.find((item: any) => item.uid == uid); + if (user) { + usernames.push(user.userName); + } + }) + window.electron.windowHandleMessage({ + key: 'currentSpeakUserWindow', + parmes: { + currentSpeakUser: usernames, + } + }) + return res + }); + return [] + }) + break; } } time = setInterval(() => { setCurrentSeconds(currentSeconds++) - setSpeackUid((uids: any) => { - const usernames: string[] = []; - setRoomUserList((res: any) => { - uids.forEach((uid: any) => { - const user = res.find((item: any) => item.uid == uid); - if (user) { - usernames.push(user.userName); - } - }) - window.electron.windowHandleMessage({ - key: 'currentSpeakUserWindow', - parmes: { - currentSpeakUser: usernames, - } - }) - return res - }); - - return [] - }) }, 1000) // 首次加载图标更新 const firstFooterList = [...footerList]