import { app , crashReporter } from 'electron' ; import EncodingDown from 'encoding-down' ; import * as fs from 'fs' ; import LevelDOWN from 'leveldown' ; import LevelUp from 'levelup' ; import * as path from 'path' ; import { apiHost , dataPath , dbPath , isDev , logPath , lvPath } from '@/config' ; import { Database } from '@/../types' ; import { Bootstrap } from '@/Bootstrap' ; import { logger } from '@/utils' ; crashReporter . start ( { productName : 'electron-vue-typescript' , companyName : 'yourcompany' , submitURL : `${ apiHost }/crash` , uploadToServer : true , } ) ; if ( ! fs . existsSync ( dataPath ) ) { fs . mkdirSync ( dataPath , '0707' ) ; } if ( ! fs . existsSync ( dbPath ) ) { fs . mkdirSync ( dbPath , '0707' ) ; } const db = LevelUp ( EncodingDown ( LevelDOWN ( lvPath ) , { valueEncoding : 'json' } ) ) ; global . db = db ; global . logPath = logPath ; global . appPath = isDev ? path . resolve ( __dirname , '..' , '..' ) : app . getAppPath ( ) ; const system = new Bootstrap ( db ) ; const gotTheLock = app . requestSingleInstanceLock ( ) ; if ( gotTheLock ) { app . on ( 'second-instance' , ( ) => { if ( system . mainWindow ) { if ( system . mainWindow . isMinimized ( ) ) { system . mainWindow . restore ( ) ; } system . mainWindow . focus ( ) ; } } ) ; } else { app . quit ( ) ; } logger . info ( 'Running...' ) ; app . allowRendererProcessReuse = true ; app . on ( 'ready' , system . ready ) ; app . on ( 'window-all-closed' , ( ) => { if ( process . platform !== 'darwin' ) { app . quit ( ) ; } } ) ; app . on ( 'activate' , ( ) => { if ( system . mainWindow === null ) { system . ready ( ) ; } } ) ;