mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-09-23 23:45:19 +00:00
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:
@@ -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
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user