2019-02-06 10:27:20 -08:00
|
|
|
import { app, BrowserWindow, BrowserWindowConstructorOptions } from 'electron'
|
|
|
|
import * as path from 'path'
|
2019-01-10 20:54:34 +01:00
|
|
|
|
2019-02-06 10:27:20 -08:00
|
|
|
let mainWindow: BrowserWindow | null = null
|
2013-07-17 16:21:33 +08:00
|
|
|
|
|
|
|
// Quit when all windows are closed.
|
2016-05-06 17:53:50 -06:00
|
|
|
app.on('window-all-closed', () => {
|
2016-03-24 13:15:04 -07:00
|
|
|
app.quit()
|
|
|
|
})
|
2013-07-17 16:21:33 +08:00
|
|
|
|
2019-02-06 10:27:20 -08:00
|
|
|
export const load = async (appUrl: string) => {
|
2018-09-21 15:24:42 +10:00
|
|
|
await app.whenReady()
|
|
|
|
|
2019-02-06 10:27:20 -08:00
|
|
|
const options: BrowserWindowConstructorOptions = {
|
2018-09-21 15:24:42 +10: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 10:27:20 -08:00
|
|
|
mainWindow.on('ready-to-show', () => mainWindow!.show())
|
2018-09-21 15:24:42 +10:00
|
|
|
|
|
|
|
mainWindow.loadURL(appUrl)
|
|
|
|
mainWindow.focus()
|
2016-03-24 13:15:04 -07:00
|
|
|
}
|