diff options
| author | Lex Neva <lexelby@users.noreply.github.com> | 2020-04-28 12:34:05 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-04-28 18:34:05 +0200 |
| commit | cb2b4e3522cb7f426ba5ad3e68deb9e6ccc581ec (patch) | |
| tree | 2a2f38823c3c9f0b5439ce2aa7c9040299109292 /electron/src/main | |
| parent | eb526927e16954390d06929535d6f5c3766b5f6c (diff) | |
electron simulator (#531)
Diffstat (limited to 'electron/src/main')
| -rw-r--r-- | electron/src/main/index.dev.js | 24 | ||||
| -rw-r--r-- | electron/src/main/index.js | 90 |
2 files changed, 114 insertions, 0 deletions
diff --git a/electron/src/main/index.dev.js b/electron/src/main/index.dev.js new file mode 100644 index 00000000..1d10bc4e --- /dev/null +++ b/electron/src/main/index.dev.js @@ -0,0 +1,24 @@ +/** + * This file is used specifically and only for development. It installs + * `electron-debug` & `vue-devtools`. There shouldn't be any need to + * modify this file, but it can be used to extend your development + * environment. + */ + +/* eslint-disable */ + +// Install `electron-debug` with `devtron` +require('electron-debug')({ showDevTools: true }) + +// Install `vue-devtools` +require('electron').app.on('ready', () => { + let installExtension = require('electron-devtools-installer') + installExtension.default(installExtension.VUEJS_DEVTOOLS) + .then(() => {}) + .catch(err => { + console.log('Unable to install `vue-devtools`: \n', err) + }) +}) + +// Require `main` process to boot app +require('./index')
\ No newline at end of file diff --git a/electron/src/main/index.js b/electron/src/main/index.js new file mode 100644 index 00000000..9e90851f --- /dev/null +++ b/electron/src/main/index.js @@ -0,0 +1,90 @@ +'use strict' + +import {app, BrowserWindow} from 'electron' + +const url = require('url') + +/** + * Set `__static` path to static files in production + * https://simulatedgreg.gitbooks.io/electron-vue/content/en/using-static-assets.html + */ +if (process.env.NODE_ENV === 'development') { + // we were run as electron --inspect=5858 path/to/main.js <args> + // so get rid of the first two args + console.log("args " + process.argv) + process.argv.shift() + process.argv.shift() +} else { + global.__static = require('path').join(__dirname, '/static').replace(/\\/g, '\\\\') +} + +let mainWindow + +var target = process.argv[1] || ""; +var targetURL = url.parse(target) +var winURL = null; + +// Print PDF will give us a full URL to a flask server, bypassing Vue entirely. +// Eventually this will be migrated to Vue. +if (targetURL.protocol) { + winURL = target +} else { + if (process.env.NODE_ENV === 'development') { + winURL = `http://localhost:9080/?${targetURL.query || ""}#${targetURL.pathname || ""}` + } else { + winURL = `file://${__dirname}/index.html?${targetURL.query || ""}#${targetURL.pathname || ""}`; + } +} + +function createWindow() { + /** + * Initial window options + */ + mainWindow = new BrowserWindow({ + height: 563, + useContentSize: true, + width: 1000, + webPreferences: {nodeIntegration: true} + }) + + mainWindow.loadURL(winURL) + mainWindow.maximize() + + mainWindow.on('closed', () => { + mainWindow = null + }) +} + +app.on('ready', createWindow) + +app.on('window-all-closed', () => { + if (process.platform !== 'darwin') { + app.quit() + } +}) + +app.on('activate', () => { + if (mainWindow === null) { + createWindow() + } +}) + +/** + * Auto Updater + * + * Uncomment the following code below and install `electron-updater` to + * support auto updating. Code Signing with a valid certificate is required. + * https://simulatedgreg.gitbooks.io/electron-vue/content/en/using-electron-builder.html#auto-updating + */ + +/* +import { autoUpdater } from 'electron-updater' + +autoUpdater.on('update-downloaded', () => { + autoUpdater.quitAndInstall() +}) + +app.on('ready', () => { + if (process.env.NODE_ENV === 'production') autoUpdater.checkForUpdates() +}) + */ |
