simplify index.js
This commit is contained in:
53
index.js
53
index.js
@@ -3,14 +3,13 @@ var path = require('path')
|
|||||||
|
|
||||||
var app = electron.app
|
var app = electron.app
|
||||||
|
|
||||||
// report crashes to the Electron project
|
// report crashes
|
||||||
require('crash-reporter').start({
|
// require('crash-reporter').start({
|
||||||
// TODO: collect crash reports
|
// productName: 'WebTorrent',
|
||||||
// productName: 'WebTorrent',
|
// companyName: 'WebTorrent',
|
||||||
// companyName: 'WebTorrent',
|
// submitURL: 'https://webtorrent.io/crash-report',
|
||||||
// submitURL: 'https://webtorrent.io/crash-report',
|
// autoSubmit: true
|
||||||
// autoSubmit: true
|
// })
|
||||||
})
|
|
||||||
|
|
||||||
// adds debug features like hotkeys for triggering dev tools and reload
|
// adds debug features like hotkeys for triggering dev tools and reload
|
||||||
require('electron-debug')()
|
require('electron-debug')()
|
||||||
@@ -18,36 +17,26 @@ require('electron-debug')()
|
|||||||
// prevent window being garbage collected
|
// prevent window being garbage collected
|
||||||
var mainWindow
|
var mainWindow
|
||||||
|
|
||||||
function onClosed () {
|
app.on('ready', function () {
|
||||||
// dereference the window
|
mainWindow = createMainWindow()
|
||||||
// for multiple windows store them in an array
|
})
|
||||||
mainWindow = null
|
|
||||||
}
|
app.on('activate', function () {
|
||||||
|
if (!mainWindow) mainWindow = createMainWindow()
|
||||||
|
})
|
||||||
|
|
||||||
|
app.on('window-all-closed', function () {
|
||||||
|
if (process.platform !== 'darwin') app.quit()
|
||||||
|
})
|
||||||
|
|
||||||
function createMainWindow () {
|
function createMainWindow () {
|
||||||
const win = new electron.BrowserWindow({
|
const win = new electron.BrowserWindow({
|
||||||
width: 600,
|
width: 600,
|
||||||
height: 400
|
height: 400
|
||||||
})
|
})
|
||||||
|
|
||||||
win.loadURL('file://' + path.join(__dirname, 'index.html'))
|
win.loadURL('file://' + path.join(__dirname, 'index.html'))
|
||||||
win.on('closed', onClosed)
|
win.once('closed', function () {
|
||||||
|
mainWindow = null
|
||||||
|
})
|
||||||
return win
|
return win
|
||||||
}
|
}
|
||||||
|
|
||||||
app.on('window-all-closed', () => {
|
|
||||||
if (process.platform !== 'darwin') {
|
|
||||||
app.quit()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
app.on('activate', () => {
|
|
||||||
if (!mainWindow) {
|
|
||||||
mainWindow = createMainWindow()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
app.on('ready', () => {
|
|
||||||
mainWindow = createMainWindow()
|
|
||||||
})
|
|
||||||
|
|||||||
Reference in New Issue
Block a user