Last active
November 20, 2016 18:44
-
-
Save rishabhbhardwaj/2c084ebcd3b64345838d8319ff28cc8d to your computer and use it in GitHub Desktop.
SampleElectron_main.js
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 electron = require('electron') | |
// Module to control application life. | |
const app = electron.app | |
// Module to create native browser window. | |
const BrowserWindow = electron.BrowserWindow | |
let mainWindow | |
function createWindow () { | |
// This will create the browser window.Change the height/width according to th need. | |
mainWindow = new BrowserWindow({width: 800, height: 600}) | |
// and load the index.html of the app. Change this if you want to render some other file. | |
mainWindow.loadURL(`file://${__dirname}/index.html`) | |
// Uncomment the below if you want your app to be open with Dev tools. | |
// mainWindow.webContents.openDevTools() | |
mainWindow.on('closed', function () { | |
mainWindow = null | |
}) | |
} | |
app.on('ready', createWindow) | |
app.on('window-all-closed', function () { | |
if (process.platform !== 'darwin') { | |
app.quit() | |
} | |
}) | |
app.on('activate', function () { | |
if (mainWindow === null) { | |
createWindow() | |
} | |
}) | |
var handleStartupEvent = function() { | |
if (process.platform !== 'win32') { | |
return false; | |
} | |
var squirrelCommand = process.argv[1]; | |
switch (squirrelCommand) { | |
case '--squirrel-install': | |
case '--squirrel-updated': | |
app.quit(); | |
return true; | |
case '--squirrel-uninstall': | |
app.quit(); | |
return true; | |
case '--squirrel-obsolete': | |
app.quit(); | |
return true; | |
} | |
}; | |
if (handleStartupEvent()) { | |
return; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment