From db468fc09527abb3b79681a605760f2e22717aab Mon Sep 17 00:00:00 2001 From: sota1235 Date: Sat, 22 Apr 2017 11:54:05 +0900 Subject: [PATCH] modify: some refactor --- lib/main-menu.js | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/lib/main-menu.js b/lib/main-menu.js index d96f592f..70a00bc6 100644 --- a/lib/main-menu.js +++ b/lib/main-menu.js @@ -3,11 +3,11 @@ const BrowserWindow = electron.BrowserWindow const shell = electron.shell const mainWindow = require('./main-window') -const OSX = process.platform === 'darwin' +const macOS = process.platform === 'darwin' // const WIN = process.platform === 'win32' const LINUX = process.platform === 'linux' -var boost = OSX +const boost = macOS ? { label: 'Boostnote', submenu: [ @@ -50,13 +50,13 @@ var boost = OSX ] } -var file = { +const file = { label: 'File', submenu: [ { label: 'New Note', accelerator: 'CommandOrControl+N', - click: function () { + click () { mainWindow.webContents.send('top:new-note') } }, @@ -94,8 +94,8 @@ var file = { }, { label: 'Delete Note', - accelerator: OSX ? 'Control+Backspace' : 'Control+Delete', - click: function () { + accelerator: macOS ? 'Control+Backspace' : 'Control+Delete', + click () { mainWindow.webContents.send('detail:delete') } } @@ -105,13 +105,12 @@ var file = { if (LINUX) { file.submenu.push({ type: 'separator' - }) - file.submenu.push({ + }, { role: 'quit' }) } -var edit = { +const edit = { label: 'Edit', submenu: [ { @@ -150,20 +149,20 @@ var edit = { ] } -var view = { +const view = { label: 'View', submenu: [ { label: 'Reload', accelerator: 'CommandOrControl+R', - click: function () { + click() { BrowserWindow.getFocusedWindow().reload() } }, { label: 'Toggle Developer Tools', - accelerator: OSX ? 'Command+Alt+I' : 'Control+Shift+I', - click: function () { + accelerator: macOS ? 'Command+Alt+I' : 'Control+Shift+I', + click() { BrowserWindow.getFocusedWindow().toggleDevTools() } }, @@ -204,7 +203,7 @@ var view = { ] } -var window = { +const window = { label: 'Window', submenu: [ { @@ -227,21 +226,21 @@ var window = { ] } -var help = { +const help = { label: 'Help', role: 'help', submenu: [ { label: 'Boostnote official site', - click: function () { shell.openExternal('https://boostnote.io/') } + click () { shell.openExternal('https://boostnote.io/') } }, { label: 'Issue Tracker', - click: function () { shell.openExternal('https://github.com/BoostIO/Boostnote/issues') } + click () { shell.openExternal('https://github.com/BoostIO/Boostnote/issues') } }, { label: 'Changelog', - click: function () { shell.openExternal('https://github.com/BoostIO/boost-releases') } + click () { shell.openExternal('https://github.com/BoostIO/boost-releases') } } ] }