视频监控窗口逻辑优化

This commit is contained in:
yj 2025-03-12 15:56:35 +08:00
parent 9924d7d14e
commit 14e90cab7e
5 changed files with 73 additions and 6 deletions

43
main.js
View File

@ -24,6 +24,7 @@ const cancellationToken = new CancellationToken()
app.allowRendererProcessReuse = false;
let mainWindow = null;
let childWindow = {}
let customizeChildWindow = {}
let isMaximized = false;
let env = 'development'; //development production xy
let regKey;
@ -624,6 +625,48 @@ app.on('ready', () => {
})
});
});
// 创建自定义子窗口
ipcMain.handle('customizeCreateChildWindow', (event, config) => {
if (config.open) {
customizeChildWindow[config.key].show()
customizeChildWindow[config.key].focus()
} else {
const customizeChild = new BrowserWindow({
webPreferences: {
contextIsolation: false,
nodeIntegration: true,
enableRemoteModule: true,
nodeIntegrationInWorker: true,
allowMediaDevices: true,
},
frame: true,
width: config.width,
height: config.height,
minWidth: config.width,
minHeight: config.height,
title: '会议监控',
})
customizeChildWindow[config.key] = customizeChild;
customizeChild.loadURL(config.url)
customizeChild.once('ready-to-show', () => {
customizeChild.show()
customizeChild.setMenuBarVisibility(false)
})
customizeChild.on('close', () => {
customizeChildWindow[config.key] = null
})
}
})
// 判断自定义窗口是否打开
ipcMain.handle('isCustomizeCreateChildOpen', (event, key) => {
return customizeChildWindow[key] ? true : false
})
// 关闭自定义窗口
ipcMain.handle('closeCustomizeCreateChildWindow', (event, key) => {
if (customizeChildWindow[key]) {
customizeChildWindow[key].close()
}
})
// 创建子窗口
ipcMain.handle('createChildWindow', (event, config) => {
const child = new BrowserWindow({

View File

@ -123,6 +123,18 @@ window.electron = {
setRegistry: (uuid) => {
ipcRenderer.invoke('setRegistry', uuid)
},
// 创建自定义子窗口
customizeCreateChildWindow: (config) => {
ipcRenderer.invoke('customizeCreateChildWindow', config)
},
// 判断自定义窗口是否打开
isCustomizeCreateChildOpen: (key) => {
return ipcRenderer.invoke('isCustomizeCreateChildOpen', key)
},
// 关闭自定义窗口
closeCustomizeCreateChildWindow: (key) => {
ipcRenderer.invoke('closeCustomizeCreateChildWindow', key)
},
// 创建子窗口
createChildWindow: (str) => {
switch (str) {

View File

@ -2007,12 +2007,20 @@ const Meeting: React.FC = () => {
}
break;
case '会议监控':
window.open(
location.hostname.includes('meeting-api.23544.com') ?
window.electron.isCustomizeCreateChildOpen('meetingMonitoring').then((req: boolean) => {
window.electron.getWindowSize().then((res: any) => {
window.electron.customizeCreateChildWindow({
url: location.hostname.includes('meeting-api.23544.com') ?
`http://192.168.2.9:8828?uid=${Number('1' + userInfo.screenShareId)}&channel=${state.channelId}&token=${userInfo.token}` :
`http://192.168.2.9:8828?uid=${Number('1' + userInfo.screenShareId)}&channel=${state.channelId}&token=${userInfo.token}`
)
`http://192.168.2.9:8828?uid=${Number('1' + userInfo.screenShareId)}&channel=${state.channelId}&token=${userInfo.token}`,
key: 'meetingMonitoring',
title: '会议监控',
width: Math.ceil(res.width / 1.5),
height: Math.ceil(res.height / 1.3),
open: req,
})
})
})
break;
case '签到':
singInRef.current.changeModal()

3
src/render.d.ts vendored
View File

@ -32,6 +32,9 @@ export interface IElectronAPI {
setRegistry: (uuid: string) => any;
getRegistry: () => any;
createChildWindow: (str: string) => void;
isCustomizeCreateChildOpen: (str: string) => Promise<boolean>;
closeCustomizeCreateChildWindow: (str: string) => void;
customizeCreateChildWindow: (config: any) => void;
setChildWindow: (config: any) => void;
setChildWindowShow: (config: any) => void;
closeChildWindow: (key: string) => void;

View File

@ -292,6 +292,7 @@ export const agora = {
})
agora.stopScreenCapture()
agora.release()
window.electron.closeCustomizeCreateChildWindow('meetingMonitoring')
},
// 加入频道
joinChannel: async () => {