Просмотр исходного кода

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

Book Pauk 3 лет назад
Родитель
Сommit
72431f0202

+ 15 - 11
client/components/Reader/Reader.vue

@@ -1146,7 +1146,7 @@ class Reader {
                         });
                         book = Object.assign({}, wasOpened, {data: resp.data});
                     } catch (e) {
-                        //молчим
+                        this.$root.notify.error('Конвертированный файл не найден на сервере', 'Ошибка загрузки');
                     }
                 }
             }
@@ -1186,16 +1186,17 @@ class Reader {
                 found = (found ? _.cloneDeep(found) : found);
 
                 if (found) {
-                    //спрашиваем, надо ли объединить файлы
-                    const askResult = (wasOpened.path == found.path) || 
-                        await this.$root.stdDialog.askYesNo(`
-Файл с именем "${wasOpened.uploadFileName}" уже есть в загруженных.
-<br>Объединить позицию?`, 'Найдена похожая книга');
-
-                    if (askResult) {
-                        wasOpened.bookPos = found.bookPos;
-                        wasOpened.bookPosSeen = found.bookPosSeen;
-                        wasOpened.sameBookKey = found.sameBookKey;
+                    if (wasOpened.sameBookKey != found.sameBookKey) {
+                        //спрашиваем, надо ли объединить файлы
+                        const askResult = bookManager.keysEqual(found.path, addedBook.path) || 
+                            await this.$root.stdDialog.askYesNo(`
+    Файл с именем "${wasOpened.uploadFileName}" уже есть в загруженных.
+    <br>Объединить позицию?`, 'Найдена похожая книга');
+                        if (askResult) {
+                            wasOpened.bookPos = found.bookPos;
+                            wasOpened.bookPosSeen = found.bookPosSeen;
+                            wasOpened.sameBookKey = found.sameBookKey;
+                        }
                     }
                 } else {
                     wasOpened.sameBookKey = wasOpened.uploadFileName;
@@ -1204,6 +1205,9 @@ class Reader {
                 wasOpened.sameBookKey = addedBook.url;
             }
 
+            if (!bookManager.keysEqual(wasOpened.path, addedBook.path))
+                delete wasOpened.loadTime;
+
             // добавляем в историю
             await bookManager.setRecentBook(Object.assign(wasOpened, addedBook));
             this.mostRecentBook();

+ 6 - 5
client/components/Reader/RecentBooksPage/RecentBooksPage.vue

@@ -70,15 +70,16 @@
                                 {{ item.desc.author }}
                             </div>
                             <div>{{ item.desc.title }}</div>
+                            <!--div>{{ item.path }}</div-->
                         </div>
 
                         <div class="row q-mt-xs" style="font-size: 80%">
-                            <div class="row justify-center row-info-bottom" style="width: 50px">
-                                {{ item.desc.perc }}
-                            </div>
-                            <div class="row justify-center row-info-bottom" style="width: 50px">
+                            <div class="row justify-center row-info-bottom" style="width: 60px">
                                 {{ item.desc.textLen }}
                             </div>
+                            <div class="row justify-center row-info-bottom" style="width: 60px">
+                                {{ item.desc.perc }}
+                            </div>
                             <div class="row justify-center row-info-bottom" style="width: 1px">
                             </div>
                         </div>
@@ -285,7 +286,7 @@ class RecentBooksPage {
                 if (book.textLength) {
                     readPart = p/book.textLength;
                     perc = `${(readPart*100).toFixed(2)}%`;
-                    textLen = `${Math.round(book.textLength/1000)}k`;
+                    textLen = `${Math.floor(readPart*book.textLength/1000)}/${Math.floor(book.textLength/1000)}`;
                 }
 
                 const bt = utils.getBookTitle(book.fb2);

+ 11 - 4
client/components/Reader/share/bookManager.js

@@ -367,6 +367,13 @@ class BookManager {
     keyFromPath(bookPath) {
         return path.basename(bookPath);
     }
+
+    keysEqual(bookPath1, bookPath2) {
+        if (bookPath1 === undefined || bookPath2 === undefined)
+            return false;
+        
+        return (this.keyFromPath(bookPath1) === this.keyFromPath(bookPath2));
+    }
     //-- recent --------------------------------------------------------------
     async recentSetItem(item = null, skipCheck = false) {
         const rev = await bmRecentStoreNew.getItem('rev');
@@ -506,8 +513,8 @@ class BookManager {
 
         for (const key in this.recent) {
             const book = this.recent[key];
-            if (!book.deleted && book.url == url && book.touchTime > max) {
-                max = book.touchTime;
+            if (!book.deleted && book.url == url && book.loadTime > max) {
+                max = book.loadTime;
                 result = book;
             }
         }
@@ -521,8 +528,8 @@ class BookManager {
 
         for (const key in this.recent) {
             const book = this.recent[key];
-            if (!book.deleted && book.sameBookKey == sameKey && book.touchTime > max) {
-                max = book.touchTime;
+            if (!book.deleted && book.sameBookKey == sameKey && book.loadTime > max) {
+                max = book.loadTime;
                 result = book;
             }
         }