2018-09-27 15:33:31 +00:00
|
|
|
const { app, BrowserWindow, systemPreferences } = require('electron')
|
2016-07-06 18:47:21 +00:00
|
|
|
const path = require('path')
|
2013-07-17 08:21:33 +00:00
|
|
|
|
2016-07-06 18:47:21 +00:00
|
|
|
let mainWindow = null
|
2013-07-17 08:21:33 +00:00
|
|
|
|
|
|
|
// Quit when all windows are closed.
|
2016-05-06 23:53:50 +00:00
|
|
|
app.on('window-all-closed', () => {
|
2016-03-24 20:15:04 +00:00
|
|
|
app.quit()
|
|
|
|
})
|
2013-07-17 08:21:33 +00:00
|
|
|
|
2018-09-21 05:24:42 +00:00
|
|
|
exports.load = async (appUrl) => {
|
|
|
|
await app.whenReady()
|
|
|
|
|
2018-09-27 15:33:31 +00:00
|
|
|
if (process.platform === 'darwin') {
|
|
|
|
systemPreferences.startAppLevelAppearanceTrackingOS()
|
|
|
|
}
|
|
|
|
|
2018-09-21 05:24:42 +00:00
|
|
|
const options = {
|
|
|
|
width: 900,
|
|
|
|
height: 600,
|
|
|
|
autoHideMenuBar: true,
|
|
|
|
backgroundColor: '#FFFFFF',
|
|
|
|
webPreferences: {
|
|
|
|
contextIsolation: true,
|
|
|
|
nodeIntegration: false,
|
|
|
|
preload: path.resolve(__dirname, 'renderer.js'),
|
|
|
|
webviewTag: false
|
|
|
|
},
|
|
|
|
useContentSize: true,
|
|
|
|
show: false
|
|
|
|
}
|
|
|
|
|
|
|
|
if (process.platform === 'linux') {
|
|
|
|
options.icon = path.join(__dirname, 'icon.png')
|
|
|
|
}
|
|
|
|
|
|
|
|
mainWindow = new BrowserWindow(options)
|
|
|
|
|
|
|
|
mainWindow.on('ready-to-show', () => mainWindow.show())
|
|
|
|
|
|
|
|
mainWindow.loadURL(appUrl)
|
|
|
|
mainWindow.focus()
|
2016-03-24 20:15:04 +00:00
|
|
|
}
|