From d9758528e9da81e5f8df554274532cae552afe13 Mon Sep 17 00:00:00 2001 From: yj <1336058017@qq.com> Date: Fri, 9 Aug 2024 13:54:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B1=8F=E5=B9=95=E5=85=B1=E4=BA=AB=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/page/Meeting/index.tsx | 59 ++++++++++++++++++++++++++++++++---- src/utils/package/signalr.ts | 1 + 2 files changed, 54 insertions(+), 6 deletions(-) diff --git a/src/page/Meeting/index.tsx b/src/page/Meeting/index.tsx index 9a91680..c8b5a87 100644 --- a/src/page/Meeting/index.tsx +++ b/src/page/Meeting/index.tsx @@ -3,7 +3,7 @@ import { useEffect, useRef, useState } from "react"; import Operation from '@/components/Operation'; import SpeakerModeModal from '@/components/SpeakerModeModal'; 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 { useLocation, useNavigate } from 'react-router-dom'; import { thumbImageBufferToBase64 } from '@/utils/package/base64' @@ -119,7 +119,9 @@ const Meeting: React.FC = () => { const [currentLookUserAccount, setCurrentLookUserAccount] = useState('') const [recorder, setRecorder] = useState('') const [mediaStream, setMediaStream] = useState('') - const [isShare, setIsShare] = useState(false) + const [isShare, setIsShare] = useState(null) + const [isSharePopConfirm, setIsSharePopConfirm] = useState(false) + const [isShareUser, setIsShareUser] = useState(null) const [currentLookUserStatus, setCurrentLookUserStatus] = useState<1 | 2 | 3 | 4>(1) let userInfo = JSON.parse(storage.getItem('user') as string) useEffect(() => { @@ -160,7 +162,7 @@ const Meeting: React.FC = () => { }, onUserJoined: async (info: any, remoteUid: any, _elapsed: any) => { if (String(remoteUid).length === 9) { - setIsShare(true) + setIsShare(remoteUid) } else { await getRoomUser() setTimeout(async () => { @@ -178,7 +180,7 @@ const Meeting: React.FC = () => { }, onUserOffline: async (info: any, remoteUid: any, _reason: any) => { if (String(remoteUid).length === 9) { - setIsShare(false) + setIsShare(null) } await agora.setupRemoteVideo({ uid: Number(remoteUid), @@ -250,6 +252,13 @@ const Meeting: React.FC = () => { } }, [currentVideoId]); + useEffect(() => { + if (isShare) { + const item = roomUserList.find((item: any) => item.screenShareId === String(isShare)) + setIsShareUser(item || null) + } + }, [isShare, roomUserList]); + useEffect(() => { onSignalr(async (item: any) => { switch (item.key) { @@ -277,6 +286,7 @@ const Meeting: React.FC = () => { // 1:全员退出会议 // 2:设置取消管理员 // 3:踢出房间 + // 4:屏幕共享 switch (item.type) { case 1: leaveChannel() @@ -285,6 +295,9 @@ const Meeting: React.FC = () => { case 3: getRoomUser() break; + case 4: + console.log(isShareUser, user); + break; } break; case 'ForceExitRoom': @@ -743,6 +756,20 @@ const Meeting: React.FC = () => { } return '' } + + // 是否有人分享屏幕确认框 + const handleOpenChange = (newOpen: boolean): void => { + if (newOpen) { + if (isShare) { + setIsSharePopConfirm(true) + } else { + clickSharedScreen() + setIsSharePopConfirm(false) + } + } else { + setIsSharePopConfirm(false) + } + }; return ( <>
{ @@ -1092,8 +1119,28 @@ const Meeting: React.FC = () => { }} checked={isFluencyPriority}>流畅度优先
- - + + { + await onInvoke('sendOper', { + roomNum: state.channelId, + type: 4, + }) + clickSharedScreen() + }} + onCancel={() => { }} + okText="是" + cancelText="否" + > + +
diff --git a/src/utils/package/signalr.ts b/src/utils/package/signalr.ts index 6d7b8fe..a98f685 100644 --- a/src/utils/package/signalr.ts +++ b/src/utils/package/signalr.ts @@ -106,6 +106,7 @@ export const onInvoke = async (str: string, data: any) => { // 1:全员退出会议 // 2:设置取消管理员 // 3:踢出房间 + // 4:屏幕共享 await connection.invoke(str, data.roomNum, data.type) break; }