Работа над BookUpdateChecker
This commit is contained in:
@@ -310,6 +310,7 @@ class Reader {
|
||||
dualPageMode = false;
|
||||
|
||||
bucEnabled = false;
|
||||
bucSetOnNew = false;
|
||||
|
||||
created() {
|
||||
this.rstore = rstore;
|
||||
@@ -359,8 +360,14 @@ class Reader {
|
||||
}
|
||||
}, 200);
|
||||
|
||||
this.debouncedRecentBooksPageUpdate = _.debounce(async() => {
|
||||
if (this.recentBooksActive) {
|
||||
await this.$refs.recentBooksPage.updateTableData();
|
||||
}
|
||||
}, 100);
|
||||
|
||||
this.recentItemKeys = [];
|
||||
this.saveRecentChanges = _.debounce(async() => {
|
||||
this.debouncedSaveRecent = _.debounce(async() => {
|
||||
let timer = setTimeout(() => {
|
||||
if (!this.offlineModeActive)
|
||||
this.$root.notify.error('Таймаут соединения');
|
||||
@@ -435,7 +442,7 @@ class Reader {
|
||||
//вечный цикл, запрашиваем периодически обновления
|
||||
while (1) {// eslint-disable-line no-constant-condition
|
||||
await this.checkBuc();
|
||||
await utils.sleep(70*60*1000); //каждые 70 минут
|
||||
await utils.sleep(/*70*60*1000*/10*1000); //каждые 70 минут
|
||||
}
|
||||
//дальше хода нет
|
||||
})();
|
||||
@@ -460,6 +467,7 @@ class Reader {
|
||||
this.dualPageMode = settings.dualPageMode;
|
||||
this.userWallpapers = settings.userWallpapers;
|
||||
this.bucEnabled = settings.bucEnabled;
|
||||
this.bucSetOnNew = settings.bucSetOnNew;
|
||||
|
||||
this.readerActionByKeyCode = utils.userHotKeysObjectSwap(settings.userHotKeys);
|
||||
this.$root.readerActionByKeyEvent = (event) => {
|
||||
@@ -595,7 +603,6 @@ class Reader {
|
||||
await bookManager.recentSetItem(book);
|
||||
}
|
||||
}
|
||||
console.log('checkBuc finished', arr);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
@@ -731,14 +738,12 @@ console.log('checkBuc finished', arr);
|
||||
}
|
||||
|
||||
if (eventName == 'recent-changed') {
|
||||
if (this.recentBooksActive) {
|
||||
await this.$refs.recentBooksPage.updateTableData();
|
||||
}
|
||||
this.debouncedRecentBooksPageUpdate();
|
||||
|
||||
//сохранение в serverStorage
|
||||
if (value && this.recentItemKeys.indexOf(value) < 0) {
|
||||
this.recentItemKeys.push(value);
|
||||
this.saveRecentChanges();
|
||||
this.debouncedSaveRecent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1307,9 +1312,13 @@ console.log('checkBuc finished', arr);
|
||||
delete wasOpened.loadTime;
|
||||
|
||||
// добавляем в историю
|
||||
await bookManager.setRecentBook(Object.assign(wasOpened, addedBook));
|
||||
const recentBook = await bookManager.setRecentBook(Object.assign(wasOpened, addedBook));
|
||||
if (this.bucSetOnNew) {
|
||||
await bookManager.setCheckBuc(recentBook, true);
|
||||
}
|
||||
|
||||
this.mostRecentBook();
|
||||
this.addAction(wasOpened.bookPos);
|
||||
this.addAction(recentBook.bookPos);
|
||||
this.updateRoute(true);
|
||||
|
||||
this.loaderActive = false;
|
||||
|
||||
@@ -105,9 +105,13 @@
|
||||
</div>
|
||||
|
||||
<div class="row-part column justify-center items-stretch" style="width: 80px">
|
||||
<div class="col row justify-center items-center clickable" style="padding: 0 2px 0 2px" @click="loadBook(item)">
|
||||
<div class="col row justify-center items-center clickable" style="padding: 0 2px 0 2px" @click="loadBook(item, bothBucEnabled && item.needBookUpdate)">
|
||||
<div v-show="isLoadedCover(item.coverPageUrl)" style="height: 80px" v-html="getCoverHtml(item.coverPageUrl)" />
|
||||
<q-icon v-show="!isLoadedCover(item.coverPageUrl)" name="la la-book" size="40px" style="color: #dddddd" />
|
||||
|
||||
<div v-show="bothBucEnabled && item.needBookUpdate" style="position: absolute; z-index: 10;">
|
||||
<q-icon name="la la-sync" size="60px" style="color: blue" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-show="!showSameBook && item.group && item.group.length > 0" class="row justify-center" style="font-size: 70%">
|
||||
@@ -127,7 +131,7 @@
|
||||
{{ item.desc.title }}
|
||||
</div>
|
||||
<div v-show="bothBucEnabled && item.needBookUpdate" style="font-size: 75%; color: blue">
|
||||
Старый размер: {{ item.bucSize }}, новый: {{ item.downloadSize }}
|
||||
Размер: {{ item.downloadSize }} → {{ item.bucSize }}, +{{ item.bucSize - item.downloadSize }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -172,7 +176,7 @@
|
||||
class="col column justify-center"
|
||||
style="font-size: 75%; padding-left: 6px; border: 1px solid #cccccc; border-left: 0;"
|
||||
>
|
||||
<div style="margin: 20px 0 0 5px">
|
||||
<div style="margin: 25px 0 0 5px">
|
||||
<a v-show="isUrl(item.url)" :href="item.url" target="_blank">Оригинал</a><br><br>
|
||||
<a :href="item.path" @click.prevent="downloadBook(item.path, item.fullTitle)">Скачать FB2</a>
|
||||
</div>
|
||||
@@ -206,7 +210,7 @@
|
||||
<q-checkbox
|
||||
v-model="item.checkBuc"
|
||||
size="xs"
|
||||
style="position: relative; top: -5px; left: -5px;"
|
||||
style="position: relative; top: -3px; left: -3px;"
|
||||
@update:model-value="checkBucChange(item)"
|
||||
>
|
||||
<q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">
|
||||
@@ -350,7 +354,7 @@ class RecentBooksPage {
|
||||
|
||||
let title = bt.bookTitle;
|
||||
title = (title ? `"${title}"`: '');
|
||||
const author = (bt.author ? bt.author : (bt.bookTitle ? bt.bookTitle : (book.uploadFileName ? book.uploadFileName : book.url)));
|
||||
const author = (bt.author ? bt.author : (bt.bookTitle ? bt.bookTitle : (book.uploadFileName ? book.uploadFileName : book.url))) || '';
|
||||
|
||||
result.push({
|
||||
key: book.key,
|
||||
@@ -397,12 +401,14 @@ class RecentBooksPage {
|
||||
//фильтрация
|
||||
const search = this.search;
|
||||
if (search) {
|
||||
const lowerSearch = search.toLowerCase();
|
||||
|
||||
result = result.filter(item => {
|
||||
return !search ||
|
||||
item.touchTime.includes(search) ||
|
||||
item.loadTime.includes(search) ||
|
||||
item.desc.title.toLowerCase().includes(search.toLowerCase()) ||
|
||||
item.desc.author.toLowerCase().includes(search.toLowerCase())
|
||||
item.desc.title.toLowerCase().includes(lowerSearch) ||
|
||||
item.desc.author.toLowerCase().includes(lowerSearch)
|
||||
});
|
||||
}
|
||||
|
||||
@@ -451,6 +457,9 @@ class RecentBooksPage {
|
||||
if (book.active)
|
||||
parents[book.sameBookKey].activeParent = true;
|
||||
|
||||
book.showCheckBuc = false;
|
||||
book.needBookUpdate = false;
|
||||
|
||||
groups[book.sameBookKey].push(book);
|
||||
}
|
||||
} else {
|
||||
@@ -546,14 +555,14 @@ class RecentBooksPage {
|
||||
this.$root.notify.info('Восстановлено из архива');
|
||||
}
|
||||
|
||||
async loadBook(item) {
|
||||
async loadBook(item, force = false) {
|
||||
//чтобы не обновлять лишний раз updateTableData
|
||||
this.inited = false;
|
||||
|
||||
if (item.deleted)
|
||||
await this.handleRestore(item.key);
|
||||
|
||||
this.$emit('load-book', {url: item.url, path: item.path});
|
||||
this.$emit('load-book', {url: item.url, path: item.path, force});
|
||||
this.close();
|
||||
}
|
||||
|
||||
@@ -753,8 +762,7 @@ class RecentBooksPage {
|
||||
async checkBucChange(item) {
|
||||
const book = await bookManager.getRecentBook(item);
|
||||
if (book) {
|
||||
book.checkBuc = item.checkBuc;
|
||||
await bookManager.recentSetItem(book);
|
||||
await bookManager.setCheckBuc(book, item.checkBuc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,17 +41,6 @@
|
||||
</q-checkbox>
|
||||
</div>
|
||||
|
||||
<div class="item row">
|
||||
<div class="label-6">Уведомление</div>
|
||||
<q-checkbox size="xs" v-model="showNeedUpdateNotify">
|
||||
Показывать уведомление о новой версии
|
||||
<q-tooltip :delay="1000" anchor="top middle" self="bottom middle" content-style="font-size: 80%">
|
||||
Напоминать о необходимости обновления страницы<br>
|
||||
при появлении новой версии читалки
|
||||
</q-tooltip>
|
||||
</q-checkbox>
|
||||
</div>
|
||||
|
||||
<!--div class="item row">
|
||||
<div class="label-6">Уведомление</div>
|
||||
<q-checkbox size="xs" v-model="showDonationDialog2020">
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
<q-tab class="tab" name="keys" icon="la la-gamepad" label="Управление" />
|
||||
<q-tab class="tab" name="pagemove" icon="la la-school" label="Листание" />
|
||||
<q-tab class="tab" name="convert" icon="la la-magic" label="Конвертир." />
|
||||
<q-tab class="tab" name="update" icon="la la-sync" label="Обновление" />
|
||||
<q-tab class="tab" name="others" icon="la la-list-ul" label="Прочее" />
|
||||
<q-tab class="tab" name="reset" icon="la la-broom" label="Сброс" />
|
||||
<div v-show="tabsScrollable" class="q-pt-lg" />
|
||||
@@ -99,6 +100,10 @@
|
||||
<div v-if="selectedTab == 'convert'" class="fit tab-panel">
|
||||
@@include('./ConvertTab.inc');
|
||||
</div>
|
||||
<!-- Обновление ------------------------------------------------------------------>
|
||||
<div v-if="selectedTab == 'update'" class="fit tab-panel">
|
||||
@@include('./UpdateTab.inc');
|
||||
</div>
|
||||
<!-- Прочее ---------------------------------------------------------------------->
|
||||
<div v-if="selectedTab == 'others'" class="fit tab-panel">
|
||||
@@include('./OthersTab.inc');
|
||||
|
||||
45
client/components/Reader/SettingsPage/UpdateTab.inc
Normal file
45
client/components/Reader/SettingsPage/UpdateTab.inc
Normal file
@@ -0,0 +1,45 @@
|
||||
<!---------------------------------------------->
|
||||
<div class="part-header">Обновление читалки</div>
|
||||
<div class="item row">
|
||||
<div class="label-6"></div>
|
||||
<q-checkbox size="xs" v-model="showNeedUpdateNotify">
|
||||
Проверять наличие новой версии
|
||||
<q-tooltip :delay="1000" anchor="top middle" self="bottom middle" content-style="font-size: 80%">
|
||||
Напоминать о необходимости обновления страницы<br>
|
||||
при появлении новой версии читалки
|
||||
</q-tooltip>
|
||||
</q-checkbox>
|
||||
</div>
|
||||
|
||||
<!---------------------------------------------->
|
||||
<div class="part-header">Обновление книг</div>
|
||||
<div class="item row">
|
||||
<div class="label-6"></div>
|
||||
<q-checkbox size="xs" v-model="bucEnabled">
|
||||
Проверять обновления книг
|
||||
</q-checkbox>
|
||||
</div>
|
||||
|
||||
<div class="item row">
|
||||
<div class="label-6"></div>
|
||||
<q-checkbox size="xs" v-model="bucSetOnNew">
|
||||
Автопроверка для вновь загружаемых
|
||||
<q-tooltip :delay="1000" anchor="top middle" self="bottom middle" content-style="font-size: 80%">
|
||||
Автоматически устанавливать флаг проверки<br>
|
||||
обновлений для всех вновь загружаемых книг
|
||||
</q-tooltip>
|
||||
</q-checkbox>
|
||||
</div>
|
||||
|
||||
<div v-show="bucEnabled" class="item row">
|
||||
<div class="label-6">Разница размеров</div>
|
||||
<div class="col row">
|
||||
<NumInput class="col-left" v-model="bucSizeDiff" />
|
||||
|
||||
<q-tooltip :delay="1000" anchor="top middle" self="bottom middle" content-style="font-size: 80%">
|
||||
Уведомлять о наличии обновления книги в списке загруженных<br>
|
||||
при указанной разнице в размерах старого и нового файлов
|
||||
</q-tooltip>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -487,6 +487,28 @@ class BookManager {
|
||||
await this.recentSetItem(item);
|
||||
}
|
||||
|
||||
async setCheckBuc(value, checkBuc = true) {
|
||||
const item = this.recent[value.key];
|
||||
|
||||
const updateItems = [];
|
||||
if (item) {
|
||||
if (item.sameBookKey !== undefined) {
|
||||
const sorted = this.getSortedRecent();
|
||||
for (const book of sorted) {
|
||||
if (book.sameBookKey === item.sameBookKey)
|
||||
updateItems.push(book);
|
||||
}
|
||||
} else {
|
||||
updateItems.push(item);
|
||||
}
|
||||
}
|
||||
|
||||
for (const book of updateItems) {
|
||||
book.checkBuc = checkBuc;
|
||||
await this.recentSetItem(book);
|
||||
}
|
||||
}
|
||||
|
||||
async cleanRecentBooks() {
|
||||
const sorted = this.getSortedRecent();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user