import { app , BrowserWindow , Menu , shell } from 'electron' ; import * as path from 'path' ; import * as url from 'url' ; import * as defaultMenu from 'electron-default-menu' ; let mainWindow ; function createWindow ( ) { const appUrl = url . format ( { pathname : path . join ( __dirname , 'index.html' ) , protocol : 'file:' , slashes : true , } ) ; mainWindow = new BrowserWindow ( { width : 1000 , height : 600 } ) ; mainWindow . loadURL ( appUrl ) ; mainWindow . on ( 'closed' , ( ) => ( mainWindow = null ) ) ; Menu . setApplicationMenu ( Menu . buildFromTemplate ( createMenu ( ) ) ) ; } function createMenu ( ) { const menu = defaultMenu ( app , shell ) ; return menu ; } app . on ( 'ready' , createWindow ) ; app . on ( 'window-all-closed' , ( ) => { app . quit ( ) ; } ) ; app . on ( 'activate' , ( ) => { if ( mainWindow === null ) { createWindow ( ) ; } } ) ;