This commit is contained in:
Xwite 2023-05-09 19:21:51 +08:00
parent 161a93bf28
commit 324711c384

View File

@ -263,7 +263,7 @@ const getContent = (index, reloadChapter = true, chapterPos = 0) => {
let data = res.data.data; let data = res.data.data;
let content = data.split(/\n+/); let content = data.split(/\n+/);
updateChapterData({ index, content, title }, reloadChapter); updateChapterData({ index, content, title }, reloadChapter);
toChapterPos(chapterPos); if (reloadChapter) toChapterPos(chapterPos);
} else { } else {
ElMessage({ message: res.data.errorMsg, type: "error" }); ElMessage({ message: res.data.errorMsg, type: "error" });
let content = [res.data.errorMsg]; let content = [res.data.errorMsg];
@ -291,6 +291,7 @@ const chapter = ref();
const toChapterPos = (pos) => { const toChapterPos = (pos) => {
nextTick(() => { nextTick(() => {
let wordCount = 0; let wordCount = 0;
if (chapter.value.length != 1) return;
for (let element of chapter.value[0].children) { for (let element of chapter.value[0].children) {
wordCount += parseInt(element.getAttribute("wordCount")) + 1;// wordCount += parseInt(element.getAttribute("wordCount")) + 1;//
if (wordCount - 1 >= pos) { if (wordCount - 1 >= pos) {