LoaderPage.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <template>
  2. <div ref="main" class="main">
  3. <div class="part">
  4. <span class="greeting bold-font">{{ title }}</span>
  5. <span class="greeting">Добро пожаловать!</span>
  6. <span class="greeting">Поддерживаются форматы: <b>fb2, html, txt</b></span>
  7. <span v-if="isExternalConverter" class="greeting">...а также: <b>rtf, doc, docx</b>, и вскоре: pdf, epub, mobi</span>
  8. <span class="greeting">...и распознается сжатие: <b>zip, bz2, gz</b></span>
  9. </div>
  10. <div class="part center">
  11. <el-input ref="input" placeholder="URL книги" v-model="bookUrl">
  12. <el-button slot="append" icon="el-icon-check" @click="submitUrl"></el-button>
  13. </el-input>
  14. <div class="space"></div>
  15. <input type="file" id="file" ref="file" @change="loadFile" style='display: none;'/>
  16. <el-button size="mini" @click="loadFileClick">
  17. Загрузить файл с диска
  18. </el-button>
  19. <div class="space"></div>
  20. <span v-if="mode == 'omnireader'" class="bottom-span clickable" @click="openComments">Комментарии</span>
  21. </div>
  22. <div class="part bottom">
  23. <span class="bottom-span clickable" @click="openHelp">Справка</span>
  24. <span class="bottom-span clickable" @click="openDonate">Помочь проекту</span>
  25. <span class="bottom-span">{{ version }}</span>
  26. </div>
  27. </div>
  28. </template>
  29. <script>
  30. //-----------------------------------------------------------------------------
  31. import Vue from 'vue';
  32. import Component from 'vue-class-component';
  33. export default @Component({
  34. })
  35. class LoaderPage extends Vue {
  36. bookUrl = null;
  37. loadPercent = 0;
  38. created() {
  39. this.commit = this.$store.commit;
  40. }
  41. mounted() {
  42. this.progress = this.$refs.progress;
  43. }
  44. activated() {
  45. this.$refs.input.focus();
  46. }
  47. get title() {
  48. if (this.$store.state.config.mode == 'omnireader')
  49. return 'Omni Reader - браузерная онлайн-читалка.';
  50. return 'Универсальная читалка книг и ресурсов интернета.';
  51. }
  52. get mode() {
  53. return this.$store.state.config.mode;
  54. }
  55. get version() {
  56. return `v${this.$store.state.config.version}`;
  57. }
  58. get isExternalConverter() {
  59. return this.$store.state.config.useExternalBookConverter;
  60. }
  61. submitUrl() {
  62. if (this.bookUrl) {
  63. this.$emit('load-book', {url: this.bookUrl});
  64. this.bookUrl = '';
  65. }
  66. }
  67. loadFileClick() {
  68. this.$refs.file.click();
  69. }
  70. loadFile() {
  71. const file = this.$refs.file.files[0];
  72. this.$refs.file.value = '';
  73. if (file)
  74. this.$emit('load-file', {file});
  75. }
  76. openHelp() {
  77. this.$emit('help-toggle');
  78. }
  79. openDonate() {
  80. this.$emit('donate-toggle');
  81. }
  82. openComments() {
  83. window.open('http://samlib.ru/comment/b/bookpauk/bookpauk_reader', '_blank');
  84. }
  85. keyHook(event) {
  86. //недостатки сторонних ui
  87. const input = this.$refs.input.$refs.input;
  88. if (document.activeElement === input && event.type == 'keydown' && event.code == 'Enter') {
  89. this.submitUrl();
  90. }
  91. if (event.type == 'keydown' && (event.code == 'F1' || (document.activeElement !== input && event.code == 'KeyH'))) {
  92. this.$emit('help-toggle');
  93. event.preventDefault();
  94. event.stopPropagation();
  95. return true;
  96. }
  97. if (event.type == 'keydown' && (document.activeElement !== input && event.code == 'KeyQ')) {
  98. this.$emit('tool-bar-toggle');
  99. event.preventDefault();
  100. event.stopPropagation();
  101. return true;
  102. }
  103. }
  104. }
  105. //-----------------------------------------------------------------------------
  106. </script>
  107. <style scoped>
  108. .main {
  109. flex: 1;
  110. display: flex;
  111. flex-direction: column;
  112. }
  113. .part {
  114. flex: 1;
  115. display: flex;
  116. flex-direction: column;
  117. justify-content: center;
  118. align-items: center;
  119. }
  120. .greeting {
  121. font-size: 130%;
  122. line-height: 170%;
  123. }
  124. .bold-font {
  125. font-weight: bold;
  126. }
  127. .clickable {
  128. color: blue;
  129. text-decoration: underline;
  130. cursor: pointer;
  131. }
  132. .center {
  133. justify-content: flex-start;
  134. padding: 0 10px 0 10px;
  135. }
  136. .bottom {
  137. justify-content: flex-end;
  138. }
  139. .bottom-span {
  140. font-size: 70%;
  141. margin-bottom: 10px;
  142. }
  143. .el-input {
  144. max-width: 700px;
  145. }
  146. .space {
  147. height: 20px;
  148. }
  149. </style>