'use strict' ; import { app , protocol , BrowserWindow } from 'electron' ; import { createProtocol } from 'vue-cli-plugin-electron-builder/lib' ; import installExtension , { VUEJS_DEVTOOLS } from 'electron-devtools-installer' ; import { autoUpdater } from 'electron-updater' ; import path from 'path' ; import ElectronMain from '@/electronMain/electronMain' ; const isDevelopment = process . env . NODE_ENV !== 'production' ; protocol . registerSchemesAsPrivileged ( [ { scheme : 'app' , privileges : { secure : true , standard : true } } ] ) ; async function createWindow ( ) { const win = new BrowserWindow ( { width : 800 , height : 600 , minWidth : 800 , minHeight : 600 , webPreferences : { nodeIntegration : ( process . env . ELECTRON_NODE_INTEGRATION as unknown ) as boolean , enableRemoteModule : true } , icon : path . join ( __static , 'icon.png' ) } ) ; win . setMenuBarVisibility ( false ) ; const electronMain = new ElectronMain ( app ) ; if ( process . env . WEBPACK_DEV_SERVER_URL ) { await win . loadURL ( process . env . WEBPACK_DEV_SERVER_URL as string ) ; if ( ! process . env . IS_TEST ) win . webContents . openDevTools ( ) ; } else { createProtocol ( 'app' ) ; win . loadURL ( 'app://./index.html' ) ; autoUpdater . checkForUpdatesAndNotify ( ) ; } } app . on ( 'window-all-closed' , ( ) => { if ( process . platform !== 'darwin' ) { app . quit ( ) ; } } ) ; app . on ( 'activate' , ( ) => { if ( BrowserWindow . getAllWindows ( ) . length === 0 ) createWindow ( ) ; } ) ; app . on ( 'ready' , async ( ) => { if ( isDevelopment && ! process . env . IS_TEST ) { try { await installExtension ( VUEJS_DEVTOOLS ) ; } catch ( e ) { console . error ( 'Vue Devtools failed to install:' , e . toString ( ) ) ; } } createWindow ( ) ; } ) ; if ( isDevelopment ) { if ( process . platform === 'win32' ) { process . on ( 'message' , ( data ) => { if ( data === 'graceful-exit' ) { app . quit ( ) ; } } ) ; } else { process . on ( 'SIGTERM' , ( ) => { app . quit ( ) ; } ) ; } }