Let's try to hide the main application window on startup and show it only when it's invoked from the system tray menu:
- The BrowserWindow class provides the show and hide methods, which we can use to control the visibility of the window instance. This means that we can call the hide method when building the window object at startup:
function createWindow() {
win = new BrowserWindow({
transparent: true,
frame: false,
webPreferences: {
nodeIntegration: true
}
});
win.hide();
win.loadURL(`http://localhost:3000`);
win.on('closed', () => {
win = null;
});
}
- Finally, you can create an additional Show menu entry to invoke win.show and display the main application window to the user:
function createTray...