Улучшил обработку ошибок
This commit is contained in:
@@ -150,12 +150,13 @@ class Reader extends Vue {
|
||||
progress.setState({progress: prog});
|
||||
});
|
||||
|
||||
this.commit('reader/addOpenedBook', bookManager.metaOnly(addedBook));
|
||||
this.commit('reader/setOpenedBook', bookManager.metaOnly(addedBook));
|
||||
this.commit('reader/setLoaderActive', false);
|
||||
|
||||
progress.hide(); this.progressActive = false;
|
||||
} catch (e) {
|
||||
progress.hide(); this.progressActive = false;
|
||||
this.commit('reader/setLoaderActive', true);
|
||||
this.$alert(e.message, 'Ошибка', {type: 'error'});
|
||||
}
|
||||
});
|
||||
@@ -164,7 +165,7 @@ class Reader extends Vue {
|
||||
parseBook(meta) {
|
||||
this.progressActive = true;
|
||||
this.$nextTick(async() => {
|
||||
if (await bookManager.hasBookParsed(meta)) {
|
||||
if (bookManager.hasBookParsed(meta)) {
|
||||
this.progressActive = false;
|
||||
return;
|
||||
}
|
||||
@@ -184,6 +185,7 @@ class Reader extends Vue {
|
||||
}
|
||||
} catch (e) {
|
||||
progress.hide(); this.progressActive = false;
|
||||
this.commit('reader/setLoaderActive', true);
|
||||
this.$alert(e.message, 'Ошибка', {type: 'error'});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
<template>
|
||||
<div class="main">
|
||||
<pre>{{ meta }}</pre>
|
||||
<p v-for="item in items" :key="item.id">
|
||||
{{ item.text }}
|
||||
</p>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -21,25 +18,30 @@ class TextPage extends Vue {
|
||||
meta = null;
|
||||
fb2 = null;
|
||||
|
||||
items = null;
|
||||
|
||||
created() {
|
||||
this.commit = this.$store.commit;
|
||||
this.dispatch = this.$store.dispatch;
|
||||
this.config = this.$store.state.config;
|
||||
this.reader = this.$store.state.reader;
|
||||
|
||||
this.book = null;
|
||||
this.openFailed = false;
|
||||
}
|
||||
|
||||
activated() {
|
||||
this.book = null;
|
||||
this.meta = null;
|
||||
this.fb2 = null;
|
||||
|
||||
const last = this.lastOpenedBook;
|
||||
if (last) {
|
||||
(async() => {
|
||||
const isParsed = await bookManager.hasBookParsed(last);
|
||||
if (!isParsed) {
|
||||
this.$root.$emit('set-app-title');
|
||||
if (!this.openFailed) {
|
||||
this.$emit('parse-book', last);
|
||||
this.openFailed = true;
|
||||
}
|
||||
return;
|
||||
}
|
||||
this.book = await bookManager.getBook(last);
|
||||
@@ -52,16 +54,6 @@ class TextPage extends Vue {
|
||||
'-',
|
||||
this.fb2.bookTitle
|
||||
]).join(' '));
|
||||
//
|
||||
let lines = [];
|
||||
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: para[i].text});
|
||||
}
|
||||
this.items = lines;
|
||||
//
|
||||
|
||||
})();
|
||||
}
|
||||
}
|
||||
@@ -70,6 +62,11 @@ class TextPage extends Vue {
|
||||
return this.$store.getters['reader/lastOpenedBook'];
|
||||
}
|
||||
|
||||
showPage() {
|
||||
if (!this.book)
|
||||
return;
|
||||
}
|
||||
|
||||
keyHook(event) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ const mutations = {
|
||||
setFullScreenActive(state, value) {
|
||||
state.fullScreenActive = value;
|
||||
},
|
||||
addOpenedBook(state, value) {
|
||||
setOpenedBook(state, value) {
|
||||
Vue.set(state.openedBook, value.key, Object.assign({}, value, {touchTime: Date.now()}));
|
||||
},
|
||||
delOpenedBook(state, value) {
|
||||
|
||||
Reference in New Issue
Block a user