Reader.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <template>
  2. <el-container>
  3. <el-header height='50px'>
  4. <div class="header">
  5. <el-tooltip content="Загрузить книгу" :open-delay="1000" effect="light">
  6. <el-button class="tool-button" :class="buttonActiveClass('loader')" @click="buttonClick('loader')"><i class="el-icon-back"></i></el-button>
  7. </el-tooltip>
  8. <div>
  9. <el-tooltip content="Действие назад" :open-delay="1000" effect="light">
  10. <el-button class="tool-button" @click="buttonClick('undoAction')" ><i class="el-icon-arrow-left"></i></el-button>
  11. </el-tooltip>
  12. <el-tooltip content="Действие вперед" :open-delay="1000" effect="light">
  13. <el-button class="tool-button" @click="buttonClick('redoAction')" ><i class="el-icon-arrow-right"></i></el-button>
  14. </el-tooltip>
  15. <div class="space"></div>
  16. <el-tooltip content="На весь экран" :open-delay="1000" effect="light">
  17. <el-button class="tool-button" :class="buttonActiveClass('fullscreen')" @click="buttonClick('fullscreen')"><i class="el-icon-rank"></i></el-button>
  18. </el-tooltip>
  19. <el-tooltip content="Прокрутка книги" :open-delay="1000" effect="light">
  20. <el-button class="tool-button" @click="buttonClick('setPosition')"><i class="el-icon-d-arrow-right"></i></el-button>
  21. </el-tooltip>
  22. <el-tooltip content="Плавный скроллинг" :open-delay="1000" effect="light">
  23. <el-button class="tool-button" @click="buttonClick('scrolling')"><i class="el-icon-sort"></i></el-button>
  24. </el-tooltip>
  25. <el-tooltip content="Найти в тексте" :open-delay="1000" effect="light">
  26. <el-button class="tool-button" @click="buttonClick('search')"><i class="el-icon-search"></i></el-button>
  27. </el-tooltip>
  28. <el-tooltip content="Принудительно обновить книгу в обход кеша" :open-delay="1000" effect="light">
  29. <el-button class="tool-button" @click="buttonClick('refresh')"><i class="el-icon-refresh"></i></el-button>
  30. </el-tooltip>
  31. <div class="space"></div>
  32. <el-tooltip content="История" :open-delay="1000" effect="light">
  33. <el-button class="tool-button" @click="buttonClick('history')"><i class="el-icon-document"></i></el-button>
  34. </el-tooltip>
  35. </div>
  36. <el-tooltip content="Настроить" :open-delay="1000" effect="light">
  37. <el-button class="tool-button" @click="buttonClick('settings')"><i class="el-icon-setting"></i></el-button>
  38. </el-tooltip>
  39. </div>
  40. </el-header>
  41. <el-main>
  42. <keep-alive>
  43. <component ref="page" :is="pageActive"></component>
  44. </keep-alive>
  45. </el-main>
  46. </el-container>
  47. </template>
  48. <script>
  49. //-----------------------------------------------------------------------------
  50. import Vue from 'vue';
  51. import Component from 'vue-class-component';
  52. import LoaderPage from './LoaderPage/LoaderPage.vue';
  53. import TextPage from './TextPage/TextPage.vue';
  54. export default @Component({
  55. components: {
  56. LoaderPage,
  57. TextPage
  58. },
  59. })
  60. class Reader extends Vue {
  61. created() {
  62. this.commit = this.$store.commit;
  63. this.dispatch = this.$store.dispatch;
  64. this.reader = this.$store.state.reader;
  65. this.$root.addKeyHook(this.keyHook);
  66. }
  67. get loaderActive() {
  68. return this.reader.loaderActive;
  69. }
  70. get fullScreenActive() {
  71. return this.reader.fullScreenActive;
  72. }
  73. get lastOpenedBook() {
  74. return this.$store.getters['reader/lastOpenedBook'];
  75. }
  76. buttonClick(button) {
  77. switch (button) {
  78. case 'loader': this.commit('reader/setLoaderActive', !this.loaderActive); break;
  79. case 'fullscreen': this.commit('reader/setFullScreenActive', !this.fullScreenActive); break;
  80. }
  81. }
  82. buttonActiveClass(button) {
  83. const classActive = { 'tool-button-active': true, 'tool-button-active:hover': true };
  84. switch (button) {
  85. case 'loader': return (this.loaderActive ? classActive : {});
  86. case 'fullscreen': return (this.fullScreenActive ? classActive : {});
  87. }
  88. return {};
  89. }
  90. get pageActive() {
  91. let result = '';
  92. if (this.lastOpenedBook)
  93. result = 'TextPage';
  94. if (this.loaderActive)
  95. result = 'LoaderPage';
  96. if (!result) {
  97. //this.commit('reader/setLoaderActive', true);
  98. //result = 'LoaderPage';
  99. }
  100. return result;
  101. }
  102. keyHook(event) {
  103. if (this.$root.rootRoute == '/reader') {
  104. if (this.$refs.page && this.$refs.page.keyHook)
  105. this.$refs.page.keyHook(event);
  106. }
  107. }
  108. }
  109. //-----------------------------------------------------------------------------
  110. //, .tool-button:focus, .tool-button:active, .tool-button:hover
  111. </script>
  112. <style scoped>
  113. .el-container {
  114. padding: 0;
  115. margin: 0;
  116. height: 100%;
  117. }
  118. .el-header {
  119. padding-left: 5px;
  120. padding-right: 5px;
  121. background-color: #1B695F;
  122. color: #000;
  123. overflow-x: auto;
  124. overflow-y: hidden;
  125. }
  126. .header {
  127. display: flex;
  128. justify-content: space-between;
  129. min-width: 500px;
  130. }
  131. .el-main {
  132. display: flex;
  133. padding: 0;
  134. margin: 0;
  135. background-color: #EBE2C9;
  136. color: #000;
  137. }
  138. .tool-button {
  139. margin: 0;
  140. margin-left: 2px;
  141. margin-right: 2px;
  142. padding: 0;
  143. color: #3E843E;
  144. background-color: #E6EDF4;
  145. margin-top: 5px;
  146. height: 38px;
  147. width: 38px;
  148. border: 0;
  149. box-shadow: 3px 3px 5px black;
  150. }
  151. .tool-button:hover {
  152. background-color: white;
  153. }
  154. .tool-button-active {
  155. box-shadow: 0 0 0;
  156. color: white;
  157. background-color: #8AB45F;
  158. position: relative;
  159. top: 1px;
  160. left: 1px;
  161. }
  162. .tool-button-active:hover {
  163. color: white;
  164. background-color: #81C581;
  165. }
  166. i {
  167. font-size: 200%;
  168. }
  169. .space {
  170. width: 10px;
  171. display: inline-block;
  172. }
  173. </style>