kopia lustrzana https://github.com/dceejay/electron-node-red
add some touchbar goodness
rodzic
ad7b3d00fc
commit
54040e45ce
42
main.js
42
main.js
|
@ -36,11 +36,12 @@ const express = require("express");
|
||||||
const electron = require('electron');
|
const electron = require('electron');
|
||||||
const isDev = require('electron-is-dev');
|
const isDev = require('electron-is-dev');
|
||||||
|
|
||||||
const {app, Menu} = electron;
|
const {app, Menu, TouchBar} = electron;
|
||||||
const ipc = electron.ipcMain;
|
const ipc = electron.ipcMain;
|
||||||
const dialog = electron.dialog;
|
const dialog = electron.dialog;
|
||||||
const BrowserWindow = electron.BrowserWindow;
|
const BrowserWindow = electron.BrowserWindow;
|
||||||
const Tray = electron.Tray;
|
const Tray = electron.Tray;
|
||||||
|
const { TouchBarButton } = TouchBar;
|
||||||
|
|
||||||
var RED = require("node-red");
|
var RED = require("node-red");
|
||||||
var red_app = express();
|
var red_app = express();
|
||||||
|
@ -313,6 +314,15 @@ function createConsole() {
|
||||||
conWindow = null;
|
conWindow = null;
|
||||||
});
|
});
|
||||||
//conWindow.webContents.openDevTools();
|
//conWindow.webContents.openDevTools();
|
||||||
|
const touchButton4 = new TouchBarButton({
|
||||||
|
label: 'Clear Log',
|
||||||
|
backgroundColor: '#910000',
|
||||||
|
click: () => { logBuffer = []; conWindow.webContents.send('logBuff', logBuffer); }
|
||||||
|
});
|
||||||
|
const consoleTouchBar = new TouchBar({
|
||||||
|
items: [ touchButton4 ]
|
||||||
|
});
|
||||||
|
conWindow.setTouchBar(consoleTouchBar);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the main browser window
|
// Create the main browser window
|
||||||
|
@ -374,6 +384,35 @@ function createWindow() {
|
||||||
mainWindow = null;
|
mainWindow = null;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// If on a Mac add some touchbar buttons...
|
||||||
|
if (process.platform === 'darwin') {
|
||||||
|
const touchButton1 = new TouchBarButton({
|
||||||
|
label: 'Editor',
|
||||||
|
backgroundColor: '#910000',
|
||||||
|
click: () => { mainWindow.loadURL("http://localhost:"+listenPort+urledit); }
|
||||||
|
});
|
||||||
|
|
||||||
|
const touchButton2 = new TouchBarButton({
|
||||||
|
label: 'Dashboard',
|
||||||
|
backgroundColor: '#910000',
|
||||||
|
click: () => { mainWindow.loadURL("http://localhost:"+listenPort+urldash); }
|
||||||
|
});
|
||||||
|
|
||||||
|
const touchButton3 = new TouchBarButton({
|
||||||
|
label: 'Map',
|
||||||
|
backgroundColor: '#910000',
|
||||||
|
click: () => { mainWindow.loadURL("http://localhost:"+listenPort+urlmap); }
|
||||||
|
});
|
||||||
|
|
||||||
|
var items = [ touchButton2 ];
|
||||||
|
if (editable) { items.push(touchButton1) }
|
||||||
|
if (showMap) { items.push(touchButton3) }
|
||||||
|
|
||||||
|
const mainTouchBar = new TouchBar({ items: items });
|
||||||
|
|
||||||
|
mainWindow.setTouchBar(mainTouchBar);
|
||||||
|
}
|
||||||
|
|
||||||
// Start the app full screen
|
// Start the app full screen
|
||||||
//mainWindow.setFullScreen(true)
|
//mainWindow.setFullScreen(true)
|
||||||
|
|
||||||
|
@ -410,7 +449,6 @@ app.on('ready', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Quit when all windows are closed.
|
// Quit when all windows are closed.
|
||||||
app.on('window-all-closed', function () {
|
app.on('window-all-closed', function () {
|
||||||
// On OS X it is common for applications and their menu bar
|
// On OS X it is common for applications and their menu bar
|
||||||
|
|
|
@ -52,13 +52,14 @@
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/dceejay/electron-node-red#readme",
|
"homepage": "https://github.com/dceejay/electron-node-red#readme",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"electron": "~10.1.1",
|
"electron": "~10.1.3",
|
||||||
"electron-builder": "^22.8.0"
|
"electron-builder": "^22.8.1"
|
||||||
},
|
},
|
||||||
"build": {
|
"build": {
|
||||||
"appId": "com.electron.node-red",
|
"appId": "com.electron.node-red",
|
||||||
"productName": "Node-RED Electron",
|
"productName": "Node-RED Electron",
|
||||||
"copyright": "Copyright © 2018,2020 D.Conway-Jones",
|
"copyright": "Copyright © 2018,2020 D.Conway-Jones",
|
||||||
|
"buildDependenciesFromSource": true,
|
||||||
"files": [
|
"files": [
|
||||||
"**/*",
|
"**/*",
|
||||||
{
|
{
|
||||||
|
|
Ładowanie…
Reference in New Issue