LoaderPage.vue 7.0 KB

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