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

Disable Finder and Auto-update on Linux

This commit is contained in:
Dick Choi
2016-04-07 08:19:04 +09:00
parent 1ca38b8741
commit cfa251b158

View File

@@ -16,14 +16,11 @@ var finderProcess = null
var finderWindow = null
var update = null
// app.on('window-all-closed', function () {
// if (process.platform !== 'darwin') app.quit()
// })
const appRootPath = path.join(process.execPath, '../..')
const updateDotExePath = path.join(appRootPath, 'Update.exe')
const exeName = path.basename(process.execPath)
// For windows app
function spawnUpdate (args, cb) {
var stdout = ''
var updateProcess = null
@@ -162,15 +159,6 @@ nodeIpc.config.id = 'node'
nodeIpc.config.retry = 1500
nodeIpc.config.silent = true
function spawnFinder() {
if (process.platform === 'darwin') {
var finderArgv = [path.join(__dirname, 'finder-app.js'), '--finder']
if (_.find(process.argv, a => a === '--hot')) finderArgv.push('--hot')
finderProcess = ChildProcess
.execFile(process.execPath, finderArgv)
}
}
nodeIpc.serve(
path.join(app.getPath('userData'), 'boost.service'),
function () {
@@ -187,7 +175,7 @@ nodeIpc.serve(
'message',
function (data, socket) {
console.log('>>', data)
format(data)
handleIpcEvent(data)
}
)
nodeIpc.server.on(
@@ -199,14 +187,18 @@ nodeIpc.serve(
}
)
function format (payload) {
function handleIpcEvent (payload) {
switch (payload.type) {
case 'show-main-window':
if (process.platform === 'darwin') {
mainWindow.show()
} else {
mainWindow.minimize()
mainWindow.restore()
switch (process.platform) {
case 'darwin':
mainWindow.show()
case 'win32':
mainWindow.minimize()
mainWindow.restore()
case 'linux':
// Do nothing
// due to bug of `app.focus()` some desktop Env
}
break
case 'copy-finder':
@@ -218,6 +210,15 @@ function format (payload) {
}
}
function spawnFinder() {
if (process.platform === 'darwin') {
var finderArgv = [path.join(__dirname, 'finder-app.js'), '--finder']
if (_.find(process.argv, a => a === '--hot')) finderArgv.push('--hot')
finderProcess = ChildProcess
.execFile(process.execPath, finderArgv)
}
}
function quitApp () {
appQuit = true
if (finderProcess) finderProcess.kill()
@@ -226,7 +227,6 @@ function quitApp () {
app.on('ready', function () {
app.on('before-quit', function () {
console.log('before quite')
appQuit = true
if (finderProcess) finderProcess.kill()
})
@@ -247,7 +247,7 @@ app.on('ready', function () {
})
}
var menu = Menu.buildFromTemplate(template)
if (process.platform === 'darwin') {
if (process.platform === 'darwin' || process.platform === 'linux') {
Menu.setApplicationMenu(menu)
}
@@ -273,21 +273,22 @@ app.on('ready', function () {
mainWindow.setMenu(menu)
}
mainWindow.on('close', function (e) {
if (appQuit) return true
e.preventDefault()
mainWindow.hide()
app.quit()
})
if (finderProcess == null && process.platform === 'darwin') {
spawnFinder()
} else {
finderWindow = require('./finder-window')
finderWindow.on('close', function (e) {
if (appQuit) return true
e.preventDefault()
finderWindow.hide()
})
switch (process.platform) {
case 'darwin':
spawnFinder()
break
case 'win32':
finderWindow = require('./finder-window')
finderWindow.on('close', function (e) {
if (appQuit) return true
e.preventDefault()
finderWindow.hide()
})
break
case 'linux':
// Do nothing.
}
nodeIpc.server.start(function (err) {