From dc1a81057497cdd692d8a384279e2bcded021ff2 Mon Sep 17 00:00:00 2001
From: 闫增涛 <1829501689@qq.com>
Date: 星期四, 27 六月 2024 09:25:21 +0800
Subject: [PATCH] 优化

---
 src/books/English/view/index.vue |   85 ++++++++++++++++++++++++++++++++++++++----
 1 files changed, 77 insertions(+), 8 deletions(-)

diff --git a/src/books/English/view/index.vue b/src/books/English/view/index.vue
index 487bb80..8d3f387 100644
--- a/src/books/English/view/index.vue
+++ b/src/books/English/view/index.vue
@@ -1,15 +1,84 @@
 <template>
-  <div class="english-book">
-
+  <div
+    class="english-book"
+    @mouseup="handleMouseUp"
+    :style="{
+      fontSize: fontSize ? fontSize + 'px' : '16px',
+      transform: `scale(${pageZoom ? pageZoom : 1})`,
+    }"
+  >
+    <pageContent></pageContent>
   </div>
 </template>
 
 <script>
-  export default {
-    name:'english-book'
-  }
+import pageContent from "./components/index.vue";
+export default {
+  name: "english-book",
+  components: { pageContent },
+  computed: {
+    fontSize() {
+      return this.$store.state.qiankun.fontSize;
+    },
+    pageZoom() {
+      return this.$store.state.qiankun.scale / 100;
+    },
+  },
+  methods: {
+    getParentWithClass(element, className) {
+      while (element.parentElement) {
+        element = element.parentElement;
+        if (element.classList.contains(className)) {
+          return element;
+        }
+      }
+    },
+    handleMouseUp(e) {
+      const selection = (
+        this.container ? this.container : window
+      ).getSelection();
+      const txt = selection.toString();
+      if (selection.type != "none" && txt) {
+        let node = selection.anchorNode.parentNode;
+        let pageHtml = this.getParentWithClass(
+          selection.anchorNode,
+          "page-box"
+        );
+        let chapterDom = this.getParentWithClass(
+          selection.anchorNode,
+          "chapter"
+        );
+        let chapterNum;
+        if (chapterDom) chapterNum = chapterDom.getAttribute("num");
+        if (pageHtml) {
+          const page = pageHtml.getAttribute("page");
+          // 鐩戝惉閫変腑鏂囨湰浜嬩欢锛屽苟瑙﹀彂鐖跺眰鏂规硶
+          if (this.$store.state.qiankun.windowSelection) {
+            this.$store.state.qiankun.windowSelection({
+              chapterNum,
+              txt,
+              page,
+              x: e.x,
+              y: e.y,
+            });
+          }
+        }
+      } else {
+        if (this.$store.state.qiankun.windowSelection) {
+          this.$store.state.qiankun.windowSelection({
+            chapterNum: "",
+            txt: "",
+            page: "",
+            x: e.x,
+            y: e.y,
+          });
+        }
+      }
+    },
+  },
+};
 </script>
 
-<style lang="less" scoped>
-
-</style>
\ No newline at end of file
+<style lang="less">
+@import "../assets/main.less";
+</style>

--
Gitblit v1.9.1