LoaderPage.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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. <span v-if="mode == 'omnireader'" class="bottom-span clickable" @click="openComments">Комментарии</span>
  21. </div>
  22. <div class="part bottom">
  23. <span class="bottom-span clickable" @click="openHelp">Справка</span>
  24. <span class="bottom-span clickable" @click="openDonate">Помочь проекту</span>
  25. <span class="bottom-span">{{ version }}</span>
  26. </div>
  27. </div>
  28. </template>
  29. <script>
  30. //-----------------------------------------------------------------------------
  31. import Vue from 'vue';
  32. import Component from 'vue-class-component';
  33. export default @Component({
  34. })
  35. class LoaderPage extends Vue {
  36. bookUrl = null;
  37. loadPercent = 0;
  38. created() {
  39. this.commit = this.$store.commit;
  40. }
  41. mounted() {
  42. this.progress = this.$refs.progress;
  43. }
  44. activated() {
  45. this.$refs.input.focus();
  46. }
  47. get title() {
  48. if (this.$store.state.config.mode == 'omnireader')
  49. return 'Omni Reader - браузерная онлайн-читалка.';
  50. return 'Универсальная читалка книг и ресурсов интернета.';
  51. }
  52. get mode() {
  53. return this.$store.state.config.mode;
  54. }
  55. get version() {
  56. return `v${this.$store.state.config.version}`;
  57. }
  58. get isExternalConverter() {
  59. return this.$store.state.config.useExternalBookConverter;
  60. }
  61. submitUrl() {
  62. if (this.bookUrl) {
  63. this.$emit('load-book', {url: this.bookUrl});
  64. this.bookUrl = '';
  65. }
  66. }
  67. loadFileClick() {
  68. this.$refs.file.click();
  69. }
  70. loadFile() {
  71. const file = this.$refs.file.files[0];
  72. this.$refs.file.value = '';
  73. if (file)
  74. this.$emit('load-file', {file});
  75. }
  76. openHelp() {
  77. this.$emit('help-toggle');
  78. }
  79. openDonate() {
  80. this.$emit('donate-toggle');
  81. }
  82. openComments() {
  83. window.open('http://samlib.ru/comment/b/bookpauk/bookpauk_reader', '_blank');
  84. }
  85. keyHook(event) {
  86. //недостатки сторонних ui
  87. const input = this.$refs.input.$refs.input;
  88. if (document.activeElement === input && event.type == 'keydown' && event.code == 'Enter') {
  89. this.submitUrl();
  90. }
  91. if (event.type == 'keydown' && (event.code == 'F1' || (document.activeElement !== input && event.code == 'KeyH'))) {
  92. this.$emit('help-toggle');
  93. event.preventDefault();
  94. event.stopPropagation();
  95. return true;
  96. }
  97. if (event.type == 'keydown' && (document.activeElement !== input && event.code == 'KeyQ')) {
  98. this.$emit('tool-bar-toggle');
  99. event.preventDefault();
  100. event.stopPropagation();
  101. return true;
  102. }
  103. }
  104. }
  105. //-----------------------------------------------------------------------------
  106. </script>
  107. <style scoped>
  108. .main {
  109. flex: 1;
  110. display: flex;
  111. flex-direction: column;
  112. min-height: 340px;
  113. }
  114. .part {
  115. flex: 1;
  116. display: flex;
  117. flex-direction: column;
  118. justify-content: center;
  119. align-items: center;
  120. }
  121. .greeting {
  122. font-size: 120%;
  123. line-height: 160%;
  124. }
  125. .bold-font {
  126. font-weight: bold;
  127. }
  128. .clickable {
  129. color: blue;
  130. text-decoration: underline;
  131. cursor: pointer;
  132. }
  133. .center {
  134. justify-content: flex-start;
  135. padding: 0 10px 0 10px;
  136. }
  137. .bottom {
  138. justify-content: flex-end;
  139. }
  140. .bottom-span {
  141. font-size: 70%;
  142. margin-bottom: 10px;
  143. }
  144. .el-input {
  145. max-width: 700px;
  146. }
  147. .space {
  148. height: 20px;
  149. }
  150. </style>