import packageInfo from '../package.json' ; import { app , protocol , ipcMain , BrowserWindow } from 'electron' ; import { createProtocol } from 'vue-cli-plugin-electron-builder/lib' ; import { WindowControl } from './utils/main/windowControl' ; import CheckUpdate from './utils/main/CheckUpdate' ; protocol . registerSchemesAsPrivileged ( [ { scheme : 'app' , privileges : { secure : true , standard : true } } ] ) ; const windowControl = new WindowControl ( ) ; const checkUpdate = new CheckUpdate ( ) ; let win = null ; function bindIpc ( ) { ipcMain . on ( 'system' , ( event , type , data ) => { switch ( type ) { case 'check-for-update' : checkUpdate . check ( event , data ) ; break ; case 'update' : checkUpdate . update ( ) ; break ; case 'exit' : app . quit ( ) ; break ; } } ) ; } function createWindow ( ) { win = windowControl . create ( { frame : true , name : 'home' , url : '' , } ) ; } const gotTheLock = app . requestSingleInstanceLock ( ) ; if ( ! gotTheLock ) { app . quit ( ) ; } else { app . on ( 'second-instance' , ( ) => { if ( win ) { win . show ( ) ; } } ) ; app . on ( 'ready' , function ( ) { bindIpc ( ) ; createProtocol ( 'app' ) ; app . setAppUserModelId ( packageInfo . appId ) ; app . commandLine . appendSwitch ( 'autoplay-policy' , 'no-user-gesture-required' ) ; createWindow ( ) ; } ) ; } app . on ( 'window-all-closed' , ( ) => { if ( process . platform !== 'darwin' ) { app . quit ( ) ; } } ) ; app . on ( 'activate' , ( ) => { if ( win === null ) { createWindow ( ) ; } } ) ;