From b387509f885e5edfe59dd6897a35f15d9224e5e8 Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Fri, 8 Jul 2022 12:26:47 +0700 Subject: [PATCH 01/47] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=B1=D0=BB=D0=BE=D0=BA=D0=B8=D1=80=D0=BE=D0=B2=D0=BA?= =?UTF-8?q?=D1=83=20=D0=BF=D1=80=D0=B8=20=D0=B7=D0=B0=D0=B3=D1=80=D1=83?= =?UTF-8?q?=D0=B7=D0=BA=D0=B5=20=D0=BA=D0=BD=D0=B8=D0=B3,=20=D1=82=D0=B5?= =?UTF-8?q?=D0=BF=D0=B5=D1=80=D1=8C=20=D0=B7=D0=B0=D0=B3=D1=80=D1=83=D0=B6?= =?UTF-8?q?=D0=B0=D1=8E=D1=82=D1=81=D1=8F=20=D0=BF=D0=BE=D1=81=D0=BB=D0=B5?= =?UTF-8?q?=D0=B4=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C=D0=BD=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/components/Reader/Reader.vue | 29 ++++++++++++---- client/share/LockQueue.js | 53 +++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 6 deletions(-) create mode 100644 client/share/LockQueue.js diff --git a/client/components/Reader/Reader.vue b/client/components/Reader/Reader.vue index 7fe007a3..69366647 100644 --- a/client/components/Reader/Reader.vue +++ b/client/components/Reader/Reader.vue @@ -201,6 +201,7 @@ import miscApi from '../../api/misc'; import {versionHistory} from './versionHistory'; import * as utils from '../../share/utils'; +import LockQueue from '../../share/LockQueue'; const componentOptions = { components: { @@ -313,6 +314,8 @@ class Reader { this.reader = this.$store.state.reader; this.config = this.$store.state.config; + this.lock = new LockQueue(100); + this.$root.addEventHook('key', this.keyHook); this.lastActivePage = false; @@ -1051,7 +1054,7 @@ class Reader { return result; } - async loadBook(opts) { + async _loadBook(opts) { if (!opts || !opts.url) { this.mostRecentBook(); return; @@ -1061,10 +1064,6 @@ class Reader { let url = encodeURI(decodeURI(opts.url)); - //TODO: убрать конвертирование 'file://' после 06.2021 - if (url.length == 71 && url.indexOf('file://') == 0) - url = url.replace(/^file/, 'disk'); - if ((url.indexOf('http://') != 0) && (url.indexOf('https://') != 0) && (url.indexOf('disk://') != 0)) url = 'http://' + url; @@ -1189,7 +1188,16 @@ class Reader { } } - async loadFile(opts) { + async loadBook(opts) { + await this.lock.get(); + try { + await this._loadBook(opts); + } finally { + this.lock.ret(); + } + } + + async _loadFile(opts) { this.progressActive = true; await this.$nextTick(); @@ -1213,6 +1221,15 @@ class Reader { } } + async loadFile(opts) { + await this.lock.get(); + try { + await this._loadFile(opts); + } finally { + this.lock.ret(); + } + } + blinkCachedLoadMessage() { if (!this.blinkCachedLoad) return; diff --git a/client/share/LockQueue.js b/client/share/LockQueue.js new file mode 100644 index 00000000..ed350c57 --- /dev/null +++ b/client/share/LockQueue.js @@ -0,0 +1,53 @@ +class LockQueue { + constructor(queueSize) { + this.queueSize = queueSize; + this.freed = true; + this.waitingQueue = []; + } + + //async + get(take = true) { + return new Promise((resolve, reject) => { + if (this.freed) { + if (take) + this.freed = false; + resolve(); + return; + } + + if (this.waitingQueue.length < this.queueSize) { + this.waitingQueue.push({resolve, reject}); + } else { + reject(new Error('Lock queue is too long')); + } + }); + } + + ret() { + if (this.waitingQueue.length) { + this.waitingQueue.shift().resolve(); + } else { + this.freed = true; + } + } + + //async + wait() { + return this.get(false); + } + + retAll() { + while (this.waitingQueue.length) { + this.waitingQueue.shift().resolve(); + } + } + + errAll(error = 'rejected') { + while (this.waitingQueue.length) { + this.waitingQueue.shift().reject(new Error(error)); + } + } + +} + +export default LockQueue; \ No newline at end of file From fce69e465759d8c8b85430709af0a4169e1c5ed8 Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Fri, 8 Jul 2022 13:21:42 +0700 Subject: [PATCH 02/47] =?UTF-8?q?=D0=9D=D0=B0=D1=81=D1=82=D1=80=D0=BE?= =?UTF-8?q?=D0=B9=D0=BA=D0=B0=20=D1=86=D0=B2=D0=B5=D1=82=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/components/ExternalLibs/ExternalLibs.vue | 15 ++++++++------- client/components/share/Window.vue | 14 +++++++++----- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/client/components/ExternalLibs/ExternalLibs.vue b/client/components/ExternalLibs/ExternalLibs.vue index f0832df0..2d91bf80 100644 --- a/client/components/ExternalLibs/ExternalLibs.vue +++ b/client/components/ExternalLibs/ExternalLibs.vue @@ -5,19 +5,19 @@ @@ -239,6 +180,9 @@ const componentOptions = { search() { this.updateTableData(); }, + sortMethod() { + this.updateTableData(); + }, settings() { this.loadSettings(); }, @@ -271,6 +215,8 @@ class RecentBooksPage { //this.$refs.input.focus();//плохо на планшетах }); + this.inited = true; + (async() => { this.showBar(); await this.updateTableData(); @@ -289,6 +235,9 @@ class RecentBooksPage { } async updateTableData() { + if (!this.inited) + return; + await this.lock.get(); try { let result = []; @@ -346,7 +295,6 @@ class RecentBooksPage { //для сортировки loadTimeRaw, touchTimeRaw: book.touchTime, - descString: `${author}${title}${perc}${textLen}`, }); } @@ -385,6 +333,18 @@ class RecentBooksPage { case 'touchTimeAsc': result.sort((a, b) => a.touchTimeRaw - b.touchTimeRaw); break; + case 'authorDesc': + result.sort((a, b) => b.desc.author.localeCompare(a.desc.author)); + break; + case 'authorAsc': + result.sort((a, b) => a.desc.author.localeCompare(b.desc.author)); + break; + case 'titleDesc': + result.sort((a, b) => b.desc.title.localeCompare(a.desc.title)); + break; + case 'titleAsc': + result.sort((a, b) => a.desc.title.localeCompare(b.desc.title)); + break; } //группировка @@ -540,6 +500,12 @@ class RecentBooksPage { this.updateTableData(); } + sortMethodSelected() { + const newSettings = _.cloneDeep(this.settings); + newSettings.recentSortMethod = this.sortMethod; + this.commit('reader/setSettings', newSettings); + } + async scrollToActiveBook() { this.lockScroll = true; try { @@ -586,6 +552,20 @@ class RecentBooksPage { } } + + get sortMethodOptions() { + return [ + {label: ' Время загрузки', value: 'loadTimeDesc'}, + {label: ' Время загрузки', value: 'loadTimeAsc'}, + {label: ' Время чтения', value: 'touchTimeDesc'}, + {label: ' Время чтения', value: 'touchTimeAsc'}, + {label: ' Автор', value: 'authorDesc'}, + {label: ' Автор', value: 'authorAsc'}, + {label: ' Название', value: 'titleDesc'}, + {label: ' Название', value: 'titleAsc'}, + ]; + } + close() { this.$emit('recent-books-close'); } From 7e89228803a7abbcca294c203846a758657b8e8a Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Tue, 12 Jul 2022 19:07:39 +0700 Subject: [PATCH 47/47] =?UTF-8?q?=D0=92=D0=B5=D1=80=D1=81=D0=B8=D1=8F=200.?= =?UTF-8?q?11.7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/components/Reader/versionHistory.js | 22 ++++++++++++++++++++++ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/client/components/Reader/versionHistory.js b/client/components/Reader/versionHistory.js index 0b054d97..00b49a3a 100644 --- a/client/components/Reader/versionHistory.js +++ b/client/components/Reader/versionHistory.js @@ -1,4 +1,26 @@ export const versionHistory = [ +{ + version: '0.11.7', + releaseDate: '2022-07-12', + showUntil: '2022-07-19', + content: +` +
    +
  • добавлено автосокрытие панели управления при листании, отключается в настройках
  • +
  • изменения в окне загруженных книг:
  • +
      +
    • добавлена группировка по версиям файла одной и той же книги
    • +
    • группировка происходит по имени загружаемого файла, либо по URL книги
    • +
    • добавлены различные методы сортировки списка загруженных книг
    • +
    • нумерация всегда осуществляется по времени загрузки
    • +
    +
  • незначительные общие изменения интерфейса, приведение к единому стилю
  • +
  • исправления багов
  • +
+ +` +}, + { version: '0.11.6', releaseDate: '2022-07-02', diff --git a/package-lock.json b/package-lock.json index 47144f71..3b35a2c2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "Liberama", - "version": "0.11.6", + "version": "0.11.7", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "Liberama", - "version": "0.11.6", + "version": "0.11.7", "hasInstallScript": true, "license": "CC0-1.0", "dependencies": { diff --git a/package.json b/package.json index d5c5d66a..1303b588 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "Liberama", - "version": "0.11.6", + "version": "0.11.7", "author": "Book Pauk ", "license": "CC0-1.0", "repository": "bookpauk/liberama",