fix(webui): redirect to initial page after login

closes #122
This commit is contained in:
Gauthier Roebroeck 2020-03-24 11:21:08 +08:00
parent 5c903502e8
commit 5f61597125
3 changed files with 9 additions and 4 deletions

View file

@ -127,8 +127,9 @@ router.beforeEach((to, from, next) => {
if (!['read-book', 'browse-book', 'browse-series'].includes(<string>to.name)) { if (!['read-book', 'browse-book', 'browse-series'].includes(<string>to.name)) {
document.title = 'Komga' document.title = 'Komga'
} }
if (to.name !== 'startup' && to.name !== 'login' && !lStore.getters.authenticated) next({ name: 'startup' }) if (to.name !== 'startup' && to.name !== 'login' && !lStore.getters.authenticated) {
else next() next({ name: 'startup', query: { redirect: to.fullPath } })
} else next()
}) })
export default router export default router

View file

@ -93,7 +93,11 @@ export default Vue.extend({
await this.$store.dispatch('getLibraries') await this.$store.dispatch('getLibraries')
if (this.$route.query.redirect) {
this.$router.push({ path: this.$route.query.redirect.toString() })
} else {
this.$router.push({ name: 'home' }) this.$router.push({ name: 'home' })
}
} catch (e) { } catch (e) {
this.showSnack(e.message) this.showSnack(e.message)
} }

View file

@ -19,7 +19,7 @@ export default Vue.extend({
await this.$store.dispatch('getLibraries') await this.$store.dispatch('getLibraries')
this.$router.back() this.$router.back()
} catch (e) { } catch (e) {
this.$router.push({ name: 'login' }) this.$router.push({ name: 'login', query: { redirect: this.$route.query.redirect } })
} }
}, },
}) })