LoaderPage.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <template>
  2. <div class="main">
  3. <div class="part">
  4. <span class="greeting bold-font">{{ title }}</span>
  5. <span class="greeting">Добро пожаловать!</span>
  6. <span class="greeting">Поддерживаются форматы: fb2, fb2.zip, html, txt</span>
  7. </div>
  8. <div class="part center">
  9. <el-input ref="input" placeholder="URL книги" v-model="bookUrl">
  10. <el-button slot="append" icon="el-icon-check" @click="submitUrl"></el-button>
  11. </el-input>
  12. <div class="space"></div>
  13. <el-button size="mini" @click="loadFle">
  14. Загрузить файл с диска
  15. </el-button>
  16. <span class="bottom-span"><pre>{{ loadState }}</pre></span>
  17. </div>
  18. <div class="part bottom">
  19. <span v-if="config.mode == 'omnireader'" class="bottom-span clickable" @click="openComments">Комментарии</span>
  20. <span class="bottom-span clickable" @click="openHelp">Справка</span>
  21. <span class="bottom-span">{{ version }}</span>
  22. </div>
  23. </div>
  24. </template>
  25. <script>
  26. //-----------------------------------------------------------------------------
  27. import Vue from 'vue';
  28. import Component from 'vue-class-component';
  29. import readerApi from '../../../api/reader';
  30. export default @Component({
  31. })
  32. class LoaderPage extends Vue {
  33. bookUrl = null;
  34. loadState = null;
  35. created() {
  36. this.commit = this.$store.commit;
  37. this.dispatch = this.$store.dispatch;
  38. this.config = this.$store.state.config;
  39. }
  40. activated() {
  41. this.$refs.input.focus();
  42. }
  43. get title() {
  44. if (this.config.mode == 'omnireader')
  45. return 'Omni Reader - браузерная онлайн-читалка.';
  46. return 'Универсальная читалка книг и ресурсов интернета.';
  47. }
  48. get version() {
  49. return `v${this.config.version}`;
  50. }
  51. async submitUrl() {
  52. if (this.bookUrl) {
  53. try {
  54. const book = await readerApi.loadBook(this.bookUrl, (state) => {
  55. this.loadState = state;
  56. });
  57. this.loadState = book;
  58. } catch (e) {
  59. this.loadState = e.message;
  60. }
  61. }
  62. }
  63. loadFle() {
  64. }
  65. openHelp() {
  66. }
  67. openComments() {
  68. window.open('http://samlib.ru/comment/b/bookpauk/bookpauk_reader', '_blank');
  69. }
  70. keyHook(event) {
  71. //недостатки сторонних ui
  72. if (document.activeElement == this.$refs.input.$refs.input && event.type == 'keyup' && event.key == 'Enter')
  73. this.submitUrl();
  74. }
  75. }
  76. //-----------------------------------------------------------------------------
  77. </script>
  78. <style scoped>
  79. .main {
  80. flex: 1;
  81. display: flex;
  82. flex-direction: column;
  83. }
  84. .part {
  85. flex: 1;
  86. display: flex;
  87. flex-direction: column;
  88. justify-content: center;
  89. align-items: center;
  90. }
  91. .greeting {
  92. font-size: 130%;
  93. line-height: 170%;
  94. }
  95. .bold-font {
  96. font-weight: bold;
  97. }
  98. .clickable {
  99. color: blue;
  100. text-decoration: underline;
  101. cursor: pointer;
  102. }
  103. .center {
  104. justify-content: flex-start;
  105. padding: 0 10px 0 10px;
  106. }
  107. .bottom {
  108. justify-content: flex-end;
  109. }
  110. .bottom-span {
  111. font-size: 70%;
  112. margin-bottom: 10px;
  113. }
  114. .el-input {
  115. max-width: 700px;
  116. }
  117. .space {
  118. height: 20px;
  119. }
  120. </style>