OS X fixes

This commit is contained in:
Scott E. Graves
2018-12-26 16:42:14 -06:00
parent 64ca0350cf
commit 3bc9fc2844
2 changed files with 16 additions and 15 deletions

View File

@@ -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();

View File

@@ -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"
},