LoaderPage.vue 4.0 KB

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