Add dev menu when in dev mode

Fix about panel
pull/11/head
Dave Conway-Jones 2019-11-14 00:36:33 +00:00
rodzic 4f4be978b5
commit c6193b3926
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 302A6725C594817F
3 zmienionych plików z 38 dodań i 1 usunięć

33
main.js
Wyświetl plik

@ -19,6 +19,7 @@ const nrIcon = "nodered.png" // Icon for the app in root dir (usually 256
//const listenPort = "18880"; // fix it if you like
const listenPort = parseInt(Math.random()*16383+49152) // or random ephemeral port
const pkg = require('./package.json');
const os = require('os');
const fs = require('fs');
const url = require('url');
@ -26,6 +27,7 @@ const path = require('path');
const http = require('http');
const express = require("express");
const electron = require('electron');
const isDev = require('electron-is-dev');
const {app, Menu} = electron;
const ipc = electron.ipcMain;
@ -205,11 +207,31 @@ if (!allowLoadSave) { template[0].submenu.splice(0,2); }
// Top and tail menu on Mac
if (process.platform === 'darwin') {
template[0].submenu.unshift({ type: 'separator' });
template[0].submenu.unshift({ role: 'about' });
template[0].submenu.unshift({ label: "About Node-RED", selector: "orderFrontStandardAboutPanel:" });
template[0].submenu.unshift({ type: 'separator' });
template[0].submenu.unshift({ type: 'separator' });
}
// Add Dev menu if in dev mode
if (isDev) {
template.push({
label: 'Development',
submenu: [
{ label: 'Reload', accelerator: 'CmdOrCtrl+R',
click (item, focusedWindow) {
if (focusedWindow) focusedWindow.reload()
}
},
{ label: 'Toggle Developer Tools',
accelerator: process.platform === 'darwin' ? 'Alt+Command+I' : 'Ctrl+Shift+I',
click (item, focusedWindow) {
if (focusedWindow) focusedWindow.webContents.toggleDevTools()
}
}
]
})
}
let fileName = "";
function saveFlow() {
dialog.showSaveDialog({
@ -355,6 +377,15 @@ app.on('activate', function() {
}
});
if (process.platform === 'darwin') {
app.setAboutPanelOptions({
applicationName: pkg.productName,
version: pkg.version,
copyright: "Copyright © 2019, D Conway-Jones.",
credits: "Node-RED and other components are copyright the JS Foundation and other contributors."
});
}
// Start the Node-RED runtime, then load the inital dashboard page
RED.start().then(function() {
server.listen(listenPort,"localhost",function() {

Wyświetl plik

@ -16,6 +16,7 @@
"url": "git+https://github.com/dceejay/electron-node-red.git"
},
"dependencies": {
"electron-is-dev": "*",
"express": "^4.17.1",
"node-red": "1.0.2",
"node-red-contrib-play-audio": "*",

Wyświetl plik

@ -1150,6 +1150,11 @@ electron-builder@^22.1.0:
update-notifier "^3.0.1"
yargs "^14.0.0"
electron-is-dev@*:
version "1.1.0"
resolved "https://registry.yarnpkg.com/electron-is-dev/-/electron-is-dev-1.1.0.tgz#b15a2a600bdc48a51a857d460e05f15b19a2522c"
integrity sha512-Z1qA/1oHNowGtSBIcWk0pcLEqYT/j+13xUw/MYOrBUOL4X7VN0i0KCTf5SqyvMPmW5pSPKbo28wkxMxzZ20YnQ==
electron-publish@21.2.0:
version "21.2.0"
resolved "https://registry.yarnpkg.com/electron-publish/-/electron-publish-21.2.0.tgz#cc225cb46aa62e74b899f2f7299b396c9802387d"