import { app , protocol , BrowserWindow } from 'electron' ; import { platform } from 'os' ; import { createProtocol , installVueDevtools , } from 'vue-cli-plugin-electron-builder/lib' ; const isDevelopment = process . env . NODE_ENV !== 'production' ; let win ; protocol . registerSchemesAsPrivileged ( [ { scheme : 'app' , privileges : { secure : true , standard : true } } , ] ) ; function createWindow ( ) { let options = { width : 1280 , height : 720 , frame : false , backgroundColor : '#FFF' , webPreferences : { nodeIntegration : true , nodeIntegrationInWorker : true , enableRemoteModule : true , spellcheck : false , } , } as Electron . BrowserWindowConstructorOptions ; options = platform ( ) === 'darwin' ? ( options = { ... options , titleBarStyle : 'hiddenInset' } ) : ( options = { ... options , frame : false } ) ; win = new BrowserWindow ( options ) ; if ( process . env . WEBPACK_DEV_SERVER_URL ) { 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' ) ; } win . on ( 'rotate-gesture' , ( e , rotation ) => { win . webContents . send ( 'rotate-gesture' , rotation ) ; } ) ; } app . on ( 'window-all-closed' , ( ) => { app . quit ( ) ; } ) ; app . on ( 'activate' , ( ) => { if ( ! win ) { createWindow ( ) ; } } ) ; app . on ( 'ready' , async ( ) => { if ( isDevelopment && ! process . env . IS_TEST ) { try { await installVueDevtools ( ) ; } 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 ( ) ; } ) ; } }