Skip to content

Commit 3e97e93

Browse files
committed
Option to toggle devtools
1 parent 4299ba7 commit 3e97e93

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,8 @@ app.on("activate", () => {
168168
});
169169

170170
app.on("ready", () => {
171-
setApplicationMenu();
172171
mainWindow = createMainWindow();
172+
setApplicationMenu(mainWindow);
173173
setUpTray(app, mainWindow);
174174

175175
// Autostart at login

menu.js

+16-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const {
1313
startAtLogin,
1414
} = require("./store");
1515

16-
const mainMenuTemplate = [
16+
const mainMenuTemplate = (win) => [
1717
{
1818
label: "Plugins",
1919
submenu: getAllPlugins().map((plugin) => {
@@ -79,13 +79,26 @@ const mainMenuTemplate = [
7979
},
8080
],
8181
},
82+
{
83+
label: "Toggle DevTools",
84+
// Cannot use "toggleDevTools" role in MacOS
85+
click: () => {
86+
const { webContents } = win;
87+
if (webContents.isDevToolsOpened()) {
88+
webContents.closeDevTools();
89+
} else {
90+
const devToolsOptions = {};
91+
webContents.openDevTools(devToolsOptions);
92+
}
93+
},
94+
},
8295
],
8396
},
8497
];
8598

8699
module.exports.mainMenuTemplate = mainMenuTemplate;
87-
module.exports.setApplicationMenu = () => {
88-
const menuTemplate = [...mainMenuTemplate];
100+
module.exports.setApplicationMenu = (win) => {
101+
const menuTemplate = [...mainMenuTemplate(win)];
89102
if (process.platform === "darwin") {
90103
const name = app.name;
91104
menuTemplate.unshift({

tray.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ module.exports.setUpTray = (app, win) => {
6161
win.show();
6262
},
6363
},
64-
...mainMenuTemplate,
64+
...mainMenuTemplate(win),
6565
{
6666
label: "Quit",
6767
click: () => {

0 commit comments

Comments
 (0)