屏幕共享优化
This commit is contained in:
parent
762ccefc66
commit
d9758528e9
|
|
@ -3,7 +3,7 @@ import { useEffect, useRef, useState } from "react";
|
||||||
import Operation from '@/components/Operation';
|
import Operation from '@/components/Operation';
|
||||||
import SpeakerModeModal from '@/components/SpeakerModeModal';
|
import SpeakerModeModal from '@/components/SpeakerModeModal';
|
||||||
import InvitingPersonnelModal from '@/components/InvitingPersonnelModal';
|
import InvitingPersonnelModal from '@/components/InvitingPersonnelModal';
|
||||||
import { Button, Input, Popover, Modal, Checkbox, message } from "antd";
|
import { Button, Input, Popover, Modal, Checkbox, message, Popconfirm } from "antd";
|
||||||
import { SearchOutlined } from '@ant-design/icons';
|
import { SearchOutlined } from '@ant-design/icons';
|
||||||
import { useLocation, useNavigate } from 'react-router-dom';
|
import { useLocation, useNavigate } from 'react-router-dom';
|
||||||
import { thumbImageBufferToBase64 } from '@/utils/package/base64'
|
import { thumbImageBufferToBase64 } from '@/utils/package/base64'
|
||||||
|
|
@ -119,7 +119,9 @@ const Meeting: React.FC = () => {
|
||||||
const [currentLookUserAccount, setCurrentLookUserAccount] = useState<any>('')
|
const [currentLookUserAccount, setCurrentLookUserAccount] = useState<any>('')
|
||||||
const [recorder, setRecorder] = useState<any>('')
|
const [recorder, setRecorder] = useState<any>('')
|
||||||
const [mediaStream, setMediaStream] = useState<any>('')
|
const [mediaStream, setMediaStream] = useState<any>('')
|
||||||
const [isShare, setIsShare] = useState<any>(false)
|
const [isShare, setIsShare] = useState<any>(null)
|
||||||
|
const [isSharePopConfirm, setIsSharePopConfirm] = useState<any>(false)
|
||||||
|
const [isShareUser, setIsShareUser] = useState<any>(null)
|
||||||
const [currentLookUserStatus, setCurrentLookUserStatus] = useState<1 | 2 | 3 | 4>(1)
|
const [currentLookUserStatus, setCurrentLookUserStatus] = useState<1 | 2 | 3 | 4>(1)
|
||||||
let userInfo = JSON.parse(storage.getItem('user') as string)
|
let userInfo = JSON.parse(storage.getItem('user') as string)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
@ -160,7 +162,7 @@ const Meeting: React.FC = () => {
|
||||||
},
|
},
|
||||||
onUserJoined: async (info: any, remoteUid: any, _elapsed: any) => {
|
onUserJoined: async (info: any, remoteUid: any, _elapsed: any) => {
|
||||||
if (String(remoteUid).length === 9) {
|
if (String(remoteUid).length === 9) {
|
||||||
setIsShare(true)
|
setIsShare(remoteUid)
|
||||||
} else {
|
} else {
|
||||||
await getRoomUser()
|
await getRoomUser()
|
||||||
setTimeout(async () => {
|
setTimeout(async () => {
|
||||||
|
|
@ -178,7 +180,7 @@ const Meeting: React.FC = () => {
|
||||||
},
|
},
|
||||||
onUserOffline: async (info: any, remoteUid: any, _reason: any) => {
|
onUserOffline: async (info: any, remoteUid: any, _reason: any) => {
|
||||||
if (String(remoteUid).length === 9) {
|
if (String(remoteUid).length === 9) {
|
||||||
setIsShare(false)
|
setIsShare(null)
|
||||||
}
|
}
|
||||||
await agora.setupRemoteVideo({
|
await agora.setupRemoteVideo({
|
||||||
uid: Number(remoteUid),
|
uid: Number(remoteUid),
|
||||||
|
|
@ -250,6 +252,13 @@ const Meeting: React.FC = () => {
|
||||||
}
|
}
|
||||||
}, [currentVideoId]);
|
}, [currentVideoId]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (isShare) {
|
||||||
|
const item = roomUserList.find((item: any) => item.screenShareId === String(isShare))
|
||||||
|
setIsShareUser(item || null)
|
||||||
|
}
|
||||||
|
}, [isShare, roomUserList]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
onSignalr(async (item: any) => {
|
onSignalr(async (item: any) => {
|
||||||
switch (item.key) {
|
switch (item.key) {
|
||||||
|
|
@ -277,6 +286,7 @@ const Meeting: React.FC = () => {
|
||||||
// 1:全员退出会议
|
// 1:全员退出会议
|
||||||
// 2:设置取消管理员
|
// 2:设置取消管理员
|
||||||
// 3:踢出房间
|
// 3:踢出房间
|
||||||
|
// 4:屏幕共享
|
||||||
switch (item.type) {
|
switch (item.type) {
|
||||||
case 1:
|
case 1:
|
||||||
leaveChannel()
|
leaveChannel()
|
||||||
|
|
@ -285,6 +295,9 @@ const Meeting: React.FC = () => {
|
||||||
case 3:
|
case 3:
|
||||||
getRoomUser()
|
getRoomUser()
|
||||||
break;
|
break;
|
||||||
|
case 4:
|
||||||
|
console.log(isShareUser, user);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'ForceExitRoom':
|
case 'ForceExitRoom':
|
||||||
|
|
@ -743,6 +756,20 @@ const Meeting: React.FC = () => {
|
||||||
}
|
}
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 是否有人分享屏幕确认框
|
||||||
|
const handleOpenChange = (newOpen: boolean): void => {
|
||||||
|
if (newOpen) {
|
||||||
|
if (isShare) {
|
||||||
|
setIsSharePopConfirm(true)
|
||||||
|
} else {
|
||||||
|
clickSharedScreen()
|
||||||
|
setIsSharePopConfirm(false)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
setIsSharePopConfirm(false)
|
||||||
|
}
|
||||||
|
};
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className={styles.meeting} onClick={() => {
|
<div className={styles.meeting} onClick={() => {
|
||||||
|
|
@ -1092,8 +1119,28 @@ const Meeting: React.FC = () => {
|
||||||
}} checked={isFluencyPriority}>流畅度优先</Checkbox>
|
}} checked={isFluencyPriority}>流畅度优先</Checkbox>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<Button type="primary" onClick={() => { setIsSharedScreenModal(false) }} style={{ backgroundColor: '#31353A', marginRight: '14px' }}>取消</Button>
|
<Button type="primary" onClick={() => {
|
||||||
<Button type="primary" className='m-ant-btn' onClick={() => clickSharedScreen()}>共享</Button>
|
setIsSharedScreenModal(false)
|
||||||
|
setIsSharePopConfirm(false)
|
||||||
|
}} style={{ backgroundColor: '#31353A', marginRight: '14px' }}>取消</Button>
|
||||||
|
<Popconfirm
|
||||||
|
title="提示"
|
||||||
|
description={`用户${isShareUser?.userName}正在屏幕,是否继续共享?`}
|
||||||
|
open={isSharePopConfirm}
|
||||||
|
onOpenChange={handleOpenChange}
|
||||||
|
onConfirm={async () => {
|
||||||
|
await onInvoke('sendOper', {
|
||||||
|
roomNum: state.channelId,
|
||||||
|
type: 4,
|
||||||
|
})
|
||||||
|
clickSharedScreen()
|
||||||
|
}}
|
||||||
|
onCancel={() => { }}
|
||||||
|
okText="是"
|
||||||
|
cancelText="否"
|
||||||
|
>
|
||||||
|
<Button type="primary" className='m-ant-btn'>共享</Button>
|
||||||
|
</Popconfirm>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -106,6 +106,7 @@ export const onInvoke = async (str: string, data: any) => {
|
||||||
// 1:全员退出会议
|
// 1:全员退出会议
|
||||||
// 2:设置取消管理员
|
// 2:设置取消管理员
|
||||||
// 3:踢出房间
|
// 3:踢出房间
|
||||||
|
// 4:屏幕共享
|
||||||
await connection.invoke(str, data.roomNum, data.type)
|
await connection.invoke(str, data.roomNum, data.type)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue