From e3770463a15cda0ebf3959e81e9ce39f4e6fc7d8 Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Thu, 7 Dec 2023 16:26:30 +0700 Subject: [PATCH] =?UTF-8?q?=D0=92=20=D1=81=D0=BF=D0=B8=D1=81=D0=BA=D0=B5?= =?UTF-8?q?=20=D0=B7=D0=B0=D0=B3=D1=80=D1=83=D0=B6=D0=B5=D0=BD=D0=BD=D1=8B?= =?UTF-8?q?=D1=85,=20=D0=BA=D0=BD=D0=B8=D0=B3=D0=B0=20=D0=B2=20=D0=B0?= =?UTF-8?q?=D1=80=D1=85=D0=B8=D0=B2=20(=D0=B8=D0=B7=20=D0=B0=D1=80=D1=85?= =?UTF-8?q?=D0=B8=D0=B2=D0=B0)=20=D0=BF=D0=B5=D1=80=D0=B5=D0=BD=D0=BE?= =?UTF-8?q?=D1=81=D0=B8=D1=82=D1=81=D1=8F=20=D1=82=D0=B5=D0=BF=D0=B5=D1=80?= =?UTF-8?q?=D1=8C=20=D1=81=D0=BE=20=D0=B2=D1=81=D0=B5=D0=B9=20=D0=B3=D1=80?= =?UTF-8?q?=D1=83=D0=BF=D0=BF=D0=BE=D0=B9=20=D1=81=D0=B2=D0=BE=D0=B8=D1=85?= =?UTF-8?q?=20=D0=B2=D0=B5=D1=80=D1=81=D0=B8=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/components/Reader/Reader.vue | 1 + .../RecentBooksPage/RecentBooksPage.vue | 49 ++++++++++++++----- client/components/Reader/share/bookManager.js | 26 +++++++++- 3 files changed, 63 insertions(+), 13 deletions(-) diff --git a/client/components/Reader/Reader.vue b/client/components/Reader/Reader.vue index fbea462c..9a12d4da 100644 --- a/client/components/Reader/Reader.vue +++ b/client/components/Reader/Reader.vue @@ -1379,6 +1379,7 @@ class Reader { found = (found ? _.cloneDeep(found) : found); if (found) { + //если такой файл уже не загружен (path не совпадают) if (wasOpened.sameBookKey != found.sameBookKey) { //спрашиваем, надо ли объединить файлы const askResult = bookManager.keysEqual(found.path, addedBook.path) || diff --git a/client/components/Reader/RecentBooksPage/RecentBooksPage.vue b/client/components/Reader/RecentBooksPage/RecentBooksPage.vue index b85ed8ee..5ab70ca1 100644 --- a/client/components/Reader/RecentBooksPage/RecentBooksPage.vue +++ b/client/components/Reader/RecentBooksPage/RecentBooksPage.vue @@ -201,7 +201,7 @@
@@ -212,7 +212,7 @@
@@ -593,21 +593,46 @@ class RecentBooksPage { } } - async handleDel(key) { - if (!this.showArchive) { - await bookManager.delRecentBook({key}); - this.$root.notify.info('Перенесено в архив'); + async handleDel(item) { + if (item.group) { + const keys = [{key: item.key}]; + for (const book of item.group) + keys.push({key: book.key}); + + if (!this.showArchive) { + await bookManager.delRecentBooks(keys); + this.$root.notify.info(`Группа книг (всего ${keys.length}) перенесена в архив`); + } else { + if (await this.$root.stdDialog.confirm(`Подтвердите удаление группы книг (всего ${keys.length}) из архива:`, ' ')) { + await bookManager.delRecentBooks(keys, 2); + this.$root.notify.info('Группа книг удалена безвозвратно'); + } + } } else { - if (await this.$root.stdDialog.confirm('Подтвердите удаление из архива:', ' ')) { - await bookManager.delRecentBook({key}, 2); - this.$root.notify.info('Удалено безвозвратно'); + if (!this.showArchive) { + await bookManager.delRecentBooks([{key: item.key}]); + this.$root.notify.info('Книга перенесена в архив'); + } else { + if (await this.$root.stdDialog.confirm('Подтвердите удаление книги из архива:', ' ')) { + await bookManager.delRecentBooks([{key: item.key}], 2); + this.$root.notify.info('Книга удалено безвозвратно'); + } } } } - async handleRestore(key) { - await bookManager.restoreRecentBook({key}); - this.$root.notify.info('Восстановлено из архива'); + async handleRestore(item) { + if (item.group) { + const keys = [{key: item.key}]; + for (const book of item.group) + keys.push({key: book.key}); + + await bookManager.restoreRecentBooks(keys); + this.$root.notify.info(`Группа книг (всего ${keys.length}) восстановлена из архива`); + } else { + await bookManager.restoreRecentBooks([{key: item.key}]); + this.$root.notify.info('Книга восстановлена из архива'); + } } async loadBook(item, force = false) { diff --git a/client/components/Reader/share/bookManager.js b/client/components/Reader/share/bookManager.js index 8308cf0d..73b7c390 100644 --- a/client/components/Reader/share/bookManager.js +++ b/client/components/Reader/share/bookManager.js @@ -467,7 +467,7 @@ class BookManager { async getRecentBook(value) { return this.recent[value.key]; } - +/* async delRecentBook(value, delFlag = 1) { const item = this.recent[value.key]; item.deleted = delFlag; @@ -479,13 +479,37 @@ class BookManager { await this.recentSetItem(item); this.emit('recent-deleted', value.key); } +*/ + async delRecentBooks(values, delFlag = 1) { + for (const value of values) { + const item = this.recent[value.key]; + item.deleted = delFlag; + if (this.recentLastKey == value.key) { + await this.recentSetLastKey(null); + } + + await this.recentSetItem(item); + } + + this.emit('recent-deleted'); + } +/* async restoreRecentBook(value) { const item = this.recent[value.key]; item.deleted = 0; await this.recentSetItem(item); } +*/ + async restoreRecentBooks(values) { + for (const value of values) { + const item = this.recent[value.key]; + item.deleted = 0; + + await this.recentSetItem(item); + } + } async setCheckBuc(value, checkBuc) { const item = this.recent[value.key];