From 8120fb16a18b1db1f63986139a0d284be48efefc Mon Sep 17 00:00:00 2001 From: Matt Date: Mon, 11 Apr 2016 02:01:26 -0400 Subject: [PATCH] got up to electron-quick-start level --- app/index.html | 13 ++++++++++++ app/main.js | 51 ++++++++++++++++++++++++++++++++++++++++++++++++ app/package.json | 7 +++++-- 3 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 app/index.html create mode 100644 app/main.js diff --git a/app/index.html b/app/index.html new file mode 100644 index 0000000..2906663 --- /dev/null +++ b/app/index.html @@ -0,0 +1,13 @@ + + + + + Hello World! + + +

Hello World!

+ We are using node , + Chromium , + and Electron . + + \ No newline at end of file diff --git a/app/main.js b/app/main.js new file mode 100644 index 0000000..0f14007 --- /dev/null +++ b/app/main.js @@ -0,0 +1,51 @@ +'use strict'; + +const electron = require('electron'); +// Module to control application life. +const app = electron.app; +// Module to create native browser window. +const BrowserWindow = electron.BrowserWindow; + +// Keep a global reference of the window object, if you don't, the window will +// be closed automatically when the JavaScript object is garbage collected. +let mainWindow; + +function createWindow () { + // Create the browser window. + mainWindow = new BrowserWindow({width: 800, height: 600}); + + // and load the index.html of the app. + mainWindow.loadURL('file://' + __dirname + '/index.html'); + + // Open the DevTools. + mainWindow.webContents.openDevTools(); + + // Emitted when the window is closed. + mainWindow.on('closed', function() { + // Dereference the window object, usually you would store windows + // in an array if your app supports multi windows, this is the time + // when you should delete the corresponding element. + mainWindow = null; + }); +} + +// This method will be called when Electron has finished +// initialization and is ready to create browser windows. +app.on('ready', createWindow); + +// Quit when all windows are closed. +app.on('window-all-closed', function () { + // On OS X it is common for applications and their menu bar + // to stay active until the user quits explicitly with Cmd + Q + if (process.platform !== 'darwin') { + app.quit(); + } +}); + +app.on('activate', function () { + // On OS X it's common to re-create a window in the app when the + // dock icon is clicked and there are no other windows open. + if (mainWindow === null) { + createWindow(); + } +}); \ No newline at end of file diff --git a/app/package.json b/app/package.json index 9a5d55e..3c13fe8 100644 --- a/app/package.json +++ b/app/package.json @@ -4,7 +4,7 @@ "description": "16mm optical printer", "main": "main.js", "scripts": { - "start" : "electron main.js" + "start": "electron main.js" }, "repository": { "type": "git", @@ -21,5 +21,8 @@ "bugs": { "url": "https://github.com/sixteenmillimeter/mcopy/issues" }, - "homepage": "https://github.com/sixteenmillimeter/mcopy#readme" + "homepage": "https://github.com/sixteenmillimeter/mcopy#readme", + "devDependencies": { + "electron-prebuilt": "^0.37.5" + } }