优化结束共享观看逻辑

This commit is contained in:
yj 2025-02-25 15:04:36 +08:00
parent d11f437e2d
commit 40342246cc
1 changed files with 24 additions and 5 deletions

View File

@ -218,6 +218,7 @@ const Meeting: React.FC = () => {
});
const [isVideoFullScreen, setIsVideoFullScreen] = useState<boolean>(false)
const [observer, setObserver] = useState<IntersectionObserver>()
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<void> => {
await PostShowUser(state.channelId, uid, name)
const allUserLook = async (uid: string, name: string, bool?: boolean): Promise<void> => {
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<void> => {