Skip to content

Instantly share code, notes, and snippets.

@easychen
Created March 30, 2018 10:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save easychen/3e17b0fafb5e2d783b14fdb8406490bc to your computer and use it in GitHub Desktop.
Save easychen/3e17b0fafb5e2d783b14fdb8406490bc to your computer and use it in GitHub Desktop.
Electron Main.js demo
const electron = require('electron');
const {app} = electron;
const {BrowserWindow} = electron;
let win;
function createWindow() {
win = new BrowserWindow({width: 600, height: 1080});
win.loadURL(`file://${__dirname}/index.html`);
win.on('closed', () => {
win = null;
});
}
app.on('ready', createWindow);
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit();
}
});
app.on('activate', () => {
if (win === null) {
createWindow();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment