From be9e87ab74a65e57409e8fe74f9e29b808466fe1 Mon Sep 17 00:00:00 2001 From: unknown <qq1940665526@163.com> Date: 星期四, 13 六月 2024 19:53:46 +0800 Subject: [PATCH] 优化 --- src/books/sportsAndHealth/view/components/index.vue | 124 +++++++++++++++++++++++------------------ 1 files changed, 69 insertions(+), 55 deletions(-) diff --git a/src/books/sportsAndHealth/view/components/index.vue b/src/books/sportsAndHealth/view/components/index.vue index 2348ec2..846fd7f 100644 --- a/src/books/sportsAndHealth/view/components/index.vue +++ b/src/books/sportsAndHealth/view/components/index.vue @@ -101,6 +101,7 @@ </template> <script> +import Vue from "vue"; import front001 from "./front001"; import ChapterOne from "./chapter001"; import ChapterTwo from "./testDynaicTable"; @@ -153,12 +154,18 @@ return this.$store.state.qiankun.scale / 100; }, }, - provide() { - return { - changeQuestionData: this.changeQuestionData, - }; - }, watch: { + swdtChange(data) { + if (this.$store.state.qiankun && this.$store.state.qiankun.chooseWords) { + this.$store.state.qiankun.chooseWords({ + type: data.type, + data: data.data, + }); + } + }, + changeDomViewer() { + this.initViewer(); + }, showCatalogList: { handler(newVal, oldVal) { if ( @@ -178,11 +185,19 @@ }, }, loadPageList: { - handler() { + handler(newVal, oldVal) { setTimeout(() => { this.initSwiper(); this.initViewer(); }, 200); + }, + }, + pageZoom: { + handler(newVal, oldVal) { + const scrollBox = ( + this.container ? this.container : document + ).querySelector(".page-main"); + scrollBox.scrollTop = (scrollBox.scrollTop / oldVal) * newVal; }, }, }, @@ -245,27 +260,51 @@ // 娴嬭瘯椤甸潰璺宠浆 // setTimeout(() => { - // this.gotoPage(1, 15); + // this.gotoPage(1,10); // setTimeout(() => { - // this.renderSign("Note", { + // this.renderSign("Highlight", { // id: "2ACA9359", - // txt: "钀ュ吇绱犲拰鐑噺锛屾墠鑳�", - // page: "100", + // txt: "棰樹竴瀛︿範涓婚涓� 杩愬姩", + // page: "10", // type: "Highlight", // color: "#F5E12A" // }); - // setTimeout(() => { - // this.delSign({ - // ids: ["2ACA9359"] - // }); - // }, 2000); - // }, 1000); - // }, 1000); + // setTimeout(() => { + // this.delSign({ + // ids: ["2ACA9359"] + // }); + // }, 2000); + // }, 5000); + + // const pageDom = (this.container ? this.container : document) + // .querySelector("#app") + // .querySelectorAll(".page-box"); + // 妫�绱� + // console.log(this.searchTextByPage("淇濇姢鍐呰剰鍣ㄥ畼"), "searchTextByPage"); + // 妫�绱㈣烦杞� + // this.searchItemLocation({ + // catalog: 2, + // page: 10, + // txt: " 杩愬姩绯荤粺鏄敱楠ㄣ�侀杩炵粨鍜岄楠艰倢涓夐儴鍒嗙粍鎴愮殑銆傚叏韬殑楠ㄩ�氳繃楠ㄨ繛缁撶粍鎴愪汉浣撻楠硷紙瑙佸浘1-1锛夈�傞楠兼槸浜轰綋鐨勬敮鏋讹紝鍏锋湁淇濇姢鍐呰剰鍣ㄥ畼銆佷緵鑲岃倝闄勭潃鍜屼綔涓鸿倢鑲夎繍鍔ㄧ殑鏉犳潌绛変綔鐢ㄣ�傚湪绁炵粡绯荤粺鐨勬敮閰嶄笅锛岃倢鑲夋敹缂╃壍鍔ㄦ墍闄勭潃鐨勯缁曠潃鍏宠妭杞姩锛屼娇韬綋浜х敓鍚勭鍔ㄤ綔銆傛墍浠ワ紝杩愬姩绯荤粺鍏锋湁杩愬姩銆佹敮鎸佸拰淇濇姢绛夊姛鑳斤紝骞煎勾鏃舵湡鐨勯楠艰繕鍏锋湁閫犺鍔熻兘銆� ", + // txtIndex: 57 + // }); + // }, 500); }, methods: { - changeDomViewer() { - this.initViewer(); - }, + // setZoom1() { + // let scale = this.$store.state.qiankun.scale + 10; + // const scrollBox = ( + // this.container ? this.container : document + // ).querySelector(".page-main"); + // this.$store.commit("setZoom", scale); + // }, + // setZoom2() { + // let scale = this.$store.state.qiankun.scale - 10; + // const scrollBox = ( + // this.container ? this.container : document + // ).querySelector(".page-main"); + // this.$store.commit("setZoom", scale); + // }, // 婊氬姩鐩戝惉 scrollFun(event) { // 鍒ゆ柇鍚戜笂婊氬姩杩樻槸鍚戜笅婊氬姩 @@ -415,7 +454,6 @@ } } }, - // 鍒犻櫎鏍囪娓叉煋 delSign({ ids, type }) { if (ids && ids.length) { @@ -443,7 +481,6 @@ } } }, - initObservation() { const sections = ( this.container ? this.container : document @@ -472,7 +509,6 @@ } }); }, - initThemeColor() { // 鑾峰彇鍚勭闇�瑕佷富棰樿壊鐨勮妭鐐� const colorDom = ( @@ -552,7 +588,15 @@ } }); }, - + getParentWithClass(element, className) { + console.log(element, className, "element, className"); + while (element.parentElement) { + element = element.parentElement; + if (element.classList.contains(className)) { + return element; + } + } + }, pageChangeCallback(entries, observer) { //entries锛氫唬琛ㄨ瀵熷埌鐨勭洰鏍囧厓绱犵殑闆嗗悎銆� observer锛氫唬琛ㄨ瀵熻�呭璞°�� entries.forEach((entry) => { @@ -584,7 +628,6 @@ } }); }, - loadPageCallback(entries, observer) { entries.forEach(async (entry) => { if (entry.isIntersecting) { @@ -621,7 +664,6 @@ } } } - // 娓叉煋杩欎竴椤电殑鏍囪 for (const key in this.renderSignMap) { if (this.renderSignMap[key][page]) { @@ -671,7 +713,6 @@ } }); }, - initSwiper() { const doms = ( this.container ? this.container : document @@ -751,7 +792,6 @@ }); } }, - initViewer() { const doms = ( this.container ? this.container : document @@ -768,16 +808,6 @@ }); } }, - - swdtChange(data) { - if (this.$store.state.qiankun && this.$store.state.qiankun.chooseWords) { - this.$store.state.qiankun.chooseWords({ - type: data.type, - data: data.data, - }); - } - }, - // 鏍规嵁鍏抽敭瀛楀叏鏂囨绱� searchTextByPage(keyword) { const searchResult = []; @@ -788,21 +818,6 @@ ChapterOne, ChapterTwo, ChapterThree, - // ChapterFour, - // ChapterFive, - // chapterSix, - // chapterSeven, - // chapterEight, - // chapterNine, - // chapter010, - // chapter011, - // chapter012, - // chapter013, - // chapter014, - // chapter015, - // chapter016, - // chapter017, - // chapter018, }; // 閬嶅巻鎵�鏈夌珷鑺傛枃浠� for (const key in pageData) { @@ -894,10 +909,9 @@ } } // 杈撳嚭鎼滅储缁撴灉 - // console.log(searchResult); + console.log(searchResult); return searchResult; }, - // 鏍规嵁妫�绱㈢粨鏋滆烦杞搴斾綅缃苟楂樹寒 searchItemLocation(data) { // 璁板綍楂樹寒淇℃伅 -- Gitblit v1.9.1