1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-14 02:06:29 +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 finderWindow = null
var update = null var update = null
// app.on('window-all-closed', function () {
// if (process.platform !== 'darwin') app.quit()
// })
const appRootPath = path.join(process.execPath, '../..') const appRootPath = path.join(process.execPath, '../..')
const updateDotExePath = path.join(appRootPath, 'Update.exe') const updateDotExePath = path.join(appRootPath, 'Update.exe')
const exeName = path.basename(process.execPath) const exeName = path.basename(process.execPath)
// For windows app
function spawnUpdate (args, cb) { function spawnUpdate (args, cb) {
var stdout = '' var stdout = ''
var updateProcess = null var updateProcess = null
@@ -162,15 +159,6 @@ nodeIpc.config.id = 'node'
nodeIpc.config.retry = 1500 nodeIpc.config.retry = 1500
nodeIpc.config.silent = true 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( nodeIpc.serve(
path.join(app.getPath('userData'), 'boost.service'), path.join(app.getPath('userData'), 'boost.service'),
function () { function () {
@@ -187,7 +175,7 @@ nodeIpc.serve(
'message', 'message',
function (data, socket) { function (data, socket) {
console.log('>>', data) console.log('>>', data)
format(data) handleIpcEvent(data)
} }
) )
nodeIpc.server.on( nodeIpc.server.on(
@@ -199,14 +187,18 @@ nodeIpc.serve(
} }
) )
function format (payload) { function handleIpcEvent (payload) {
switch (payload.type) { switch (payload.type) {
case 'show-main-window': case 'show-main-window':
if (process.platform === 'darwin') { switch (process.platform) {
mainWindow.show() case 'darwin':
} else { mainWindow.show()
mainWindow.minimize() case 'win32':
mainWindow.restore() mainWindow.minimize()
mainWindow.restore()
case 'linux':
// Do nothing
// due to bug of `app.focus()` some desktop Env
} }
break break
case 'copy-finder': 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 () { function quitApp () {
appQuit = true appQuit = true
if (finderProcess) finderProcess.kill() if (finderProcess) finderProcess.kill()
@@ -226,7 +227,6 @@ function quitApp () {
app.on('ready', function () { app.on('ready', function () {
app.on('before-quit', function () { app.on('before-quit', function () {
console.log('before quite')
appQuit = true appQuit = true
if (finderProcess) finderProcess.kill() if (finderProcess) finderProcess.kill()
}) })
@@ -247,7 +247,7 @@ app.on('ready', function () {
}) })
} }
var menu = Menu.buildFromTemplate(template) var menu = Menu.buildFromTemplate(template)
if (process.platform === 'darwin') { if (process.platform === 'darwin' || process.platform === 'linux') {
Menu.setApplicationMenu(menu) Menu.setApplicationMenu(menu)
} }
@@ -273,21 +273,22 @@ app.on('ready', function () {
mainWindow.setMenu(menu) mainWindow.setMenu(menu)
} }
mainWindow.on('close', function (e) { mainWindow.on('close', function (e) {
if (appQuit) return true app.quit()
e.preventDefault()
mainWindow.hide()
}) })
switch (process.platform) {
if (finderProcess == null && process.platform === 'darwin') { case 'darwin':
spawnFinder() spawnFinder()
} else { break
finderWindow = require('./finder-window') case 'win32':
finderWindow = require('./finder-window')
finderWindow.on('close', function (e) { finderWindow.on('close', function (e) {
if (appQuit) return true if (appQuit) return true
e.preventDefault() e.preventDefault()
finderWindow.hide() finderWindow.hide()
}) })
break
case 'linux':
// Do nothing.
} }
nodeIpc.server.start(function (err) { nodeIpc.server.start(function (err) {