From fe52c75b42ef2815dc5c66e964c2b388ed09d097 Mon Sep 17 00:00:00 2001
From: zhongshujie <2862698242@qq.com>
Date: 星期五, 25 四月 2025 11:28:21 +0800
Subject: [PATCH] 环境变量修改

---
 src/books/artAndDance/view/components/index.vue |  240 ++++++++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 169 insertions(+), 71 deletions(-)

diff --git a/src/books/artAndDance/view/components/index.vue b/src/books/artAndDance/view/components/index.vue
index 78947f5..80a52cf 100644
--- a/src/books/artAndDance/view/components/index.vue
+++ b/src/books/artAndDance/view/components/index.vue
@@ -3,63 +3,43 @@
     <div id="searchDomBox" style="display: none">
       <div id="searchContent"></div>
     </div>
-    <div
-      class="page-content"
-      :style="{
-        fontSize: fontSize ? fontSize + 'px' : '16px',
-        transform: `scale(${pageZoom ? pageZoom : 1})`,
-        transformOrigin: 'center top',
-      }"
-    >
-      <pageHeader
-        v-if="showCatalogList.indexOf(1) > -1"
-        :showPageList="loadPageList"
-      ></pageHeader>
-      <chapterOne
-        v-if="showCatalogList.indexOf(2) > -1"
-        :showPageList="loadPageList"
-      ></chapterOne>
-      <chapterTwo
-        v-if="showCatalogList.indexOf(3) > -1"
-        :showPageList="loadPageList"
-      >
+    <div class="page-content" :style="{
+      fontSize: fontSize ? fontSize + 'px' : '16px',
+      transform: `scale(${pageZoom ? pageZoom : 1})`,
+      transformOrigin: 'center top',
+    }">
+      <pageHeader v-if="showCatalogList.indexOf(1) > -1" :showPageList="loadPageList"></pageHeader>
+      <chapterOne v-if="showCatalogList.indexOf(2) > -1" :showPageList="loadPageList"></chapterOne>
+      <chapterTwo v-if="showCatalogList.indexOf(3) > -1" :showPageList="loadPageList">
       </chapterTwo>
-      <chapterThree
-      v-if="showCatalogList.indexOf(4) > -1"
-        :showPageList="loadPageList"
-      ></chapterThree>
-      <chapterFour
-      v-if="showCatalogList.indexOf(5) > -1"
-        :showPageList="loadPageList"
-      ></chapterFour>
-      <chapterFive
-      v-if="showCatalogList.indexOf(6) > -1"
-        :showPageList="loadPageList"
-      ></chapterFive>
-      <chapterSix
-        v-if="showCatalogList.indexOf(7) > -1"
-        :showPageList="loadPageList"
-      ></chapterSix>
+      <chapterThree v-if="showCatalogList.indexOf(4) > -1" :showPageList="loadPageList"></chapterThree>
+      <chapterFour v-if="showCatalogList.indexOf(5) > -1" :showPageList="loadPageList"></chapterFour>
+      <chapterFive v-if="showCatalogList.indexOf(6) > -1" :showPageList="loadPageList"></chapterFive>
+      <chapterSix v-if="showCatalogList.indexOf(7) > -1" :showPageList="loadPageList"></chapterSix>
     </div>
-
+    <miniAudio :path="audioPath" :currentTime="currentTime" @closeMiniAudio="closeMiniAudio" ref="audioPlayer">
+    </miniAudio>
   </div>
 </template>
 
 <script>
+import Vue from 'vue'
 import pageHeader from "./header.vue";
 import chapterOne from "./chapter001.vue";
 import chapterTwo from "./chapter002.vue";
-import chapterThree from "./chapter003.vue"
-import chapterFour from './chapter004.vue'
-import chapterFive from './chapter005.vue'
-import chapterSix from './chapter006.vue'
+import chapterThree from "./chapter003.vue";
+import chapterFour from "./chapter004.vue";
+import chapterFive from "./chapter005.vue";
+import chapterSix from "./chapter006.vue";
 import NoteIcon from "@/assets/images/biji.png";
+import miniAudio from "@/components/miniAudio/index.vue";
 import _ from "lodash";
 import Swiper from "swiper/bundle";
 import "swiper/swiper-bundle.css";
 import Viewer from "viewerjs";
 import "viewerjs/dist/viewer.css";
 export default {
+  name: "pageContent",
   data() {
     return {
       catalogLength: 7, // 鎬荤珷鑺傛暟
@@ -74,6 +54,9 @@
       questionDataMap: {},
       renderSignMap: {},
       highlightData: null,
+      audioPath: "",
+      currentTime: null,
+      videoList: [],
     };
   },
   computed: {
@@ -108,6 +91,8 @@
         setTimeout(() => {
           this.initSwiper();
           this.initViewer();
+          this.closeAudio();
+          this.closeVideo();
         }, 200);
       },
     },
@@ -179,7 +164,7 @@
 
     // 娴嬭瘯椤甸潰璺宠浆
     // setTimeout(() => {
-    //   this.gotoPage(1, 10);
+    //   this.gotoPage(6, 30);
     //   setTimeout(() => {
     //     this.renderSign("Highlight", {
     //       id: "2ACA9359",
@@ -193,7 +178,7 @@
     //     ids: ["2ACA9359"]
     //   });
     // }, 2000);
-    //   }, 5000);
+    // }, 500);
 
     // const pageDom = (this.container ? this.container : document)
     //   .querySelector("#app")
@@ -207,7 +192,7 @@
     //   txt: " 杩愬姩绯荤粺鏄敱楠ㄣ�侀杩炵粨鍜岄楠艰倢涓夐儴鍒嗙粍鎴愮殑銆傚叏韬殑楠ㄩ�氳繃楠ㄨ繛缁撶粍鎴愪汉浣撻楠硷紙瑙佸浘1-1锛夈�傞楠兼槸浜轰綋鐨勬敮鏋讹紝鍏锋湁淇濇姢鍐呰剰鍣ㄥ畼銆佷緵鑲岃倝闄勭潃鍜屼綔涓鸿倢鑲夎繍鍔ㄧ殑鏉犳潌绛変綔鐢ㄣ�傚湪绁炵粡绯荤粺鐨勬敮閰嶄笅锛岃倢鑲夋敹缂╃壍鍔ㄦ墍闄勭潃鐨勯缁曠潃鍏宠妭杞姩锛屼娇韬綋浜х敓鍚勭鍔ㄤ綔銆傛墍浠ワ紝杩愬姩绯荤粺鍏锋湁杩愬姩銆佹敮鎸佸拰淇濇姢绛夊姛鑳斤紝骞煎勾鏃舵湡鐨勯楠艰繕鍏锋湁閫犺鍔熻兘銆� ",
     //   txtIndex: 57
     // });
-    // }, 5000);
+    // }, 500);
   },
   methods: {
     // setZoom1() {
@@ -226,8 +211,10 @@
     // },
     // 婊氬姩鐩戝惉
     scrollFun(event) {
+      this.handleVideoPicture()
       // 鍒ゆ柇鍚戜笂婊氬姩杩樻槸鍚戜笅婊氬姩
       if (event.target.scrollTop > this.previousScrollTop) {
+        this.getAduio();
         // 鍚戜笅
         const currentScrollTop =
           event.target.scrollTop + event.target.offsetHeight;
@@ -251,6 +238,7 @@
           }
         }
       } else if (event.target.scrollTop < this.previousScrollTop) {
+        this.handleAudio();
         // 鍚戜笂
         const currentScrollTop = event.target.scrollTop;
         if (currentScrollTop <= this.loadThreshold) {
@@ -329,7 +317,10 @@
           this.container ? this.container : document
         ).querySelector(`[page="${data.page}"]`);
         // 鍒涘缓 createTreeWalker 杩唬鍣紝鐢ㄤ簬閬嶅巻鏂囨湰鑺傜偣锛屼繚瀛樺埌涓�涓暟缁�
-        const treeWalker = document.createTreeWalker(pageDom, NodeFilter.SHOW_TEXT);
+        const treeWalker = document.createTreeWalker(
+          pageDom,
+          NodeFilter.SHOW_TEXT
+        );
         const allTextNodes = [];
         let currentNode = treeWalker.nextNode();
         while (currentNode) {
@@ -461,8 +452,8 @@
           page && pageThemeColor && pageThemeColor[page]
             ? pageThemeColor[page]
             : chapterNum && chapterThemeColor && chapterThemeColor[chapterNum]
-            ? chapterThemeColor[chapterNum]
-            : bookThemeColor;
+              ? chapterThemeColor[chapterNum]
+              : bookThemeColor;
         if (themeColor) {
           domItem.style.color = themeColor;
         }
@@ -479,8 +470,8 @@
           page && pageThemeColor && pageThemeColor[page]
             ? pageThemeColor[page]
             : chapterNum && chapterThemeColor && chapterThemeColor[chapterNum]
-            ? chapterThemeColor[chapterNum]
-            : bookThemeColor;
+              ? chapterThemeColor[chapterNum]
+              : bookThemeColor;
         if (themeColor) {
           domItem.style.backgroundColor = themeColor;
         }
@@ -497,8 +488,8 @@
           page && pageThemeColor && pageThemeColor[page]
             ? pageThemeColor[page]
             : chapterNum && chapterThemeColor && chapterThemeColor[chapterNum]
-            ? chapterThemeColor[chapterNum]
-            : bookThemeColor;
+              ? chapterThemeColor[chapterNum]
+              : bookThemeColor;
         if (themeColor) {
           domItem.style.borderColor = themeColor;
         }
@@ -528,7 +519,7 @@
           const catalog = catalogDom.getAttribute("num");
           let text = null;
           if (target.querySelector("p")) {
-            text = target.querySelector("p").textContent.substring(0, 20);
+            text = target.querySelector("p").textContent.substring(0, 50);
           }
           // 杩斿洖椤电爜鍜岀珷鑺備俊鎭�
           if (this.$store.state.qiankun && this.$store.state.qiankun.pageChange)
@@ -554,6 +545,8 @@
               target,
               "chapter"
             );
+            // 娣诲姞椤电爜
+            this.loadPageList.push(Number(page));
             const catalog = catalogDom.getAttribute("num");
             // if (!this.questionDataMap[page]) {
             //   if (testData && testData[catalog]) {
@@ -579,8 +572,6 @@
             //     }
             //   }
             // }
-            // 娣诲姞椤电爜
-            this.loadPageList.push(Number(page));
             // 娓叉煋杩欎竴椤电殑鏍囪
             for (const key in this.renderSignMap) {
               if (this.renderSignMap[key][page]) {
@@ -594,7 +585,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();
@@ -645,16 +639,12 @@
           spaceBetween: 30, // 闂撮殧
           // 濡傛灉闇�瑕佸墠杩涘悗閫�鎸夐挳
           navigation: {
-            nextEl: (this.container ? this.container : document).querySelector(
-              ".swiper-button-next"
-            ),
-            prevEl: (this.container ? this.container : document).querySelector(
-              ".swiper-button-prev"
-            ),
+            nextEl: dom.querySelector(".swiper-button-next"),
+            prevEl: dom.querySelector(".swiper-button-prev"),
           },
           // 绐楀彛鍙樺寲,閲嶆柊init,閽堝F11鍏ㄥ睆鍜屾斁澶х缉灏�,蹇呴』鍔�
-          observer: true,
-          observeParents: true,
+          // observer: true,
+          // observeParents: true
           // // 濡傛灉闇�瑕佸垎椤靛櫒
           // pagination: {
           //   el: (this.container ? this.container : document).querySelector(
@@ -677,12 +667,8 @@
           spaceBetween: 30, // 闂撮殧
           // 濡傛灉闇�瑕佸墠杩涘悗閫�鎸夐挳
           navigation: {
-            nextEl: (this.container ? this.container : document).querySelector(
-              ".swiper-button-next"
-            ),
-            prevEl: (this.container ? this.container : document).querySelector(
-              ".swiper-button-prev"
-            ),
+            nextEl: dom.querySelector(".swiper-button-next"),
+            prevEl: dom.querySelector(".swiper-button-prev"),
           },
           // 绐楀彛鍙樺寲,閲嶆柊init,閽堝F11鍏ㄥ睆鍜屾斁澶х缉灏�,蹇呴』鍔�
           observer: true,
@@ -746,6 +732,7 @@
           propsData: {
             showPageList: [],
             questionData: {},
+            isSearch: true,
           },
         });
         pageExample.$mount(
@@ -777,6 +764,7 @@
               propsData: {
                 showPageList: [pageNum],
                 questionData: {},
+                isSearch: true,
               },
             });
             pageExample.$mount(
@@ -790,7 +778,10 @@
               .querySelector(`[page="${pageNum}"]`);
             if (thisPageDom) {
               // 鑾峰彇椤甸潰鎵�鏈塼ext鑺傜偣
-              const pageTextList = document.createTreeWalker(thisPageDom, NodeFilter.SHOW_TEXT);
+              const pageTextList = document.createTreeWalker(
+                thisPageDom,
+                NodeFilter.SHOW_TEXT
+              );
               // 鍖归厤鍏抽敭瀛�
               const allPageTextNodes = [];
               let currentNode = pageTextList.nextNode();
@@ -829,8 +820,113 @@
       // 璁板綍楂樹寒淇℃伅
       this.highlightData = data;
       // 璺宠浆
-      this.gotoPage(data.catalog, data.page, () => {});
+      this.gotoPage(data.catalog, data.page, () => { });
     },
+    // 椤甸潰鍚戜笅婊氬姩锛岄煶棰戝皬绐楁挱鏀惧姛鑳�
+    getAduio() {
+      let allVideo = (
+        this.container ? this.container : document
+      ).querySelectorAll(".audio");
+      allVideo = Array.from(allVideo);
+      this.videoList = allVideo;
+      if (allVideo.length) {
+        // 鏌ユ壘鎾斁鐘舵�佺殑鏈�鍚庝竴鏉¢煶棰�
+        const playAudio = allVideo
+          .reverse()
+          .find((item) => item.paused == false);
+        if (playAudio) {
+          const bottomGap = playAudio.getBoundingClientRect().bottom;
+          if (bottomGap < 0) {
+            playAudio.pause();
+            this.audioPath = playAudio.src;
+            this.currentTime = playAudio.currentTime;
+          }
+        }
+      }
+    },
+    // 椤甸潰鍚戜笂婊氬姩锛岄煶棰戝皬绐楀洖鏀�
+    handleAudio() {
+      if (!this.audioPath) return false;
+      let allVideo = (
+        this.container ? this.container : document
+      ).querySelectorAll(".audio");
+      allVideo = Array.from(allVideo);
+      if (allVideo.length) {
+        //鏌ユ壘涓庡皬绐楁挱鏀鹃煶棰戝悓婧愮殑椤甸潰audio DOM
+        const playAudio = allVideo.find((item) => item.src == this.audioPath);
+        if (playAudio) {
+          const bottomGap = playAudio.getBoundingClientRect().bottom;
+          if (bottomGap >= 0) {
+            if (this.$refs.audioPlayer) {
+              const playerState = this.$refs.audioPlayer.getVideoPlayer();
+              this.audioPath = "";
+              playAudio.currentTime = playerState.currentTime;
+              if (!playerState.paused) playAudio.play();
+            }
+          }
+        }
+      }
+    },
+    // 鍏抽棴mini video
+    closeMiniAudio() {
+      this.audioPath = "";
+    },
+    // 鐐瑰嚮闊抽鎾斁锛屽叧闂叾浠栭煶棰�
+    closeAudio() {
+      let allAudio = (
+        this.container ? this.container : document
+      ).querySelectorAll(".audio");
+      for (let index = 0; index < allAudio.length; index++) {
+        const item = allAudio[index];
+        item.addEventListener("play", () => {
+          const audioList = Array.from(allAudio);
+          for (let cindex = 0; cindex < audioList.length; cindex++) {
+            const citem = audioList[cindex];
+            if (citem.currentSrc != item.src) {
+              citem.pause();
+            }
+          }
+          this.closeMiniAudio();
+        });
+      }
+    },
+    // 鐐瑰嚮瑙嗛鍏抽棴鍏朵粬
+    closeVideo() {
+      let allVideo = (
+        this.container ? this.container : document
+      ).querySelectorAll(".video");
+      for (let index = 0; index < allVideo.length; index++) {
+        const item = allVideo[index];
+        item.addEventListener("playing", (item) => {
+          const path = item.srcElement.src;
+          const videoList = Array.from(allVideo);
+          for (let cindex = 0; cindex < videoList.length; cindex++) {
+            const citem = videoList[cindex];
+            if (citem.currentSrc != path && path) {
+              citem.pause();
+            }
+          }
+        });
+      }
+    },
+    // 瑙嗛灏忕獥
+    handleVideoPicture() {
+      let doms = (
+        this.container ? this.container : document
+      ).querySelectorAll(".video");
+      doms = Array.from(doms)
+      if (!doms.length) return false
+      const playVudio = doms
+        .reverse()
+        .find((item) => item.paused == false);
+      if (playVudio) {
+        const bottomGap = playVudio.getBoundingClientRect().bottom;
+        const topGap = playVudio.getBoundingClientRect().top;
+        if (bottomGap < 0 || topGap > window.innerHeight) {
+          if(playVudio.readyState) playVudio.requestPictureInPicture();
+        }
+      }
+    }
   },
   components: {
     pageHeader,
@@ -840,6 +936,7 @@
     chapterFour,
     chapterFive,
     chapterSix,
+    miniAudio,
   },
 };
 </script>
@@ -849,6 +946,7 @@
   width: 100%;
   height: 100%;
   overflow: auto;
+
   .page-content {
     max-width: 816px;
     min-width: 375px;

--
Gitblit v1.9.1