Browse Source

Работа над HistoryPage

Book Pauk 6 years ago
parent
commit
470ee63714

+ 12 - 5
client/components/Reader/HistoryPage/HistoryPage.vue

@@ -26,8 +26,10 @@
                             Время<br>просм.
                             Время<br>просм.
                         </template>
                         </template>
                         <template slot-scope="scope"><!-- eslint-disable-line vue/no-unused-vars -->
                         <template slot-scope="scope"><!-- eslint-disable-line vue/no-unused-vars -->
-                            {{ scope.row.touchDate }}<br>
-                            {{ scope.row.touchTime }}
+                            <div class="desc" @click="loadBook(scope.row.url)">
+                                {{ scope.row.touchDate }}<br>
+                                {{ scope.row.touchTime }}
+                            </div>
                         </template>
                         </template>
                     </el-table-column>
                     </el-table-column>
 
 
@@ -46,8 +48,8 @@
                             >
                             >
                             <template slot-scope="scope">
                             <template slot-scope="scope">
                                 <div class="desc" @click="loadBook(scope.row.url)">
                                 <div class="desc" @click="loadBook(scope.row.url)">
-                                    <span>{{ scope.row.desc.author }}</span><br>
-                                    <span>{{ `"${scope.row.desc.title}"` }}</span>
+                                    <span style="color: green">{{ scope.row.desc.author }}</span><br>
+                                    <span>{{ scope.row.desc.title }}</span>
                                 </div>
                                 </div>
                             </template>
                             </template>
                         </el-table-column>
                         </el-table-column>
@@ -113,12 +115,17 @@ class HistoryPage extends Vue {
             d.setTime(book.touchTime);
             d.setTime(book.touchTime);
             const t = formatDate(d).split(' ');
             const t = formatDate(d).split(' ');
 
 
+            let perc = '';
+            const p = (book.bookPosSeen ? book.bookPosSeen : (book.bookPos ? book.bookPos : 0));
+            if (book.textLength)
+                perc = ` [${((p/book.textLength)*100).toFixed(2)}%]`;
+
             result.push({
             result.push({
                 touchDateTime: book.touchTime,
                 touchDateTime: book.touchTime,
                 touchDate: t[0],
                 touchDate: t[0],
                 touchTime: t[1],
                 touchTime: t[1],
                 desc: {
                 desc: {
-                    title: book.fb2.bookTitle,
+                    title: `"${book.fb2.bookTitle}"${perc}`,
                     author: _.compact([
                     author: _.compact([
                         book.fb2.lastName,
                         book.fb2.lastName,
                         book.fb2.firstName,
                         book.fb2.firstName,

+ 5 - 3
client/components/Reader/Reader.vue

@@ -84,7 +84,7 @@ export default @Component({
                     textPage.bookPos = newValue;
                     textPage.bookPos = newValue;
                 }
                 }
                 if (this.lastOpenedBook && this.lastOpenedBook.bookPos != newValue) {
                 if (this.lastOpenedBook && this.lastOpenedBook.bookPos != newValue) {
-                    this.commit('reader/setOpenedBook', Object.assign({}, this.lastOpenedBook, {bookPos: newValue}));
+                    this.commit('reader/setOpenedBook', Object.assign({}, this.lastOpenedBook, {bookPos: newValue, bookPosSeen: this.bookPosSeen}));
                 }
                 }
             }
             }
         },
         },
@@ -168,6 +168,7 @@ class Reader extends Vue {
     }
     }
 
 
     bookPosChanged(event) {
     bookPosChanged(event) {
+        this.bookPosSeen = event.bookPosSeen;
         this.bookPos = event.bookPos;
         this.bookPos = event.bookPos;
         this.updateRoute();
         this.updateRoute();
     }
     }
@@ -311,6 +312,7 @@ class Reader extends Vue {
                 let wasOpened = this.reader.openedBook[key];
                 let wasOpened = this.reader.openedBook[key];
                 wasOpened = (wasOpened ? wasOpened : {});
                 wasOpened = (wasOpened ? wasOpened : {});
                 const bookPos = (opts.bookPos !== undefined ? opts.bookPos : wasOpened.bookPos);
                 const bookPos = (opts.bookPos !== undefined ? opts.bookPos : wasOpened.bookPos);
+                const bookPosSeen = (opts.bookPos !== undefined ? opts.bookPos : wasOpened.bookPosSeen);
 
 
                 let book = null;
                 let book = null;
 
 
@@ -322,7 +324,7 @@ class Reader extends Vue {
 
 
                     // если есть в локальном кеше
                     // если есть в локальном кеше
                     if (bookParsed) {
                     if (bookParsed) {
-                        this.commit('reader/setOpenedBook', Object.assign({bookPos}, bookManager.metaOnly(bookParsed)));
+                        this.commit('reader/setOpenedBook', Object.assign({bookPos, bookPosSeen}, bookManager.metaOnly(bookParsed)));
                         this.loaderActive = false;
                         this.loaderActive = false;
                         progress.hide(); this.progressActive = false;
                         progress.hide(); this.progressActive = false;
                         return;
                         return;
@@ -358,7 +360,7 @@ class Reader extends Vue {
                 });
                 });
 
 
                 // добавляем в историю
                 // добавляем в историю
-                this.commit('reader/setOpenedBook', Object.assign({bookPos}, bookManager.metaOnly(addedBook)));
+                this.commit('reader/setOpenedBook', Object.assign({bookPos, bookPosSeen}, bookManager.metaOnly(addedBook)));
                 this.updateRoute(true);
                 this.updateRoute(true);
 
 
                 this.loaderActive = false;
                 this.loaderActive = false;

+ 3 - 2
client/components/Reader/TextPage/TextPage.vue

@@ -68,7 +68,7 @@ class TextPage extends Vue {
         this.reader = this.$store.state.reader;
         this.reader = this.$store.state.reader;
 
 
         this.debouncedEmitPosChange = _.debounce((newValue) => {
         this.debouncedEmitPosChange = _.debounce((newValue) => {
-            this.$emit('book-pos-changed', {bookPos: newValue});
+            this.$emit('book-pos-changed', {bookPos: newValue, bookPosSeen: this.bookPosSeen});
         }, 1000);
         }, 1000);
 
 
         this.debouncedStartClickRepeat = _.debounce((x, y) => {
         this.debouncedStartClickRepeat = _.debounce((x, y) => {
@@ -285,7 +285,7 @@ class TextPage extends Vue {
                 await this.loadFonts();
                 await this.loadFonts();
 
 
                 //this.draw();
                 //this.draw();
-                
+
                 // шрифты хрен знает когда подгружаются, поэтому
                 // шрифты хрен знает когда подгружаются, поэтому
                 let i = 0;
                 let i = 0;
                 this.parsed.force = true;
                 this.parsed.force = true;
@@ -459,6 +459,7 @@ class TextPage extends Vue {
             if (i >= 0) {
             if (i >= 0) {
                 this.statusBar = this.drawHelper.drawStatusBar(this.statusBarTop, this.statusBarHeight, 
                 this.statusBar = this.drawHelper.drawStatusBar(this.statusBarTop, this.statusBarHeight, 
                     lines[i].end, this.parsed.textLength, this.title);
                     lines[i].end, this.parsed.textLength, this.title);
+                this.bookPosSeen = lines[i].end;
             }
             }
         }
         }
     }
     }