11'use strict' ;
22
33const electron = require ( 'electron' ) ;
4- const ipcMain = electron . ipcMain ;
5- const app = electron . app ; // 어플리케이션 기반을 조작 하는 모듈.
6- const BrowserWindow = electron . BrowserWindow ; // 네이티브 브라우저 창을 만드는 모듈.
4+ const { app, BrowserWindow, Menu, globalShortcut, ipcMain} = electron ;
75const path = require ( 'path' ) ;
86const fs = require ( 'fs' ) ;
9- const Menu = electron . Menu ;
107const packageJson = require ( './package.json' ) ;
118const ChildProcess = require ( 'child_process' ) ;
129
@@ -258,7 +255,6 @@ var handleStartupEvent = function() {
258255 }
259256} ;
260257
261-
262258var mainWindow = null ;
263259var hardwareWindow = null ;
264260var isClose = true ;
@@ -269,12 +265,17 @@ app.on('window-all-closed', function() {
269265} ) ;
270266
271267var shouldQuit = app . makeSingleInstance ( function ( commandLine , workingDirectory ) {
272- // 어플리케이션을 중복 실행했습니다. 주 어플리케이션 인스턴스를 활성화 합니다.
268+ // 어플리케이션을 중복 실행했습니다. 주 어플리케이션 인스턴스를 활성화 합니다.
273269 if ( mainWindow ) {
274270 if ( mainWindow . isMinimized ( ) )
275271 mainWindow . restore ( ) ;
276272 mainWindow . focus ( ) ;
273+
274+ if ( Array . isArray ( commandLine ) && commandLine [ 1 ] ) {
275+ mainWindow . webContents . send ( 'loadProject' , commandLine [ 1 ] ) ;
276+ }
277277 }
278+
278279 return true ;
279280} ) ;
280281
@@ -317,10 +318,25 @@ app.once('ready', function() {
317318 e . preventDefault ( ) ;
318319 } ) ;
319320 mainWindow . on ( 'close' , function ( e ) {
321+ if ( hardwareWindow ) {
322+ hardwareWindow . close ( ) ;
323+ }
320324 mainWindow . webContents . send ( 'main-close' ) ;
321325 } ) ;
322326 mainWindow . on ( 'closed' , function ( ) {
323327 mainWindow = null ;
328+ app . quit ( ) ;
329+ process . exit ( 0 ) ;
330+ } ) ;
331+
332+ let inspectorShortcut = '' ;
333+ if ( process . platform == 'darwin' ) {
334+ inspectorShortcut = 'Command+Alt+i' ;
335+ } else {
336+ inspectorShortcut = 'Control+Shift+i' ;
337+ }
338+ globalShortcut . register ( inspectorShortcut , ( ) => {
339+ mainWindow . webContents . openDevTools ( ) ;
324340 } ) ;
325341} ) ;
326342
@@ -356,24 +372,10 @@ ipcMain.on('openHardware', function(event, arg) {
356372 }
357373
358374 hardwareWindow . show ( ) ;
375+ } else {
376+ if ( hardwareWindow . isMinimized ( ) )
377+ hardwareWindow . restore ( ) ;
378+ hardwareWindow . focus ( ) ;
359379 }
360380
361381} ) ;
362-
363- // try{
364- // if (handleStartupEvent()) {
365- // logger('handleStartupEvent = true');
366- // app.quit();
367- // process.exit(0);
368- // // setTimeout(function () {
369- // // }, 1000)
370- // return;
371- // } else {
372- // logger('handleStartupEvent = false');
373-
374- // }
375- // } catch(e) {
376- // logger(e.stack);
377- // app.quit();
378- // process.exit(0);
379- // }
0 commit comments