|
@@ -1,6 +1,8 @@
|
|
|
<template>
|
|
|
<div class="main">
|
|
|
<pre>{{ meta }}</pre>
|
|
|
+ <pre>{{ bookPos }}</pre>
|
|
|
+ <pre>{{ $route.query }}</pre>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
@@ -13,10 +15,22 @@ import _ from 'lodash';
|
|
|
import bookManager from '../share/bookManager';
|
|
|
|
|
|
export default @Component({
|
|
|
+ watch: {
|
|
|
+ bookPos: function(newValue) {
|
|
|
+ this.updateRoute(newValue);
|
|
|
+ this.drawPage();
|
|
|
+ },
|
|
|
+ routeParamPos: function(newValue) {
|
|
|
+ if (newValue !== undefined && newValue != this.bookPos) {
|
|
|
+ this.bookPos = newValue;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ },
|
|
|
})
|
|
|
class TextPage extends Vue {
|
|
|
meta = null;
|
|
|
fb2 = null;
|
|
|
+ bookPos = 0;
|
|
|
|
|
|
created() {
|
|
|
this.commit = this.$store.commit;
|
|
@@ -24,7 +38,7 @@ class TextPage extends Vue {
|
|
|
this.config = this.$store.state.config;
|
|
|
this.reader = this.$store.state.reader;
|
|
|
|
|
|
- this.openFailed = false;
|
|
|
+ this.lastOpenTry = '';
|
|
|
}
|
|
|
|
|
|
activated() {
|
|
@@ -32,15 +46,15 @@ class TextPage extends Vue {
|
|
|
this.meta = null;
|
|
|
this.fb2 = null;
|
|
|
|
|
|
- const last = this.lastOpenedBook;
|
|
|
+ let last = this.lastOpenedBook;
|
|
|
if (last) {
|
|
|
(async() => {
|
|
|
const isParsed = await bookManager.hasBookParsed(last);
|
|
|
if (!isParsed) {
|
|
|
this.$root.$emit('set-app-title');
|
|
|
- if (!this.openFailed) {
|
|
|
+ if (this.lastOpenTry != last) {
|
|
|
this.$emit('parse-book', last);
|
|
|
- this.openFailed = true;
|
|
|
+ this.lastOpenTry = last;
|
|
|
}
|
|
|
return;
|
|
|
}
|
|
@@ -55,6 +69,8 @@ class TextPage extends Vue {
|
|
|
this.fb2.bookTitle
|
|
|
]).join(' '));
|
|
|
|
|
|
+ this.bookPos = (this.routeParamPos !== undefined ? this.routeParamPos : last.bookPos || 0);
|
|
|
+ this.updateRoute(this.bookPos);
|
|
|
this.drawPage();
|
|
|
})();
|
|
|
}
|
|
@@ -64,6 +80,23 @@ class TextPage extends Vue {
|
|
|
return this.$store.getters['reader/lastOpenedBook'];
|
|
|
}
|
|
|
|
|
|
+ get routeParamPos() {
|
|
|
+ let result = undefined;
|
|
|
+ const q = this.$route.query;
|
|
|
+ if (q['__p']) {
|
|
|
+ result = q['__p'];
|
|
|
+ if (Array.isArray(result))
|
|
|
+ result = result[0];
|
|
|
+ }
|
|
|
+
|
|
|
+ return (result ? parseInt(result, 10) || 0 : result);
|
|
|
+ }
|
|
|
+
|
|
|
+ updateRoute(newPos) {
|
|
|
+ if (this.book)
|
|
|
+ this.$router.replace(`/reader?__p=${newPos}&url=${this.lastOpenedBook.url}`);
|
|
|
+ }
|
|
|
+
|
|
|
drawPage() {
|
|
|
const last = this.lastOpenedBook;
|
|
|
if (!last)
|