summaryrefslogtreecommitdiffstats
path: root/main.js
diff options
context:
space:
mode:
Diffstat (limited to 'main.js')
-rw-r--r--main.js39
1 files changed, 39 insertions, 0 deletions
diff --git a/main.js b/main.js
new file mode 100644
index 0000000..3884136
--- /dev/null
+++ b/main.js
@@ -0,0 +1,39 @@
+'use strict'
+const electron = require('electron')
+
+const app = electron.app // this is our app
+const BrowserWindow = electron.BrowserWindow // This is a Module that creates windows
+
+let mainWindow // saves a global reference to mainWindow so it doesn't get garbage collected
+
+app.on('ready', createWindow) // called when electron has initialized
+
+// This will create our app window, no surprise there
+function createWindow () {
+ mainWindow = new BrowserWindow({
+ width: 1024,
+ height: 768
+ })
+
+ // display the index.html file
+ mainWindow.loadURL(`file://${ __dirname }/src/static/index.html`)
+
+ // open dev tools by default so we can see any console errors
+ mainWindow.webContents.openDevTools()
+
+ mainWindow.on('closed', function () {
+ mainWindow = null
+ })
+}
+
+/* Mac Specific things */
+
+// when you close all the windows on a non-mac OS it quits the app
+app.on('window-all-closed', () => {
+ if (process.platform !== 'darwin') { app.quit() }
+})
+
+// if there is no mainWindow it creates one (like when you click the dock icon)
+app.on('activate', () => {
+ if (mainWindow === null) { createWindow() }
+}) \ No newline at end of file