mirror of
https://gitlab.com/futo-org/fcast.git
synced 2025-06-24 21:25:23 +00:00
Electron: Fixed memory leak when creating and destorying main window
This commit is contained in:
parent
65edb0d40e
commit
3c72010604
1 changed files with 15 additions and 12 deletions
|
@ -285,6 +285,11 @@ export class Main {
|
||||||
return [].concat(Main.tcpListenerService.getSessions(), Main.webSocketListenerService.getSessions());
|
return [].concat(Main.tcpListenerService.getSessions(), Main.webSocketListenerService.getSessions());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
ipcMain.on('network-changed', (event: IpcMainEvent, value: any) => {
|
||||||
|
Main.mainWindow?.webContents?.send("device-info", { name: os.hostname(), interfaces: value });
|
||||||
|
});
|
||||||
|
|
||||||
if (Main.shouldOpenMainWindow) {
|
if (Main.shouldOpenMainWindow) {
|
||||||
Main.openMainWindow();
|
Main.openMainWindow();
|
||||||
}
|
}
|
||||||
|
@ -324,17 +329,8 @@ export class Main {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Main.mainWindow.loadFile(path.join(__dirname, 'main/index.html'));
|
|
||||||
Main.mainWindow.on('closed', () => {
|
|
||||||
Main.mainWindow = null;
|
|
||||||
});
|
|
||||||
|
|
||||||
Main.mainWindow.maximize();
|
|
||||||
Main.mainWindow.show();
|
|
||||||
|
|
||||||
Main.mainWindow.on('ready-to-show', () => {
|
|
||||||
const networkWorker = new BrowserWindow({
|
const networkWorker = new BrowserWindow({
|
||||||
show: false,
|
show: true,
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
nodeIntegration: true,
|
nodeIntegration: true,
|
||||||
contextIsolation: false,
|
contextIsolation: false,
|
||||||
|
@ -342,9 +338,16 @@ export class Main {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
ipcMain.on('network-changed', (event: IpcMainEvent, value: any) => {
|
Main.mainWindow.loadFile(path.join(__dirname, 'main/index.html'));
|
||||||
Main.mainWindow?.webContents?.send("device-info", { name: os.hostname(), interfaces: value });
|
Main.mainWindow.on('closed', () => {
|
||||||
|
Main.mainWindow = null;
|
||||||
|
networkWorker.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Main.mainWindow.maximize();
|
||||||
|
Main.mainWindow.show();
|
||||||
|
|
||||||
|
Main.mainWindow.on('ready-to-show', () => {
|
||||||
networkWorker.loadFile(path.join(__dirname, 'main/worker.html'));
|
networkWorker.loadFile(path.join(__dirname, 'main/worker.html'));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue