Работа над BookInfoDialog
This commit is contained in:
@@ -8,8 +8,15 @@
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<div ref="box" class="column q-mt-xs overflow-auto no-wrap" style="padding: 0px 10px 10px 10px;">
|
||||
<div v-html="annotation" />
|
||||
<div ref="box" class="fit column q-mt-xs overflow-auto no-wrap" style="padding: 0px 10px 10px 10px;">
|
||||
<div class="row" style="height: 300px">
|
||||
<div style="height: 300px">
|
||||
<img v-if="coverSrc" :src="coverSrc" style="height: 100%;" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="q-mt-md" v-html="annotation" />
|
||||
<pre>{{ annotation }}</pre>
|
||||
</div>
|
||||
|
||||
<template #footer>
|
||||
@@ -25,7 +32,7 @@
|
||||
import vueComponent from '../../vueComponent.js';
|
||||
|
||||
import Dialog from '../../share/Dialog.vue';
|
||||
import XmlParser from '../../../../server/core/xml/XmlParser';
|
||||
import Fb2Parser from '../../../../server/core/fb2/Fb2Parser';
|
||||
|
||||
const componentOptions = {
|
||||
components: {
|
||||
@@ -53,6 +60,7 @@ class BookInfoDialog {
|
||||
dialogVisible = false;
|
||||
|
||||
//info props
|
||||
coverSrc = '';
|
||||
annotation = '';
|
||||
|
||||
created() {
|
||||
@@ -65,21 +73,29 @@ class BookInfoDialog {
|
||||
|
||||
parseBookInfo() {
|
||||
const bookInfo = this.bookInfo;
|
||||
const xml = new XmlParser();
|
||||
const parser = new Fb2Parser();
|
||||
|
||||
//defaults
|
||||
this.coverSrc = '';
|
||||
this.annotation = '';
|
||||
|
||||
if (bookInfo.fb2) {
|
||||
const desc = xml.navigator(bookInfo.fb2);
|
||||
//cover
|
||||
if (bookInfo.cover)
|
||||
this.coverSrc = bookInfo.cover;
|
||||
|
||||
//fb2
|
||||
if (bookInfo.fb2 && bookInfo.fb2.fictionbook && bookInfo.fb2.fictionbook.description) {
|
||||
const desc = parser.inspector(bookInfo.fb2.fictionbook.description);
|
||||
|
||||
//annotation
|
||||
const annObj = desc.v('description/title-info/annotation');
|
||||
const annObj = desc.v('title-info/annotation');
|
||||
if (annObj) {
|
||||
this.annotation = xml.fromObject(annObj).toString({noHeader: true});
|
||||
this.annotation = parser.fromObject(annObj).toString({noHeader: true, format: true});
|
||||
this.annotation = parser.toHtml(this.annotation);
|
||||
this.annotation = this.annotation.replace(/<p>/g, `<p class="p-annotation">`);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
okClick() {
|
||||
|
||||
@@ -480,8 +480,8 @@ class WebWorker {
|
||||
result.fb2 = false;
|
||||
|
||||
if (book.ext == 'fb2') {
|
||||
const {desc, cover, coverExt} = await this.fb2Helper.getDescAndCover(bookFile);
|
||||
result.fb2 = desc;
|
||||
const {fb2, cover, coverExt} = await this.fb2Helper.getDescAndCover(bookFile);
|
||||
result.fb2 = fb2;
|
||||
|
||||
if (cover) {
|
||||
result.cover = `${this.config.filesPathStatic}/${hash}${coverExt}`;
|
||||
|
||||
@@ -56,15 +56,15 @@ class Fb2Helper {
|
||||
|
||||
data = this.checkEncoding(data);
|
||||
|
||||
const fb2 = new Fb2Parser();
|
||||
const parser = new Fb2Parser();
|
||||
|
||||
fb2.fromString(data.toString(), {
|
||||
parser.fromString(data.toString(), {
|
||||
lowerCase: true,
|
||||
pickNode: route => route.indexOf('fictionbook/body') !== 0,
|
||||
});
|
||||
|
||||
const desc = fb2.$$('description').toObject();
|
||||
const coverImage = fb2.inspector(desc).$('description/title-info/coverpage/image');
|
||||
const desc = parser.$$('description').toObject();
|
||||
const coverImage = parser.inspector(desc).$('description/title-info/coverpage/image');
|
||||
|
||||
let cover = null;
|
||||
let coverExt = '';
|
||||
@@ -79,7 +79,7 @@ class Fb2Helper {
|
||||
const binaryId = (href[0] == '#' ? href.substring(1) : href);
|
||||
|
||||
//найдем нужный image
|
||||
fb2.$$('binary').eachSelf(node => {
|
||||
parser.$$('binary').eachSelf(node => {
|
||||
let attrs = node.attrs();
|
||||
if (!attrs)
|
||||
return;
|
||||
@@ -95,7 +95,8 @@ class Fb2Helper {
|
||||
}
|
||||
}
|
||||
|
||||
return {desc, cover, coverExt};
|
||||
parser.remove('binary');
|
||||
return {fb2: parser.toObject(), cover, coverExt};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user