BookInfoDialog.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <template>
  2. <Dialog ref="dialog" v-model="dialogVisible">
  3. <template #header>
  4. <div class="row items-center">
  5. <div style="font-size: 110%">
  6. Информация о книге
  7. </div>
  8. </div>
  9. </template>
  10. <div ref="box" class="fit column q-mt-xs overflow-auto no-wrap" style="padding: 0px 10px 10px 10px;">
  11. <div class="row" style="height: 300px">
  12. <div style="height: 300px">
  13. <img v-if="coverSrc" :src="coverSrc" style="height: 100%;" />
  14. </div>
  15. </div>
  16. <div class="q-mt-md" v-html="annotation" />
  17. </div>
  18. <template #footer>
  19. <q-btn class="q-px-md q-ml-sm" color="primary" dense no-caps @click="okClick">
  20. OK
  21. </q-btn>
  22. </template>
  23. </Dialog>
  24. </template>
  25. <script>
  26. //-----------------------------------------------------------------------------
  27. import vueComponent from '../../vueComponent.js';
  28. import Dialog from '../../share/Dialog.vue';
  29. import Fb2Parser from '../../../../server/core/fb2/Fb2Parser';
  30. const componentOptions = {
  31. components: {
  32. Dialog
  33. },
  34. watch: {
  35. modelValue(newValue) {
  36. this.dialogVisible = newValue;
  37. },
  38. dialogVisible(newValue) {
  39. this.$emit('update:modelValue', newValue);
  40. },
  41. bookInfo() {
  42. this.parseBookInfo();
  43. }
  44. }
  45. };
  46. class BookInfoDialog {
  47. _options = componentOptions;
  48. _props = {
  49. modelValue: Boolean,
  50. bookInfo: Object,
  51. };
  52. dialogVisible = false;
  53. //info props
  54. coverSrc = '';
  55. annotation = '';
  56. info = [];
  57. created() {
  58. this.commit = this.$store.commit;
  59. this.parseBookInfo();
  60. }
  61. mounted() {
  62. }
  63. parseBookInfo() {
  64. const bookInfo = this.bookInfo;
  65. const parser = new Fb2Parser();
  66. //defaults
  67. this.coverSrc = '';
  68. this.annotation = '';
  69. this.info = [];
  70. //cover
  71. if (bookInfo.cover)
  72. this.coverSrc = bookInfo.cover;
  73. //fb2
  74. if (bookInfo.fb2) {
  75. this.info = parser.bookInfoList(bookInfo.fb2);
  76. const infoObj = parser.bookInfo(bookInfo.fb2);
  77. if (infoObj) {
  78. let ann = infoObj.titleInfo.annotationHtml;
  79. if (ann) {
  80. ann = ann.replace(/<p>/g, `<p class="p-annotation">`);
  81. this.annotation = ann;
  82. }
  83. }
  84. }
  85. }
  86. okClick() {
  87. this.dialogVisible = false;
  88. }
  89. }
  90. export default vueComponent(BookInfoDialog);
  91. //-----------------------------------------------------------------------------
  92. </script>
  93. <style scoped>
  94. </style>
  95. <style>
  96. .p-annotation {
  97. text-indent: 20px;
  98. text-align: justify;
  99. padding: 0;
  100. margin: 0;
  101. }
  102. </style>