LoaderPage.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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. }
  73. openComments() {
  74. window.open('http://samlib.ru/comment/b/bookpauk/bookpauk_reader', '_blank');
  75. }
  76. keyHook(event) {
  77. //недостатки сторонних ui
  78. if (document.activeElement === this.$refs.input.$refs.input && event.type == 'keydown' && event.key == 'Enter') {
  79. this.submitUrl();
  80. }
  81. }
  82. }
  83. //-----------------------------------------------------------------------------
  84. </script>
  85. <style scoped>
  86. .main {
  87. flex: 1;
  88. display: flex;
  89. flex-direction: column;
  90. }
  91. .part {
  92. flex: 1;
  93. display: flex;
  94. flex-direction: column;
  95. justify-content: center;
  96. align-items: center;
  97. }
  98. .greeting {
  99. font-size: 130%;
  100. line-height: 170%;
  101. }
  102. .bold-font {
  103. font-weight: bold;
  104. }
  105. .clickable {
  106. color: blue;
  107. text-decoration: underline;
  108. cursor: pointer;
  109. }
  110. .center {
  111. justify-content: flex-start;
  112. padding: 0 10px 0 10px;
  113. }
  114. .bottom {
  115. justify-content: flex-end;
  116. }
  117. .bottom-span {
  118. font-size: 70%;
  119. margin-bottom: 10px;
  120. }
  121. .el-input {
  122. max-width: 700px;
  123. }
  124. .space {
  125. height: 20px;
  126. }
  127. </style>