From 0d689caa2ed37236cf6c354abbd2ed3539391686 Mon Sep 17 00:00:00 2001 From: Kylart Date: Mon, 8 May 2017 12:20:46 +0200 Subject: [PATCH] Fully implemented button to open KawAnime in the browser. --- assets/scripts/init/main.js | 6 +++++- assets/scripts/init/openExternal.js | 8 ++++++++ layouts/default.vue | 12 ++++++++++++ main.js | 1 + store/index.js | 4 ++++ 5 files changed, 30 insertions(+), 1 deletion(-) diff --git a/assets/scripts/init/main.js b/assets/scripts/init/main.js index a0b03d0..9484d5e 100644 --- a/assets/scripts/init/main.js +++ b/assets/scripts/init/main.js @@ -71,7 +71,7 @@ if (!fs.existsSync(historyPath)) fs.writeFileSync(historyPath, '{}', 'utf-8') } -const {openExternal} = require('./openExternal.js') +const {openExternal, openInBrowser} = require('./openExternal.js') const seasons = require('./seasons.js') const news = require('./news.js') const local = require('./local.js') @@ -160,6 +160,10 @@ const route = (nuxt) => { res.end(); break + case '/_openInBrowser': + openInBrowser(process.nuxtURL, res) + break + default: nuxt.render(req, res) } diff --git a/assets/scripts/init/openExternal.js b/assets/scripts/init/openExternal.js index f9b2ddc..19b663c 100644 --- a/assets/scripts/init/openExternal.js +++ b/assets/scripts/init/openExternal.js @@ -80,4 +80,12 @@ exports.openExternal = (url, res) => { default: break } +} + +exports.openInBrowser = (uri, res) => { + shell.openExternal(uri) + + res.writeHead(200, {"Content-Type": "application/json"}) + res.write(JSON.stringify({uri: uri})) + res.end() } \ No newline at end of file diff --git a/layouts/default.vue b/layouts/default.vue index 4381ac9..2d3af51 100644 --- a/layouts/default.vue +++ b/layouts/default.vue @@ -42,6 +42,13 @@ + + + open_in_new + @@ -255,6 +262,11 @@ color: rgba(255, 255, 255, 0.8); } + .open-in-browser + { + margin-top: 6px !important; + } + .sidebar-title-container { margin-top: 20px; diff --git a/main.js b/main.js index dca00da..5dc07ca 100755 --- a/main.js +++ b/main.js @@ -106,6 +106,7 @@ app.on('ready', () => { newWin() process.win = win + process.nuxtURL = _NUXT_URL_ }) // Quit when all windows are closed. diff --git a/store/index.js b/store/index.js index bb740c6..b187b7e 100644 --- a/store/index.js +++ b/store/index.js @@ -378,6 +378,10 @@ const store = new Vuex.Store({ console.log(`[${(new Date()).toLocaleTimeString()}]: An error occurred while gathering the history.`) commit('setHistory', data) + }, + async openInBrowser() { + const {data} = await axios.get('/_openInBrowser') + console.log(`[${(new Date()).toLocaleTimeString()}]: Opening KawAnime in browser at ${data.uri}.`) } } })