Эх сурвалжийг харах

Мелкий рефакторинг, добавлено удобочитаемое имя при сохраненнии fb2

Book Pauk 4 жил өмнө
parent
commit
3a211ded2e

+ 10 - 12
client/components/Reader/RecentBooksPage/RecentBooksPage.vue

@@ -59,7 +59,7 @@
                     <q-td key="links" :props="props" class="td-mp" auto-width>
                         <div class="break-word" style="width: 75px; font-size: 90%">
                             <a v-show="isUrl(props.row.url)" :href="props.row.url" target="_blank">Оригинал</a><br>
-                            <a :href="props.row.path" @click.prevent="downloadBook(props.row.path)">Скачать FB2</a>
+                            <a :href="props.row.path" @click.prevent="downloadBook(props.row.path, props.row.fullTitle)">Скачать FB2</a>
                         </div>
                     </q-td>
 
@@ -237,9 +237,10 @@ class RecentBooksPage extends Vue {
                     author,
                     title: `${title}${perc}${textLen}`,
                 },
-                descString: `${author}${title}${perc}${textLen}`,
+                descString: `${author}${title}${perc}${textLen}`,//для сортировки
                 url: book.url,
                 path: book.path,
+                fullTitle: bt.fullTitle,
                 key: book.key,
             });
         }
@@ -272,13 +273,18 @@ class RecentBooksPage extends Vue {
         return `${(this.search ? 'Найдено' : 'Всего')} ${len} книг${this.wordEnding(len)}`;
     }
 
-    async downloadBook(fb2path) {
+    async downloadBook(fb2path, fullTitle) {
         try {
             await readerApi.checkCachedBook(fb2path);
 
             const d = this.$refs.download;
             d.href = fb2path;
-            d.download = path.basename(fb2path).substr(0, 10) + '.fb2';
+            try {
+                const fn = utils.makeValidFilename(fullTitle);
+                d.download = fn.substring(0, 100) + '.fb2';
+            } catch(e) {
+                d.download = path.basename(fb2path).substr(0, 10) + '.fb2';
+            }
 
             d.click();
         } catch (e) {
@@ -289,14 +295,6 @@ class RecentBooksPage extends Vue {
         }
     }
 
-    openOriginal(url) {
-        window.open(url, '_blank');
-    }
-
-    openFb2(path) {
-        window.open(path, '_blank');
-    }
-
     async handleDel(key) {
         await bookManager.delRecentBook({key});
         //this.updateTableData();//обновление уже происходит Reader.bookManagerEvent

+ 1 - 1
client/components/Reader/TextPage/TextPage.vue

@@ -393,7 +393,7 @@ class TextPage extends Vue {
                     this.meta = bookManager.metaOnly(this.book);
                     const bt = utils.getBookTitle(this.meta.fb2);
 
-                    this.title = bt.title;
+                    this.title = bt.fullTitle;
 
                     this.$root.$emit('set-app-title', this.title);
 

+ 1 - 1
client/share/utils.js

@@ -349,7 +349,7 @@ export function getBookTitle(fb2) {
 
     result.bookTitle = _.compact([result.sequenceTitle, fb2.bookTitle]).join(' ');
 
-    result.title = _.compact([
+    result.fullTitle = _.compact([
         result.author,
         result.bookTitle
     ]).join(' - ');