From ea9138a6eb9b54c46369a2805be40e65a43a55e3 Mon Sep 17 00:00:00 2001 From: 闫增涛 <1829501689@qq.com> Date: 星期四, 23 五月 2024 11:01:29 +0800 Subject: [PATCH] 英语 --- src/books/childHealth/view/content/index.vue | 109 ++++++++++++++++++++++++++++++++++++++++++++++++------ 1 files changed, 96 insertions(+), 13 deletions(-) diff --git a/src/books/childHealth/view/content/index.vue b/src/books/childHealth/view/content/index.vue index 76fa26a..3164729 100644 --- a/src/books/childHealth/view/content/index.vue +++ b/src/books/childHealth/view/content/index.vue @@ -1,7 +1,6 @@ <template> <div class="page-main" @scroll="throttledScrollHandler"> - <div class="page-content" :style="{fontSize: fontSize ? fontSize + 'px' : '16px', - transform: `scale(${pageZoom ? pageZoom : 1})`}"> + <div class="page-content"> <pageHeader v-if="showCatalogList.indexOf(0) > -1"></pageHeader> <chapterOne v-if="showCatalogList.indexOf(1) > -1"></chapterOne> <chapterTwo v-if="showCatalogList.indexOf(2) > -1"></chapterTwo> @@ -51,14 +50,6 @@ observer: null }; }, - computed:{ - fontSize() { - return this.$store.state.qiankun.fontSize - }, - pageZoom() { - return this.$store.state.qiankun.scale / 100 - } - }, watch: { showCatalogList: { handler(newVal, oldVal) { @@ -74,13 +65,14 @@ // 鍚姩椤电爜瑙傚療 setTimeout(() => { this.initObservation(); + this.initThemeColor(); }, 500); } } }, mounted() { // 榛樿鍔犺浇绔犺妭 - this.showCatalogList = [3]; + this.showCatalogList = [0]; // 婊氬姩鐩戝惉鑺傛祦 this.throttledScrollHandler = _.throttle( this.scrollFun, @@ -116,6 +108,7 @@ // 鍚姩椤电爜瑙傚療 setTimeout(() => { this.initObservation(); + this.initThemeColor(); }, 500); // 娴嬭瘯椤甸潰璺宠浆 @@ -213,6 +206,7 @@ console.log("绔犺妭閿欒锛�"); } }, + // 娓叉煋鏍囪 renderSign(type, data) { const existence = ( @@ -277,9 +271,11 @@ } }, initObservation() { - const sections = document.querySelectorAll(".page-box"); - //observer 瑙傚療姣忎釜鍏冪礌锛屼互渚垮湪瀹冧滑杩涘叆鎴栫寮�瑙嗙獥鏃惰Е鍙戝洖璋冨嚱鏁般�� + const sections = ( + this.container ? this.container : document + ).querySelectorAll(".page-box"); sections.forEach((section) => { + //observer 瑙傚療姣忎釜鍏冪礌锛屼互渚垮湪瀹冧滑杩涘叆鎴栫寮�瑙嗙獥鏃惰Е鍙戝洖璋冨嚱鏁般�� const isObserver = section.getAttribute("observer"); if (!isObserver) { this.observer.observe(section); @@ -287,6 +283,93 @@ } }); }, + initThemeColor() { + // 鑾峰彇鍚勭闇�瑕佷富棰樿壊鐨勮妭鐐� + const colorDom = ( + this.container ? this.container : document + ).querySelectorAll(".theme-color"); + const backgroundColorDom = ( + this.container ? this.container : document + ).querySelectorAll(".theme-back"); + const borderColorDom = ( + this.container ? this.container : document + ).querySelectorAll(".theme-border"); + // 鑾峰彇閰嶇疆鐨勪富棰樿壊 + const bookThemeColor = + this.thisBookConfig && this.thisBookConfig.bookThemeColor + ? this.thisBookConfig.bookThemeColor + : null; + const chapterThemeColor = + this.thisBookConfig && this.thisBookConfig.chapterThemeColor + ? this.thisBookConfig.chapterThemeColor + : null; + const pageThemeColor = + this.thisBookConfig && this.thisBookConfig.pageThemeColor + ? this.thisBookConfig.pageThemeColor + : null; + colorDom.forEach((domItem) => { + // 鑾峰彇绔犺妭銆侀〉鐮� + let pageDom = this.getParentWithClass(domItem, "page-box"); + let chapterDom = this.getParentWithClass(domItem, "chapter"); + let page, chapterNum; + if (pageDom) page = pageDom.getAttribute("page"); + if (chapterDom) chapterNum = chapterDom.getAttribute("num"); + // 鍚戜笂鍖归厤涓婚鑹� + const themeColor = + page && pageThemeColor && pageThemeColor[page] + ? pageThemeColor[page] + : chapterNum && chapterThemeColor && chapterThemeColor[chapterNum] + ? chapterThemeColor[chapterNum] + : bookThemeColor; + if (themeColor) { + domItem.style.color = themeColor; + } + }); + backgroundColorDom.forEach((domItem) => { + // 鑾峰彇绔犺妭銆侀〉鐮� + let pageDom = this.getParentWithClass(domItem, "page-box"); + let chapterDom = this.getParentWithClass(domItem, "chapter"); + let page, chapterNum; + if (pageDom) page = pageDom.getAttribute("page"); + if (chapterDom) chapterNum = chapterDom.getAttribute("num"); + // 鍚戜笂鍖归厤涓婚鑹� + const themeColor = + page && pageThemeColor && pageThemeColor[page] + ? pageThemeColor[page] + : chapterNum && chapterThemeColor && chapterThemeColor[chapterNum] + ? chapterThemeColor[chapterNum] + : bookThemeColor; + if (themeColor) { + domItem.style.backgroundColor = themeColor; + } + }); + borderColorDom.forEach((domItem) => { + // 鑾峰彇绔犺妭銆侀〉鐮� + let pageDom = this.getParentWithClass(domItem, "page-box"); + let chapterDom = this.getParentWithClass(domItem, "chapter"); + let page, chapterNum; + if (pageDom) page = pageDom.getAttribute("page"); + if (chapterDom) chapterNum = chapterDom.getAttribute("num"); + // 鍚戜笂鍖归厤涓婚鑹� + const themeColor = + page && pageThemeColor && pageThemeColor[page] + ? pageThemeColor[page] + : chapterNum && chapterThemeColor && chapterThemeColor[chapterNum] + ? chapterThemeColor[chapterNum] + : bookThemeColor; + if (themeColor) { + domItem.style.borderColor = themeColor; + } + }); + }, + getParentWithClass(element, className) { + while (element.parentElement) { + element = element.parentElement; + if (element.classList.contains(className)) { + return element; + } + } + }, pageChangeCallback(entries, observer) { //entries锛氫唬琛ㄨ瀵熷埌鐨勭洰鏍囧厓绱犵殑闆嗗悎銆� observer锛氫唬琛ㄨ瀵熻�呭璞°�� entries.forEach((entry) => { -- Gitblit v1.9.1