LoaderPage.vue 7.3 KB

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