From 72f8977071bc028e275980162b2e89f52ebdacd0 Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Wed, 16 Dec 2020 01:41: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=D0=BE=20=D0=BE=D1=82=D0=BE=D0=B1=D1=80=D0=B0=D0=B6=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=BD=D0=BE=D0=BC=D0=B5=D1=80=D0=B0=20?= =?UTF-8?q?=D0=B8=D0=B7=D0=BE=D0=B1=D1=80=D0=B0=D0=B6=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F=20=D0=B2=20=D1=81=D1=82=D0=B0=D1=82=D1=83=D1=81=D0=B1?= =?UTF-8?q?=D0=B0=D1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/Reader/TextPage/DrawHelper.js | 9 +++--- .../components/Reader/TextPage/TextPage.vue | 18 ++++++++++- client/components/Reader/share/BookParser.js | 31 +++++++++++-------- 3 files changed, 40 insertions(+), 18 deletions(-) diff --git a/client/components/Reader/TextPage/DrawHelper.js b/client/components/Reader/TextPage/DrawHelper.js index c48e69f7..ec62d9a7 100644 --- a/client/components/Reader/TextPage/DrawHelper.js +++ b/client/components/Reader/TextPage/DrawHelper.js @@ -160,12 +160,13 @@ export default class DrawHelper { return out; } - drawPercentBar(x, y, w, h, font, fontSize, bookPos, textLength) { + drawPercentBar(x, y, w, h, font, fontSize, bookPos, textLength, imageNum, imageLength) { const pad = 3; const fh = h - 2*pad; const fh2 = fh/2; - const t1 = `${Math.floor((bookPos + 1)/1000)}/${Math.floor(textLength/1000)}`; + const tImg = (imageNum > 0 ? ` (${imageNum}/${imageLength})` : ''); + const t1 = `${Math.floor((bookPos + 1)/1000)}/${Math.floor(textLength/1000)}${tImg}`; const w1 = this.measureTextFont(t1, font) + fh2; const read = (bookPos + 1)/textLength; const t2 = `${(read*100).toFixed(2)}%`; @@ -188,7 +189,7 @@ export default class DrawHelper { return out; } - drawStatusBar(statusBarTop, statusBarHeight, bookPos, textLength, title) { + drawStatusBar(statusBarTop, statusBarHeight, bookPos, textLength, title, imageNum, imageLength) { let out = `
`, 0); - else - newParagraph(`${' '.repeat(maxImageLineCount)}`, maxImageLineCount); + imageNum++; - imageIndex++; - this.images.push({paraIndex, num: imageIndex, id}); + if (inPara && !this.showInlineImagesInCenter && !center) + growParagraph(``, 0); + else + newParagraph(`${' '.repeat(maxImageLineCount)}`, maxImageLineCount); + + this.images.push({paraIndex, num: imageNum, id}); if (inPara && this.showInlineImagesInCenter) newParagraph(' ', 1); } else {//external - dimPromises.push(getExternalImageDimensions(href)); - newParagraph(`${' '.repeat(maxImageLineCount)}`, maxImageLineCount); + imageNum++; - imageIndex++; - this.images.push({paraIndex, num: imageIndex, id}); + dimPromises.push(getExternalImageDimensions(href)); + newParagraph(`${' '.repeat(maxImageLineCount)}`, maxImageLineCount); + + this.images.push({paraIndex, num: imageNum, id}); } } } @@ -574,6 +576,7 @@ export default class BookParser { if (attrs.href && attrs.href.value) { image = this.imageHrefToId(attrs.href.value); image.inline = false; + image.num = (attrs.num && attrs.num.value ? attrs.num.value : 0); } break; } @@ -582,6 +585,7 @@ export default class BookParser { if (attrs.href && attrs.href.value) { const img = this.imageHrefToId(attrs.href.value); img.inline = true; + img.num = (attrs.num && attrs.num.value ? attrs.num.value : 0); result.push({ style: Object.assign({}, style), image: img, @@ -811,6 +815,7 @@ export default class BookParser { paraIndex, w: imageWidth, h: imageHeight, + num: part.image.num }}); lines.push(line); line = {begin: line.end + 1, parts: []}; @@ -821,7 +826,7 @@ export default class BookParser { line.last = true; line.parts.push({style, text: ' ', image: {local: part.image.local, inline: false, id: part.image.id, - imageLine: i, lineCount, paraIndex, w: imageWidth, h: imageHeight} + imageLine: i, lineCount, paraIndex, w: imageWidth, h: imageHeight, num: part.image.num} }); continue; @@ -833,7 +838,7 @@ export default class BookParser { let imgH = (bin.h > this.fontSize ? this.fontSize : bin.h); imgW += bin.w*imgH/bin.h; line.parts.push({style, text: '', - image: {local: part.image.local, inline: true, id: part.image.id}}); + image: {local: part.image.local, inline: true, id: part.image.id, num: part.image.num}}); } }