TextPage.vue 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. this.drawPage();
  51. })();
  52. }
  53. }
  54. get lastOpenedBook() {
  55. return this.$store.getters['reader/lastOpenedBook'];
  56. }
  57. drawPage() {
  58. const last = this.lastOpenedBook;
  59. if (!last)
  60. return;
  61. //пустой канвас
  62. if (!this.book)
  63. return;
  64. }
  65. keyHook(event) {
  66. }
  67. }
  68. //-----------------------------------------------------------------------------
  69. </script>
  70. <style scoped>
  71. .main {
  72. flex: 1;
  73. display: flex;
  74. flex-direction: column;
  75. }
  76. </style>