From 11506e97dfbb3c49754b8570f5328a6b17d22ed0 Mon Sep 17 00:00:00 2001 From: unknown <qq1940665526@163.com> Date: 星期五, 07 六月 2024 18:08:48 +0800 Subject: [PATCH] 优化 --- src/books/lifeCare/view/components/index.vue | 129 ++++++++++++------------------------------ 1 files changed, 37 insertions(+), 92 deletions(-) diff --git a/src/books/lifeCare/index.vue b/src/books/lifeCare/view/components/index.vue similarity index 90% rename from src/books/lifeCare/index.vue rename to src/books/lifeCare/view/components/index.vue index 57b0dc2..b01f62f 100644 --- a/src/books/lifeCare/index.vue +++ b/src/books/lifeCare/view/components/index.vue @@ -5,7 +5,6 @@ </div> <div class="public-bookInnerContent" - @mouseup="handleMouseUp" :style="{ fontSize: fontSize ? fontSize + 'px' : '16px', transform: `scale(${pageZoom ? pageZoom : 1})`, @@ -115,29 +114,29 @@ </template> <script> -import front001 from "./view/front001"; -import ChapterOne from "./view/chapter001"; -import ChapterTwo from "./view/chapter002"; -import ChapterThree from "./view/chapter003"; -import ChapterFour from "./view/chapter004"; -import ChapterFive from "./view/chapter005"; -import chapterSix from "./view/chapter006"; -import chapterSeven from "./view/chapter007"; -import chapterEight from "./view/chapter008"; -import chapterNine from "./view/chapter009"; -import chapter010 from "./view/chapter010"; -import chapter011 from "./view/chapter011"; -import chapter012 from "./view/chapter012"; -import chapter013 from "./view/chapter013"; -import chapter014 from "./view/chapter014"; -import chapter015 from "./view/chapter015"; -import chapter016 from "./view/chapter016"; -import chapter017 from "./view/chapter017"; -import chapter018 from "./view/chapter018"; +import front001 from "./front001"; +import ChapterOne from "./chapter001"; +import ChapterTwo from "./chapter002"; +import ChapterThree from "./chapter003"; +import ChapterFour from "./chapter004"; +import ChapterFive from "./chapter005"; +import chapterSix from "./chapter006"; +import chapterSeven from "./chapter007"; +import chapterEight from "./chapter008"; +import chapterNine from "./chapter009"; +import chapter010 from "./chapter010"; +import chapter011 from "./chapter011"; +import chapter012 from "./chapter012"; +import chapter013 from "./chapter013"; +import chapter014 from "./chapter014"; +import chapter015 from "./chapter015"; +import chapter016 from "./chapter016"; +import chapter017 from "./chapter017"; +import chapter018 from "./chapter018"; import NoteIcon from "@/assets/images/biji.png"; import _ from "lodash"; import getQuestionList from "@/assets/methods/examination"; -import testData from "./js/examinationList"; +import testData from "../../js/examinationList"; import Swiper from "swiper/bundle"; import "swiper/swiper-bundle.css"; import Viewer from "viewerjs"; @@ -203,7 +202,7 @@ }, mounted() { // 榛樿鍔犺浇绔犺妭 - this.showCatalogList = [6]; + this.showCatalogList = [1]; // 婊氬姩鐩戝惉鑺傛祦 this.throttledScrollHandler = _.throttle( this.scrollFun, @@ -586,7 +585,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) @@ -613,36 +612,33 @@ target, "chapter" ); + // 娣诲姞椤电爜 + this.loadPageList.push(Number(page)); 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])) { - if (token) { this.questionDataMap[page] = await getQuestionList( page, testData[catalog][page], this.config.activeBook ); - } } else { const obj = {}; for (let key in testData[catalog][page]) { - obj[key] = await getQuestionList( - [], - testData[catalog][page][key], - this.config.activeBook - ); + obj[key] = await getQuestionList( + [], + testData[catalog][page][key], + this.config.activeBook + ); } this.questionDataMap[page] = obj; } - console.log("棰樼洰", this.questionDataMap); } } } - // 娣诲姞椤电爜 - this.loadPageList.push(Number(page)); + // 娓叉煋杩欎竴椤电殑鏍囪 for (const key in this.renderSignMap) { if (this.renderSignMap[key][page]) { @@ -656,10 +652,7 @@ // 楂樹寒琛� setTimeout(() => { // 鑾峰彇椤甸潰鎵�鏈塼ext鑺傜偣 - const pageTextList = document.createTreeWalker( - target, - NodeFilter.SHOW_TEXT - ); + const pageTextList = document.createTreeWalker(target, NodeFilter.SHOW_TEXT); // 鍖归厤鍏抽敭瀛� const allPageTextNodes = []; let currentNode = pageTextList.nextNode(); @@ -790,56 +783,12 @@ } }, - 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 - ).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, - }); - } + swdtChange(data) { + if (this.$store.state.qiankun && this.$store.state.qiankun.chooseWords) { + this.$store.state.qiankun.chooseWords({ + type: data.type, + data: data.data, + }); } }, @@ -992,7 +941,3 @@ }, }; </script> - -<style lang="less"> -@import "./css/default.less"; -</style> -- Gitblit v1.9.1