mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-15 10:46:32 +00:00
add quit option to menu & fix sudden app quit caused by finder-window
This commit is contained in:
@@ -36,8 +36,10 @@ nodeIpc.connectTo(
|
|||||||
'disconnect',
|
'disconnect',
|
||||||
function () {
|
function () {
|
||||||
nodeIpc.log('<< disconnected from main'.notice)
|
nodeIpc.log('<< disconnected from main'.notice)
|
||||||
appQuit = true
|
if (process.platform === 'darwin') {
|
||||||
app.quit()
|
appQuit = true
|
||||||
|
app.quit()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
nodeIpc.of.main.on(
|
nodeIpc.of.main.on(
|
||||||
@@ -95,9 +97,11 @@ finderWindow.on('blur', function () {
|
|||||||
})
|
})
|
||||||
|
|
||||||
finderWindow.on('close', function (e) {
|
finderWindow.on('close', function (e) {
|
||||||
if (appQuit) return true
|
if (process.platform === 'darwin') {
|
||||||
e.preventDefault()
|
if (appQuit) return true
|
||||||
finderWindow.hide()
|
e.preventDefault()
|
||||||
|
finderWindow.hide()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
var appIcon = new Tray(path.join(__dirname, '../resources/tray-icon.png'))
|
var appIcon = new Tray(path.join(__dirname, '../resources/tray-icon.png'))
|
||||||
|
|||||||
23
main.js
23
main.js
@@ -56,7 +56,7 @@ var handleStartupEvent = function () {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
var squirrelCommand = process.argv[1];
|
var squirrelCommand = process.argv[1]
|
||||||
switch (squirrelCommand) {
|
switch (squirrelCommand) {
|
||||||
case '--squirrel-install':
|
case '--squirrel-install':
|
||||||
spawnUpdate(['--createShortcut', exeName], function (err) {
|
spawnUpdate(['--createShortcut', exeName], function (err) {
|
||||||
@@ -228,8 +228,24 @@ app.on('ready', function () {
|
|||||||
})
|
})
|
||||||
|
|
||||||
var template = require('./atom-lib/menu-template')
|
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)
|
var menu = Menu.buildFromTemplate(template)
|
||||||
Menu.setApplicationMenu(menu)
|
if (process.platform === 'darwin') {
|
||||||
|
Menu.setApplicationMenu(menu)
|
||||||
|
}
|
||||||
|
|
||||||
if (process.platform === 'darwin') {
|
if (process.platform === 'darwin') {
|
||||||
setInterval(function () {
|
setInterval(function () {
|
||||||
@@ -268,6 +284,9 @@ app.on('ready', function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mainWindow = require('./atom-lib/main-window')
|
mainWindow = require('./atom-lib/main-window')
|
||||||
|
if (process.platform === 'win32') {
|
||||||
|
mainWindow.setMenu(menu)
|
||||||
|
}
|
||||||
mainWindow.on('close', function (e) {
|
mainWindow.on('close', function (e) {
|
||||||
if (appQuit) return true
|
if (appQuit) return true
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
|
|||||||
Reference in New Issue
Block a user