Рефакторинг

This commit is contained in:
Book Pauk
2020-12-15 23:01:58 +07:00
parent 37e14b397c
commit a51150c729
2 changed files with 4 additions and 4 deletions

View File

@@ -195,7 +195,6 @@ class ContentsPage extends Vue {
const ims = parsed.images; const ims = parsed.images;
for (i = 0; i < ims.length; i++) { for (i = 0; i < ims.length; i++) {
const image = ims[i]; const image = ims[i];
let {id} = parsed.imageHrefToId(image.href);
const label = `Изображение ${image.num}`; const label = `Изображение ${image.num}`;
const indentStyle = getIndentStyle(1); const indentStyle = getIndentStyle(1);
@@ -203,7 +202,7 @@ class ContentsPage extends Vue {
const p = parsed.para[image.paraIndex]; const p = parsed.para[image.paraIndex];
newImages.push({perc: (p.offset/parsed.textLength*100).toFixed(0), label, key: i, offset: p.offset, newImages.push({perc: (p.offset/parsed.textLength*100).toFixed(0), label, key: i, offset: p.offset,
indentStyle, labelStyle, type: (parsed.binary[id] ? parsed.binary[id].type : '')}); indentStyle, labelStyle, type: (parsed.binary[image.id] ? parsed.binary[image.id].type : '')});
} }
this.images = newImages; this.images = newImages;

View File

@@ -204,6 +204,7 @@ export default class BookParser {
let attrs = sax.getAttrsSync(tail); let attrs = sax.getAttrsSync(tail);
if (attrs.href && attrs.href.value) { if (attrs.href && attrs.href.value) {
const href = attrs.href.value; const href = attrs.href.value;
const {id} = this.imageHrefToId(href);
if (href[0] == '#') {//local if (href[0] == '#') {//local
if (inPara && !this.showInlineImagesInCenter && !center) if (inPara && !this.showInlineImagesInCenter && !center)
growParagraph(`<image-inline href="${href}"></image-inline>`, 0); growParagraph(`<image-inline href="${href}"></image-inline>`, 0);
@@ -211,7 +212,7 @@ export default class BookParser {
newParagraph(`<image href="${href}">${' '.repeat(maxImageLineCount)}</image>`, maxImageLineCount); newParagraph(`<image href="${href}">${' '.repeat(maxImageLineCount)}</image>`, maxImageLineCount);
imageIndex++; imageIndex++;
this.images.push({paraIndex, num: imageIndex, href}); this.images.push({paraIndex, num: imageIndex, id});
if (inPara && this.showInlineImagesInCenter) if (inPara && this.showInlineImagesInCenter)
newParagraph(' ', 1); newParagraph(' ', 1);
@@ -220,7 +221,7 @@ export default class BookParser {
newParagraph(`<image href="${href}">${' '.repeat(maxImageLineCount)}</image>`, maxImageLineCount); newParagraph(`<image href="${href}">${' '.repeat(maxImageLineCount)}</image>`, maxImageLineCount);
imageIndex++; imageIndex++;
this.images.push({paraIndex, num: imageIndex, href}); this.images.push({paraIndex, num: imageIndex, id});
} }
} }
} }