67
src/MenuTemplate.ts
Normal file
67
src/MenuTemplate.ts
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
import { Menu, app } from 'electron'
|
||||||
|
|
||||||
|
const applicationMenu = {
|
||||||
|
label: 'Application',
|
||||||
|
submenu: [
|
||||||
|
{
|
||||||
|
label: 'About Application',
|
||||||
|
selector: 'orderFrontStandardAboutPanel:',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'separator' as 'separator',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Quit',
|
||||||
|
accelerator: 'Command+Q',
|
||||||
|
click: () => {
|
||||||
|
app.quit()
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|
||||||
|
const editMenu = {
|
||||||
|
label: 'Edit',
|
||||||
|
submenu: [
|
||||||
|
{
|
||||||
|
label: 'Undo',
|
||||||
|
accelerator: 'CmdOrCtrl+Z',
|
||||||
|
selector: 'undo:',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Redo',
|
||||||
|
accelerator: 'Shift+CmdOrCtrl+Z',
|
||||||
|
selector: 'redo:',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'separator' as 'separator',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Cut',
|
||||||
|
accelerator: 'CmdOrCtrl+X',
|
||||||
|
selector: 'cut:',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Copy',
|
||||||
|
accelerator: 'CmdOrCtrl+C',
|
||||||
|
selector: 'copy:',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Paste',
|
||||||
|
accelerator: 'CmdOrCtrl+V',
|
||||||
|
selector: 'paste:',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Select All',
|
||||||
|
accelerator: 'CmdOrCtrl+A',
|
||||||
|
selector: 'selectAll:',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|
||||||
|
const template = [
|
||||||
|
applicationMenu,
|
||||||
|
editMenu,
|
||||||
|
]
|
||||||
|
|
||||||
|
export const menuTemplate = Menu.buildFromTemplate(template)
|
||||||
@@ -1,17 +1,15 @@
|
|||||||
import { UpdateInfo } from '../events'
|
import { UpdateInfo } from '../events'
|
||||||
import { BrowserWindow, app } from 'electron'
|
import { BrowserWindow, app, Menu } from 'electron'
|
||||||
import * as path from 'path'
|
import * as path from 'path'
|
||||||
import * as fs from 'fs'
|
import { menuTemplate } from './MenuTemplate'
|
||||||
|
import { autoUpdater } from 'electron-updater'
|
||||||
const { autoUpdater } = require('electron-updater')
|
import * as log from 'electron-log'
|
||||||
const log = require('electron-log')
|
|
||||||
import { ConnectionManager, updateNotifier } from '../backend/src/index'
|
import { ConnectionManager, updateNotifier } from '../backend/src/index'
|
||||||
|
|
||||||
const isDebugEnabled = Boolean(process.argv.find(arg => arg === 'debug'))
|
const isDebugEnabled = Boolean(process.argv.find(arg => arg === 'debug'))
|
||||||
require('electron-debug')({ enabled: isDebugEnabled })
|
require('electron-debug')({ enabled: isDebugEnabled })
|
||||||
|
|
||||||
autoUpdater.logger = log
|
autoUpdater.logger = log
|
||||||
autoUpdater.logger.transports.file.level = 'info'
|
|
||||||
log.info('App starting...')
|
log.info('App starting...')
|
||||||
|
|
||||||
const connectionManager = new ConnectionManager()
|
const connectionManager = new ConnectionManager()
|
||||||
@@ -33,7 +31,7 @@ function createWindow() {
|
|||||||
icon: iconPath,
|
icon: iconPath,
|
||||||
})
|
})
|
||||||
|
|
||||||
console.log(iconPath)
|
console.log('icon path', iconPath)
|
||||||
// and load the index.html of the app.
|
// and load the index.html of the app.
|
||||||
mainWindow.loadFile('app/index.html')
|
mainWindow.loadFile('app/index.html')
|
||||||
|
|
||||||
@@ -56,6 +54,7 @@ function createWindow() {
|
|||||||
// initialization and is ready to create browser windows.
|
// initialization and is ready to create browser windows.
|
||||||
// Some APIs can only be used after this event occurs.
|
// Some APIs can only be used after this event occurs.
|
||||||
app.on('ready', () => {
|
app.on('ready', () => {
|
||||||
|
Menu.setApplicationMenu(menuTemplate)
|
||||||
createWindow()
|
createWindow()
|
||||||
|
|
||||||
let updateInfo: UpdateInfo
|
let updateInfo: UpdateInfo
|
||||||
|
|||||||
Reference in New Issue
Block a user