From ab9e7d10dda650f8fb03493fb81a7c574a51728c Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Fri, 31 Jan 2020 16:08:37 +0700 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20=D0=BE=D1=82=D0=BB=D0=BE=D0=B2=20=D0=BE=D1=88=D0=B8?= =?UTF-8?q?=D0=B1=D0=BE=D0=BA=20=D0=BF=D1=80=D0=B8=20=D0=B8=D0=BD=D0=B8?= =?UTF-8?q?=D1=86=D0=B8=D0=B0=D0=BB=D0=B8=D0=B7=D0=B0=D1=86=D0=B8=D0=B8,?= =?UTF-8?q?=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B0=20?= =?UTF-8?q?=D0=B3=D0=B5=D0=BD=D0=B5=D1=80=D0=B0=D1=86=D0=B8=D1=8F=20=D0=BE?= =?UTF-8?q?=D1=88=D0=B8=D0=B1=D0=BA=D0=B8=20measureText?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/Reader/TextPage/TextPage.vue | 86 ++++++++++--------- 1 file changed, 46 insertions(+), 40 deletions(-) diff --git a/client/components/Reader/TextPage/TextPage.vue b/client/components/Reader/TextPage/TextPage.vue index a81ef4fe..912c177c 100644 --- a/client/components/Reader/TextPage/TextPage.vue +++ b/client/components/Reader/TextPage/TextPage.vue @@ -211,7 +211,9 @@ class TextPage extends Vue { this.parsed.wordWrap = this.wordWrap; this.parsed.cutEmptyParagraphs = this.cutEmptyParagraphs; this.parsed.addEmptyParagraphs = this.addEmptyParagraphs; - let t = ''; + let t = 'Щ'; + if (this.drawHelper.measureText(t, {}) == 0) + throw new Error('Ошибка measureText'); while (this.drawHelper.measureText(t, {}) < this.w) t += 'Щ'; this.parsed.maxWordLength = t.length - 1; this.parsed.measureText = this.drawHelper.measureText.bind(this.drawHelper); @@ -368,47 +370,51 @@ class TextPage extends Vue { if (this.lastBook) { (async() => { - //подождем ленивый парсинг - this.stopLazyParse = true; - while (this.doingLazyParse) await sleep(10); + try { + //подождем ленивый парсинг + this.stopLazyParse = true; + while (this.doingLazyParse) await sleep(10); - const isParsed = await bookManager.hasBookParsed(this.lastBook); - if (!isParsed) { - return; + 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; + + let authorNames = []; + if (this.fb2.author) { + authorNames = this.fb2.author.map(a => _.compact([ + a.lastName, + a.firstName, + a.middleName + ]).join(' ')); + } + + this.title = _.compact([ + authorNames.join(', '), + this.fb2.bookTitle + ]).join(' - '); + + this.$root.$emit('set-app-title', this.title); + + this.parsed = this.book.parsed; + + this.page1 = null; + this.page2 = null; + this.statusBar = null; + await this.stopTextScrolling(); + + await this.calcPropsAndLoadFonts(); + + this.refreshTime(); + if (this.lazyParseEnabled) + this.lazyParsePara(); + } catch (e) { + this.$alert(e.message, 'Ошибка', {type: 'error'}); } - - this.book = await bookManager.getBook(this.lastBook); - this.meta = bookManager.metaOnly(this.book); - this.fb2 = this.meta.fb2; - - let authorNames = []; - if (this.fb2.author) { - authorNames = this.fb2.author.map(a => _.compact([ - a.lastName, - a.firstName, - a.middleName - ]).join(' ')); - } - - this.title = _.compact([ - authorNames.join(', '), - this.fb2.bookTitle - ]).join(' - '); - - this.$root.$emit('set-app-title', this.title); - - this.parsed = this.book.parsed; - - this.page1 = null; - this.page2 = null; - this.statusBar = null; - await this.stopTextScrolling(); - - this.calcPropsAndLoadFonts(); - - this.refreshTime(); - if (this.lazyParseEnabled) - this.lazyParsePara(); })(); } }