2019-02-06 18:27:20 +00:00
|
|
|
import { app, BrowserWindow, BrowserWindowConstructorOptions } from 'electron'
|
|
|
|
import * as path from 'path'
|
2019-01-10 19:54:34 +00:00
|
|
|
|
2019-02-06 18:27:20 +00:00
|
|
|
let mainWindow: BrowserWindow | null = 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
|
|
|
|
2019-02-06 18:27:20 +00:00
|
|
|
export const load = async (appUrl: string) => {
|
2018-09-21 05:24:42 +00:00
|
|
|
await app.whenReady()
|
|
|
|
|
2019-02-06 18:27:20 +00:00
|
|
|
const options: BrowserWindowConstructorOptions = {
|
2018-09-21 05:24:42 +00:00
|
|
|
width: 900,
|
|
|
|
height: 600,
|
|
|
|
autoHideMenuBar: true,
|
|
|
|
backgroundColor: '#FFFFFF',
|
|
|
|
webPreferences: {
|
|
|
|
contextIsolation: true,
|
|
|
|
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)
|
|
|
|
|
2019-02-06 18:27:20 +00:00
|
|
|
mainWindow.on('ready-to-show', () => mainWindow!.show())
|
2018-09-21 05:24:42 +00:00
|
|
|
|
|
|
|
mainWindow.loadURL(appUrl)
|
|
|
|
mainWindow.focus()
|
2016-03-24 20:15:04 +00:00
|
|
|
}
|