Рефакторинг

This commit is contained in:
Book Pauk
2019-01-28 12:46:53 +07:00
parent fbb0fa91b6
commit 7309f2f80e
3 changed files with 25 additions and 15 deletions

View File

@@ -92,7 +92,7 @@ import Vue from 'vue';
import Component from 'vue-class-component'; import Component from 'vue-class-component';
import Window from '../../share/Window.vue'; import Window from '../../share/Window.vue';
import reader from '../../../store/modules/reader'; import rstore from '../../../store/modules/reader';
const propsData = { const propsData = {
textColor: '#000000', textColor: '#000000',
@@ -147,6 +147,7 @@ class SettingsPage extends Vue {
fontItalic = false; fontItalic = false;
webFonts = []; webFonts = [];
fonts = [];
created() { created() {
this.commit = this.$store.commit; this.commit = this.$store.commit;
@@ -161,7 +162,9 @@ class SettingsPage extends Vue {
} }
this.fontBold = (this.fontWeight == 'bold'); this.fontBold = (this.fontWeight == 'bold');
this.fontItalic = (this.fontStyle == 'italic'); this.fontItalic = (this.fontStyle == 'italic');
this.webFonts = reader.webFonts;
this.fonts = rstore.fonts;
this.webFonts = rstore.webFonts;
} }
get settings() { get settings() {

View File

@@ -32,7 +32,7 @@ import {sleep} from '../../../share/utils';
import bookManager from '../share/bookManager'; import bookManager from '../share/bookManager';
import DrawHelper from './DrawHelper'; import DrawHelper from './DrawHelper';
import reader from '../../../store/modules/reader'; import rstore from '../../../store/modules/reader';
const minLayoutWidth = 100; const minLayoutWidth = 100;
export default @Component({ export default @Component({
@@ -90,6 +90,11 @@ class TextPage extends Vue {
this.$root.$on('resize', () => {this.$nextTick(this.onResize)}); this.$root.$on('resize', () => {this.$nextTick(this.onResize)});
this.mobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent); this.mobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent);
this.fontShifts = {};
for (const font of rstore.fonts) {
this.fontShifts[font.name] = font.fontVertShift;
}
} }
mounted() { mounted() {
@@ -103,15 +108,6 @@ class TextPage extends Vue {
calcDrawProps() { calcDrawProps() {
//preloaded fonts //preloaded fonts
this.fontShifts = {//%
ReaderDefault: 0,
Roboto: 0,
OpenSans: 0,
Rubik: 0,
Avrile: -10,
Arimo: 0,
GEO_1: 10,
}
if (!this.fontShifts.hasOwnProperty(this.fontName)) if (!this.fontShifts.hasOwnProperty(this.fontName))
this.fontShifts[this.fontName] = this.fontVertShift; this.fontShifts[this.fontName] = this.fontVertShift;
this.fontList = []; this.fontList = [];
@@ -238,11 +234,11 @@ class TextPage extends Vue {
this.fontName = settings.fontName; this.fontName = settings.fontName;
const wf = settings.webFontName; const wf = settings.webFontName;
const i = _.findIndex(reader.webFonts, ['name', wf]); const i = _.findIndex(rstore.webFonts, ['name', wf]);
if (wf && i >= 0) { if (wf && i >= 0) {
this.fontName = wf; this.fontName = wf;
this.fontCssUrl = reader.webFonts[i].css; this.fontCssUrl = rstore.webFonts[i].css;
this.fontVertShift = reader.webFonts[i].fontVertShift; this.fontVertShift = rstore.webFonts[i].fontVertShift;
} }
this.lineInterval = settings.lineInterval;// px, межстрочный интервал this.lineInterval = settings.lineInterval;// px, межстрочный интервал

View File

@@ -1,5 +1,15 @@
import Vue from 'vue'; import Vue from 'vue';
const fonts = [
{name: 'ReaderDefault', label: 'По-умолчанию', fontVertShift: 0},
{name: 'GEO_1', label: 'BPG Arial', fontVertShift: 10},
{name: 'Arimo', fontVertShift: 0},
{name: 'Avrile', fontVertShift: -10},
{name: 'OpenSans', fontVertShift: 0},
{name: 'Roboto', fontVertShift: 0},
{name: 'Rubik', fontVertShift: 0},
];
const webFonts = [ const webFonts = [
{css: 'https://fonts.googleapis.com/css?family=Oswald', name: 'Oswald', fontVertShift: 0}, {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=Lobster', name: 'Lobster', fontVertShift: 0},
@@ -100,6 +110,7 @@ const mutations = {
}; };
export default { export default {
fonts,
webFonts, webFonts,
namespaced: true, namespaced: true,
state, state,