Files
Exiled-Exchange-2/src/background.ts
T

56 lines
1.8 KiB
TypeScript

'use strict'
import { app, protocol } from 'electron'
import { installVueDevtools } from 'vue-cli-plugin-electron-builder/lib'
import ioHook from 'iohook'
import { setupShortcuts } from './main/shortcuts'
import { setupWindowManager } from './main/window-manager'
import { createTray } from './main/tray'
import { createWindow } from './main/window'
import { setupShowHide } from './main/positioning'
import { setupConfig } from './main/config'
const isDevelopment = process.env.NODE_ENV !== 'production'
// Scheme must be registered before the app is ready
protocol.registerSchemesAsPrivileged([{ scheme: 'app', privileges: { secure: true, standard: true } }])
app.on('ready', async () => {
if (isDevelopment && !process.env.IS_TEST) {
// Install Vue Devtools
// Devtools extensions are broken in Electron 6.0.0 and greater
// See https://github.com/nklayman/vue-cli-plugin-electron-builder/issues/378 for more info
// Electron will not launch with Devtools extensions installed on Windows 10 with dark mode
// If you are not using Windows 10 dark mode, you may uncomment these lines
// In addition, if the linked issue is closed, you can upgrade electron and uncomment these lines
try {
await installVueDevtools()
} catch (e) {
console.error('Vue Devtools failed to install:', e.toString())
}
}
await setupWindowManager()
setupConfig()
setupShowHide()
createWindow()
createTray()
setupShortcuts()
})
// Exit cleanly on request from parent process in development mode.
if (isDevelopment) {
if (process.platform === 'win32') {
process.on('message', data => {
if (data === 'graceful-exit') {
ioHook.stop()
app.quit()
}
})
} else {
process.on('SIGTERM', () => {
ioHook.stop()
app.quit()
})
}
}