TextPage.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <template>
  2. <div class="main">
  3. <pre>{{ meta }}</pre>
  4. </div>
  5. </template>
  6. <script>
  7. //-----------------------------------------------------------------------------
  8. import Vue from 'vue';
  9. import Component from 'vue-class-component';
  10. import _ from 'lodash';
  11. import bookManager from '../share/bookManager';
  12. export default @Component({
  13. })
  14. class TextPage extends Vue {
  15. meta = null;
  16. fb2 = null;
  17. created() {
  18. this.commit = this.$store.commit;
  19. this.dispatch = this.$store.dispatch;
  20. this.config = this.$store.state.config;
  21. this.reader = this.$store.state.reader;
  22. this.openFailed = false;
  23. }
  24. activated() {
  25. this.book = null;
  26. this.meta = null;
  27. this.fb2 = null;
  28. const last = this.lastOpenedBook;
  29. if (last) {
  30. (async() => {
  31. const isParsed = await bookManager.hasBookParsed(last);
  32. if (!isParsed) {
  33. this.$root.$emit('set-app-title');
  34. if (!this.openFailed) {
  35. this.$emit('parse-book', last);
  36. this.openFailed = true;
  37. }
  38. return;
  39. }
  40. this.book = await bookManager.getBook(last);
  41. this.meta = bookManager.metaOnly(this.book);
  42. this.fb2 = this.meta.fb2;
  43. this.$root.$emit('set-app-title', _.compact([
  44. this.fb2.lastName,
  45. this.fb2.middleName,
  46. this.fb2.firstName,
  47. '-',
  48. this.fb2.bookTitle
  49. ]).join(' '));
  50. })();
  51. }
  52. }
  53. get lastOpenedBook() {
  54. return this.$store.getters['reader/lastOpenedBook'];
  55. }
  56. showPage() {
  57. if (!this.book)
  58. return;
  59. }
  60. keyHook(event) {
  61. }
  62. }
  63. //-----------------------------------------------------------------------------
  64. </script>
  65. <style scoped>
  66. .main {
  67. flex: 1;
  68. display: flex;
  69. flex-direction: column;
  70. }
  71. p {
  72. margin: 0;
  73. padding: 0;
  74. text-indent: 3%;
  75. }
  76. </style>