Jelajahi Sumber

Доделки загрузки книг

Book Pauk 6 tahun lalu
induk
melakukan
bc0b0d6e04

+ 1 - 2
client/components/Reader/HistoryPage/HistoryPage.vue

@@ -207,8 +207,7 @@ class HistoryPage extends Vue {
     }
 
     loadBook(url) {
-        if (this.mostRecentBook.url != url)
-            this.$emit('load-book', {url});
+        this.$emit('load-book', {url});
         this.close();
     }
 

+ 11 - 2
client/components/Reader/Reader.vue

@@ -148,6 +148,7 @@ class Reader extends Vue {
     mostRecentBookReactive = null;
 
     created() {
+        this.loading = true;
         this.commit = this.$store.commit;
         this.dispatch = this.$store.dispatch;
         this.reader = this.$store.state.reader;
@@ -187,6 +188,7 @@ class Reader extends Vue {
                     this.loaderActive = true;
                 }
             }
+            this.loading = false;
         })();
     }
 
@@ -471,7 +473,7 @@ class Reader extends Vue {
         else if (this.mostRecentBookReactive)
             result = 'TextPage';
 
-        if (!result) {
+        if (!result && !this.loading) {
             this.loaderActive = true;
             result = 'LoaderPage';
         }
@@ -484,7 +486,7 @@ class Reader extends Vue {
             //акивируем страницу с текстом
             this.$nextTick(async() => {
                 const last = this.mostRecentBookReactive;
-                const isParsed = await bookManager.hasBookParsed(last);
+                const isParsed = bookManager.hasBookParsed(last);
                 if (!isParsed) {
                     this.$root.$emit('set-app-title');
                     return;
@@ -511,6 +513,13 @@ class Reader extends Vue {
             return;
         }
 
+        // уже просматривается сейчас
+        const recent = this.mostRecentBook();
+        if (recent && recent.url == opts.url && bookManager.hasBookParsed(recent)) {
+            this.loaderActive = false;
+            return;
+        }
+
         this.progressActive = true;
         this.$nextTick(async() => {
             const progress = this.$refs.page;

+ 1 - 1
client/components/Reader/share/bookManager.js

@@ -93,7 +93,7 @@ class BookManager {
         if (!meta.key)
             meta.key = this.keyFromUrl(meta.url);
         let book = this.books[meta.key];
-        return (book && book.parsed);
+        return !!(book && book.parsed);
     }
 
     async getBook(meta, callback) {