Browse Source

add application menu

Paul Frazee 4 years ago
parent
commit
db3018c698
2 changed files with 20 additions and 9 deletions
  1. 15
    4
      app/index.js
  2. 5
    5
      package.json

+ 15
- 4
app/index.js View File

@@ -12,17 +12,28 @@ var tray
12 12
 app.on('ready', function ready () {
13 13
   // start sbot
14 14
 	require('scuttlebot').init(config, function (err, sbot) {
15
+    // open the web app
16
+    shell.openExternal('http://localhost:8008')
17
+
18
+    // setup menu
19
+    Menu.setApplicationMenu(Menu.buildFromTemplate([{
20
+      label: 'Window',
21
+      submenu: [
22
+        { label: 'Open Web App', click: onopen },
23
+        { label: 'Quit', click: onquit }
24
+      ]
25
+    }]))
15 26
 
16 27
     // setup tray icon
17 28
     tray = new Tray(__dirname+'/icon.png')
18
-    var contextMenu = Menu.buildFromTemplate([
19
-      { label: 'Open App', click: onopen },
29
+    tray.setContextMenu(Menu.buildFromTemplate([
30
+      { label: 'Open Web App', click: onopen },
20 31
       { label: 'Quit', click: onquit }
21
-    ])
22
-    tray.setContextMenu(contextMenu)
32
+    ]))
23 33
     tray.setToolTip('Secure Scuttlebutt: Running on port 8008')
24 34
     tray.on('double-clicked', onopen)
25 35
 
36
+    // menu handlers
26 37
     function onopen () {
27 38
       shell.openExternal('http://localhost:8008')
28 39
     }

+ 5
- 5
package.json View File

@@ -5,13 +5,13 @@
5 5
   "main": "app/index.js",
6 6
   "scripts": {
7 7
     "start": "electron .",
8
-    "clean": "rm -rf ./dist",
9
-    "clean:osx": "rm -rf ./dist/osx",
10
-    "clean:win": "rm -rf ./dist/win",
8
+    "clean": "rm -Rf ./dist",
9
+    "clean:osx": "rm -Rf ./dist/osx",
10
+    "clean:win": "rm -Rf ./dist/win",
11 11
     "build": "npm run clean && npm run build:osx && npm run build:win",
12 12
     "build:icon": "./scripts/make-icns.sh assets/icon1024.png assets/osx/scuttlebot.icns",
13
-    "build:osx": "npm run clean:osx && electron-packager ./ \"Scuttlebot\" --out=dist/osx --platform=darwin --arch=x64 --ignore=node_modules/electron* --version=0.28.3 --icon=assets/osx/scuttlebot.icns",
14
-    "build:win": "npm run clean:win && electron-packager ./ \"Scuttlebot\" --out=dist/win --platform=win32 --arch=ia32 --ignore=node_modules/electron* --version=0.28.3 --icon=assets/win/scuttlebot.ico",
13
+    "build:osx": "electron-packager ./ \"Scuttlebot\" --out=dist/osx --platform=darwin --arch=x64 --ignore=node_modules/electron* --version=0.28.3 --icon=assets/osx/scuttlebot.icns",
14
+    "build:win": "electron-packager ./ \"Scuttlebot\" --out=dist/win --platform=win32 --arch=ia32 --ignore=node_modules/electron* --version=0.28.3 --icon=assets/win/scuttlebot.ico",
15 15
     "pack": "npm run pack:osx && npm run pack:win",
16 16
     "pack:osx": "electron-builder \"dist/osx/Scuttlebot.app\" --platform=osx --out=\"dist/osx\" --config=packager.json",
17 17
     "pack:win": "electron-builder \"dist/win/Scuttlebot-win32\" --platform=win --out=\"dist/win\" --config=packager.json"

Loading…
Cancel
Save