diff --git a/client/components/Reader/RecentBooksPage/RecentBooksPage.vue b/client/components/Reader/RecentBooksPage/RecentBooksPage.vue index 04515175..6e653b60 100644 --- a/client/components/Reader/RecentBooksPage/RecentBooksPage.vue +++ b/client/components/Reader/RecentBooksPage/RecentBooksPage.vue @@ -9,7 +9,62 @@ - +
+ + + +
+ + +
+
+ {{ index }} +
+ +
+
+
+ {{ item.desc.author }} +
+
{{ item.desc.title }}
+
+
+
+ + + +
+ + + +
+
+
+ + + @@ -103,6 +158,7 @@ import path from 'path-browserify'; //import _ from 'lodash'; import * as utils from '../../../share/utils'; +import LockQueue from '../../../share/LockQueue'; import Window from '../../share/Window.vue'; import bookManager from '../share/bookManager'; import readerApi from '../../../api/reader'; @@ -127,10 +183,14 @@ class RecentBooksPage { pagination = {}; created() { - this.firstInit = true; - this.pagination = {rowsPerPage: 0}; + this.lastScrollTop1 = 0; + this.lastScrollTop2 = 0; - this.columns = [ + this.lock = new LockQueue(100); + + //this.pagination = {rowsPerPage: 0}; + + /*this.columns = [ { name: 'num', label: '#', @@ -168,7 +228,7 @@ class RecentBooksPage { label: '', align: 'left', }, - ]; + ];*/ } init() { @@ -177,28 +237,84 @@ class RecentBooksPage { this.$nextTick(() => { //this.$refs.input.focus();//плохо на планшетах }); - (async() => {//подгрузка списка - if (this.initing) - return; - this.initing = true; - if (this.firstInit) {//для отзывчивости - await this.updateTableData(20); - this.firstInit = false; - } - await utils.sleep(50); - await this.updateTableData(); - - this.initing = false; - })(); + this.updateTableData();//no await } - async updateTableData(limit) { + async updateTableData() { + await this.lock.get(); + try { + let result = []; + + const sorted = bookManager.getSortedRecent(); + const activeBook = bookManager.mostRecentBook(); + + let num = 0; + for (const book of sorted) { + if (book.deleted) + continue; + + num++; + + let d = new Date(); + d.setTime(book.touchTime); + const touchTime = utils.formatDate(d); + + let readPart = 0; + let perc = ''; + let textLen = ''; + const p = (book.bookPosSeen ? book.bookPosSeen : (book.bookPos ? book.bookPos : 0)); + if (book.textLength) { + readPart = p/book.textLength; + perc = ` [${(readPart*100).toFixed(2)}%]`; + textLen = ` ${Math.round(book.textLength/1000)}k`; + } + + const bt = utils.getBookTitle(book.fb2); + + let title = bt.bookTitle; + title = (title ? `"${title}"`: ''); + const author = (bt.author ? bt.author : (bt.bookTitle ? bt.bookTitle : (book.uploadFileName ? book.uploadFileName : book.url))); + + result.push({ + num, + touchTime, + desc: { + author, + title: `${title}${perc}${textLen}`, + }, + readPart, + url: book.url, + path: book.path, + fullTitle: bt.fullTitle, + key: book.key, + active: (activeBook.key == book.key), + + //для сортировки + touchTimeRaw: book.touchTime, + descString: `${author}${title}${perc}${textLen}`, + }); + } + + const search = this.search; + result = result.filter(item => { + return !search || + item.touchTime.includes(search) || + item.desc.title.toLowerCase().includes(search.toLowerCase()) || + item.desc.author.toLowerCase().includes(search.toLowerCase()) + }); + + this.tableData = result; + } finally { + this.lock.ret(); + } + } + + /*async updateTableData(limit) { while (this.updating) await utils.sleep(100); this.updating = true; let result = []; - this.loading = !!limit; const sorted = bookManager.getSortedRecent(); let num = 0; @@ -260,7 +376,7 @@ class RecentBooksPage { this.tableData = result; this.updating = false; - } + }*/ resetSearch() { this.search = ''; @@ -324,6 +440,24 @@ class RecentBooksPage { return false; } + onScroll() { + const curScrollTop = this.$refs.vsContainer.scrollTop; + + if (curScrollTop - this.lastScrollTop1 > 150) { + this.$refs.header.style.top = `-${this.$refs.header.offsetHeight}px`; + this.$refs.header.style.transition = 'top 0.2s ease 0s'; + + this.lastScrollTop1 = curScrollTop; + } else if (curScrollTop - this.lastScrollTop2 < 0) { + this.$refs.header.style.position = 'sticky'; + this.$refs.header.style.top = 0; + + this.lastScrollTop1 = curScrollTop; + } + + this.lastScrollTop2 = curScrollTop; + } + close() { this.$emit('recent-books-close'); } @@ -341,31 +475,34 @@ export default vueComponent(RecentBooksPage); - diff --git a/client/quasar.js b/client/quasar.js index 0994aa2a..dfbc5404 100644 --- a/client/quasar.js +++ b/client/quasar.js @@ -32,6 +32,8 @@ import {QPopupProxy} from 'quasar/src/components/popup-proxy'; import {QDialog} from 'quasar/src/components/dialog'; import {QChip} from 'quasar/src/components/chip'; import {QTree} from 'quasar/src/components/tree'; +import {QVirtualScroll} from 'quasar/src/components/virtual-scroll'; + //import {QExpansionItem} from 'quasar/src/components/expansion-item'; const components = { @@ -62,6 +64,7 @@ const components = { QChip, QTree, //QExpansionItem, + QVirtualScroll, }; //directives