import { BrowserWindow , Menu } from 'electron' ; import path from 'path' ; import { autoUpdater } from 'electron-updater' ; import { isDarwin , isWindows } from '../helpers/env' ; import packageJson from '../../package.json' ; class TrayMenu { tray = null ; constructor ( tray ) { this . tray = tray ; } getMenu ( ) { return Menu . buildFromTemplate ( [ { label : 'Toggle window' , click : ( ) => { this . tray . toggleWindow ( ) ; } , } , { label : 'Check for update...' , click : ( ) => { autoUpdater . checkForUpdates ( ) ; } , } , { label : 'About CoinWatch' , click ( ) { if ( ! isWindows ) { let aboutWindow = new BrowserWindow ( { width : 200 , height : 200 , show : false , autoHideMenuBar : true , resizable : true , webPreferences : { nodeIntegration : true , } , } ) ; aboutWindow . on ( 'closed' , ( ) => { aboutWindow = null ; } ) ; const basePath = path . join ( __dirname , process . env . NODE_ENV === 'development' ? '/..' : '' ) ; aboutWindow . loadURL ( `file://${ basePath }/windows/about/about.html` ) ; aboutWindow . once ( 'ready-to-show' , ( ) => { aboutWindow . webContents . send ( 'get-version' , packageJson . version ) ; aboutWindow . show ( ) ; if ( process . env . NODE_ENV === 'development' || process . env . DEBUG_PROD === 'true' ) { } } ) ; } } , } , { type : 'separator' , } , { label : 'Quit' , accelerator : isDarwin ? 'Command+Q' : 'Alt+F4' , role : 'quit' , } , ] ) ; } } export default TrayMenu ;