Last active
October 29, 2017 16:06
-
-
Save afterburn/31bcc8d5bf59bfaba4b4aa9fbeff1524 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 electron = require('electron'); | |
const { app, BrowserWindow } = electron; | |
const path = require('path'); | |
const url = require('url'); | |
class Application { | |
constructor() { | |
this.windows = {}; | |
app.on('ready', () => this.createWindow('main')); | |
app.on('activate', () => this.createWindow('main')); | |
app.on('window-all-closed', function () { | |
if (process.platform !== 'darwin') { | |
app.quit(); | |
} | |
}); | |
} | |
createWindow(name) { | |
if(!this.windows.hasOwnProperty(name)) { | |
const window = this.windows[name] = new BrowserWindow({ width: 800, height: 600 }); | |
window.loadURL(url.format({ | |
pathname: path.join(__dirname, 'gui', 'index.html'), | |
protocol: 'file:', | |
slashes: true | |
})); | |
window.webContents.openDevTools(); | |
window.on('closed', () => { | |
this.windows[name] = null; | |
}); | |
} | |
} | |
} | |
new Application(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment