This repository has been archived on 2020-11-22. You can view files and clone it, but cannot push or open issues/pull-requests.
mangareader/frontend/src/router.js

50 lines
1.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

import API from '@/api-client.js'
import Reader from './views/Reader.vue'
import Router from 'vue-router'
import SeriesList from './views/SeriesList.vue'
import VolumeList from './views/VolumeList.vue'
import Vue from 'vue'
Vue.use(Router)
const router = new Router({
mode: 'history',
base: process.env.BASE_URL,
routes: [
{
path: '/',
name: 'series-list',
component: SeriesList,
meta: {
title: (to, callback) => callback('Home')
}
},
{
path: '/series/:id',
name: 'volume-list',
component: VolumeList,
meta: {
title: (to, callback) => API.getSeriesInfo(to.params.id, info => callback(info.title))
}
},
{
path: '/volume/:id',
name: 'reader',
component: Reader,
meta: {
title: (to, callback) => API.getVolumeInfo(to.params.id, info => callback(info.title))
}
}
]
})
// https://github.com/vuejs/vue-router/issues/914#issuecomment-261461921
router.beforeEach((to, from, next) => {
to.meta.title(to, (title) => {
document.title = `${title} Manga Reader`
})
next()
})
export default router