From 988c959eba960c7b1e9c3a4b76eb365804fb47be Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Tue, 12 Jul 2022 04:05:51 +0700 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=20=D0=BD?= =?UTF-8?q?=D0=B0=D0=B4=20=D0=B3=D1=80=D1=83=D0=BF=D0=BF=D0=B8=D1=80=D0=BE?= =?UTF-8?q?=D0=B2=D0=BA=D0=BE=D0=B9=20=D1=84=D0=B0=D0=B9=D0=BB=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RecentBooksPage/RecentBooksPage.vue | 144 +++++++++++++++--- client/store/modules/reader.js | 3 + 2 files changed, 128 insertions(+), 19 deletions(-) diff --git a/client/components/Reader/RecentBooksPage/RecentBooksPage.vue b/client/components/Reader/RecentBooksPage/RecentBooksPage.vue index 6de40be9..7f38920d 100644 --- a/client/components/Reader/RecentBooksPage/RecentBooksPage.vue +++ b/client/components/Reader/RecentBooksPage/RecentBooksPage.vue @@ -10,11 +10,15 @@
-
+
+ + + + @@ -31,22 +35,47 @@ virtual-scroll-item-size="80" @virtual-scroll="onScroll" > -
-
- {{ item.num }} +
+
+
-
-
+
+
+ +
+ +
+ {{ (item.group ? item.group.length + 1 : 0) }} верси{{ wordEnding((item.group ? item.group.length : 0), 1) }} +
+
+ +
+
+
+ {{ item.num }} +
+
+ Чит: {{ item.touchTime }} +
+
+ Загр: {{ item.addTime }} +
+
+
+
+ +
{{ item.desc.author }}
{{ item.desc.title }}
-
+ +
-
+ @@ -155,7 +184,7 @@ import vueComponent from '../../vueComponent.js'; import path from 'path-browserify'; -//import _ from 'lodash'; +import _ from 'lodash'; import * as utils from '../../../share/utils'; import LockQueue from '../../../share/LockQueue'; @@ -168,9 +197,12 @@ const componentOptions = { Window, }, watch: { - search: function() { + search() { this.updateTableData(); - } + }, + settings() { + this.loadSettings(); + }, }, }; class RecentBooksPage { @@ -180,12 +212,17 @@ class RecentBooksPage { search = ''; tableData = []; sortMethod = ''; + showSameBook = false; created() { + this.commit = this.$store.commit; + this.lastScrollTop1 = 0; this.lastScrollTop2 = 0; this.lock = new LockQueue(100); + + this.loadSettings(); } init() { @@ -198,6 +235,16 @@ class RecentBooksPage { this.updateTableData();//no await } + loadSettings() { + const settings = this.settings; + this.showSameBook = settings.recentShowSameBook; + this.sortMethod = settings.recentSortMethod || 'addTimeDesc'; + } + + get settings() { + return this.$store.state.reader.settings; + } + async updateTableData() { await this.lock.get(); try { @@ -214,6 +261,8 @@ class RecentBooksPage { let d = new Date(); d.setTime(book.touchTime); const touchTime = utils.formatDate(d); + d.setTime(book.addTime); + const addTime = utils.formatDate(d); let readPart = 0; let perc = ''; @@ -233,6 +282,7 @@ class RecentBooksPage { result.push({ touchTime, + addTime, desc: { author, title: `${title}${perc}${textLen}`, @@ -244,6 +294,8 @@ class RecentBooksPage { key: book.key, sameBookKey: book.sameBookKey, active: (activeBook.key == book.key), + activeParent: false, + inGroup: false, //для сортировки addTimeRaw: book.addTime, @@ -290,14 +342,21 @@ class RecentBooksPage { //группировка const groups = {}; - const newResult = []; + const parents = {}; + let newResult = []; for (const book of result) { if (book.sameBookKey !== undefined) { if (!groups[book.sameBookKey]) { groups[book.sameBookKey] = []; + parents[book.sameBookKey] = book; + book.group = groups[book.sameBookKey]; newResult.push(book); } else { + book.inGroup = true; + if (book.active) + parents[book.sameBookKey].activeParent = true; + groups[book.sameBookKey].push(book); } } else { @@ -306,6 +365,21 @@ class RecentBooksPage { } result = newResult; + //showSameBook + if (this.showSameBook) { + newResult = []; + for (const book of result) { + newResult.push(book); + if (book.group) { + for (const sameBook of book.group) { + newResult.push(sameBook); + } + } + } + + result = newResult; + } + //другие стадии //..... @@ -388,13 +462,16 @@ class RecentBooksPage { this.$refs.input.focus(); } - wordEnding(num) { - const endings = ['ов', '', 'а', 'а', 'а', 'ов', 'ов', 'ов', 'ов', 'ов']; + wordEnding(num, type = 0) { + const endings = [ + ['ов', '', 'а', 'а', 'а', 'ов', 'ов', 'ов', 'ов', 'ов'], + ['й', 'я', 'и', 'и', 'и', 'й', 'й', 'й', 'й', 'й'] + ]; const deci = num % 100; if (deci > 10 && deci < 20) { - return 'ов'; + return endings[type][0]; } else { - return endings[num % 10]; + return endings[type][num % 10]; } } @@ -463,6 +540,16 @@ class RecentBooksPage { this.lastScrollTop2 = curScrollTop; } + showSameBookClick() { + this.showSameBook = !this.showSameBook; + + const newSettings = _.cloneDeep(this.settings); + newSettings.recentShowSameBook = this.showSameBook; + this.commit('reader/setSettings', newSettings); + + this.updateTableData(); + } + close() { this.$emit('recent-books-close'); } @@ -508,7 +595,7 @@ export default vueComponent(RecentBooksPage); } .break-word { - line-height: 150%; + line-height: 180%; overflow-wrap: break-word; word-wrap: break-word; white-space: normal; @@ -517,13 +604,32 @@ export default vueComponent(RecentBooksPage); .read-bar { height: 3px; background-color: #aaaaaa; + margin-bottom: 2px; } .even { - background-color: #f0f0f0; + background-color: #f2f2f2; } .active-book { background-color: #b0f0b0 !important; } + +.active-parent-book { + background-color: #ffbbbb !important; +} + +.icon { + transition: transform 0.2s; +} + +.expanded-icon { + transform: rotate(90deg); +} + +.row-info-panel { + line-height: 110%; + border-left: 1px solid #cccccc; + border-bottom: 1px solid #cccccc; +} diff --git a/client/store/modules/reader.js b/client/store/modules/reader.js index d4bb9b87..ab4a8972 100644 --- a/client/store/modules/reader.js +++ b/client/store/modules/reader.js @@ -188,6 +188,9 @@ const settingDefaults = { toolBarHideOnScroll: true, userHotKeys: {}, userWallpapers: [], + + recentShowSameBook: false, + recentSortMethod: '', }; for (const font of fonts)