Reader.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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 :is="componentActive"></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. export default @Component({
  54. components: {
  55. LoaderPage
  56. },
  57. })
  58. class Reader extends Vue {
  59. created() {
  60. this.commit = this.$store.commit;
  61. this.dispatch = this.$store.dispatch;
  62. this.reader = this.$store.state.reader;
  63. this.$root.addKeyHook(this.keyHook);
  64. }
  65. get loaderActive() {
  66. return this.reader.loaderActive;
  67. }
  68. get fullScreenActive() {
  69. return this.reader.fullScreenActive;
  70. }
  71. buttonClick(button) {
  72. switch (button) {
  73. case 'loader': this.commit('reader/setLoaderActive', !this.loaderActive); break;
  74. case 'fullscreen': this.commit('reader/setFullScreenActive', !this.fullScreenActive); break;
  75. }
  76. }
  77. buttonActiveClass(button) {
  78. const classActive = { 'tool-button-active': true, 'tool-button-active:hover': true };
  79. switch (button) {
  80. case 'loader': return (this.loaderActive ? classActive : {});
  81. case 'fullscreen': return (this.fullScreenActive ? classActive : {});
  82. }
  83. return {};
  84. }
  85. get componentActive() {
  86. let result = '';
  87. if (this.loaderActive)
  88. result = 'LoaderPage';
  89. if (!result) {
  90. //this.commit('reader/setLoaderActive', true);
  91. //result = 'LoaderPage';
  92. }
  93. return result;
  94. }
  95. keyHook(event) {
  96. //console.log(this.componentActive);
  97. }
  98. }
  99. //-----------------------------------------------------------------------------
  100. //, .tool-button:focus, .tool-button:active, .tool-button:hover
  101. </script>
  102. <style scoped>
  103. .el-container {
  104. padding: 0;
  105. margin: 0;
  106. height: 100%;
  107. }
  108. .el-header {
  109. padding-left: 5px;
  110. padding-right: 5px;
  111. background-color: #1B695F;
  112. color: #000;
  113. overflow-x: auto;
  114. overflow-y: hidden;
  115. }
  116. .header {
  117. display: flex;
  118. justify-content: space-between;
  119. min-width: 500px;
  120. }
  121. .el-main {
  122. display: flex;
  123. padding: 0;
  124. margin: 0;
  125. background-color: #EBE2C9;
  126. color: #000;
  127. }
  128. .tool-button {
  129. margin: 0;
  130. margin-left: 2px;
  131. margin-right: 2px;
  132. padding: 0;
  133. color: #3E843E;
  134. background-color: #E6EDF4;
  135. margin-top: 5px;
  136. height: 38px;
  137. width: 38px;
  138. border: 0;
  139. box-shadow: 3px 3px 5px black;
  140. }
  141. .tool-button:hover {
  142. background-color: white;
  143. }
  144. .tool-button-active {
  145. box-shadow: 0 0 0;
  146. color: white;
  147. background-color: #8AB45F;
  148. position: relative;
  149. top: 1px;
  150. left: 1px;
  151. }
  152. .tool-button-active:hover {
  153. color: white;
  154. background-color: #81C581;
  155. }
  156. i {
  157. font-size: 200%;
  158. }
  159. .space {
  160. width: 10px;
  161. display: inline-block;
  162. }
  163. </style>