LoaderPage.vue 7.3 KB

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