LoaderPage.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. <template>
  2. <div ref="main" class="main">
  3. <div class="part">
  4. <span class="greeting bold-font">{{ title }}</span>
  5. <div class="space"></div>
  6. <span class="greeting">Добро пожаловать!</span>
  7. <span class="greeting">Поддерживаются форматы: <b>fb2, html, txt</b> и сжатие: <b>zip, bz2, gz</b></span>
  8. <span v-if="isExternalConverter" class="greeting">...а также форматы: <b>rtf, doc, docx, pdf, epub, mobi</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. <el-button size="mini" @click="loadBufferClick">
  21. Из буфера обмена
  22. </el-button>
  23. <div class="space"></div>
  24. <div class="space"></div>
  25. <div v-if="mode == 'omnireader'" ref="yaShare2" class="ya-share2"
  26. data-services="collections,vkontakte,facebook,odnoklassniki,twitter,telegram"
  27. data-description="Чтение fb2-книг онлайн. Загрузка любой страницы интернета одним кликом, синхронизация между устройствами, удобное управление, регистрация не требуется."
  28. data-title="Omni Reader - браузерная онлайн-читалка"
  29. data-url="https://omnireader.ru">
  30. </div>
  31. <div class="space"></div>
  32. <span v-if="mode == 'omnireader'" class="bottom-span clickable" @click="openComments">Отзывы о читалке</span>
  33. <span v-if="mode == 'omnireader'" class="bottom-span clickable" @click="openOldVersion">Старая версия</span>
  34. </div>
  35. <div class="part bottom">
  36. <span class="bottom-span clickable" @click="openHelp">Справка</span>
  37. <span class="bottom-span clickable" @click="openDonate">Помочь проекту</span>
  38. <span v-if="version == clientVersion" class="bottom-span">v{{ version }}</span>
  39. <span v-else class="bottom-span">Версия сервера {{ version }}, версия клиента {{ clientVersion }}, необходимо обновить страницу</span>
  40. </div>
  41. <PasteTextPage v-if="pasteTextActive" ref="pasteTextPage" @paste-text-toggle="pasteTextToggle" @load-buffer="loadBuffer"></PasteTextPage>
  42. </div>
  43. </template>
  44. <script>
  45. //-----------------------------------------------------------------------------
  46. import Vue from 'vue';
  47. import Component from 'vue-class-component';
  48. import PasteTextPage from './PasteTextPage/PasteTextPage.vue';
  49. import {versionHistory} from '../versionHistory';
  50. export default @Component({
  51. components: {
  52. PasteTextPage,
  53. },
  54. })
  55. class LoaderPage extends Vue {
  56. bookUrl = null;
  57. loadPercent = 0;
  58. pasteTextActive = false;
  59. created() {
  60. this.commit = this.$store.commit;
  61. }
  62. mounted() {
  63. this.progress = this.$refs.progress;
  64. if (this.mode == 'omnireader')
  65. Ya.share2(this.$refs.yaShare2);// eslint-disable-line no-undef
  66. }
  67. activated() {
  68. this.$refs.input.focus();
  69. }
  70. get title() {
  71. if (this.mode == 'omnireader')
  72. return 'Omni Reader - браузерная онлайн-читалка.';
  73. return 'Универсальная читалка книг и ресурсов интернета.';
  74. }
  75. get mode() {
  76. return this.$store.state.config.mode;
  77. }
  78. get version() {
  79. return this.$store.state.config.version;
  80. }
  81. get isExternalConverter() {
  82. return this.$store.state.config.useExternalBookConverter;
  83. }
  84. get clientVersion() {
  85. let v = versionHistory[0].header;
  86. v = v.split(' ')[0];
  87. return v;
  88. }
  89. submitUrl() {
  90. if (this.bookUrl) {
  91. this.$emit('load-book', {url: this.bookUrl});
  92. this.bookUrl = '';
  93. }
  94. }
  95. loadFileClick() {
  96. this.$refs.file.click();
  97. }
  98. loadFile() {
  99. const file = this.$refs.file.files[0];
  100. this.$refs.file.value = '';
  101. if (file)
  102. this.$emit('load-file', {file});
  103. }
  104. loadBufferClick() {
  105. this.pasteTextToggle();
  106. }
  107. loadBuffer(opts) {
  108. if (opts.buffer.length) {
  109. const file = new File([opts.buffer], 'dummyName-PasteFromClipboard');
  110. this.$emit('load-file', {file});
  111. }
  112. }
  113. pasteTextToggle() {
  114. this.pasteTextActive = !this.pasteTextActive;
  115. }
  116. openHelp() {
  117. this.$emit('help-toggle');
  118. }
  119. openDonate() {
  120. this.$emit('donate-toggle');
  121. }
  122. openComments() {
  123. window.open('http://samlib.ru/comment/b/bookpauk/bookpauk_reader', '_blank');
  124. }
  125. openOldVersion() {
  126. window.open('http://old.omnireader.ru', '_blank');
  127. }
  128. keyHook(event) {
  129. if (this.pasteTextActive) {
  130. return this.$refs.pasteTextPage.keyHook(event);
  131. }
  132. //недостатки сторонних ui
  133. const input = this.$refs.input.$refs.input;
  134. if (document.activeElement === input && event.type == 'keydown' && event.code == 'Enter') {
  135. this.submitUrl();
  136. }
  137. if (event.type == 'keydown' && (event.code == 'F1' || (document.activeElement !== input && event.code == 'KeyH'))) {
  138. this.$emit('help-toggle');
  139. event.preventDefault();
  140. event.stopPropagation();
  141. return true;
  142. }
  143. if (event.type == 'keydown' && (document.activeElement !== input && event.code == 'KeyQ')) {
  144. this.$emit('tool-bar-toggle');
  145. event.preventDefault();
  146. event.stopPropagation();
  147. return true;
  148. }
  149. }
  150. }
  151. //-----------------------------------------------------------------------------
  152. </script>
  153. <style scoped>
  154. .main {
  155. flex: 1;
  156. display: flex;
  157. flex-direction: column;
  158. min-height: 400px;
  159. }
  160. .part {
  161. flex: 1;
  162. display: flex;
  163. flex-direction: column;
  164. justify-content: center;
  165. align-items: center;
  166. }
  167. .greeting {
  168. font-size: 120%;
  169. line-height: 160%;
  170. }
  171. .bold-font {
  172. font-weight: bold;
  173. }
  174. .clickable {
  175. color: blue;
  176. text-decoration: underline;
  177. cursor: pointer;
  178. }
  179. .center {
  180. justify-content: flex-start;
  181. padding: 0 10px 0 10px;
  182. }
  183. .bottom {
  184. justify-content: flex-end;
  185. }
  186. .bottom-span {
  187. font-size: 70%;
  188. margin-bottom: 10px;
  189. }
  190. .el-input {
  191. max-width: 700px;
  192. }
  193. .space {
  194. height: 20px;
  195. }
  196. </style>