This commit is contained in:
yj 2024-10-12 09:56:12 +08:00
parent e89d820797
commit 49d73bedce
6 changed files with 47 additions and 10 deletions

33
main.js
View File

@ -273,10 +273,7 @@ app.on('ready', () => {
// 设置窗口尺寸
mainWindow.setSize(config.width, config.height)
// 设置窗口位置使其居中于当前屏幕
const display = screen.getDisplayMatching({ ...mainWindow.getBounds() });
const x = Math.round((display.workArea.width - mainWindow.getSize()[0]) / 2);
const y = Math.round((display.workArea.height - mainWindow.getSize()[1]) / 2);
mainWindow.setPosition(x, y);
mainWindowCenter()
});
// 写入注册表
ipcMain.handle('setRegistry', (event, uuid) => {
@ -326,14 +323,19 @@ app.on('ready', () => {
windowOperation(config)
})
});
// 隐藏窗口
// 关闭子窗口
ipcMain.handle('closeChildWindow', (event, key) => {
childWindow[key].close()
childWindow[key] = ""
const display = screen.getDisplayMatching({ ...mainWindow.getBounds() });
const x = Math.round((display.workArea.width - mainWindow.getSize()[0]) / 2);
const y = Math.round((display.workArea.height - mainWindow.getSize()[1]) / 2);
mainWindow.setPosition(x, y);
mainWindowCenter()
});
// 隐藏主窗口
ipcMain.handle('mainWindowHide', () => {
mainWindowHide()
});
// 居中主窗口
ipcMain.handle('mainWindowCenter', () => {
mainWindowCenter()
});
}
});
@ -412,9 +414,20 @@ function windowOperation(config) {
child.setPosition(x, 0);
child.setResizable(false)
child.setMovable(false)
mainWindow.setPosition(-999999, -999999);
mainWindowHide()
if (env === 'development') {
child.webContents.openDevTools()
}
}
}
// 主窗口居中
function mainWindowCenter() {
const display = screen.getDisplayMatching({ ...mainWindow.getBounds() });
const x = Math.round((display.workArea.width - mainWindow.getSize()[0]) / 2);
const y = Math.round((display.workArea.height - mainWindow.getSize()[1]) / 2);
mainWindow.setPosition(x, y);
}
// 主窗口隐藏
function mainWindowHide() {
mainWindow.setPosition(-999999, -999999);
}

View File

@ -81,4 +81,12 @@ window.electron = {
closeChildWindow: (key) => {
ipcRenderer.invoke('closeChildWindow', key)
},
// 隐藏主窗口
mainWindowHide: () => {
ipcRenderer.invoke('mainWindowHide')
},
// 居中主窗口
mainWindowCenter: () => {
ipcRenderer.invoke('mainWindowCenter')
},
}

View File

@ -99,6 +99,10 @@ const StupWizard = forwardRef((props: any, ref: any) => {
if (location.hash.indexOf('/meeting') === -1) {
agora.release()
}
if (storage.getItem('isOpenChildWindow') === 'true') {
window.electron.mainWindowHide()
storage.setItem('isOpenChildWindow', false)
}
setIsStupWizard(false)
}}
/>

View File

@ -207,6 +207,10 @@ const Meeting: React.FC = () => {
await stopScreenCapture()
await allUserLook(userInfo.uid, userInfo.userName)
break;
case 'setting':
stupWizardRef.current.changeModal(3);
window.electron.mainWindowCenter()
break;
case 'footerListsTitle':
switch (footerListsTitle) {
case '静音':
@ -1309,6 +1313,7 @@ const Meeting: React.FC = () => {
// height: 70,
// key: 'shareScreenWindow',
// })
// storage.setItem('isOpenChildWindow', true)
} else {
message.error('请选择应用!')
}

View File

@ -126,6 +126,11 @@ const ShareScreenWindow: React.FC = () => {
footerListsTitle: item.title
});
break;
case '设置':
channel.postMessage({
type: 'setting'
});
break;
}
}}
key={index}>

2
src/render.d.ts vendored
View File

@ -20,6 +20,8 @@ export interface IElectronAPI {
getRegistry: () => any;
createChildWindow: (config: any) => void;
closeChildWindow: (key: string) => void;
mainWindowCenter: () => any;
mainWindowHide: () => any;
}
declare global {