replaced executeJavaScript with IPC event

This commit is contained in:
Jan Prochazka
2021-12-25 11:29:46 +01:00
parent 0e95082be6
commit ab4aef6c7e
5 changed files with 11 additions and 73 deletions

View File

@@ -38,7 +38,7 @@ function commandItem(id) {
accelerator: command ? command.keyText : undefined,
enabled: command ? command.enabled : false,
click() {
mainWindow.webContents.executeJavaScript(`dbgate_runCommand('${id}')`);
mainWindow.webContents.send('run-command', id);
},
};
}
@@ -179,11 +179,9 @@ function createWindow() {
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
// enableRemoteModule: true,
},
});
mainWindow.webContents.openDevTools();
// require('@electron/remote/main').enable(mainWindow.webContents);
if (store.get('winIsMaximized')) {
mainWindow.maximize();
}
@@ -199,18 +197,6 @@ function createWindow() {
protocol: 'file:',
slashes: true,
});
// mainWindow.webContents.on('did-finish-load', function () {
// mainWindow.webContents.executeJavaScript(
// `runInit=()=>{
// try{
// dbgate_initializeElectron(${JSON.stringify(initArgs)});
// }catch(e){
// setTimeout(runInit,100)
// }
// };
// runInit()`
// );
// });
mainWindow.on('close', () => {
store.set('winBounds', mainWindow.getBounds());
store.set('winIsMaximized', mainWindow.isMaximized());
@@ -232,34 +218,6 @@ function createWindow() {
loadMainWindow();
// if (process.env.ELECTRON_START_URL) {
// loadMainWindow({});
// } else {
// const apiProcess = fork(path.join(__dirname, '../packages/api/dist/bundle.js'), [
// '--dynport',
// '--is-electron-bundle',
// '--native-modules',
// path.join(__dirname, 'nativeModules'),
// // '../../../src/nativeModules'
// ]);
// apiProcess.on('message', msg => {
// if (msg.msgtype == 'listening') {
// const { port, authorization } = msg;
// loadMainWindow({
// port,
// authorization,
// });
// }
// });
// }
// and load the index.html of the app.
// mainWindow.loadURL('http://localhost:3000');
// Open the DevTools.
// mainWindow.webContents.openDevTools();
// Emitted when the window is closed.
mainWindow.on('closed', function () {
// Dereference the window object, usually you would store windows