tidy up touchbar

master
Dave Conway-Jones 2020-10-10 17:10:47 +01:00
rodzic 4816ef4816
commit 5e3c7eede5
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 88BA2B8A411BE9FF
3 zmienionych plików z 21 dodań i 20 usunięć

29
main.js
Wyświetl plik

@ -426,43 +426,44 @@ function createWindow() {
// If on a Mac add some touchbar buttons... // If on a Mac add some touchbar buttons...
if (process.platform === 'darwin') { if (process.platform === 'darwin') {
const touchButton1 = new TouchBarButton({
label: 'Editor',
backgroundColor: '#910000',
click: () => { mainWindow.loadURL("http://localhost:"+listenPort+urledit); }
});
const touchButton2 = new TouchBarButton({ const touchButton1 = new TouchBarButton({
label: 'Dashboard', label: 'Dashboard',
backgroundColor: '#910000', backgroundColor: '#910000',
click: () => { mainWindow.loadURL("http://localhost:"+listenPort+urldash); } click: () => { mainWindow.loadURL("http://localhost:"+listenPort+urldash); }
}); });
const touchButton2 = new TouchBarButton({
label: 'Editor',
backgroundColor: '#910000',
click: () => { mainWindow.loadURL("http://localhost:"+listenPort+urledit); }
});
const touchButton3 = new TouchBarButton({ const touchButton3 = new TouchBarButton({
label: 'Map', label: 'Map',
backgroundColor: '#910000', backgroundColor: '#910000',
click: () => { mainWindow.loadURL("http://localhost:"+listenPort+urlmap); } click: () => { mainWindow.loadURL("http://localhost:"+listenPort+urlmap); }
}); });
const spacer = new TouchBarSpacer({ size: 'flexible' });
const touchButton4 = new TouchBarButton({ const touchButton4 = new TouchBarButton({
label: 'Console', label: 'Console',
backgroundColor: '#910000', backgroundColor: '#910000',
click: () => { createConsole(); } click: () => { createConsole(); }
}); });
var items = [ touchButton2 ]; var items = [ touchButton1 ];
if (editable) { items.push(touchButton1) } if (editable) { items.push(touchButton2) }
if (showMap) { items.push(touchButton3) } if (showMap) { items.push(touchButton3) }
if (editable) { if (editable) {
items.push(spacer); items.push(new TouchBarSpacer({ size: 'flexible' }));
items.push(touchButton4); items.push(touchButton4);
} }
const mainTouchBar = new TouchBar({ items: items }); // Only bother to add buttons if more than one
if (items.length != 1) {
mainWindow.setTouchBar(mainTouchBar); const mainTouchBar = new TouchBar({ items: items });
mainWindow.setTouchBar(mainTouchBar);
}
} }
// Start the app full screen // Start the app full screen

Wyświetl plik

@ -22,8 +22,8 @@ if (process.argv.length === 3 ) {
app = require(arg); app = require(arg);
} }
} }
else { else {
app = require(path.join(arg, "package.json")); app = require(path.join(arg, "package.json"));
dn = arg; dn = arg;
} }
} }
@ -40,12 +40,12 @@ const merge = {
pkg.dependencies = merge; pkg.dependencies = merge;
// Try to get flow file name from package.json setiings // Try to get flow file name from package.json setiings
if (app.hasOwnProperty("node-red") && app["node-red"].hasOwnProperty("settings") && app["node-red"].settings.hasOwnProperty("flowFile") ) { if (app.hasOwnProperty("node-red") && app["node-red"].hasOwnProperty("settings") && app["node-red"].settings.hasOwnProperty("flowFile") ) {
pkg.NRelectron.flowFile = app["node-red"].settings.flowFile; pkg.NRelectron.flowFile = app["node-red"].settings.flowFile;
} // or the npm scripts if there is a run command } // or the npm scripts if there is a run command
else if (app.hasOwnProperty("scripts") && app.scripts.hasOwnProperty("start")) { else if (app.hasOwnProperty("scripts") && app.scripts.hasOwnProperty("start")) {
pkg.NRelectron.flowFile = app.scripts.start.split(' ').pop(); pkg.NRelectron.flowFile = app.scripts.start.split(' ').pop();
} // or the command line if the user gave us a name - or just guess flow.json. } // or the command line if the user gave us a name - or just guess flow.json.
else { else {
pkg.NRelectron.flowFile = flowfile || "flow.json"; pkg.NRelectron.flowFile = flowfile || "flow.json";
} }
@ -73,7 +73,7 @@ fs.copyFile(path.join(arg, creds), path.join("./", creds), (err) => {
else { console.log('Copied creds file - '+creds); } else { console.log('Copied creds file - '+creds); }
}); });
// Finally re-write th new package.json // Finally re-write the new package.json
fs.writeFile("./package.json", JSON.stringify(pkg, null, 4), 'utf8', function (err) { fs.writeFile("./package.json", JSON.stringify(pkg, null, 4), 'utf8', function (err) {
if (err) { console.log("Failed to re-write package.json file."); } if (err) { console.log("Failed to re-write package.json file."); }
else { else {

Wyświetl plik

@ -11,7 +11,7 @@
"kioskMode": false, "kioskMode": false,
"addNodes": true, "addNodes": true,
"flowFile": "electronflow.json", "flowFile": "electronflow.json",
"start": "editor" "start": "dashboard"
}, },
"scripts": { "scripts": {
"pack": "electron-builder --dir", "pack": "electron-builder --dir",