diff --git a/main.js b/main.js index a2648eb..d5a19ab 100644 --- a/main.js +++ b/main.js @@ -95,6 +95,7 @@ function createWindow() { } const additionalData = { myKey: 'myValue' } app.on('ready', () => { + // const gotTheLock = true const gotTheLock = app.requestSingleInstanceLock(additionalData) if (gotTheLock) { app.getPath('crashDumps') @@ -185,6 +186,7 @@ app.on('ready', () => { connection.off('ModifyNickName'); connection.off('JoinChannelCallback'); connection.off('ExitSharedScreen'); + connection.off('SetSpeaker'); } }); ipcMain.handle('onStop', (event) => { @@ -226,6 +228,10 @@ app.on('ready', () => { // 退出房间 await connection.invoke(str, data.roomNum) break; + case 'SetSpeakerCallback': + // 发言人设置成功 + await connection.invoke(str, data) + break; } }); ipcMain.handle('onOtherSignalr', (event) => { @@ -394,6 +400,13 @@ app.on('ready', () => { key: 'ExitSharedScreen' }) }); + // 设置发言人 + connection.on("SetSpeaker", (RoomManagerInputDTO) => { + mainWindow.webContents.send('onSignalr', { + key: 'SetSpeaker', + RoomManagerInputDTO + }) + }); } }); // 放大缩小退出窗口 diff --git a/src/api/Meeting/index.ts b/src/api/Meeting/index.ts index 6bf6328..7005eba 100644 --- a/src/api/Meeting/index.ts +++ b/src/api/Meeting/index.ts @@ -71,14 +71,20 @@ export const PostRoomManager = (data: any) => request({ url: `/room/manager`, method: 'post', - data + data: { + ...data, + SettingUserId: '' + } }) export const DeleteRoomManager = (data: any) => request({ url: `/room/manager`, method: 'delete', - data + data: { + ...data, + SettingUserId: '' + } }) export const GetRoomKickout = (roomNum: string, kickUid: string) => diff --git a/src/page/Meeting/index.tsx b/src/page/Meeting/index.tsx index 05eb526..8161c6a 100644 --- a/src/page/Meeting/index.tsx +++ b/src/page/Meeting/index.tsx @@ -162,6 +162,7 @@ const Meeting: React.FC = () => { const [_speackUid, setSpeackUid] = useState([]) const [currentSpeakUser, setCurrentSpeakUser] = useState([]) const [chatList, setChatList] = useState([]) + const [applyUserList, setApplyUserList] = useState([]) const [isExpand, setIsExpand] = useState(false) const [currentVideoId, setCurrentVideoId] = useState('') const [currentVideoUid, setCurrentVideoUid] = useState('') @@ -1022,6 +1023,10 @@ const Meeting: React.FC = () => { return res }) break; + // 共享 + case 'SetSpeaker': + window.electron.onInvoke('SetSpeakerCallback', item.RoomManagerInputDTO) + break; } }) return () => { @@ -1177,6 +1182,49 @@ const Meeting: React.FC = () => { return () => clearTimeout(timer); }, [isClickedMediaSteam]); + useEffect(() => { + let timer: NodeJS.Timeout | undefined; + if (timer) { + clearInterval(timer) + timer = undefined; + } + if (applyUserList.length) { + timer = setInterval(() => { + setRoomUserList((list: any) => { + let newApplyUserList = [...applyUserList] + newApplyUserList.forEach((item: any, index: number) => { + const user = list.find((i: any) => i.uid === item.uid) + if (user) { + if (user.isRoomManager) { + newApplyUserList.splice(index, 1) + } else { + item.status-- + if (item.status <= 0) { + message.error(`用户${user.userName}设置管理员失败!`) + newApplyUserList.splice(index, 1) + } + } + } else { + newApplyUserList.splice(index, 1) + } + }); + if (newApplyUserList.length === 0) { + clearInterval(timer) + timer = undefined; + } + setApplyUserList(newApplyUserList) + return list + }) + }, 1000); + } else { + if (timer) { + clearInterval(timer) + timer = undefined; + } + } + return () => timer ? clearTimeout(timer) : null; + }, [applyUserList]); + useEffect(() => { const elements = document.querySelectorAll('.intersectionObserver-view'); if (elements.length && currentVideoId) { @@ -1991,6 +2039,13 @@ const Meeting: React.FC = () => { roomId: data.roomId, roomNum: data.roomNum, userId: data.userId + }).then(res => { + if (res.code === 200) { + setApplyUserList((newChatList: any) => [...newChatList, { + uid: data.userId, + status: 5 + }]) + } }) } }