Fixed: Using OnReadyToShow to display the main window in Blazor does not seem to work with Show set to false #361

This commit is contained in:
Gregor Biswanger
2020-04-21 14:39:21 +02:00
parent 073eb0e00d
commit 11fbd6b259
3 changed files with 30 additions and 1 deletions

View File

@@ -2,11 +2,17 @@
const electron_1 = require("electron");
const path = require('path');
const windows = [];
let readyToShowWindowsIds = [];
let window, lastOptions, electronSocket;
module.exports = (socket, app) => {
electronSocket = socket;
socket.on('register-browserWindow-ready-to-show', (id) => {
if (readyToShowWindowsIds.includes(id)) {
readyToShowWindowsIds = readyToShowWindowsIds.filter(value => value !== id);
electronSocket.emit('browserWindow-ready-to-show' + id);
}
getWindowById(id).on('ready-to-show', () => {
readyToShowWindowsIds.push(id);
electronSocket.emit('browserWindow-ready-to-show' + id);
});
});
@@ -169,6 +175,14 @@ module.exports = (socket, app) => {
options = { ...options, webPreferences: { nodeIntegration: true } };
}
window = new electron_1.BrowserWindow(options);
window.on('ready-to-show', () => {
if (readyToShowWindowsIds.includes(window.id)) {
readyToShowWindowsIds = readyToShowWindowsIds.filter(value => value !== window.id);
}
else {
readyToShowWindowsIds.push(window.id);
}
});
lastOptions = options;
window.on('closed', (sender) => {
for (let index = 0; index < windows.length; index++) {

File diff suppressed because one or more lines are too long

View File

@@ -1,12 +1,19 @@
import { BrowserWindow, Menu, nativeImage } from 'electron';
const path = require('path');
const windows: Electron.BrowserWindow[] = [];
let readyToShowWindowsIds: number[] = [];
let window, lastOptions, electronSocket;
export = (socket: SocketIO.Socket, app: Electron.App) => {
electronSocket = socket;
socket.on('register-browserWindow-ready-to-show', (id) => {
if (readyToShowWindowsIds.includes(id)) {
readyToShowWindowsIds = readyToShowWindowsIds.filter(value => value !== id);
electronSocket.emit('browserWindow-ready-to-show' + id);
}
getWindowById(id).on('ready-to-show', () => {
readyToShowWindowsIds.push(id);
electronSocket.emit('browserWindow-ready-to-show' + id);
});
});
@@ -202,6 +209,14 @@ export = (socket: SocketIO.Socket, app: Electron.App) => {
}
window = new BrowserWindow(options);
window.on('ready-to-show', () => {
if (readyToShowWindowsIds.includes(window.id)) {
readyToShowWindowsIds = readyToShowWindowsIds.filter(value => value !== window.id);
} else {
readyToShowWindowsIds.push(window.id);
}
});
lastOptions = options;
window.on('closed', (sender) => {