LoaderPage.vue 7.1 KB

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