Промежуточный коммит
This commit is contained in:
@@ -53,7 +53,8 @@ class ProgressPage extends Vue {
|
||||
}
|
||||
|
||||
setState(state) {
|
||||
this.text = (ruMessage[state.state] ? ruMessage[state.state] : state.state);
|
||||
if (state.state)
|
||||
this.text = (ruMessage[state.state] ? ruMessage[state.state] : state.state);
|
||||
this.step = (state.step ? state.step : this.step);
|
||||
this.totalSteps = (state.totalSteps > this.totalSteps ? state.totalSteps : this.totalSteps);
|
||||
this.progress = (state.progress ? state.progress : this.progress);
|
||||
|
||||
@@ -128,13 +128,20 @@ class Reader extends Vue {
|
||||
this.$nextTick(async() => {
|
||||
const progress = this.$refs.page;
|
||||
await progress.show();
|
||||
progress.setState({totalSteps: 4});
|
||||
progress.setState({totalSteps: 5});
|
||||
|
||||
try {
|
||||
const book = await readerApi.loadBook(url, (state) => {
|
||||
progress.setState(state);
|
||||
});
|
||||
|
||||
await bookManager.add(book);
|
||||
progress.setState({state: 'parse', step: 5, progress: 0});
|
||||
const meta = await bookManager.addBook(book, (prog) => {
|
||||
progress.setState({progress: prog});
|
||||
});
|
||||
|
||||
this.commit('reader/addOpenedBook', meta);
|
||||
this.commit('reader/setLoaderActive', false);
|
||||
|
||||
this.progressActive = await progress.hide();
|
||||
} catch (e) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div class="main">
|
||||
Text page
|
||||
<pre>{{ lastOpenedBook }}</pre>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
import Vue from 'vue';
|
||||
import Component from 'vue-class-component';
|
||||
import bookManager from '../share/bookManager';
|
||||
|
||||
export default @Component({
|
||||
})
|
||||
@@ -16,6 +17,11 @@ class TextPage extends Vue {
|
||||
this.commit = this.$store.commit;
|
||||
this.dispatch = this.$store.dispatch;
|
||||
this.config = this.$store.state.config;
|
||||
this.reader = this.$store.state.reader;
|
||||
}
|
||||
|
||||
get lastOpenedBook() {
|
||||
return this.$store.getters['reader/lastOpenedBook'];
|
||||
}
|
||||
|
||||
keyHook(event) {
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
export default class BookParser {
|
||||
}
|
||||
@@ -1,7 +1,23 @@
|
||||
import 'localforage';
|
||||
import path from 'path';
|
||||
|
||||
import BookParser from './BookParser';
|
||||
|
||||
class BookManager {
|
||||
async add() {
|
||||
async addBook(book, callback) {
|
||||
let meta = {url: book.url, path: book.path};
|
||||
|
||||
meta.key = path.basename(book.path);
|
||||
|
||||
if (callback)
|
||||
callback(100);
|
||||
return meta;
|
||||
}
|
||||
|
||||
async hasBook(meta) {
|
||||
}
|
||||
|
||||
async getBook(meta) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user