Xwite 3 лет назад
Родитель
Сommit
cb7fb6eb92
1 измененных файлов с 2 добавлено и 1 удалено
  1. 2 1
      modules/web/src/views/BookChapter.vue

+ 2 - 1
modules/web/src/views/BookChapter.vue

@@ -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) {