Skip to content

Instantly share code, notes, and snippets.

@subramanian-vv
Last active December 29, 2020 18:17
Show Gist options
  • Save subramanian-vv/4fb4401b0e0cf8687198be7603ed3a1e to your computer and use it in GitHub Desktop.
Save subramanian-vv/4fb4401b0e0cf8687198be7603ed3a1e to your computer and use it in GitHub Desktop.
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