UNPKG

metadata-editor-workspace

Version:

Metadata Editor Workspace module for ME-Core Powered by Assyst

228 lines (215 loc) 4.21 kB
/** * Include our app */ const {app, BrowserWindow } = require('electron'); const electron = require('electron'); // browser-window creates a native window let mainWindow = null; app.on('window-all-closed', () => { // On macOS it is common for applications and their menu bar // to stay active until the user quits explicitly with Cmd + Q if (process.platform !== 'darwin') { app.quit(); } }); const createWindow = () => { //Set the webpack distribution path let fPath = __dirname; if(fPath.indexOf('src') != -1) { fPath = fPath.split('\src')[0] + 'dist'; } // Initialize the window to our specified dimensions mainWindow = new BrowserWindow({ width: 1200, height: 900, icon: fPath+'/assets/icon/favicon.ico' }); // Tell Electron where to load the entry point from mainWindow.loadURL('file://' + fPath + '/index.html') /////////////////////////////////// //////// Custome Menu////////////// const {app, Menu} = require('electron') const template = [ { label: 'File', submenu: [ { role: 'quit' }] }, { label: 'Edit', submenu: [ { role: 'undo' }, { role: 'redo' }, { type: 'separator' }, { role: 'cut' }, { role: 'copy' }, { role: 'paste' }, { role: 'pasteandmatchstyle' }, { role: 'delete' }, { role: 'selectall' } ] }, { label: 'View', submenu: [ { role: 'reload' }, { role: 'forcereload' }, { role: 'toggledevtools' }, { type: 'separator' }, { role: 'resetzoom' }, { role: 'zoomin' }, { role: 'zoomout' }, { type: 'separator' }, { role: 'togglefullscreen' } ] }, { role: 'window', submenu: [ { role: 'minimize' }, { role: 'close' } ] }, { role: 'help', submenu: [ { label: 'Learn More', click () { require('electron').shell.openExternal('http://electron.atom.io') } } ] } ] if (process.platform === 'darwin') { template.unshift({ label: app.getName(), submenu: [ { role: 'about' }, { type: 'separator' }, { role: 'services', submenu: [] }, { type: 'separator' }, { role: 'hide' }, { role: 'hideothers' }, { role: 'unhide' }, { type: 'separator' }, { role: 'quit' } ] }) // Edit menu. template[1].submenu.push( { type: 'separator' }, { label: 'Speech', submenu: [ { role: 'startspeaking' }, { role: 'stopspeaking' } ] } ) // Window menu. template[3].submenu = [ { label: 'Close', accelerator: 'CmdOrCtrl+W', role: 'close' }, { label: 'Minimize', accelerator: 'CmdOrCtrl+M', role: 'minimize' }, { label: 'Zoom', role: 'zoom' }, { type: 'separator' }, { label: 'Bring All to Front', role: 'front' } ] } const menu = Menu.buildFromTemplate(template) Menu.setApplicationMenu(menu) /////////////////////////////////// /////////////////////////////////// // Open the DevTools. mainWindow.webContents.openDevTools(); // Clear out the main window when the app is closed mainWindow.on('closed', () => { mainWindow = null; }); }; app.on('ready', createWindow); app.on('activate', () => { // On macOS it's common to re-create a window in the app when the // dock icon is clicked and there are no other windows open. if (mainWindow === null) { createWindow(); } });