kopia lustrzana https://github.com/dceejay/electron-node-red
rodzic
4f4be978b5
commit
c6193b3926
33
main.js
33
main.js
|
@ -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 = "18880"; // fix it if you like
|
||||||
const listenPort = parseInt(Math.random()*16383+49152) // or random ephemeral port
|
const listenPort = parseInt(Math.random()*16383+49152) // or random ephemeral port
|
||||||
|
|
||||||
|
const pkg = require('./package.json');
|
||||||
const os = require('os');
|
const os = require('os');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const url = require('url');
|
const url = require('url');
|
||||||
|
@ -26,6 +27,7 @@ const path = require('path');
|
||||||
const http = require('http');
|
const http = require('http');
|
||||||
const express = require("express");
|
const express = require("express");
|
||||||
const electron = require('electron');
|
const electron = require('electron');
|
||||||
|
const isDev = require('electron-is-dev');
|
||||||
|
|
||||||
const {app, Menu} = electron;
|
const {app, Menu} = electron;
|
||||||
const ipc = electron.ipcMain;
|
const ipc = electron.ipcMain;
|
||||||
|
@ -205,11 +207,31 @@ if (!allowLoadSave) { template[0].submenu.splice(0,2); }
|
||||||
// Top and tail menu on Mac
|
// Top and tail menu on Mac
|
||||||
if (process.platform === 'darwin') {
|
if (process.platform === 'darwin') {
|
||||||
template[0].submenu.unshift({ type: 'separator' });
|
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' });
|
||||||
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 = "";
|
let fileName = "";
|
||||||
function saveFlow() {
|
function saveFlow() {
|
||||||
dialog.showSaveDialog({
|
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
|
// Start the Node-RED runtime, then load the inital dashboard page
|
||||||
RED.start().then(function() {
|
RED.start().then(function() {
|
||||||
server.listen(listenPort,"localhost",function() {
|
server.listen(listenPort,"localhost",function() {
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
"url": "git+https://github.com/dceejay/electron-node-red.git"
|
"url": "git+https://github.com/dceejay/electron-node-red.git"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"electron-is-dev": "*",
|
||||||
"express": "^4.17.1",
|
"express": "^4.17.1",
|
||||||
"node-red": "1.0.2",
|
"node-red": "1.0.2",
|
||||||
"node-red-contrib-play-audio": "*",
|
"node-red-contrib-play-audio": "*",
|
||||||
|
|
|
@ -1150,6 +1150,11 @@ electron-builder@^22.1.0:
|
||||||
update-notifier "^3.0.1"
|
update-notifier "^3.0.1"
|
||||||
yargs "^14.0.0"
|
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:
|
electron-publish@21.2.0:
|
||||||
version "21.2.0"
|
version "21.2.0"
|
||||||
resolved "https://registry.yarnpkg.com/electron-publish/-/electron-publish-21.2.0.tgz#cc225cb46aa62e74b899f2f7299b396c9802387d"
|
resolved "https://registry.yarnpkg.com/electron-publish/-/electron-publish-21.2.0.tgz#cc225cb46aa62e74b899f2f7299b396c9802387d"
|
||||||
|
|
Ładowanie…
Reference in New Issue