Reader.vue 5.9 KB

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