This commit is contained in:
yj 2024-08-27 14:59:33 +08:00
parent 2791d94a31
commit beb94a8eba
2 changed files with 39 additions and 23 deletions

View File

@ -79,6 +79,14 @@ const Index: React.FC = () => {
}
})
}
const postRefresh = async (callBack: Function): Promise<void> => {
await PostRefresh(user.refresh_token).then(res => {
if (res.code === 200) {
storage.setItem('user', JSON.stringify(res.data))
callBack(res.data)
}
})
}
return (
<>
<div className={styles.index}>
@ -147,21 +155,22 @@ const Index: React.FC = () => {
if (userInfo.roleId === '1') {
joinSettingRef.current.changeModal(item.roomNum)
} else {
await PostRefresh(userInfo.refresh_token)
getRoomRtcToken(item.roomNum, (options: any) => {
if (options) {
navigate(`/meeting`, {
state: {
channelId: item.roomNum,
token: options.token,
tokenA: options.tokenA,
roomId: item.id,
roomName: item.roomName,
enableMicr: false,
enableCamera: false,
}
})
}
postRefresh(() => {
getRoomRtcToken(item.roomNum, (options: any) => {
if (options) {
navigate(`/meeting`, {
state: {
channelId: item.roomNum,
token: options.token,
tokenA: options.tokenA,
roomId: item.id,
roomName: item.roomName,
enableMicr: false,
enableCamera: false,
}
})
}
})
})
}
}}

View File

@ -223,15 +223,22 @@ const agora = {
await rtcEngine.joinChannelEx(
option.tokenA,
{ channelId: option.channelId + '1', localUid: Number('1' + option.screenShareId) },
{
autoSubscribeAudio: false,//设置是否自动订阅所有音频流
autoSubscribeVideo: false,//设置是否自动订阅所有视频流
publishMicrophoneTrack: false,//设置是否发布麦克风采集到的音频
publishCameraTrack: true,//设置是否发布摄像头采集的视频
clientRoleType: ClientRoleType.ClientRoleAudience,//用户角色 ClientRoleBroadcaster 主播 ClientRoleAudience 观众
publishScreenTrack: false,//设置是否发布屏幕采集的视频
}
{}
);
await agora.updateChannelMediaOptionsEx(false)
},
updateChannelMediaOptionsEx: async (bool: boolean) => {
rtcEngine.updateChannelMediaOptionsEx({
clientRoleType: bool ? ClientRoleType.ClientRoleBroadcaster : ClientRoleType.ClientRoleAudience, //用户角色 ClientRoleBroadcaster 主播 ClientRoleAudience 观众
autoSubscribeAudio: true,//设置是否自动订阅所有音频流
autoSubscribeVideo: true,//设置是否自动订阅所有视频流
publishMicrophoneTrack: true,//设置是否发布麦克风采集到的音频
publishCameraTrack: true,//设置是否发布摄像头采集的视频
publishScreenTrack: false,//设置是否发布屏幕采集的视频
}, {
channelId: option.channelId + '1',
localUid: Number('1' + option.screenShareId)
})
},
// 离开共享屏幕频道
leaveChannelEx: async (uid: any) => {