mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-07-20 23:57:11 +00:00
Add method to destroy all windows manually
This commit is contained in:
@@ -262,6 +262,25 @@ module.exports = (socket, app) => {
|
||||
socket.on('browserWindowDestroy', (id) => {
|
||||
getWindowById(id)?.destroy();
|
||||
});
|
||||
|
||||
socket.on('browserWindowDestroyAll', () => {
|
||||
const windows = electron_1.BrowserWindow.getAllWindows();
|
||||
let count = 0;
|
||||
if (windows.length) {
|
||||
windows.forEach(w => {
|
||||
try {
|
||||
w.hide();
|
||||
w.destroy();
|
||||
count++;
|
||||
}
|
||||
catch {
|
||||
//ignore, probably already destroyed
|
||||
}
|
||||
});
|
||||
}
|
||||
electronSocket.emit('browserWindowDestroyAll-completed', count);
|
||||
});
|
||||
|
||||
socket.on('browserWindowClose', (id) => {
|
||||
getWindowById(id)?.close();
|
||||
});
|
||||
|
||||
@@ -288,6 +288,24 @@ export = (socket: Socket, app: Electron.App) => {
|
||||
getWindowById(id)?.destroy();
|
||||
});
|
||||
|
||||
socket.on('browserWindowDestroyAll', () => {
|
||||
const windows = BrowserWindow.getAllWindows();
|
||||
let count = 0;
|
||||
if (windows.length) {
|
||||
windows.forEach(w => {
|
||||
try {
|
||||
w.hide();
|
||||
w.destroy();
|
||||
count++;
|
||||
}
|
||||
catch {
|
||||
//ignore, probably already destroyed
|
||||
}
|
||||
});
|
||||
}
|
||||
electronSocket.emit('browserWindowDestroyAll-completed', count);
|
||||
});
|
||||
|
||||
socket.on('browserWindowClose', (id) => {
|
||||
getWindowById(id)?.close();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user