Работа над BookInfoDialog

This commit is contained in:
Book Pauk
2022-11-09 19:25:59 +07:00
parent 7b5061df5f
commit ffc65ab944
4 changed files with 51 additions and 4 deletions

View File

@@ -133,6 +133,10 @@ body, html, #app {
animation: rotating 2s linear infinite; animation: rotating 2s linear infinite;
} }
.q-dialog__inner--minimized > div {
max-width: 800px;
}
@keyframes rotating { @keyframes rotating {
from { from {
transform: rotate(0deg); transform: rotate(0deg);

View File

@@ -8,7 +8,8 @@
</div> </div>
</template> </template>
<div ref="box" class="column q-mt-xs overflow-auto no-wrap" style="width: 200px; padding: 0px 10px 10px 10px;"> <div ref="box" class="column q-mt-xs overflow-auto no-wrap" style="padding: 0px 10px 10px 10px;">
<div v-html="annotation" />
</div> </div>
<template #footer> <template #footer>
@@ -24,6 +25,7 @@
import vueComponent from '../../vueComponent.js'; import vueComponent from '../../vueComponent.js';
import Dialog from '../../share/Dialog.vue'; import Dialog from '../../share/Dialog.vue';
import XmlParser from '../../../../server/core/xml/XmlParser';
const componentOptions = { const componentOptions = {
components: { components: {
@@ -36,23 +38,50 @@ const componentOptions = {
dialogVisible(newValue) { dialogVisible(newValue) {
this.$emit('update:modelValue', newValue); this.$emit('update:modelValue', newValue);
}, },
bookInfo() {
this.parseBookInfo();
}
} }
}; };
class BookInfoDialog { class BookInfoDialog {
_options = componentOptions; _options = componentOptions;
_props = { _props = {
modelValue: Boolean, modelValue: Boolean,
bookInfo: Object,
}; };
dialogVisible = false; dialogVisible = false;
//info props
annotation = '';
created() { created() {
this.commit = this.$store.commit; this.commit = this.$store.commit;
this.parseBookInfo();
} }
mounted() { mounted() {
} }
parseBookInfo() {
const bookInfo = this.bookInfo;
const xml = new XmlParser();
//defaults
this.annotation = '';
if (bookInfo.fb2) {
const desc = xml.navigator(bookInfo.fb2);
//annotation
const annObj = desc.v('description/title-info/annotation');
if (annObj) {
this.annotation = xml.fromObject(annObj).toString({noHeader: true});
this.annotation = this.annotation.replace(/<p>/g, `<p class="p-annotation">`);
}
}
}
okClick() { okClick() {
this.dialogVisible = false; this.dialogVisible = false;
} }
@@ -63,4 +92,13 @@ export default vueComponent(BookInfoDialog);
</script> </script>
<style scoped> <style scoped>
</style> </style>
<style>
.p-annotation {
text-indent: 20px;
text-align: justify;
padding: 0;
margin: 0;
}
</style>

View File

@@ -250,7 +250,7 @@
<SelectLangDialog v-model="selectLangDialogVisible" v-model:lang="search.lang" :lang-list="langList" :lang-default="langDefault" /> <SelectLangDialog v-model="selectLangDialogVisible" v-model:lang="search.lang" :lang-list="langList" :lang-default="langDefault" />
<SelectLibRateDialog v-model="selectLibRateDialogVisible" v-model:librate="search.librate" /> <SelectLibRateDialog v-model="selectLibRateDialogVisible" v-model:librate="search.librate" />
<SelectDateDialog v-model="selectDateDialogVisible" v-model:date="search.date" /> <SelectDateDialog v-model="selectDateDialogVisible" v-model:date="search.date" />
<BookInfoDialog v-model="bookInfoDialogVisible" book-info="bookInfo" /> <BookInfoDialog v-model="bookInfoDialogVisible" :book-info="bookInfo" />
</div> </div>
</template> </template>

View File

@@ -59,7 +59,7 @@ class ObjectNavigator {
return null; return null;
raw = (Array.isArray(raw) ? raw : [raw]); raw = (Array.isArray(raw) ? raw : [raw]);
const result = []; const result = [];
for (const r of raw) for (const r of raw)
result.push(new ObjectNavigator(r)); result.push(new ObjectNavigator(r));
@@ -80,6 +80,11 @@ class ObjectNavigator {
return this.raw; return this.raw;
} }
v(selector = '') {
const res = this.$(selector);
return (res ? res.value : null);
}
text(selector = '') { text(selector = '') {
const res = this.$(`${selector}/*TEXT`); const res = this.$(`${selector}/*TEXT`);
return (res ? res.value : null); return (res ? res.value : null);