From cdb75e000d815c2b5a2b320ea0e6b9f3e1d29cd2 Mon Sep 17 00:00:00 2001
From: 闫增涛 <1829501689@qq.com>
Date: 星期五, 16 五月 2025 16:05:05 +0800
Subject: [PATCH] 翻译组件优化

---
 src/books/hotelEnglishTrainingBrochure2nd/view/components/index.vue |   37 +++++++++++++++++++++++--------------
 1 files changed, 23 insertions(+), 14 deletions(-)

diff --git a/src/books/hotelEnglishTrainingBrochure2nd/view/components/index.vue b/src/books/hotelEnglishTrainingBrochure2nd/view/components/index.vue
index 7409fe3..76c00a1 100644
--- a/src/books/hotelEnglishTrainingBrochure2nd/view/components/index.vue
+++ b/src/books/hotelEnglishTrainingBrochure2nd/view/components/index.vue
@@ -37,9 +37,13 @@
               :showPageList="loadPageList"
               :interfaceQuestion="questionDataMap"
             ></chapterFive>  -->
-     
     </div>
-      <translateWord :pageX="pageX" :pageY="pageY" :showWord="showWord" v-if="showWord" />
+    <translateWord
+      :pageX="pageX"
+      :pageY="pageY"
+      :showWord="showWord"
+      v-if="showWord"
+    />
   </div>
 </template>
 
@@ -78,9 +82,9 @@
       audioPath: "",
       currentTime: null,
       videoList: [],
-      pageX:0,
-      pageY:0,
-      showWord:"",
+      pageX: 0,
+      pageY: 0,
+      showWord: "",
     };
   },
   computed: {
@@ -123,7 +127,7 @@
           this.initViewer();
           this.closeAudio();
           this.closeVideo();
-          this.handleTanslateWord()
+          this.handleTanslateWord();
         }, 200);
       },
     },
@@ -963,19 +967,24 @@
       const doms = (
         this.container ? this.container : document
       ).querySelectorAll(".ts-word");
-      for(let index = 0;index < doms.length;index++){
+      for (let index = 0; index < doms.length; index++) {
         const dom = doms[index];
         dom.onmouseenter = (event) => {
-          this.pageX = event.pageX;
-          this.pageY = event.pageY;
-          this.showWord = event.target.innerText;
-          console.log(event.target.innerText);
+          if (this.showWord != event.target.innerText) {
+            const rect = dom.getBoundingClientRect();
+            this.pageX = event.pageX - rect.width;
+            this.pageY = event.pageY + 20;
+            this.showWord = event.target.innerText;
+            console.log(event);
+          }
         };
-        dom.onmouseleave = () => {
-          this.showWord = ""
+        dom.onmouseleave = (event) => {
+          if(this.showWord == event.target.innerText) {
+            this.showWord = "";
+          }
         };
       }
-    }
+    },
   },
   components: {
     translateWord,

--
Gitblit v1.9.1