-
-
Save subramanian-vv/4fb4401b0e0cf8687198be7603ed3a1e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { app, BrowserWindow } = require("electron"); | |
//Function to create a window | |
function createWindow() { | |
const mainWindow = new BrowserWindow({ | |
width: 800, | |
height: 600, | |
webPreferences: { | |
nodeIntegration: true, //Grants access to use NodeJS API | |
}, | |
}); | |
mainWindow.loadFile("index.html"); | |
} | |
//Loads the created window | |
app.whenReady().then(createWindow); | |
//Quits the app on closing all the windows | |
app.on("window-all-closed", () => { | |
if (process.platform !== "darwin") { | |
app.quit(); | |
} | |
}); | |
//Prevents re-launching of an already running app | |
app.on("activate", () => { | |
if (BrowserWindow.getAllWindows().length === 0) { | |
createWindow(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment