diff options
| author | Priyansh <[email protected]> | 2020-12-22 18:08:49 +0530 |
|---|---|---|
| committer | Priyansh <[email protected]> | 2020-12-22 18:08:49 +0530 |
| commit | 5a6ae80df4f63d71e99fcbcbbee0697bf6e78a2d (patch) | |
| tree | db5e7f99aae5b611dc1a1491b01ff18ffad9fec4 | |
| parent | 19fa6c89ab00ee43f0a39f203bdb17b0717382a3 (diff) | |
| download | styx-5a6ae80df4f63d71e99fcbcbbee0697bf6e78a2d.tar.xz styx-5a6ae80df4f63d71e99fcbcbbee0697bf6e78a2d.zip | |
Added: win.once ready-to-show then show window gracefully
| -rw-r--r-- | main.js | 65 |
1 files changed, 36 insertions, 29 deletions
@@ -1,48 +1,55 @@ -const {app, BrowserWindow} = require('electron') -const path = require('path') -const url = require('url') -let win +const { app, BrowserWindow } = require("electron"); +const path = require("path"); +const url = require("url"); +let win; -function createWindow () { +function createWindow() { // Create the browser window. win = new BrowserWindow({ - minWidth: 800, - minHeight: 600, - width: 800, - height: 600, - webPreferences: { - nodeIntegration: true - } - }) + minWidth: 800, + minHeight: 600, + width: 800, + height: 600, + webPreferences: { + nodeIntegration: true, + }, + }); // and load the index.html of the app. - win.loadURL(url.format({ - pathname: path.join(__dirname, 'app/app.html'), - protocol: 'file:', - slashes: true - })) + win.loadURL( + url.format({ + pathname: path.join(__dirname, "app/app.html"), + protocol: "file:", + slashes: true, + }) + ); // Open the DevTools. // win.webContents.openDevTools() // Emitted when the window is closed. - win.on('closed', () => { + win.on("closed", () => { // Dereference the window object, usually you would store windows // in an array if your app supports multi windows, this is the time // when you should delete the corresponding element. - win = null - }) + win = null; + }); + + win.once("ready-to-show", () => { + win.show(); + }); } -app.on('ready', createWindow) -app.on('window-all-closed', () => { - if (process.platform !== 'darwin') { - app.quit() +app.on("ready", createWindow); + +app.on("window-all-closed", () => { + if (process.platform !== "darwin") { + app.quit(); } -}) +}); -app.on('activate', () => { +app.on("activate", () => { if (win === null) { - createWindow() + createWindow(); } -})
\ No newline at end of file +}); |
