Browse Source

Merge branch 'release/0.7.9'

Book Pauk 5 years ago
parent
commit
7d0059f573

+ 5 - 1
client/api/reader.js

@@ -56,7 +56,11 @@ class Reader {
         }
     }
 
-    async loadCachedBook(url, callback){
+    async checkUrl(url) {
+        return await axios.head(url, {headers: {'Cache-Control': 'no-cache'}});
+    }
+
+    async loadCachedBook(url, callback) {
         const response = await axios.head(url);
 
         let estSize = 1000000;

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

@@ -1,5 +1,8 @@
 <template>
     <el-container>
+        <div v-show="isShowMigrationWarning" style="height: 30px; overflow: hidden; white-space:nowrap;">
+            <span style="margin-left: 10px; font-size: 20px; position: relative; top: 2px" class="clickable" @click="showMigrationHttp">HTTP-версия читалки скоро станет недоступна. Подробнее...</span>
+        </div>
         <el-header v-show="toolBarActive" height='50px'>
             <div ref="header" class="header">
                 <el-tooltip content="Загрузить книгу" :open-delay="1000" effect="light">
@@ -320,15 +323,6 @@ class Reader extends Vue {
         });
 
         this.loadSettings();
-
-        //TODO: убрать в будущем
-        if (this.showToolButton['history']) {
-            const newShowToolButton = Object.assign({}, this.showToolButton);
-            newShowToolButton['recentBooks'] = true;
-            delete newShowToolButton['history'];
-            const newSettings = Object.assign({}, this.settings, { showToolButton: newShowToolButton });
-            this.commit('reader/setSettings', newSettings);
-        }
     }
 
     mounted() {
@@ -444,6 +438,14 @@ class Reader extends Vue {
         }
     }
 
+    get isShowMigrationWarning() {
+        return window.location.protocol == 'http:';
+    }
+
+    showMigrationHttp() {
+        this.migrationVisible1 = true;
+    }
+
     migrationDialogDisable() {
         this.migrationVisible1 = false;
         this.migrationVisible2 = false;

+ 18 - 4
client/components/Reader/RecentBooksPage/RecentBooksPage.vue

@@ -5,6 +5,7 @@
             <span v-show="loading"><i class="el-icon-loading" style="font-size: 25px"></i> <span style="position: relative; top: -4px">Список загружается</span></span>
         </template>
 
+        <a ref="download" style='display: none;'></a>
         <el-table
             :data="tableData"
             style="width: 570px"
@@ -72,7 +73,7 @@
                     >
                     <template slot-scope="scope">
                         <a v-show="isUrl(scope.row.url)" :href="scope.row.url" target="_blank">Оригинал</a><br>
-                        <a :href="scope.row.path" :download="getFileNameFromPath(scope.row.path)">Скачать FB2</a>
+                        <a :href="scope.row.path" @click.prevent="downloadBook(scope.row.path)">Скачать FB2</a>
                     </template>
                 </el-table-column>
 
@@ -104,6 +105,7 @@ import _ from 'lodash';
 import * as utils from '../../../share/utils';
 import Window from '../../share/Window.vue';
 import bookManager from '../share/bookManager';
+import readerApi from '../../../api/reader';
 
 export default @Component({
     components: {
@@ -209,7 +211,7 @@ class RecentBooksPage extends Vue {
                     a.middleName
                 ]).join(' '));
                 author = authorNames.join(', ');
-            } else {
+            } else {//TODO: убрать в будущем
                 author = _.compact([
                     fb2.lastName,
                     fb2.firstName,
@@ -268,8 +270,20 @@ class RecentBooksPage extends Vue {
         return result;
     }
 
-    getFileNameFromPath(fb2Path) {
-        return path.basename(fb2Path).substr(0, 10) + '.fb2';
+    async downloadBook(fb2path) {
+        try {
+            await readerApi.checkUrl(fb2path);
+
+            const d = this.$refs.download;
+            d.href = fb2path;
+            d.download = path.basename(fb2path).substr(0, 10) + '.fb2';
+            d.click();
+        } catch (e) {
+            let errMes = e.message;
+            if (errMes.indexOf('404') >= 0)
+                errMes = 'Файл не найден на сервере (возможно был удален как устаревший)';
+            this.$alert(errMes, 'Ошибка', {type: 'error'});
+        }
     }
 
     openOriginal(url) {

+ 0 - 3
client/components/Reader/share/BookParser.js

@@ -32,9 +32,6 @@ export default class BookParser {
 
         //defaults
         let fb2 = {
-            firstName: '',
-            middleName: '',
-            lastName: '',
             bookTitle: '',
         };
 

+ 0 - 1
client/components/Reader/share/bookManager.js

@@ -319,7 +319,6 @@ class BookManager {
 
     metaOnly(book) {
         let result = Object.assign({}, book);
-        delete result.data;//можно будет убрать эту строку со временем
         delete result.parsed;
         return result;
     }

+ 12 - 0
client/components/Reader/versionHistory.js

@@ -1,4 +1,16 @@
 export const versionHistory = [
+{
+    showUntil: '2019-11-26',
+    header: '0.7.9 (2019-11-27)',
+    content:
+`
+<ul>
+    <li>добавлен неубираемый баннер для http-версии о переходе на httpS</li>
+    <li>исправления багов</li>
+</ul>
+`
+},
+
 {
     showUntil: '2019-11-24',
     header: '0.7.8 (2019-11-25)',

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "Liberama",
-  "version": "0.7.8",
+  "version": "0.7.9",
   "engines": {
     "node": ">=10.0.0"
   },