SettingsPage.vue 6.7 KB

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