Добавил установку document.title

This commit is contained in:
Book Pauk
2019-01-15 01:26:39 +07:00
parent 0e8d9564ef
commit 4cdb258703
4 changed files with 67 additions and 14 deletions

View File

@@ -126,6 +126,10 @@ class Reader extends Vue {
//this.commit('reader/setLoaderActive', true);
//result = 'LoaderPage';
}
if (result != 'TextPage') {
this.$root.$emit('set-app-title');
}
return result;
}

View File

@@ -1,5 +1,6 @@
<template>
<div class="main">
<pre>{{ meta }}</pre>
<p v-for="item in items" :key="item.id">
{{ item.text }}
</p>
@@ -10,11 +11,14 @@
//-----------------------------------------------------------------------------
import Vue from 'vue';
import Component from 'vue-class-component';
import _ from 'lodash';
import bookManager from '../share/bookManager';
export default @Component({
})
class TextPage extends Vue {
meta = null;
items = null;
created() {
@@ -32,18 +36,30 @@ class TextPage extends Vue {
(async() => {
const isParsed = await bookManager.hasBookParsed(last);
if (!isParsed) {
this.$root.$emit('set-app-title');
this.$emit('parse-book', last);
return;
}
const book = await bookManager.getBook(last);
this.book = book.parsed;
this.book = await bookManager.getBook(last);
this.meta = bookManager.metaOnly(this.book);
const fb2 = this.meta.fb2;
this.$root.$emit('set-app-title', _.compact([
fb2.lastName,
fb2.middleName,
fb2.firstName,
'-',
fb2.bookTitle
]).join(' '));
//
let lines = [];
const len = (this.book.para.length > 50 ? 50 : this.book.para.length);
let para = this.book.parsed.para;
const len = (para.length > 50 ? 50 : para.length);
for (let i = 0; i < len; i++) {
lines.push({key: i, text: this.book.para[i].text});
lines.push({key: i, text: para[i].text});
}
this.items = lines;
//
})();
}
}

View File

@@ -17,6 +17,14 @@ export default class BookParser {
throw new Error('Неверный формат файла');
}
//defaults
let fb2 = {
firstName: '',
middleName: '',
lastName: '',
bookTitle: '',
};
let path = '';
let tag = '';
let nextPerc = 0;
@@ -66,8 +74,6 @@ export default class BookParser {
paraOffset += p.length;
};
let fb2 = {};
const parser = this.parser;
parser.on('error', (msgError) => {// eslint-disable-line no-unused-vars
@@ -101,6 +107,9 @@ export default class BookParser {
case '/FictionBook/description/title-info/author/first-name':
fb2.firstName = text;
break;
case '/FictionBook/description/title-info/author/middle-name':
fb2.middleName = text;
break;
case '/FictionBook/description/title-info/author/last-name':
fb2.lastName = text;
break;