Настройка правильных редиректов роутера
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
Reference in New Issue
Block a user