diff --git a/src/page/Meeting/index.tsx b/src/page/Meeting/index.tsx index 3703373..045d8bb 100644 --- a/src/page/Meeting/index.tsx +++ b/src/page/Meeting/index.tsx @@ -218,6 +218,7 @@ const Meeting: React.FC = () => { }); const [isVideoFullScreen, setIsVideoFullScreen] = useState(false) const [observer, setObserver] = useState() + const [_activeSpeaker, setActiveSpeaker] = useState('') let userInfo = JSON.parse(storage.getItem('user') as string) const msgTips = '您不是管理员或发言人,无法开启此功能!' const channel = new BroadcastChannel('meeting_channel'); @@ -275,7 +276,7 @@ const Meeting: React.FC = () => { case 'shareScreenWindowClose': setCurrentSeconds(shareScreenWindowClose) await stopScreenCapture() - await allUserLook(userInfo.uid, userInfo.userName) + await allUserLook(userInfo.uid, userInfo.userName, true) break; case 'shareScreenWindowfooterListsTitle': switch (shareScreenWindowfooterListsTitle) { @@ -1417,7 +1418,7 @@ const Meeting: React.FC = () => { if (bool) { stopScreenCapture() setSharedScreenItem('') - allUserLook(userInfo.uid, userInfo.userName) + allUserLook(userInfo.uid, userInfo.userName, true) } return bool }) @@ -1463,6 +1464,9 @@ const Meeting: React.FC = () => { setAudioStatus(newState) }, onActiveSpeaker: (_connection: RtcConnection, uid: number) => { + if (String(uid).length !== 9) { + setActiveSpeaker(String(uid)) + } setIsShare((res: any) => { if (!res && String(uid).length !== 9) { renderVideo(String(uid)) @@ -1811,7 +1815,7 @@ const Meeting: React.FC = () => { } }) if (row.title === '停止共享') { - await allUserLook(userInfo.uid, userInfo.userName) + await allUserLook(userInfo.uid, userInfo.userName, true) } break; case '静音': @@ -2078,8 +2082,23 @@ const Meeting: React.FC = () => { }) }; // 设置全员看谁 - const allUserLook = async (uid: string, name: string): Promise => { - await PostShowUser(state.channelId, uid, name) + const allUserLook = async (uid: string, name: string, bool?: boolean): Promise => { + if (bool) { + setRoomUserList((newChatList: any) => { + setActiveSpeaker(res => { + let item = newChatList.find((item: any) => item.uid === res) + if (item && item.isRoom && item.isAdmin) { + PostShowUser(state.channelId, item.uid, name) + } else { + PostShowUser(state.channelId, uid, name) + } + return res + }) + return newChatList + }) + } else { + await PostShowUser(state.channelId, uid, name) + } } // 设置发言人 const postRoomManager = async (data: any): Promise => {