LoaderPage.vue 3.6 KB

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