diff --git a/src/page/Meeting/index.tsx b/src/page/Meeting/index.tsx index a33e1d9..89152c2 100644 --- a/src/page/Meeting/index.tsx +++ b/src/page/Meeting/index.tsx @@ -348,7 +348,7 @@ const Meeting: React.FC = () => { const otherUsers = [] as any; // 遍历原始数组 arr.forEach((item: any) => { - if (item.role === '1' || item.isRoomManager) { + if (item.roleId === '1' || item.isRoomManager) { // 如果是管理员或主讲人,添加到 adminsAndSpeakers 数组 adminsAndSpeakers.push(item); } else { @@ -533,14 +533,22 @@ const Meeting: React.FC = () => { setNoViewChatList(0) break; case '共享屏幕': - getDesktopCapturerVideo() - setIsSharedScreenModal(true) + if (user.roleId === '1') { + getDesktopCapturerVideo() + setIsSharedScreenModal(true) + } else { + message.error(msgTips) + } break; case '停止共享': - await agora.leaveChannelEx(userInfo.screenShareId) - agora.stopScreenCapture() - await allUserLook(userInfo.uid) - footerListTemplate[itemIndex][rowIndex].title = '共享屏幕' + if (user.roleId === '1') { + await agora.leaveChannelEx(userInfo.screenShareId) + agora.stopScreenCapture() + await allUserLook(userInfo.uid) + footerListTemplate[itemIndex][rowIndex].title = '共享屏幕' + } else { + message.error(msgTips) + } break; case '静音': await postOpenMicr(false, user.uid) diff --git a/src/utils/package/agora.ts b/src/utils/package/agora.ts index 49b8a9f..2a2ee1c 100644 --- a/src/utils/package/agora.ts +++ b/src/utils/package/agora.ts @@ -188,19 +188,18 @@ const agora = { // 加入频道 joinChannel: async () => { await rtcEngine.enableAudioVolumeIndication(100, 1, true) - await rtcEngine.joinChannel(option.token, option.channelId, option.uid, { - autoSubscribeAudio: true,//设置是否自动订阅所有音频流 - autoSubscribeVideo: true,//设置是否自动订阅所有视频流 - publishMicrophoneTrack: true,//设置是否发布麦克风采集到的音频 - publishCameraTrack: true,//设置是否发布摄像头采集的视频 - publishScreenTrack: false,//设置是否发布屏幕采集的视频 - }); + await rtcEngine.joinChannel(option.token, option.channelId, option.uid); await agora.updateChannelMediaOptions() }, // 更新频道配置 updateChannelMediaOptions: async () => { await rtcEngine.updateChannelMediaOptions({ clientRoleType: option.roleId === '1' ? ClientRoleType.ClientRoleBroadcaster : ClientRoleType.ClientRoleAudience, //用户角色 ClientRoleBroadcaster 主播 ClientRoleAudience 观众 + autoSubscribeAudio: true,//设置是否自动订阅所有音频流 + autoSubscribeVideo: true,//设置是否自动订阅所有视频流 + publishMicrophoneTrack: true,//设置是否发布麦克风采集到的音频 + publishCameraTrack: true,//设置是否发布摄像头采集的视频 + publishScreenTrack: false,//设置是否发布屏幕采集的视频 }) }, // 共享屏幕单独用户