2021-09-09 09:37:02 +08:00
|
|
|
import path from 'path'
|
2020-08-16 20:42:52 +08:00
|
|
|
import { app, BrowserWindow } from 'electron'
|
2021-09-09 09:37:02 +08:00
|
|
|
import { register } from './communication'
|
2021-02-18 17:29:45 +08:00
|
|
|
|
2021-09-09 09:37:02 +08:00
|
|
|
let win: BrowserWindow | null = null
|
2020-08-16 20:42:52 +08:00
|
|
|
|
2021-09-09 09:37:02 +08:00
|
|
|
function bootstrap() {
|
2020-08-16 20:42:52 +08:00
|
|
|
win = new BrowserWindow({
|
2020-08-31 09:50:57 +08:00
|
|
|
webPreferences: {
|
2021-09-09 09:37:02 +08:00
|
|
|
preload: path.join(__dirname, '../preload/index.js'),
|
2020-08-31 09:50:57 +08:00
|
|
|
},
|
2020-08-16 20:42:52 +08:00
|
|
|
})
|
|
|
|
|
2021-09-09 09:37:02 +08:00
|
|
|
if (app.isPackaged) {
|
|
|
|
win.loadFile(path.join(__dirname, '../render/index.html'))
|
|
|
|
} else {
|
|
|
|
win.maximize()
|
|
|
|
win.webContents.openDevTools()
|
|
|
|
win.loadURL(`http://localhost:${process.env.PORT}`)
|
|
|
|
}
|
2020-08-16 20:42:52 +08:00
|
|
|
|
2021-09-09 09:37:02 +08:00
|
|
|
// something init setup
|
|
|
|
register(win)
|
2020-08-16 20:42:52 +08:00
|
|
|
}
|
|
|
|
|
2021-09-09 09:37:02 +08:00
|
|
|
app.whenReady().then(bootstrap)
|
|
|
|
|
|
|
|
app.on('window-all-closed', () => { win = null })
|