Skip to content

Commit d083a53

Browse files
committed
Misc macOS fixes before release
1 parent b55d2bc commit d083a53

File tree

1 file changed

+21
-14
lines changed

1 file changed

+21
-14
lines changed

app.js

100755100644
+21-14
Original file line numberDiff line numberDiff line change
@@ -17,30 +17,40 @@
1717
"use strict";
1818

1919
const { app, ipcMain, dialog, Menu, BrowserWindow } = require('electron');
20-
const menu = Menu.buildFromTemplate([
20+
const isDarwin = process.platform === 'darwin';
21+
const menuTemplate = [
2122
{
2223
label: 'File',
2324
submenu: [
2425
{ mact: 'odlfold', label: 'Open output folder', click: menuOnClick },
2526
{ mact: 'ologsfold', label: 'Open logs folder', click: menuOnClick },
26-
{ mact: 'aexit', label: 'Quit', click: menuOnClick },
27-
]
27+
{ mact: 'aexit', label: 'Quit', click: menuOnClick, visible: !isDarwin }
28+
],
29+
role: 'appMenu'
2830
},
2931
{
30-
label: 'Sharedown',
32+
label: 'Help',
3133
submenu: [
3234
{ mact: 'owiki', label: 'Open Wiki (external)', click: menuOnClick },
33-
{ mact: 'osrc', label: 'Open repository (external)', click: menuOnClick },
34-
]
35+
{ mact: 'osrc', label: 'Open repository (external)', click: menuOnClick }
36+
],
37+
role: 'help'
3538
},
3639
{
37-
mact: 'about', label: 'About', click: menuOnClick
40+
label: 'About',
41+
submenu: [
42+
{ mact: 'about', label: 'About Sharedown', click: menuOnClick }
43+
],
44+
role: 'about'
3845
}
39-
]);
46+
];
4047
const path = require('path');
4148
let mainW = null;
4249

43-
Menu.setApplicationMenu(menu);
50+
if (isDarwin) // about must be first on macOS
51+
menuTemplate.unshift(menuTemplate.pop());
52+
53+
Menu.setApplicationMenu(Menu.buildFromTemplate(menuTemplate));
4454

4555
function createWindow () {
4656
const win = new BrowserWindow({
@@ -72,7 +82,7 @@ app.whenReady().then(() => {
7282
});
7383

7484
app.on('window-all-closed', () => {
75-
if (process.platform !== 'darwin')
85+
if (!isDarwin)
7686
app.quit();
7787
});
7888

@@ -102,7 +112,7 @@ ipcMain.on('sharedown-async', (e, args) => {
102112
case "showabout": {
103113
const win = new BrowserWindow({
104114
width: 350,
105-
height: 230,
115+
height: 250,
106116
webPreferences: {
107117
devTools: false,
108118
}
@@ -113,9 +123,6 @@ ipcMain.on('sharedown-async', (e, args) => {
113123
win.setResizable(false);
114124
win.setSkipTaskbar(true);
115125
win.setParentWindow(mainW);
116-
mainW.setEnabled(false);
117-
118-
win.once('closed', () => mainW.setEnabled(true));
119126
}
120127
break;
121128
default:

0 commit comments

Comments
 (0)