From b358b340b46dccd013f99a60d053f5d912f4f7ce Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Sat, 19 Dec 2020 00:20:11 +0700 Subject: [PATCH] =?UTF-8?q?=D0=A3=D0=BB=D1=83=D1=87=D1=88=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D1=84=D0=BE=D1=80=D0=BC=D0=B8=D1=80=D0=BE=D0=B2?= =?UTF-8?q?=D0=B0=D0=BD=D0=B8=D1=8F=20=D0=BE=D0=B3=D0=BB=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Reader/ContentsPage/ContentsPage.vue | 42 ++++++++++++------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/client/components/Reader/ContentsPage/ContentsPage.vue b/client/components/Reader/ContentsPage/ContentsPage.vue index 317a2980..ca2257ec 100644 --- a/client/components/Reader/ContentsPage/ContentsPage.vue +++ b/client/components/Reader/ContentsPage/ContentsPage.vue @@ -146,25 +146,36 @@ class ContentsPage extends ContentsPageProps { await this.$nextTick(); const pc = parsed.contents; - const newpc = []; - //преобразуем все, кроме первого, разделы body в title-subtitle - let curSubtitles = []; - let prevBodyIndex = -1; - for (let i = 0; i < pc.length; i++) { - const cont = pc[i]; - if (prevBodyIndex != cont.bodyIndex) - curSubtitles = []; + const ims = parsed.images; + const newpc = []; + if (pc.length) {//если есть оглавление + //преобразуем все, кроме первого, разделы body в title-subtitle + let curSubtitles = []; + let prevBodyIndex = -1; + for (let i = 0; i < pc.length; i++) { + const cont = pc[i]; + if (prevBodyIndex != cont.bodyIndex) + curSubtitles = []; - prevBodyIndex = cont.bodyIndex; + prevBodyIndex = cont.bodyIndex; - if (cont.bodyIndex > 1) { - if (cont.inset < 1) { - newpc.push(Object.assign({}, cont, {subtitles: curSubtitles})); + if (cont.bodyIndex > 1) { + if (cont.inset < 1) { + newpc.push(Object.assign({}, cont, {subtitles: curSubtitles})); + } else { + curSubtitles.push(Object.assign({}, cont, {inset: cont.inset - 1})); + } } else { - curSubtitles.push(Object.assign({}, cont, {inset: cont.inset - 1})); + newpc.push(cont); + } + } + } else {//попробуем вытащить из images + for (let i = 0; i < ims.length; i++) { + const image = ims[i]; + + if (image.alt) { + newpc.push({paraIndex: image.paraIndex, title: image.alt, inset: 1, bodyIndex: 0, subtitles: []}); } - } else { - newpc.push(cont); } } @@ -213,7 +224,6 @@ class ContentsPage extends ContentsPageProps { //формируем newImages const newImages = []; - const ims = parsed.images; for (i = 0; i < ims.length; i++) { const image = ims[i]; const bin = parsed.binary[image.id];