多窗口初始化并未使用

This commit is contained in:
yj 2024-10-10 16:11:27 +08:00
parent 8ce430ac4d
commit 6e85e5e3e7
5 changed files with 55 additions and 0 deletions

26
main.js
View File

@ -17,6 +17,7 @@ const { autoUpdater, CancellationToken } = require('electron-updater');
const cancellationToken = new CancellationToken()
app.allowRendererProcessReuse = false;
let mainWindow = null;
let childWindow = []
let isMaximized = false;
let env;
let regKey;
@ -299,6 +300,31 @@ app.on('ready', () => {
})
});
});
// 创建子窗口
ipcMain.handle('createChildWindow', (event, config) => {
const child = new BrowserWindow({
parent: mainWindow,
webPreferences: {
contextIsolation: false,
nodeIntegration: true,
enableRemoteModule: true,
nodeIntegrationInWorker: true,
allowMediaDevices: true,
// preload: path.join(__dirname, 'preload.js')
},
// show: false,
// frame: false,
// backgroundColor: '#00000000',
// transparent: true,
})
child.loadURL(config.url)
childWindow.push(child)
child.once('ready-to-show', () => {
child.show()
console.log(config);
child.setSize(config.width, config.height)
})
});
}
});
// 检测更新在你想要检查更新的时候执行renderer事件触发后的操作自行编写

View File

@ -73,4 +73,8 @@ window.electron = {
setRegistry: (uuid) => {
ipcRenderer.invoke('setRegistry', uuid)
},
// 创建子窗口
createChildWindow: (config) => {
ipcRenderer.invoke('createChildWindow', config)
},
}

View File

@ -0,0 +1,5 @@
.shareScreenWindow {
background-color: red;
color: red;
font-size: 30px;
}

View File

@ -0,0 +1,19 @@
import styles from '@/page/Meeting/ShareScreenWindow/index.module.scss'
import { useEffect } from "react";
const ShareScreenWindow: React.FC = () => {
useEffect(() => {
}, []);
return (
<>
<div className={styles.shareScreenWindow}>
2222
</div>
</>
)
}
export default ShareScreenWindow

1
src/render.d.ts vendored
View File

@ -18,6 +18,7 @@ export interface IElectronAPI {
getVersion: () => Promise<string>;
setRegistry: (uuid: string) => any;
getRegistry: () => any;
createChildWindow: (config: any) => void;
}
declare global {