From eeff64f494ed72d8acaa13d653c9f3ee181ac950 Mon Sep 17 00:00:00 2001
From: unknown <qq1940665526@163.com>
Date: 星期五, 07 六月 2024 16:09:46 +0800
Subject: [PATCH] 优化

---
 src/books/lifeCare/index.vue |   85 ++++++++++++++++++++++++------------------
 1 files changed, 48 insertions(+), 37 deletions(-)

diff --git a/src/books/lifeCare/index.vue b/src/books/lifeCare/index.vue
index 257a80b..57b0dc2 100644
--- a/src/books/lifeCare/index.vue
+++ b/src/books/lifeCare/index.vue
@@ -20,44 +20,44 @@
       <ChapterOne
         v-if="showCatalogList.indexOf(2) > -1"
         :showPageList="loadPageList"
-        :questionData="questionData"
+        :questionData="questionDataMap"
         :isSearch="isSearch"
       />
       <ChapterTwo
         v-if="showCatalogList.indexOf(3) > -1"
         :showPageList="loadPageList"
-        :questionData="questionData"
+        :questionData="questionDataMap"
         :isSearch="isSearch"
       />
       <ChapterThree
         v-if="showCatalogList.indexOf(4) > -1"
         :showPageList="loadPageList"
-        :questionData="questionData"
+        :questionData="questionDataMap"
         :isSearch="isSearch"
       />
       <ChapterFour
         v-if="showCatalogList.indexOf(5) > -1"
         :showPageList="loadPageList"
-        :questionData="questionData"
+        :questionData="questionDataMap"
         :isSearch="isSearch"
       />
       <ChapterFive
         v-if="showCatalogList.indexOf(6) > -1"
         :showPageList="loadPageList"
-        :questionData="questionData"
+        :questionData="questionDataMap"
         @Upload_initViewer="changeDomViewer"
         :isSearch="isSearch"
       />
       <chapterSix
         v-if="showCatalogList.indexOf(7) > -1"
         :showPageList="loadPageList"
-        :questionData="questionData"
+        :questionData="questionDataMap"
         :isSearch="isSearch"
       />
       <chapterSeven
         v-if="showCatalogList.indexOf(8) > -1"
         :showPageList="loadPageList"
-        :questionData="questionData"
+        :questionData="questionDataMap"
         @eventSwdt="swdtChange"
         @Upload_initViewer="changeDomViewer"
         :isSearch="isSearch"
@@ -65,13 +65,13 @@
       <chapterEight
         v-if="showCatalogList.indexOf(9) > -1"
         :showPageList="loadPageList"
-        :questionData="questionData"
+        :questionData="questionDataMap"
         :isSearch="isSearch"
       />
       <chapterNine
         v-if="showCatalogList.indexOf(10) > -1"
         :showPageList="loadPageList"
-        :questionData="questionData"
+        :questionData="questionDataMap"
         :isSearch="isSearch"
       />
       <chapter010
@@ -202,8 +202,8 @@
     },
   },
   mounted() {
-  // 榛樿鍔犺浇绔犺妭
-  this.showCatalogList = [1];
+    // 榛樿鍔犺浇绔犺妭
+    this.showCatalogList = [6];
     // 婊氬姩鐩戝惉鑺傛祦
     this.throttledScrollHandler = _.throttle(
       this.scrollFun,
@@ -283,6 +283,7 @@
         this.initViewer();
       }, 500);
     },
+
     // 婊氬姩鐩戝惉
     scrollFun(event) {
       // 鍒ゆ柇鍚戜笂婊氬姩杩樻槸鍚戜笅婊氬姩
@@ -361,6 +362,12 @@
 
     // 澶勭悊鏍囪鏁版嵁
     handelSignData(type, data) {
+      if (this.loadPageList.indexOf(Number(data.page)) > -1) {
+        // 绔嬪嵆娓叉煋
+        this.renderSign(type, data);
+      }
+
+      // 鍌ㄥ瓨鏁版嵁
       if (!this.renderSignMap[type]) this.renderSignMap[type] = {};
       if (!this.renderSignMap[type][data.page])
         this.renderSignMap[type][data.page] = [];
@@ -369,6 +376,10 @@
 
     // 娓叉煋鏍囪
     renderSign(type, data) {
+      // 鐖跺眰璁剧疆绂佹娓叉煋鏍囪鏃朵笉鍐嶈繘琛屾覆鏌�
+      if (this.$store.state.qiankun.disableSign) {
+        return false;
+      }
       const existence = (
         this.container ? this.container : document
       ).querySelector(`[dataid="${data.id}"]`);
@@ -422,6 +433,7 @@
         }
       }
     },
+
     // 鍒犻櫎鏍囪娓叉煋
     delSign({ ids, type }) {
       if (ids && ids.length) {
@@ -559,15 +571,6 @@
       });
     },
 
-    getParentWithClass(element, className) {
-      while (element.parentElement) {
-        element = element.parentElement;
-        if (element.classList.contains(className)) {
-          return element;
-        }
-      }
-    },
-
     pageChangeCallback(entries, observer) {
       //entries锛氫唬琛ㄨ瀵熷埌鐨勭洰鏍囧厓绱犵殑闆嗗悎銆� observer锛氫唬琛ㄨ瀵熻�呭璞°��
       entries.forEach((entry) => {
@@ -612,14 +615,17 @@
             );
             const catalog = catalogDom.getAttribute("num");
             if (!this.questionDataMap[page]) {
+              const token = localStorage.getItem(this.config.tokenKey);
               if (testData && testData[catalog]) {
                 if (testData[catalog][page]) {
                   if (Array.isArray(testData[catalog][page])) {
-                    this.questionDataMap[page] = await getQuestionList(
-                      page,
-                      testData[catalog][page],
-                      this.config.activeBook
-                    );
+                    if (token) {
+                      this.questionDataMap[page] = await getQuestionList(
+                        page,
+                        testData[catalog][page],
+                        this.config.activeBook
+                      );
+                    }
                   } else {
                     const obj = {};
                     for (let key in testData[catalog][page]) {
@@ -631,7 +637,7 @@
                     }
                     this.questionDataMap[page] = obj;
                   }
-                  // console.log("棰樼洰", this.questionDataMap);
+                  console.log("棰樼洰", this.questionDataMap);
                 }
               }
             }
@@ -650,7 +656,10 @@
               // 楂樹寒琛�
               setTimeout(() => {
                 // 鑾峰彇椤甸潰鎵�鏈塼ext鑺傜偣
-                const pageTextList = document.createTreeWalker(target, NodeFilter.SHOW_TEXT);
+                const pageTextList = document.createTreeWalker(
+                  target,
+                  NodeFilter.SHOW_TEXT
+                );
                 // 鍖归厤鍏抽敭瀛�
                 const allPageTextNodes = [];
                 let currentNode = pageTextList.nextNode();
@@ -781,6 +790,16 @@
       }
     },
 
+    getParentWithClass(element, className) {
+      // console.log(element, className, "element, className");
+      while (element.parentElement) {
+        element = element.parentElement;
+        if (element.classList.contains(className)) {
+          return element;
+        }
+      }
+    },
+    
     handleMouseUp(e) {
       const selection = (
         this.container ? this.container : window
@@ -821,14 +840,6 @@
             y: e.y,
           });
         }
-      }
-    },
-
-    swdtChange(data) {
-      if (this.$store.state.qiankun && this.$store.state.qiankun.chooseWords) {
-        this.$store.state.qiankun.chooseWords({
-          type: data,
-        });
       }
     },
 
@@ -946,10 +957,10 @@
         }
       }
       // 杈撳嚭鎼滅储缁撴灉
-      console.log(searchResult);
+      // console.log(searchResult);
       return searchResult;
     },
-    
+
     // 鏍规嵁妫�绱㈢粨鏋滆烦杞搴斾綅缃苟楂樹寒
     searchItemLocation(data) {
       // 璁板綍楂樹寒淇℃伅

--
Gitblit v1.9.1