git clone https://github.com/electron/electron-quick-start
cd electron-quick-start
npm install && npm start
your-app/
├── package.json
├── main.js
└── index.html
main.js
event based
const {app/*, more */} = require('electron')
function createWindow () { }; // #1
app.on('ready', createWindow); // #1
/** more things related to OS compatibilities */
function createWindow () {
win = new BrowserWindow({width: 800, height: 600})
win.loadURL(url.format({
pathname: path.join(__dirname, 'index.html'),
protocol: 'file:',
slashes: true
}))
win.webContents.openDevTools()
win.on('closed', () => { win = null; });
}
electron .
const alertOnlineStatus = () => {
window.alert(navigator.onLine ? 'online' : 'offline')
}
window.addEventListener('online', alertOnlineStatus)
window.addEventListener('offline', alertOnlineStatus)
const {crashReporter} = require('electron')
crashReporter.start({
productName: 'My App Name',
companyName: 'Corporate',
submitURL: 'https://error.yourcorporate.tld/url-to-submit',
uploadToServer: true
})