import { app , BrowserWindow , Menu } from 'electron' ; const dev = process . env . NODE_ENV === 'development' ; const path = require ( 'path' ) ; const url = require ( 'url' ) ; const fixPath = require ( 'fix-path' ) ; const MainMenu = require ( './mainMenu' ) ; require ( './channels' ) ; fixPath ( ) ; let mainWindow ; function createWindow ( ) { mainWindow = new BrowserWindow ( { width : 1800 , height : 1400 , minWidth : 900 , minHeight : 720 , title : 'SeeQR' , show : false , webPreferences : { nodeIntegration : true , enableRemoteModule : true } , icon : path . join ( __dirname , '../../assets/logo/seeqr_dock.png' ) , } ) ; if ( process . platform === 'darwin' ) { app . dock . setIcon ( path . join ( __dirname , '../../assets/logo/seeqr_dock.png' ) ) ; } let indexPath ; if ( dev ) { indexPath = url . format ( { protocol : 'http:' , host : 'localhost:8080' , pathname : 'index.html' , slashes : true , } ) ; Menu . setApplicationMenu ( Menu . buildFromTemplate ( MainMenu ) ) ; } else { indexPath = url . format ( { protocol : 'file:' , pathname : path . join ( __dirname , '../../dist' , 'index.html' ) , slashes : true , } ) ; } mainWindow . loadURL ( indexPath ) ; mainWindow . once ( 'ready-to-show' , ( ) => { if ( mainWindow ) mainWindow . show ( ) ; } ) ; } if ( dev ) { const { default : installExtension , REACT_DEVELOPER_TOOLS , } = require ( 'electron-devtools-installer' ) ; app . on ( 'ready' , ( ) => { installExtension ( REACT_DEVELOPER_TOOLS ) ; } ) ; } app . on ( 'ready' , createWindow ) ; app . on ( 'window-all-closed' , ( ) => { if ( process . platform !== 'darwin' ) { app . quit ( ) ; } else { mainWindow = null ; } } ) ; app . on ( 'activate' , ( ) => { if ( mainWindow === null ) { createWindow ( ) ; } } ) ;