Настройка правильных редиректов роутера

This commit is contained in:
Book Pauk
2021-11-07 15:38:17 +07:00
parent 084197530e
commit 6053ca6c0e
3 changed files with 29 additions and 2 deletions

View File

@@ -1,6 +1,5 @@
<template>
<div>
<router-view v-slot="{ Component }">
<keep-alive>
<component :is="Component" />
@@ -38,6 +37,17 @@ class CardIndex {
_options = componentOptions;
selectedTab = null;
created() {
this.$watch(
() => this.$route.path,
(newValue) => {
if (newValue == '/cardindex' && this.isReader) {
this.$router.replace({ path: '/reader' });
}
}
)
}
mounted() {
this.setTabByRoute(this.curRoute);
}
@@ -60,11 +70,19 @@ class CardIndex {
}
}
get mode() {
return this.$store.state.config.mode;
}
get curRoute() {
const m = this.$route.path.match(/^(\/[^/]*\/[^/]*).*$/i);
return (m ? m[1] : this.$route.path);
}
get isReader() {
return (this.mode !== null && (this.mode == 'reader' || this.mode == 'omnireader' || this.mode == 'liberama.top'));
}
}
export default vueComponent(CardIndex);

View File

@@ -288,6 +288,15 @@ class Reader {
this.lastActivePage = false;
this.$watch(
() => this.$route.path,
(newValue) => {
if (newValue == '/reader') {
this.updateRoute();
}
}
);
this.debouncedSetRecentBook = _.debounce(async(newValue) => {
const recent = this.mostRecentBook();
if (recent && (recent.bookPos != newValue || recent.bookPosSeen !== this.bookPosSeen)) {