@@ -112,6 +112,7 @@ function VideoConferenceComponent(props: {
112112 const [ e2eeSetupComplete , setE2eeSetupComplete ] = React . useState ( false ) ;
113113 const [ messageApi , contextHolder ] = message . useMessage ( ) ;
114114 const [ notApi , notHolder ] = notification . useNotification ( ) ;
115+ const [ permissionOpened , setPermissionOpened ] = useState ( false ) ;
115116 const [ permissionModalVisible , setPermissionModalVisible ] = useState ( false ) ;
116117 const [ permissionRequested , setPermissionRequested ] = useState ( false ) ;
117118 const [ permissionError , setPermissionError ] = useState < string | null > ( null ) ;
@@ -200,18 +201,26 @@ function VideoConferenceComponent(props: {
200201 messageApi . error ( t ( 'msg.error.device.not_found' ) ) ;
201202 break ;
202203 case MediaDeviceFailure . PermissionDenied :
203- notApi . open ( {
204- duration : 3 ,
205- message : t ( 'msg.error.device.permission_denied_title' ) ,
206- description : t ( 'msg.error.device.permission_denied_desc' ) ,
207- btn : (
208- < Space >
209- < Button type = "primary" size = "small" onClick = { ( ) => setPermissionModalVisible ( true ) } >
210- { t ( 'msg.request.device.allow' ) }
211- </ Button >
212- </ Space >
213- ) ,
214- } ) ;
204+ if ( ! permissionOpened ) {
205+ setPermissionOpened ( true ) ;
206+ notApi . open ( {
207+ duration : 3 ,
208+ message : t ( 'msg.error.device.permission_denied_title' ) ,
209+ description : t ( 'msg.error.device.permission_denied_desc' ) ,
210+ btn : (
211+ < Space >
212+ < Button
213+ type = "primary"
214+ size = "small"
215+ onClick = { ( ) => setPermissionModalVisible ( true ) }
216+ >
217+ { t ( 'msg.request.device.allow' ) }
218+ </ Button >
219+ </ Space >
220+ ) ,
221+ onClose : ( ) => setPermissionOpened ( false ) ,
222+ } ) ;
223+ }
215224 break ;
216225 case MediaDeviceFailure . Other :
217226 messageApi . error ( t ( 'msg.error.device.other' ) ) ;
@@ -233,11 +242,6 @@ function VideoConferenceComponent(props: {
233242 audio : true ,
234243 } ) ;
235244
236- await navigator . mediaDevices . getDisplayMedia ( {
237- video : true ,
238- audio : true ,
239- } ) ;
240-
241245 // 权限已获取,通知用户
242246 messageApi . success ( t ( 'msg.success.device.granted' ) ) ;
243247
0 commit comments