1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 09:46:22 +00:00

add quit option to menu & fix sudden app quit caused by finder-window

This commit is contained in:
Dick Choi
2015-12-22 20:17:40 +09:00
committed by Rokt33r
parent 1a527cca10
commit ae1fc7572a
2 changed files with 30 additions and 7 deletions

View File

@@ -36,8 +36,10 @@ nodeIpc.connectTo(
'disconnect',
function () {
nodeIpc.log('<< disconnected from main'.notice)
appQuit = true
app.quit()
if (process.platform === 'darwin') {
appQuit = true
app.quit()
}
}
)
nodeIpc.of.main.on(
@@ -95,9 +97,11 @@ finderWindow.on('blur', function () {
})
finderWindow.on('close', function (e) {
if (appQuit) return true
e.preventDefault()
finderWindow.hide()
if (process.platform === 'darwin') {
if (appQuit) return true
e.preventDefault()
finderWindow.hide()
}
})
var appIcon = new Tray(path.join(__dirname, '../resources/tray-icon.png'))

23
main.js
View File

@@ -56,7 +56,7 @@ var handleStartupEvent = function () {
return false
}
var squirrelCommand = process.argv[1];
var squirrelCommand = process.argv[1]
switch (squirrelCommand) {
case '--squirrel-install':
spawnUpdate(['--createShortcut', exeName], function (err) {
@@ -228,8 +228,24 @@ app.on('ready', function () {
})
var template = require('./atom-lib/menu-template')
if (process.platform === 'win32') {
template.unshift({
label: 'Boostnote',
submenu: [
{
label: 'Quit',
accelerator: 'Control+Q',
click: function (e) {
quitApp()
}
}
]
})
}
var menu = Menu.buildFromTemplate(template)
Menu.setApplicationMenu(menu)
if (process.platform === 'darwin') {
Menu.setApplicationMenu(menu)
}
if (process.platform === 'darwin') {
setInterval(function () {
@@ -268,6 +284,9 @@ app.on('ready', function () {
}
mainWindow = require('./atom-lib/main-window')
if (process.platform === 'win32') {
mainWindow.setMenu(menu)
}
mainWindow.on('close', function (e) {
if (appQuit) return true
e.preventDefault()