Настройка правильных редиректов роутера
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
|
|
||||||
<router-view v-slot="{ Component }">
|
<router-view v-slot="{ Component }">
|
||||||
<keep-alive>
|
<keep-alive>
|
||||||
<component :is="Component" />
|
<component :is="Component" />
|
||||||
@@ -38,6 +37,17 @@ class CardIndex {
|
|||||||
_options = componentOptions;
|
_options = componentOptions;
|
||||||
selectedTab = null;
|
selectedTab = null;
|
||||||
|
|
||||||
|
created() {
|
||||||
|
this.$watch(
|
||||||
|
() => this.$route.path,
|
||||||
|
(newValue) => {
|
||||||
|
if (newValue == '/cardindex' && this.isReader) {
|
||||||
|
this.$router.replace({ path: '/reader' });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
this.setTabByRoute(this.curRoute);
|
this.setTabByRoute(this.curRoute);
|
||||||
}
|
}
|
||||||
@@ -60,11 +70,19 @@ class CardIndex {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get mode() {
|
||||||
|
return this.$store.state.config.mode;
|
||||||
|
}
|
||||||
|
|
||||||
get curRoute() {
|
get curRoute() {
|
||||||
const m = this.$route.path.match(/^(\/[^/]*\/[^/]*).*$/i);
|
const m = this.$route.path.match(/^(\/[^/]*\/[^/]*).*$/i);
|
||||||
return (m ? m[1] : this.$route.path);
|
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);
|
export default vueComponent(CardIndex);
|
||||||
|
|||||||
@@ -288,6 +288,15 @@ class Reader {
|
|||||||
|
|
||||||
this.lastActivePage = false;
|
this.lastActivePage = false;
|
||||||
|
|
||||||
|
this.$watch(
|
||||||
|
() => this.$route.path,
|
||||||
|
(newValue) => {
|
||||||
|
if (newValue == '/reader') {
|
||||||
|
this.updateRoute();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
this.debouncedSetRecentBook = _.debounce(async(newValue) => {
|
this.debouncedSetRecentBook = _.debounce(async(newValue) => {
|
||||||
const recent = this.mostRecentBook();
|
const recent = this.mostRecentBook();
|
||||||
if (recent && (recent.bookPos != newValue || recent.bookPosSeen !== this.bookPosSeen)) {
|
if (recent && (recent.bookPos != newValue || recent.bookPosSeen !== this.bookPosSeen)) {
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ const myRoutes = [
|
|||||||
['/settings', Settings],
|
['/settings', Settings],
|
||||||
['/help', Help],
|
['/help', Help],
|
||||||
['/404', NotFound404],
|
['/404', NotFound404],
|
||||||
['/(.*)', null, null, '/cardindex'],
|
['/:pathMatch(.*)*', null, null, '/cardindex'],
|
||||||
];
|
];
|
||||||
|
|
||||||
let routes = {};
|
let routes = {};
|
||||||
|
|||||||
Reference in New Issue
Block a user