92 lines
2.2 KiB
Vue
92 lines
2.2 KiB
Vue
<template>
|
|
<div ref="main" class="main">
|
|
<pre>{{ bookPos }}</pre>
|
|
<pre>{{ lastBook }}</pre>
|
|
<pre>{{ meta }}</pre>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
//-----------------------------------------------------------------------------
|
|
import Vue from 'vue';
|
|
import Component from 'vue-class-component';
|
|
import _ from 'lodash';
|
|
|
|
import bookManager from '../share/bookManager';
|
|
|
|
export default @Component({
|
|
watch: {
|
|
bookPos: function(newValue) {
|
|
this.$emit('book-pos-changed', {bookPos: newValue});
|
|
this.drawPage();
|
|
},
|
|
},
|
|
})
|
|
class TextPage extends Vue {
|
|
lastBook = null;
|
|
meta = null;
|
|
fb2 = null;
|
|
bookPos = 0;
|
|
|
|
created() {
|
|
this.commit = this.$store.commit;
|
|
this.dispatch = this.$store.dispatch;
|
|
this.config = this.$store.state.config;
|
|
this.reader = this.$store.state.reader;
|
|
}
|
|
|
|
showBook() {
|
|
this.$refs.main.focus();
|
|
this.book = null;
|
|
this.meta = null;
|
|
this.fb2 = null;
|
|
|
|
this.drawPage();//пока не загрузили, очистим канвас
|
|
|
|
if (this.lastBook) {
|
|
(async() => {
|
|
const isParsed = await bookManager.hasBookParsed(this.lastBook);
|
|
if (!isParsed) {
|
|
return;
|
|
}
|
|
this.book = await bookManager.getBook(this.lastBook);
|
|
this.meta = bookManager.metaOnly(this.book);
|
|
this.fb2 = this.meta.fb2;
|
|
|
|
this.$root.$emit('set-app-title', _.compact([
|
|
this.fb2.lastName,
|
|
this.fb2.middleName,
|
|
this.fb2.firstName,
|
|
'-',
|
|
this.fb2.bookTitle
|
|
]).join(' '));
|
|
|
|
this.drawPage();
|
|
})();
|
|
}
|
|
}
|
|
|
|
drawPage() {
|
|
if (!this.lastBook)
|
|
return;
|
|
|
|
//пустой канвас
|
|
|
|
if (!this.book)
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
keyHook(event) {
|
|
}
|
|
}
|
|
//-----------------------------------------------------------------------------
|
|
</script>
|
|
<style scoped>
|
|
.main {
|
|
flex: 1;
|
|
display: flex;
|
|
flex-direction: column;
|
|
}
|
|
</style> |