LoaderPage.vue 4.6 KB

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