kopia lustrzana https://github.com/dceejay/electron-node-red
slight tidy of main.js
rodzic
33762ca46b
commit
2245a3c579
24
main.js
24
main.js
|
@ -4,8 +4,9 @@
|
||||||
// Some settings you can edit easily
|
// Some settings you can edit easily
|
||||||
|
|
||||||
const editable = true; // Set this to false to create a run only application - no editor/no console
|
const editable = true; // Set this to false to create a run only application - no editor/no console
|
||||||
const allowLoadSave = false; // set to true to allow omport and export of flow
|
const allowLoadSave = false; // set to true to allow import and export of flow file
|
||||||
const showMap = false; // set to true to add Worldmap to the menu
|
const showMap = false; // set to true to add Worldmap to the menu
|
||||||
|
|
||||||
let flowfile = 'electronflow.json'; // default Flows file name - loaded at start
|
let flowfile = 'electronflow.json'; // default Flows file name - loaded at start
|
||||||
const urldash = "/ui/#/0"; // Start on the dashboard page
|
const urldash = "/ui/#/0"; // Start on the dashboard page
|
||||||
const urledit = "/red"; // url for the editor page
|
const urledit = "/red"; // url for the editor page
|
||||||
|
@ -13,7 +14,7 @@ const urlconsole = "/console.htm"; // url for the console page
|
||||||
const urlmap = "/worldmap"; // url for the worldmap
|
const urlmap = "/worldmap"; // url for the worldmap
|
||||||
const nrIcon = "nodered.png" // Icon for the app in root dir (usually 256x256)
|
const nrIcon = "nodered.png" // Icon for the app in root dir (usually 256x256)
|
||||||
|
|
||||||
// tcp port to use
|
// TCP port to use
|
||||||
//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
|
||||||
|
|
||||||
|
@ -93,17 +94,17 @@ let logBuffer = [];
|
||||||
let logLength = 250; // No. of lines of console log to keep.
|
let logLength = 250; // No. of lines of console log to keep.
|
||||||
const levels = [ "", "fatal", "error", "warn", "info", "debug", "trace" ];
|
const levels = [ "", "fatal", "error", "warn", "info", "debug", "trace" ];
|
||||||
|
|
||||||
ipc.on('clearLogBuffer', function(event, arg) { logBuffer = []; });
|
ipc.on('clearLogBuffer', function() { logBuffer = []; });
|
||||||
|
|
||||||
// Create the settings object - see default settings.js file for other options
|
// Create the settings object - see default settings.js file for other options
|
||||||
var settings = {
|
var settings = {
|
||||||
uiHost: "127.0.0.1", // only allow local connections
|
uiHost: "127.0.0.1", // only allow local connections, remove if you want to allow external access
|
||||||
httpAdminRoot: "/red", // set to false to disable editor/deploy
|
httpAdminRoot: "/red", // set to false to disable editor and deploy
|
||||||
httpNodeRoot: "/",
|
httpNodeRoot: "/",
|
||||||
userDir: userdir,
|
userDir: userdir,
|
||||||
flowFile: flowfile,
|
flowFile: flowfile,
|
||||||
editorTheme: { projects:{ enabled:false } },
|
editorTheme: { projects:{ enabled:false } }, // enable projects feature
|
||||||
functionGlobalContext: { }, // enables global context
|
functionGlobalContext: { }, // enables global context - add extras ehre if you need them
|
||||||
logging: {
|
logging: {
|
||||||
websock: {
|
websock: {
|
||||||
level: 'info',
|
level: 'info',
|
||||||
|
@ -137,7 +138,7 @@ if (!editable) {
|
||||||
// Initialise the runtime with a server and settings
|
// Initialise the runtime with a server and settings
|
||||||
RED.init(server,settings);
|
RED.init(server,settings);
|
||||||
|
|
||||||
// Serve the editor UI from /red
|
// Serve the editor UI from /red (if editable)
|
||||||
if (settings.httpAdminRoot !== false) {
|
if (settings.httpAdminRoot !== false) {
|
||||||
red_app.use(settings.httpAdminRoot,RED.httpAdmin);
|
red_app.use(settings.httpAdminRoot,RED.httpAdmin);
|
||||||
}
|
}
|
||||||
|
@ -147,7 +148,7 @@ red_app.use(settings.httpNodeRoot,RED.httpNode);
|
||||||
|
|
||||||
// Create the Application's main menu
|
// Create the Application's main menu
|
||||||
var template = [];
|
var template = [];
|
||||||
if (process.platform === 'darwin') {
|
if (process.platform === 'darwin') { // Mac has it's own first menu
|
||||||
template.push( {
|
template.push( {
|
||||||
label: app.getName(),
|
label: app.getName(),
|
||||||
submenu: [
|
submenu: [
|
||||||
|
@ -164,6 +165,7 @@ if (process.platform === 'darwin') {
|
||||||
]
|
]
|
||||||
} )
|
} )
|
||||||
}
|
}
|
||||||
|
// Now add the main Node-RED menu
|
||||||
template.push(
|
template.push(
|
||||||
{ label: 'Node-RED',
|
{ label: 'Node-RED',
|
||||||
submenu: [
|
submenu: [
|
||||||
|
@ -352,10 +354,6 @@ function createWindow() {
|
||||||
//mainWindow.webContents.openDevTools();
|
//mainWindow.webContents.openDevTools();
|
||||||
}
|
}
|
||||||
|
|
||||||
app.on('orderFrontStandardAboutPanel', function() {
|
|
||||||
createConsole();
|
|
||||||
});
|
|
||||||
|
|
||||||
// Called when Electron has finished initialization and is ready to create browser windows.
|
// Called when Electron has finished initialization and is ready to create browser windows.
|
||||||
app.on('ready', createWindow );
|
app.on('ready', createWindow );
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue