| | |
| | | <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, // 总章节数 |
| | |
| | | questionDataMap: {}, |
| | | renderSignMap: {}, |
| | | highlightData: null, |
| | | audioPath: "", |
| | | currentTime: null, |
| | | videoList: [], |
| | | }; |
| | | }, |
| | | computed: { |
| | |
| | | setTimeout(() => { |
| | | this.initSwiper(); |
| | | this.initViewer(); |
| | | this.closeAudio(); |
| | | this.closeVideo(); |
| | | }, 200); |
| | | }, |
| | | }, |
| | |
| | | |
| | | // 测试页面跳转 |
| | | // setTimeout(() => { |
| | | // this.gotoPage(1, 10); |
| | | // this.gotoPage(6, 30); |
| | | // setTimeout(() => { |
| | | // this.renderSign("Highlight", { |
| | | // id: "2ACA9359", |
| | |
| | | // ids: ["2ACA9359"] |
| | | // }); |
| | | // }, 2000); |
| | | // }, 5000); |
| | | // }, 500); |
| | | |
| | | // const pageDom = (this.container ? this.container : document) |
| | | // .querySelector("#app") |
| | |
| | | // txt: " 运动系统是由骨、骨连结和骨骼肌三部分组成的。全身的骨通过骨连结组成人体骨骼(见图1-1)。骨骼是人体的支架,具有保护内脏器官、供肌肉附着和作为肌肉运动的杠杆等作用。在神经系统的支配下,肌肉收缩牵动所附着的骨绕着关节转动,使身体产生各种动作。所以,运动系统具有运动、支持和保护等功能,幼年时期的骨骼还具有造血功能。 ", |
| | | // txtIndex: 57 |
| | | // }); |
| | | // }, 5000); |
| | | // }, 500); |
| | | }, |
| | | methods: { |
| | | // setZoom1() { |
| | |
| | | // }, |
| | | // 滚动监听 |
| | | scrollFun(event) { |
| | | this.handleVideoPicture() |
| | | // 判断向上滚动还是向下滚动 |
| | | if (event.target.scrollTop > this.previousScrollTop) { |
| | | this.getAduio(); |
| | | // 向下 |
| | | const currentScrollTop = |
| | | event.target.scrollTop + event.target.offsetHeight; |
| | |
| | | } |
| | | } |
| | | } else if (event.target.scrollTop < this.previousScrollTop) { |
| | | this.handleAudio(); |
| | | // 向上 |
| | | const currentScrollTop = event.target.scrollTop; |
| | | if (currentScrollTop <= this.loadThreshold) { |
| | |
| | | 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) { |
| | |
| | | page && pageThemeColor && pageThemeColor[page] |
| | | ? pageThemeColor[page] |
| | | : chapterNum && chapterThemeColor && chapterThemeColor[chapterNum] |
| | | ? chapterThemeColor[chapterNum] |
| | | : bookThemeColor; |
| | | ? chapterThemeColor[chapterNum] |
| | | : bookThemeColor; |
| | | if (themeColor) { |
| | | domItem.style.color = themeColor; |
| | | } |
| | |
| | | page && pageThemeColor && pageThemeColor[page] |
| | | ? pageThemeColor[page] |
| | | : chapterNum && chapterThemeColor && chapterThemeColor[chapterNum] |
| | | ? chapterThemeColor[chapterNum] |
| | | : bookThemeColor; |
| | | ? chapterThemeColor[chapterNum] |
| | | : bookThemeColor; |
| | | if (themeColor) { |
| | | domItem.style.backgroundColor = themeColor; |
| | | } |
| | |
| | | page && pageThemeColor && pageThemeColor[page] |
| | | ? pageThemeColor[page] |
| | | : chapterNum && chapterThemeColor && chapterThemeColor[chapterNum] |
| | | ? chapterThemeColor[chapterNum] |
| | | : bookThemeColor; |
| | | ? chapterThemeColor[chapterNum] |
| | | : bookThemeColor; |
| | | if (themeColor) { |
| | | domItem.style.borderColor = themeColor; |
| | | } |
| | |
| | | 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) |
| | |
| | | target, |
| | | "chapter" |
| | | ); |
| | | // 添加页码 |
| | | this.loadPageList.push(Number(page)); |
| | | const catalog = catalogDom.getAttribute("num"); |
| | | // if (!this.questionDataMap[page]) { |
| | | // if (testData && testData[catalog]) { |
| | |
| | | // } |
| | | // } |
| | | // } |
| | | // 添加页码 |
| | | this.loadPageList.push(Number(page)); |
| | | // 渲染这一页的标记 |
| | | for (const key in this.renderSignMap) { |
| | | if (this.renderSignMap[key][page]) { |
| | |
| | | // 高亮行 |
| | | setTimeout(() => { |
| | | // 获取页面所有text节点 |
| | | const pageTextList = document.createTreeWalker(target, NodeFilter.SHOW_TEXT); |
| | | const pageTextList = document.createTreeWalker( |
| | | target, |
| | | NodeFilter.SHOW_TEXT |
| | | ); |
| | | // 匹配关键字 |
| | | const allPageTextNodes = []; |
| | | let currentNode = pageTextList.nextNode(); |
| | |
| | | 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( |
| | |
| | | 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, |
| | |
| | | propsData: { |
| | | showPageList: [], |
| | | questionData: {}, |
| | | isSearch: true, |
| | | }, |
| | | }); |
| | | pageExample.$mount( |
| | |
| | | propsData: { |
| | | showPageList: [pageNum], |
| | | questionData: {}, |
| | | isSearch: true, |
| | | }, |
| | | }); |
| | | pageExample.$mount( |
| | |
| | | .querySelector(`[page="${pageNum}"]`); |
| | | if (thisPageDom) { |
| | | // 获取页面所有text节点 |
| | | const pageTextList = document.createTreeWalker(thisPageDom, NodeFilter.SHOW_TEXT); |
| | | const pageTextList = document.createTreeWalker( |
| | | thisPageDom, |
| | | NodeFilter.SHOW_TEXT |
| | | ); |
| | | // 匹配关键字 |
| | | const allPageTextNodes = []; |
| | | let currentNode = pageTextList.nextNode(); |
| | |
| | | // 记录高亮信息 |
| | | 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, |
| | |
| | | chapterFour, |
| | | chapterFive, |
| | | chapterSix, |
| | | miniAudio, |
| | | }, |
| | | }; |
| | | </script> |
| | |
| | | width: 100%; |
| | | height: 100%; |
| | | overflow: auto; |
| | | |
| | | .page-content { |
| | | max-width: 816px; |
| | | min-width: 375px; |