TextPage.vue 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <template>
  2. <div class="main">
  3. <pre>{{ parsedBook }}</pre>
  4. </div>
  5. </template>
  6. <script>
  7. //-----------------------------------------------------------------------------
  8. import Vue from 'vue';
  9. import Component from 'vue-class-component';
  10. import bookManager from '../share/bookManager';
  11. export default @Component({
  12. })
  13. class TextPage extends Vue {
  14. parsedBook = null;
  15. created() {
  16. this.commit = this.$store.commit;
  17. this.dispatch = this.$store.dispatch;
  18. this.config = this.$store.state.config;
  19. this.reader = this.$store.state.reader;
  20. this.book = null;
  21. }
  22. activated() {
  23. const last = this.lastOpenedBook;
  24. if (last) {
  25. (async() => {
  26. const isParsed = await bookManager.hasBookParsed(last);
  27. if (!isParsed) {
  28. this.$emit('parse-book', last);
  29. return;
  30. }
  31. const book = await bookManager.getBook(last);
  32. this.book = book.parsed;
  33. })();
  34. }
  35. }
  36. get lastOpenedBook() {
  37. return this.$store.getters['reader/lastOpenedBook'];
  38. }
  39. keyHook(event) {
  40. }
  41. }
  42. //-----------------------------------------------------------------------------
  43. </script>
  44. <style scoped>
  45. .main {
  46. flex: 1;
  47. display: flex;
  48. flex-direction: column;
  49. }
  50. </style>