Fully implemented button to open KawAnime in the browser.

This commit is contained in:
Kylart 2017-05-08 12:20:46 +02:00
parent 4aab73432c
commit 0d689caa2e
5 changed files with 30 additions and 1 deletions

View File

@ -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)
}

View File

@ -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()
}

View File

@ -42,6 +42,13 @@
</v-card-row>
</v-card>
</v-dialog>
<v-btn icon
class="open-in-browser"
v-tooltip:left="{ html: 'Open KawAnime in your browser' }"
@click.native="$store.dispatch('openInBrowser')">
<v-icon>open_in_new</v-icon>
</v-btn>
</div>
</div>
</v-toolbar-logo>
@ -255,6 +262,11 @@
color: rgba(255, 255, 255, 0.8);
}
.open-in-browser
{
margin-top: 6px !important;
}
.sidebar-title-container
{
margin-top: 20px;

View File

@ -106,6 +106,7 @@ app.on('ready', () => {
newWin()
process.win = win
process.nuxtURL = _NUXT_URL_
})
// Quit when all windows are closed.

View File

@ -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}.`)
}
}
})