Работа над группировкой по файлам

This commit is contained in:
Book Pauk
2022-07-12 14:46:34 +07:00
parent 988c959eba
commit 8808cc4779
2 changed files with 24 additions and 18 deletions

View File

@@ -46,20 +46,20 @@
</div> </div>
<div v-show="!showSameBook && item.group && item.group.length > 0" class="row justify-center" style="font-size: 70%"> <div v-show="!showSameBook && item.group && item.group.length > 0" class="row justify-center" style="font-size: 70%">
{{ (item.group ? item.group.length + 1 : 0) }} верси{{ wordEnding((item.group ? item.group.length : 0), 1) }} {{ (item.group ? item.group.length + 1 : 0) }} верси{{ wordEnding((item.group ? item.group.length + 1 : 0), 1) }}
</div> </div>
</div> </div>
<div class="row-part column items-stretch clickable" :style="{ 'width': (350 - 40*(+item.inGroup)) + 'px' }" style="font-size: 75%" @click="loadBook(item)"> <div class="row-part column items-stretch clickable" :style="{ 'width': (350 - 40*(+item.inGroup)) + 'px' }" style="font-size: 75%" @click="loadBook(item)">
<div class="row" style="font-size: 90%"> <div class="row" style="font-size: 80%">
<div class="row justify-center row-info-panel" style="width: 40px"> <div class="row justify-center row-info-panel" style="width: 40px">
{{ item.num }} {{ item.num }}
</div> </div>
<div class="row justify-center row-info-panel" style="width: 130px"> <div class="row justify-center row-info-panel" style="width: 140px">
Чит: {{ item.touchTime }} Читался: {{ item.touchTime }}
</div> </div>
<div class="row justify-center row-info-panel" style="width: 130px"> <div class="row justify-center row-info-panel" style="width: 140px">
Загр: {{ item.addTime }} Загружен: {{ item.loadTime }}
</div> </div>
<div class="row justify-center row-info-panel" style="width: 1px"> <div class="row justify-center row-info-panel" style="width: 1px">
</div> </div>
@@ -238,7 +238,7 @@ class RecentBooksPage {
loadSettings() { loadSettings() {
const settings = this.settings; const settings = this.settings;
this.showSameBook = settings.recentShowSameBook; this.showSameBook = settings.recentShowSameBook;
this.sortMethod = settings.recentSortMethod || 'addTimeDesc'; this.sortMethod = settings.recentSortMethod || 'loadTimeDesc';
} }
get settings() { get settings() {
@@ -261,8 +261,9 @@ class RecentBooksPage {
let d = new Date(); let d = new Date();
d.setTime(book.touchTime); d.setTime(book.touchTime);
const touchTime = utils.formatDate(d); const touchTime = utils.formatDate(d);
d.setTime(book.addTime); const loadTimeRaw = (book.loadTime ? book.loadTime : 0);//book.addTime);
const addTime = utils.formatDate(d); d.setTime(loadTimeRaw);
const loadTime = utils.formatDate(d);
let readPart = 0; let readPart = 0;
let perc = ''; let perc = '';
@@ -282,7 +283,7 @@ class RecentBooksPage {
result.push({ result.push({
touchTime, touchTime,
addTime, loadTime,
desc: { desc: {
author, author,
title: `${title}${perc}${textLen}`, title: `${title}${perc}${textLen}`,
@@ -298,7 +299,7 @@ class RecentBooksPage {
inGroup: false, inGroup: false,
//для сортировки //для сортировки
addTimeRaw: book.addTime, loadTimeRaw,
touchTimeRaw: book.touchTime, touchTimeRaw: book.touchTime,
descString: `${author}${title}${perc}${textLen}`, descString: `${author}${title}${perc}${textLen}`,
}); });
@@ -307,7 +308,7 @@ class RecentBooksPage {
//нумерация //нумерация
let num = 0; let num = 0;
result.sort((a, b) => b.addTimeRaw - a.addTimeRaw); result.sort((a, b) => b.loadTimeRaw - a.loadTimeRaw);
for (const book of result) { for (const book of result) {
num++; num++;
book.num = num; book.num = num;
@@ -326,11 +327,11 @@ class RecentBooksPage {
//сортировка //сортировка
switch (this.sortMethod) { switch (this.sortMethod) {
case 'addTimeDesc': case 'loadTimeDesc':
result.sort((a, b) => b.addTimeRaw - a.addTimeRaw); result.sort((a, b) => b.loadTimeRaw - a.loadTimeRaw);
break; break;
case 'addTimeAsc': case 'loadTimeAsc':
result.sort((a, b) => a.addTimeRaw - b.addTimeRaw); result.sort((a, b) => a.loadTimeRaw - b.loadTimeRaw);
break; break;
case 'touchTimeDesc': case 'touchTimeDesc':
result.sort((a, b) => b.touchTimeRaw - a.touchTimeRaw); result.sort((a, b) => b.touchTimeRaw - a.touchTimeRaw);

View File

@@ -90,6 +90,8 @@ class BookManager {
newRecent[newKey] = _.cloneDeep(book); newRecent[newKey] = _.cloneDeep(book);
newRecent[newKey].key = newKey; newRecent[newKey].key = newKey;
if (!newRecent[newKey].loadTime)
newRecent[newKey].loadTime = newRecent[newKey].addTime;
} }
this.recent = newRecent; this.recent = newRecent;
@@ -231,7 +233,7 @@ class BookManager {
async addBook(newBook, callback) { async addBook(newBook, callback) {
let meta = {url: newBook.url, path: newBook.path}; let meta = {url: newBook.url, path: newBook.path};
meta.key = this.keyFromPath(meta.path); meta.key = this.keyFromPath(meta.path);
meta.addTime = Date.now(); meta.addTime = Date.now();//время добавления в кеш
const cb = (perc) => { const cb = (perc) => {
const p = Math.round(30*perc/100); const p = Math.round(30*perc/100);
@@ -405,7 +407,10 @@ class BookManager {
async setRecentBook(value) { async setRecentBook(value) {
let result = this.metaOnly(value); let result = this.metaOnly(value);
result.touchTime = Date.now(); result.touchTime = Date.now();//время последнего чтения
if (!result.loadTime)
result.loadTime = Date.now();//время загрузки файла
result.deleted = 0; result.deleted = 0;
if (this.recent[result.key]) { if (this.recent[result.key]) {