From fbb0fa91b68558cf52d983debd14a13dad7e9f40 Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Mon, 28 Jan 2019 12:36:50 +0700 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=20=D0=BD?= =?UTF-8?q?=D0=B0=D0=B4=20SettingsPage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Reader/SettingsPage/SettingsPage.vue | 60 +++++++++++++++---- .../components/Reader/TextPage/TextPage.vue | 12 +++- client/store/modules/reader.js | 12 +++- 3 files changed, 67 insertions(+), 17 deletions(-) diff --git a/client/components/Reader/SettingsPage/SettingsPage.vue b/client/components/Reader/SettingsPage/SettingsPage.vue index 7fe21cf9..98973eaa 100644 --- a/client/components/Reader/SettingsPage/SettingsPage.vue +++ b/client/components/Reader/SettingsPage/SettingsPage.vue @@ -8,7 +8,7 @@ - +
Цвет
@@ -22,15 +22,12 @@
- +
Шрифт
- - - - - - + + + @@ -40,6 +37,32 @@ + +   + + + + + + + + + + + + + + + + + + Жирный + + + Курсив +
@@ -69,6 +92,7 @@ import Vue from 'vue'; import Component from 'vue-class-component'; import Window from '../../share/Window.vue'; +import reader from '../../../store/modules/reader'; const propsData = { textColor: '#000000', @@ -77,8 +101,7 @@ const propsData = { fontWeight: '',// 'bold' fontSize: 20,// px fontName: 'ReaderDefault', - fontCssUrl: '', - fontVertShift: 0, + webFontName: '', lineInterval: 3,// px, межстрочный интервал textAlignJustify: true,// выравнивание по ширине @@ -109,11 +132,21 @@ export default @Component({ form: function(newValue) { this.commit('reader/setSettings', newValue); }, + fontBold: function(newValue) { + this.fontWeight = (newValue ? 'bold' : ''); + }, + fontItalic: function(newValue) { + this.fontStyle = (newValue ? 'italic' : ''); + }, }, }) class SettingsPage extends Vue { selectedTab = null; form = {}; + fontBold = false; + fontItalic = false; + + webFonts = []; created() { this.commit = this.$store.commit; @@ -126,6 +159,9 @@ class SettingsPage extends Vue { this.form = Object.assign({}, this.form, {[prop]: newValue}) }); } + this.fontBold = (this.fontWeight == 'bold'); + this.fontItalic = (this.fontStyle == 'italic'); + this.webFonts = reader.webFonts; } get settings() { @@ -193,13 +229,13 @@ class SettingsPage extends Vue { .el-form { border-top: 2px solid #bbbbbb; - margin-bottom: 15px; + margin-bottom: 5px; } .el-form-item { padding: 0; margin: 0; - position: relative; + margin-bottom: 5px; } .color-picked { diff --git a/client/components/Reader/TextPage/TextPage.vue b/client/components/Reader/TextPage/TextPage.vue index 02543943..7419d4bd 100644 --- a/client/components/Reader/TextPage/TextPage.vue +++ b/client/components/Reader/TextPage/TextPage.vue @@ -32,7 +32,7 @@ import {sleep} from '../../../share/utils'; import bookManager from '../share/bookManager'; import DrawHelper from './DrawHelper'; - +import reader from '../../../store/modules/reader'; const minLayoutWidth = 100; export default @Component({ @@ -236,8 +236,14 @@ class TextPage extends Vue { this.fontWeight = settings.fontWeight;// 'bold' this.fontSize = settings.fontSize;// px this.fontName = settings.fontName; - this.fontCssUrl = settings.fontCssUrl; - this.fontVertShift = settings.fontVertShift; + + const wf = settings.webFontName; + const i = _.findIndex(reader.webFonts, ['name', wf]); + if (wf && i >= 0) { + this.fontName = wf; + this.fontCssUrl = reader.webFonts[i].css; + this.fontVertShift = reader.webFonts[i].fontVertShift; + } this.lineInterval = settings.lineInterval;// px, межстрочный интервал this.textAlignJustify = settings.textAlignJustify;// выравнивание по ширине diff --git a/client/store/modules/reader.js b/client/store/modules/reader.js index e9dee37b..aff63692 100644 --- a/client/store/modules/reader.js +++ b/client/store/modules/reader.js @@ -1,5 +1,13 @@ import Vue from 'vue'; +const webFonts = [ + {css: 'https://fonts.googleapis.com/css?family=Oswald', name: 'Oswald', fontVertShift: 0}, + {css: 'https://fonts.googleapis.com/css?family=Lobster', name: 'Lobster', fontVertShift: 0}, + {css: 'https://fonts.googleapis.com/css?family=Pacifico', name: 'Pacifico', fontVertShift: 0}, + {css: 'https://fonts.googleapis.com/css?family=Comfortaa', name: 'Comfortaa', fontVertShift: 0}, + +]; + // initial state const state = { toolBarActive: true, @@ -11,8 +19,7 @@ const state = { fontWeight: '',// 'bold' fontSize: 20,// px fontName: 'ReaderDefault', - fontCssUrl: '', - fontVertShift: 0, + webFontName: '', lineInterval: 3,// px, межстрочный интервал textAlignJustify: true,// выравнивание по ширине @@ -93,6 +100,7 @@ const mutations = { }; export default { + webFonts, namespaced: true, state, getters,