@@ -16,14 +16,11 @@ var finderProcess = null
1616var finderWindow = null
1717var update = null
1818
19- // app.on('window-all-closed', function () {
20- // if (process.platform !== 'darwin') app.quit()
21- // })
22-
2319const appRootPath = path . join ( process . execPath , '../..' )
2420const updateDotExePath = path . join ( appRootPath , 'Update.exe' )
2521const exeName = path . basename ( process . execPath )
2622
23+ // For windows app
2724function spawnUpdate ( args , cb ) {
2825 var stdout = ''
2926 var updateProcess = null
@@ -162,15 +159,6 @@ nodeIpc.config.id = 'node'
162159nodeIpc . config . retry = 1500
163160nodeIpc . config . silent = true
164161
165- function spawnFinder ( ) {
166- if ( process . platform === 'darwin' ) {
167- var finderArgv = [ path . join ( __dirname , 'finder-app.js' ) , '--finder' ]
168- if ( _ . find ( process . argv , a => a === '--hot' ) ) finderArgv . push ( '--hot' )
169- finderProcess = ChildProcess
170- . execFile ( process . execPath , finderArgv )
171- }
172- }
173-
174162nodeIpc . serve (
175163 path . join ( app . getPath ( 'userData' ) , 'boost.service' ) ,
176164 function ( ) {
@@ -187,7 +175,7 @@ nodeIpc.serve(
187175 'message' ,
188176 function ( data , socket ) {
189177 console . log ( '>>' , data )
190- format ( data )
178+ handleIpcEvent ( data )
191179 }
192180 )
193181 nodeIpc . server . on (
@@ -199,14 +187,18 @@ nodeIpc.serve(
199187 }
200188)
201189
202- function format ( payload ) {
190+ function handleIpcEvent ( payload ) {
203191 switch ( payload . type ) {
204192 case 'show-main-window' :
205- if ( process . platform === 'darwin' ) {
206- mainWindow . show ( )
207- } else {
208- mainWindow . minimize ( )
209- mainWindow . restore ( )
193+ switch ( process . platform ) {
194+ case 'darwin' :
195+ mainWindow . show ( )
196+ case 'win32' :
197+ mainWindow . minimize ( )
198+ mainWindow . restore ( )
199+ case 'linux' :
200+ // Do nothing
201+ // due to bug of `app.focus()` some desktop Env
210202 }
211203 break
212204 case 'copy-finder' :
@@ -218,6 +210,15 @@ function format (payload) {
218210 }
219211}
220212
213+ function spawnFinder ( ) {
214+ if ( process . platform === 'darwin' ) {
215+ var finderArgv = [ path . join ( __dirname , 'finder-app.js' ) , '--finder' ]
216+ if ( _ . find ( process . argv , a => a === '--hot' ) ) finderArgv . push ( '--hot' )
217+ finderProcess = ChildProcess
218+ . execFile ( process . execPath , finderArgv )
219+ }
220+ }
221+
221222function quitApp ( ) {
222223 appQuit = true
223224 if ( finderProcess ) finderProcess . kill ( )
@@ -226,7 +227,6 @@ function quitApp () {
226227
227228app . on ( 'ready' , function ( ) {
228229 app . on ( 'before-quit' , function ( ) {
229- console . log ( 'before quite' )
230230 appQuit = true
231231 if ( finderProcess ) finderProcess . kill ( )
232232 } )
@@ -247,7 +247,7 @@ app.on('ready', function () {
247247 } )
248248 }
249249 var menu = Menu . buildFromTemplate ( template )
250- if ( process . platform === 'darwin' ) {
250+ if ( process . platform === 'darwin' || process . platform === 'linux' ) {
251251 Menu . setApplicationMenu ( menu )
252252 }
253253
@@ -273,21 +273,22 @@ app.on('ready', function () {
273273 mainWindow . setMenu ( menu )
274274 }
275275 mainWindow . on ( 'close' , function ( e ) {
276- if ( appQuit ) return true
277- e . preventDefault ( )
278- mainWindow . hide ( )
276+ app . quit ( )
279277 } )
280-
281- if ( finderProcess == null && process . platform === 'darwin' ) {
282- spawnFinder ( )
283- } else {
284- finderWindow = require ( './finder-window' )
285-
286- finderWindow . on ( 'close' , function ( e ) {
287- if ( appQuit ) return true
288- e . preventDefault ( )
289- finderWindow . hide ( )
290- } )
278+ switch ( process . platform ) {
279+ case 'darwin' :
280+ spawnFinder ( )
281+ break
282+ case 'win32' :
283+ finderWindow = require ( './finder-window' )
284+ finderWindow . on ( 'close' , function ( e ) {
285+ if ( appQuit ) return true
286+ e . preventDefault ( )
287+ finderWindow . hide ( )
288+ } )
289+ break
290+ case 'linux' :
291+ // Do nothing.
291292 }
292293
293294 nodeIpc . server . start ( function ( err ) {
0 commit comments