SettingsPage.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. <template>
  2. <div ref="main" class="main" @click="close">
  3. <div class="mainWindow" @click.stop>
  4. <Window @close="close">
  5. <template slot="header">
  6. Настройки
  7. </template>
  8. <el-tabs type="border-card" tab-position="left" style="height: 100%;" v-model="selectedTab">
  9. <el-tab-pane label="Вид">
  10. <el-form :model="form" size="mini" label-width="100px">
  11. <el-form-item>
  12. <b>Цвет</b>
  13. </el-form-item>
  14. <el-form-item label="Текст">
  15. <el-color-picker v-model="textColor" color-format="hex" :predefine="predefineTextColors"></el-color-picker>
  16. <span class="color-picked"><b>{{ textColor }}</b></span>
  17. </el-form-item>
  18. <el-form-item label="Фон">
  19. <el-color-picker v-model="backgroundColor" color-format="hex" :predefine="predefineBackgroundColors"></el-color-picker>
  20. <span class="color-picked"><b>{{ backgroundColor }}</b></span>
  21. </el-form-item>
  22. </el-form>
  23. <el-form :model="form" size="mini" label-width="100px">
  24. <el-form-item>
  25. <b>Шрифт</b>
  26. </el-form-item>
  27. </el-form>
  28. <el-form :model="form" size="mini" label-width="100px">
  29. <el-form-item>
  30. <b>Текст</b>
  31. </el-form-item>
  32. </el-form>
  33. <el-form :model="form" size="mini" label-width="100px">
  34. <el-form-item>
  35. <b>Строка статуса</b>
  36. </el-form-item>
  37. </el-form>
  38. </el-tab-pane>
  39. <el-tab-pane label="Листание">
  40. </el-tab-pane>
  41. <el-tab-pane label="Другое">
  42. </el-tab-pane>
  43. </el-tabs>
  44. </Window>
  45. </div>
  46. </div>
  47. </template>
  48. <script>
  49. //-----------------------------------------------------------------------------
  50. import Vue from 'vue';
  51. import Component from 'vue-class-component';
  52. import Window from '../../share/Window.vue';
  53. const propsData = {
  54. textColor: '#000000',
  55. backgroundColor: '#EBE2C9',
  56. fontStyle: '',// 'italic'
  57. fontWeight: '',// 'bold'
  58. fontSize: 20,// px
  59. fontName: 'ReaderDefault',
  60. fontCssUrl: '',
  61. fontVertShift: 0,
  62. lineInterval: 3,// px, межстрочный интервал
  63. textAlignJustify: true,// выравнивание по ширине
  64. p: 25,// px, отступ параграфа
  65. indent: 15,// px, отступ всего текста слева и справа
  66. wordWrap: true,//перенос по слогам
  67. keepLastToFirst: true,// перенос последней строки в первую при листании
  68. showStatusBar: true,
  69. statusBarTop: false,// top, bottom
  70. statusBarHeight: 19,// px
  71. statusBarColorAlpha: 0.4,
  72. pageChangeTransition: '',// '' - нет, downShift, rightShift, thaw - протаивание, blink - мерцание
  73. pageChangeTransitionSpeed: 50, //0-100%
  74. allowUrlParamBookPos: true,
  75. };
  76. export default @Component({
  77. components: {
  78. Window,
  79. },
  80. data: function() {
  81. return Object.assign({}, propsData);
  82. },
  83. watch: {
  84. form: function(newValue) {
  85. this.commit('reader/setSettings', newValue);
  86. },
  87. },
  88. })
  89. class SettingsPage extends Vue {
  90. selectedTab = null;
  91. form = {};
  92. created() {
  93. this.commit = this.$store.commit;
  94. this.reader = this.$store.state.reader;
  95. this.form = this.settings;
  96. for (let prop in propsData) {
  97. this[prop] = this.form[prop];
  98. this.$watch(prop, (newValue) => {
  99. this.form = Object.assign({}, this.form, {[prop]: newValue})
  100. });
  101. }
  102. }
  103. get settings() {
  104. return this.$store.state.reader.settings;
  105. }
  106. get predefineTextColors() {
  107. return [
  108. '#ffffff',
  109. '#000000',
  110. '#202020',
  111. '#323232',
  112. '#aaaaaa',
  113. '#00c0c0',
  114. ];
  115. }
  116. get predefineBackgroundColors() {
  117. return [
  118. '#ffffff',
  119. '#000000',
  120. '#202020',
  121. '#ebe2c9',
  122. '#478355',
  123. '#909080',
  124. '#808080',
  125. '#a6caf0',
  126. '#c8c8c8',
  127. ];
  128. }
  129. close() {
  130. this.$emit('settings-toggle');
  131. }
  132. keyHook(event) {
  133. if (event.type == 'keydown' && event.code == 'Escape') {
  134. this.close();
  135. }
  136. return true;
  137. }
  138. }
  139. //-----------------------------------------------------------------------------
  140. </script>
  141. <style scoped>
  142. .main {
  143. position: absolute;
  144. width: 100%;
  145. height: 100%;
  146. z-index: 60;
  147. display: flex;
  148. flex-direction: column;
  149. justify-content: center;
  150. align-items: center;
  151. }
  152. .mainWindow {
  153. width: 100%;
  154. max-width: 600px;
  155. height: 70%;
  156. display: flex;
  157. position: relative;
  158. }
  159. .el-form {
  160. border-top: 2px solid #bbbbbb;
  161. }
  162. .el-form-item {
  163. padding: 0;
  164. margin: 0;
  165. position: relative;
  166. }
  167. .color-picked {
  168. margin-left: 10px;
  169. position: relative;
  170. top: -9px;
  171. }
  172. </style>