SettingsPage.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  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 class="tabs" type="border-card" tab-position="left" v-model="selectedTab">
  9. <el-tab-pane label="Вид">
  10. <el-form :model="form" size="small" label-width="120px">
  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="120px">
  22. <div class="partHeader">Шрифт</div>
  23. <el-form-item label="Локальный/веб">
  24. <el-col :span="10">
  25. <el-select v-model="fontName" placeholder="Шрифт" :disabled="webFontName != ''">
  26. <el-option v-for="item in fonts"
  27. :key="item.name"
  28. :label="item.label"
  29. :value="item.name">
  30. </el-option>
  31. </el-select>
  32. </el-col>
  33. <el-col :span="1">
  34. &nbsp;
  35. </el-col>
  36. <el-col :span="10">
  37. <el-select v-model="webFontName">
  38. <el-option label="Нет" value=""></el-option>
  39. <el-option v-for="item in webFonts"
  40. :key="item.name"
  41. :value="item.name">
  42. </el-option>
  43. </el-select>
  44. </el-col>
  45. </el-form-item>
  46. <el-form-item label="Размер">
  47. <el-col :span="10">
  48. <el-input-number v-model="fontSize" :min="5" :max="100"></el-input-number>
  49. </el-col>
  50. </el-form-item>
  51. <el-form-item label="Стиль">
  52. <el-col :span="11">
  53. <el-checkbox v-model="fontBold">Жирный</el-checkbox>
  54. </el-col>
  55. <el-col :span="11">
  56. <el-checkbox v-model="fontItalic">Курсив</el-checkbox>
  57. </el-col>
  58. </el-form-item>
  59. </el-form>
  60. <el-form :model="form" size="mini" label-width="120px">
  61. <div class="partHeader">Текст</div>
  62. <el-form-item label="Интервал">
  63. <el-input-number v-model="lineInterval" :min="0" :max="100"></el-input-number>
  64. </el-form-item>
  65. <el-form-item label="Параграф">
  66. <el-input-number v-model="p" :min="0" :max="200"></el-input-number>
  67. </el-form-item>
  68. <el-form-item label="Выравнивание">
  69. <el-checkbox v-model="textAlignJustify">По ширине</el-checkbox>
  70. <el-checkbox v-model="wordWrap">Перенос по слогам</el-checkbox>
  71. </el-form-item>
  72. </el-form>
  73. <el-form :model="form" size="mini" label-width="120px">
  74. <div class="partHeader">Строка статуса</div>
  75. <el-form-item label="Статус">
  76. <el-checkbox v-model="showStatusBar">Показывать</el-checkbox>
  77. <el-checkbox v-model="statusBarTop" :disabled="!showStatusBar">Вверху/внизу</el-checkbox>
  78. </el-form-item>
  79. <el-form-item label="Высота">
  80. <el-input-number v-model="statusBarHeight" :min="5" :max="50" :disabled="!showStatusBar"></el-input-number>
  81. </el-form-item>
  82. <el-form-item label="Прозрачность">
  83. <el-input-number v-model="statusBarColorAlpha" :min="0" :max="1" :precision="2" :step="0.1" :disabled="!showStatusBar"></el-input-number>
  84. </el-form-item>
  85. </el-form>
  86. </el-tab-pane>
  87. <el-tab-pane label="Листание">
  88. </el-tab-pane>
  89. <el-tab-pane label="Другое">
  90. </el-tab-pane>
  91. </el-tabs>
  92. </Window>
  93. </div>
  94. </div>
  95. </template>
  96. <script>
  97. //-----------------------------------------------------------------------------
  98. import Vue from 'vue';
  99. import Component from 'vue-class-component';
  100. import Window from '../../share/Window.vue';
  101. import rstore from '../../../store/modules/reader';
  102. const propsData = {
  103. textColor: '#000000',
  104. backgroundColor: '#EBE2C9',
  105. fontStyle: '',// 'italic'
  106. fontWeight: '',// 'bold'
  107. fontSize: 20,// px
  108. fontName: 'ReaderDefault',
  109. webFontName: '',
  110. lineInterval: 3,// px, межстрочный интервал
  111. textAlignJustify: true,// выравнивание по ширине
  112. p: 25,// px, отступ параграфа
  113. indent: 15,// px, отступ всего текста слева и справа
  114. wordWrap: true,//перенос по слогам
  115. keepLastToFirst: true,// перенос последней строки в первую при листании
  116. showStatusBar: true,
  117. statusBarTop: false,// top, bottom
  118. statusBarHeight: 19,// px
  119. statusBarColorAlpha: 0.4,
  120. pageChangeTransition: '',// '' - нет, downShift, rightShift, thaw - протаивание, blink - мерцание
  121. pageChangeTransitionSpeed: 50, //0-100%
  122. allowUrlParamBookPos: true,
  123. };
  124. export default @Component({
  125. components: {
  126. Window,
  127. },
  128. data: function() {
  129. return Object.assign({}, propsData);
  130. },
  131. watch: {
  132. form: function(newValue) {
  133. this.commit('reader/setSettings', newValue);
  134. },
  135. fontBold: function(newValue) {
  136. this.fontWeight = (newValue ? 'bold' : '');
  137. },
  138. fontItalic: function(newValue) {
  139. this.fontStyle = (newValue ? 'italic' : '');
  140. },
  141. },
  142. })
  143. class SettingsPage extends Vue {
  144. selectedTab = null;
  145. form = {};
  146. fontBold = false;
  147. fontItalic = false;
  148. webFonts = [];
  149. fonts = [];
  150. created() {
  151. this.commit = this.$store.commit;
  152. this.reader = this.$store.state.reader;
  153. this.form = this.settings;
  154. for (let prop in propsData) {
  155. this[prop] = this.form[prop];
  156. this.$watch(prop, (newValue) => {
  157. this.form = Object.assign({}, this.form, {[prop]: newValue})
  158. });
  159. }
  160. this.fontBold = (this.fontWeight == 'bold');
  161. this.fontItalic = (this.fontStyle == 'italic');
  162. this.fonts = rstore.fonts;
  163. this.webFonts = rstore.webFonts;
  164. }
  165. get settings() {
  166. return this.$store.state.reader.settings;
  167. }
  168. get predefineTextColors() {
  169. return [
  170. '#ffffff',
  171. '#000000',
  172. '#202020',
  173. '#323232',
  174. '#aaaaaa',
  175. '#00c0c0',
  176. ];
  177. }
  178. get predefineBackgroundColors() {
  179. return [
  180. '#ffffff',
  181. '#000000',
  182. '#202020',
  183. '#ebe2c9',
  184. '#478355',
  185. '#909080',
  186. '#808080',
  187. '#a6caf0',
  188. '#c8c8c8',
  189. ];
  190. }
  191. close() {
  192. this.$emit('settings-toggle');
  193. }
  194. keyHook(event) {
  195. if (event.type == 'keydown' && event.code == 'Escape') {
  196. this.close();
  197. }
  198. return true;
  199. }
  200. }
  201. //-----------------------------------------------------------------------------
  202. </script>
  203. <style scoped>
  204. .main {
  205. position: absolute;
  206. width: 100%;
  207. height: 100%;
  208. z-index: 60;
  209. display: flex;
  210. flex-direction: column;
  211. justify-content: center;
  212. align-items: center;
  213. }
  214. .mainWindow {
  215. width: 100%;
  216. max-width: 600px;
  217. height: 70%;
  218. display: flex;
  219. position: relative;
  220. }
  221. .el-form {
  222. border-top: 2px solid #bbbbbb;
  223. margin-bottom: 5px;
  224. }
  225. .el-form-item {
  226. padding: 0;
  227. margin: 0;
  228. margin-bottom: 5px;
  229. }
  230. .color-picked {
  231. margin-left: 10px;
  232. position: relative;
  233. top: -11px;
  234. }
  235. .partHeader {
  236. font-weight: bold;
  237. margin-bottom: 5px;
  238. }
  239. .tabs {
  240. flex: 1;
  241. display: flex;
  242. }
  243. .el-tab-pane {
  244. height: 100%;
  245. overflow-y: auto;
  246. }
  247. </style>