Răsfoiți Sursa

Merge branch 'hotfix/0.4.1'

Book Pauk 6 ani în urmă
părinte
comite
19da1aff45

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

@@ -201,7 +201,7 @@ class Reader extends Vue {
 
     mounted() {
         (async() => {
-            await bookManager.init();
+            await bookManager.init(this.settings);
             await restoreOldSettings(this.settings, bookManager, this.commit);
 
             if (this.$root.rootRoute == '/reader') {

+ 10 - 1
client/components/Reader/SettingsPage/SettingsPage.vue

@@ -203,6 +203,16 @@
                                      
                                 </el-col>
                                 <el-col :span="11">
+                                    <el-tooltip :open-delay="500" effect="light" placement="top">
+                                        <template slot="content">
+                                            Выносить все изображения в центр экрана
+                                        </template>
+                                        <el-checkbox v-model="showInlineImagesInCenter" @change="needReload">Инлайн в центр</el-checkbox>
+                                    </el-tooltip>
+                                </el-col>
+                            </el-form-item>
+                            <el-form-item label="">
+                                    Размер изображения
                                     <el-tooltip :open-delay="500" effect="light" placement="top">
                                         <template slot="content">
                                             Определяет высоту изображения количеством строк.<br>
@@ -212,7 +222,6 @@
                                         </template>
                                         <el-input-number v-model="imageHeightLines" :min="1" :max="100"></el-input-number>
                                     </el-tooltip>
-                                </el-col>
                             </el-form-item>
                         </el-form>
 

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

@@ -219,6 +219,7 @@ class TextPage extends Vue {
             this.parsed.measureText = this.drawHelper.measureText.bind(this.drawHelper);
             this.parsed.lineHeight = this.lineHeight;
             this.parsed.showImages = this.showImages;
+            this.parsed.showInlineImagesInCenter = this.showInlineImagesInCenter;
             this.parsed.imageHeightLines = this.imageHeightLines;
         }
 

+ 9 - 2
client/components/Reader/share/BookParser.js

@@ -5,7 +5,11 @@ import {sleep} from '../../../share/utils';
 const maxImageLineCount = 100;
 
 export default class BookParser {
-    constructor() {
+    constructor(settings) {
+        if (settings) {
+            this.showInlineImagesInCenter = settings.showInlineImagesInCenter;
+        }
+
         // defaults
         this.p = 30;// px, отступ параграфа
         this.w = 300;// px, ширина страницы
@@ -151,10 +155,13 @@ export default class BookParser {
             if (tag == 'image') {
                 let attrs = sax.getAttrsSync(tail);
                 if (attrs.href.value) {
-                    if (inPara)
+                    if (inPara && !this.showInlineImagesInCenter)
                         growParagraph(`<image-inline href="${attrs.href.value}"></image-inline>`, 0);
                     else
                         newParagraph(`<image href="${attrs.href.value}">${' '.repeat(maxImageLineCount)}</image>`, maxImageLineCount);
+
+                    if (inPara && this.showInlineImagesInCenter)
+                        newParagraph(' ', 1);
                 }
             }
 

+ 3 - 2
client/components/Reader/share/bookManager.js

@@ -18,7 +18,8 @@ const bmRecentStore = localForage.createInstance({
 });
 
 class BookManager {
-    async init() {
+    async init(settings) {
+        this.settings = settings;
         this.books = {};
         this.recent = {};
         this.recentChanged1 = true;
@@ -131,7 +132,7 @@ class BookManager {
     async parseBook(meta, data, callback) {
         if (!this.books) 
             await this.init();
-        const parsed = new BookParser();
+        const parsed = new BookParser(this.settings);
 
         const parsedMeta = await parsed.parse(data, callback);
         const result = Object.assign({}, meta, parsedMeta, {

+ 1 - 2
client/store/modules/reader.js

@@ -1,5 +1,3 @@
-import Vue from 'vue';
-
 const fonts = [
     {name: 'ReaderDefault', label: 'По-умолчанию', fontVertShift: 0},
     {name: 'GEO_1', label: 'BPG Arial', fontVertShift: 10},
@@ -164,6 +162,7 @@ const settingDefaults = {
         addEmptyParagraphs: 0,
         blinkCachedLoad: true,
         showImages: true,
+        showInlineImagesInCenter: false,
         imageHeightLines: 100,
 
         fontShifts: {},

+ 1 - 1
package.json

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