From 9abf067e27cfb881654bced2e96c151488159443 Mon Sep 17 00:00:00 2001 From: Matias Tucci Date: Tue, 27 Dec 2016 03:15:34 +0700 Subject: [PATCH 1/5] helpers service --- app/src/services/helpers/index.js | 61 +++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 app/src/services/helpers/index.js diff --git a/app/src/services/helpers/index.js b/app/src/services/helpers/index.js new file mode 100644 index 0000000..25a44c3 --- /dev/null +++ b/app/src/services/helpers/index.js @@ -0,0 +1,61 @@ +import Vue from 'vue' +const bus = new Vue() + +const electron = require('electron') +const shell = electron.shell +const ipcRenderer = electron.ipcRenderer +const autoUpdater = electron.remote.autoUpdater + +function setupExternalLinks() { + const supportExternalLinks = function (e) { + let href + let isExternal = false + const checkDomElement = function (element) { + if (element.nodeName === 'A') { + href = element.getAttribute('href') + } + if (element.classList.contains('js-external-link')) { + isExternal = true + } + if (href && isExternal) { + shell.openExternal(href) + e.preventDefault() + } else if (element.parentElement) { + checkDomElement(element.parentElement) + } + } + checkDomElement(e.target) + } + document.addEventListener('click', supportExternalLinks, false) +} + +function listenToPing() { + ipcRenderer.on('ping', (event, message) => { + console.log('ping: ', message) + switch (message) { + case 'update-available': + case 'update-downloaded': + case 'update-error': + bus.$emit(message) + break + default: + break + } + }) +} + +function toggleDevTools() { + electron.remote.getCurrentWindow().toggleDevTools() +} + +function quitAndInstall() { + autoUpdater.quitAndInstall() +} + +export default { + setupExternalLinks, + listenToPing, + toggleDevTools, + quitAndInstall, + bus, +} From ebd65f87d64c7b83056a1484ead3497cd23f7556 Mon Sep 17 00:00:00 2001 From: Matias Tucci Date: Tue, 27 Dec 2016 03:15:47 +0700 Subject: [PATCH 2/5] toggle devtools --- app/src/components/Info.vue | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/app/src/components/Info.vue b/app/src/components/Info.vue index fbb7a0c..fcc9243 100644 --- a/app/src/components/Info.vue +++ b/app/src/components/Info.vue @@ -1,22 +1,21 @@