From 3bc9fc2844da76e1e3799b2999ca9a820e5ce1a4 Mon Sep 17 00:00:00 2001 From: "Scott E. Graves" Date: Wed, 26 Dec 2018 16:42:14 -0600 Subject: [PATCH] OS X fixes --- electron.js | 28 ++++++++++++++-------------- package.json | 3 ++- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/electron.js b/electron.js index 453d343..00acdd3 100644 --- a/electron.js +++ b/electron.js @@ -84,9 +84,17 @@ function createWindow() { protocol: 'file:', slashes: true }); - mainWindow.loadURL(startUrl); - // Emitted when the window is closed. + mainWindow.on('close', function (event) { + if (!isQuiting) { + event.preventDefault(); + if (mainWindow.isVisible()) { + setWindowVisibility(false); + } + event.returnValue = false; + } + }); + mainWindow.on('closed', function () { // Dereference the window object, usually you would store windows // in an array if your app supports multi windows, this is the time @@ -112,7 +120,6 @@ function createWindow() { path: appPath, }); - const image = nativeImage.createFromPath(path.join(__dirname, (os.platform() === 'darwin') ? '/build/logo_mac.png' : '/build/logo.png')); trayContextMenu = Menu.buildFromTemplate([ { label: 'Visible', type: 'checkbox', click(item) { @@ -149,28 +156,21 @@ function createWindow() { } ]); - mainWindow.on('close', function (event) { - if (!isQuiting) { - event.preventDefault(); - if (mainWindow.isVisible()) { - setWindowVisibility(false); - } - event.returnValue = false; - } - }); + const image = nativeImage.createFromPath(path.join(__dirname, (os.platform() === 'darwin') ? '/build/logo_mac.png' : '/build/logo.png')); + mainWindowTray = new Tray(image); autoLauncher .isEnabled() .then((enabled) => { trayContextMenu.items[1].checked = enabled; - - mainWindowTray = new Tray(image); mainWindowTray.setToolTip('Repertory UI'); mainWindowTray.setContextMenu(trayContextMenu) }) .catch(() => { closeApplication(); }); + + mainWindow.loadURL(startUrl); } const instanceLock = app.requestSingleInstanceLock(); diff --git a/package.json b/package.json index 3696d0c..18148a1 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,8 @@ "start": "node scripts/start.js", "build": "node scripts/build.js", "test": "node scripts/test.js --env=jsdom", - "electron-dev": "cross-env ELECTRON_START_URL=http://localhost:3000 electron .", + "electron-dev": "cross-env ELECTRON_START_URL=http://localhost:3000 electron %NODE_DEBUG_OPTION% .", + "electron-dev-unix": "cross-env ELECTRON_START_URL=http://localhost:3000 electron $NODE_DEBUG_OPTION .", "pack": "npm run build && electron-builder --dir", "dist": "npm run build && electron-builder" },