Browse Source

add very simple electron app wrapper (#75)

master
Charlie Wolf 2 years ago
parent
commit
a5c725853f
2 changed files with 39 additions and 0 deletions
  1. 30
    0
      index.js
  2. 9
    0
      package.json

+ 30
- 0
index.js View File

@@ -0,0 +1,30 @@
1
+// Very simple electron wrapper script that allows us to use asciiflow2 as a desktop application
2
+
3
+const electron = require('electron')
4
+const app = electron.app
5
+const BrowserWindow = electron.BrowserWindow
6
+
7
+const path = require('path')
8
+const url = require('url')
9
+
10
+let mainWindow;
11
+
12
+function createWindow () {
13
+  mainWindow = new BrowserWindow({width: 800, height: 600, icon: path.join(__dirname, 'images', 'favicon.png')});
14
+  mainWindow.setMenu(null);
15
+  mainWindow.loadURL(url.format({
16
+    pathname: path.join(__dirname, 'index.html'),
17
+    protocol: 'file:',
18
+    slashes: true
19
+  }))
20
+
21
+  mainWindow.on('closed', function () {
22
+    mainWindow = null
23
+  })
24
+}
25
+
26
+app.on('ready', createWindow)
27
+
28
+app.on('window-all-closed', function () {
29
+    app.quit()
30
+})

+ 9
- 0
package.json View File

@@ -0,0 +1,9 @@
1
+{
2
+  "name": "asciiflow2",
3
+  "main": "index.js",
4
+  "icon": "images/favicon.png",
5
+  "scripts": {
6
+      "start": "electron ."
7
+  }
8
+}
9
+

Loading…
Cancel
Save