LoaderPage.vue 3.6 KB

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