37 lines
872 B
TypeScript
37 lines
872 B
TypeScript
import { app, WebContents, RenderProcessGoneDetails } from 'electron'
|
|
import Constants from './utils/Constants'
|
|
import { createErrorWindow, createMainWindow } from './MainRunner'
|
|
import Menus from './utils/Menus'
|
|
|
|
let mainWindow
|
|
let errorWindow
|
|
|
|
app.on('ready', () => {
|
|
Menus.macOSDisableDefaultMenuItem()
|
|
|
|
mainWindow = createMainWindow(mainWindow)
|
|
})
|
|
|
|
app.on('activate', () => {
|
|
if (!mainWindow) {
|
|
mainWindow = createMainWindow(mainWindow)
|
|
}
|
|
})
|
|
|
|
app.on('window-all-closed', () => {
|
|
mainWindow = null
|
|
errorWindow = null
|
|
|
|
if (!Constants.IS_MAC) {
|
|
app.quit()
|
|
}
|
|
})
|
|
|
|
app.on('render-process-gone', (event: Event, webContents: WebContents, details: RenderProcessGoneDetails) => {
|
|
errorWindow = createErrorWindow(errorWindow, mainWindow, details)
|
|
})
|
|
|
|
process.on('uncaughtException', () => {
|
|
errorWindow = createErrorWindow(errorWindow, mainWindow)
|
|
})
|