From d373b2079affa74cbf9c8a53b7fee8c96f75aec6 Mon Sep 17 00:00:00 2001 From: 闫增涛 <1829501689@qq.com> Date: 星期四, 27 六月 2024 15:26:04 +0800 Subject: [PATCH] 音频小窗和关闭其他优化 --- src/books/artAndDance/view/components/chapter003.vue | 7 - src/books/artAndDance/view/components/chapter002.vue | 7 - src/books/artAndDance/view/components/chapter001.vue | 7 - src/books/artAndDance/view/components/chapter004.vue | 7 - src/books/artAndDance/view/components/chapter005.vue | 7 - src/books/artAndDance/view/components/index.vue | 32 ++++--- src/App.vue | 2 src/books/English/view/components/index.vue | 157 ++++++++++++++++++++++----------------- 8 files changed, 116 insertions(+), 110 deletions(-) diff --git a/src/App.vue b/src/App.vue index 65f4077..16e08b0 100644 --- a/src/App.vue +++ b/src/App.vue @@ -65,7 +65,7 @@ process.env.VUE_APP_RESOURCE_CTX + (process.env.VUE_APP_ENV == "product" ? process.env.VUE_APP_BOOK_ID - : "childHealth") + : "artAndDance") ); // 娴嬭瘯璇曡30椤� // this.activeBook.tryPageCount = 10; diff --git a/src/books/English/view/components/index.vue b/src/books/English/view/components/index.vue index 7d81bc6..4b14da9 100644 --- a/src/books/English/view/components/index.vue +++ b/src/books/English/view/components/index.vue @@ -1,21 +1,48 @@ <template> <div class="page-main" @scroll="throttledScrollHandler"> - <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 @saveCharacters="saveCharacters" @closeMiniAudio="closeMiniAudio" - v-if="showCatalogList.indexOf(2) > -1" :showPageList="loadPageList"></chapterOne> - <chapterTwo @saveCharacters="saveCharacters" @closeMiniAudio="closeMiniAudio" - v-if="showCatalogList.indexOf(3) > -1" :showPageList="loadPageList"></chapterTwo> - <chapterThree @saveCharacters="saveCharacters" @closeMiniAudio="closeMiniAudio" - v-if="showCatalogList.indexOf(4) > -1" :showPageList="loadPageList"></chapterThree> - <chapterFour @saveCharacters="saveCharacters" @closeMiniAudio="closeMiniAudio" - v-if="showCatalogList.indexOf(5) > -1" :showPageList="loadPageList"></chapterFour> + <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 + @saveCharacters="saveCharacters" + @closeMiniAudio="closeMiniAudio" + v-if="showCatalogList.indexOf(2) > -1" + :showPageList="loadPageList" + ></chapterOne> + <chapterTwo + @saveCharacters="saveCharacters" + @closeMiniAudio="closeMiniAudio" + v-if="showCatalogList.indexOf(3) > -1" + :showPageList="loadPageList" + ></chapterTwo> + <chapterThree + @saveCharacters="saveCharacters" + @closeMiniAudio="closeMiniAudio" + v-if="showCatalogList.indexOf(4) > -1" + :showPageList="loadPageList" + ></chapterThree> + <chapterFour + @saveCharacters="saveCharacters" + @closeMiniAudio="closeMiniAudio" + v-if="showCatalogList.indexOf(5) > -1" + :showPageList="loadPageList" + ></chapterFour> </div> - <miniAudio :path="audioPath" :currentTime="currentTime" @closeMiniAudio="closeMiniAudio" ref="audioPlayer"> + <miniAudio + :path="audioPath" + :currentTime="currentTime" + @closeMiniAudio="closeMiniAudio" + ref="audioPlayer" + > </miniAudio> </div> </template> @@ -23,9 +50,9 @@ <script> 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 chapterTwo from "./chapter002.vue"; +import chapterThree from "./chapter003.vue"; +import chapterFour from "./chapter004.vue"; import miniAudio from "@/components/miniAudio/index.vue"; import NoteIcon from "@/assets/images/biji.png"; import _ from "lodash"; @@ -157,33 +184,33 @@ // 娴嬭瘯椤甸潰璺宠浆 // setTimeout(() => { // this.gotoPage(4,59); - // setTimeout(() => { - // this.renderSign("Highlight", { - // id: "2ACA9359", - // txt: "棰樹竴瀛︿範涓婚涓� 杩愬姩", - // page: "10", - // type: "Highlight", - // color: "#F5E12A" - // }); - // setTimeout(() => { - // this.delSign({ - // ids: ["2ACA9359"] - // }); - // }, 2000); - // }, 5000); + // setTimeout(() => { + // this.renderSign("Highlight", { + // id: "2ACA9359", + // txt: "棰樹竴瀛︿範涓婚涓� 杩愬姩", + // page: "10", + // type: "Highlight", + // color: "#F5E12A" + // }); + // 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 - // }); + // 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 + // }); // }, 50); }, methods: { @@ -443,8 +470,8 @@ page && pageThemeColor && pageThemeColor[page] ? pageThemeColor[page] : chapterNum && chapterThemeColor && chapterThemeColor[chapterNum] - ? chapterThemeColor[chapterNum] - : bookThemeColor; + ? chapterThemeColor[chapterNum] + : bookThemeColor; if (themeColor) { domItem.style.color = themeColor; } @@ -461,8 +488,8 @@ page && pageThemeColor && pageThemeColor[page] ? pageThemeColor[page] : chapterNum && chapterThemeColor && chapterThemeColor[chapterNum] - ? chapterThemeColor[chapterNum] - : bookThemeColor; + ? chapterThemeColor[chapterNum] + : bookThemeColor; if (themeColor) { domItem.style.backgroundColor = themeColor; } @@ -479,8 +506,8 @@ page && pageThemeColor && pageThemeColor[page] ? pageThemeColor[page] : chapterNum && chapterThemeColor && chapterThemeColor[chapterNum] - ? chapterThemeColor[chapterNum] - : bookThemeColor; + ? chapterThemeColor[chapterNum] + : bookThemeColor; if (themeColor) { domItem.style.borderColor = themeColor; } @@ -623,23 +650,19 @@ autoplay: { //鑷姩寮�濮� delay: 3000, //鏃堕棿闂撮殧 - disableOnInteraction: false //*鎵嬪姩鎿嶄綔杞挱鍥惧悗涓嶄細鏆傚仠* + disableOnInteraction: false, //*鎵嬪姩鎿嶄綔杞挱鍥惧悗涓嶄細鏆傚仠* }, paginationClickable: true, slidesPerView: 1, // 涓�缁勪笁涓� spaceBetween: 30, // 闂撮殧 // 濡傛灉闇�瑕佸墠杩涘悗閫�鎸夐挳 navigation: { - nextEl: dom.querySelector( - ".swiper-button-next" - ), - prevEl: dom.querySelector( - ".swiper-button-prev" - ) + nextEl: dom.querySelector(".swiper-button-next"), + prevEl: dom.querySelector(".swiper-button-prev"), }, // 绐楀彛鍙樺寲,閲嶆柊init,閽堝F11鍏ㄥ睆鍜屾斁澶х缉灏�,蹇呴』鍔� observer: true, - observeParents: true + observeParents: true, // // 濡傛灉闇�瑕佸垎椤靛櫒 // pagination: { // el: (this.container ? this.container : document).querySelector( @@ -662,12 +685,8 @@ spaceBetween: 30, // 闂撮殧 // 濡傛灉闇�瑕佸墠杩涘悗閫�鎸夐挳 navigation: { - nextEl: dom.querySelector( - ".swiper-button-next" - ), - prevEl: dom.querySelector( - ".swiper-button-prev" - ) + nextEl: dom.querySelector(".swiper-button-next"), + prevEl: dom.querySelector(".swiper-button-prev"), }, // 绐楀彛鍙樺寲,閲嶆柊init,閽堝F11鍏ㄥ睆鍜屾斁澶х缉灏�,蹇呴』鍔� observer: true, @@ -686,8 +705,8 @@ var paginationInfoEl = dom.querySelector(".pageBox"); if (paginationInfoEl) paginationInfoEl.textContent = currentPage + "/" + totalPages; - } - } + }, + }, }); } }, @@ -729,7 +748,7 @@ propsData: { showPageList: [], questionData: {}, - isSearch: true + isSearch: true, }, }); pageExample.$mount( @@ -761,7 +780,7 @@ propsData: { showPageList: [pageNum], questionData: {}, - isSearch: true + isSearch: true, }, }); pageExample.$mount( @@ -817,7 +836,7 @@ // 璁板綍楂樹寒淇℃伅 this.highlightData = data; // 璺宠浆 - this.gotoPage(data.catalog, data.page, () => { }); + this.gotoPage(data.catalog, data.page, () => {}); }, // 鐐瑰嚮浜嬩欢锛氬皢鐢熷兓鍗曡瘝浼犵粰 涓诲簲鐢� 浠庤�岃皟鐢ㄨ瘝鍏稿姛鑳� saveCharacters(event, word) { diff --git a/src/books/artAndDance/view/components/chapter001.vue b/src/books/artAndDance/view/components/chapter001.vue index 7b8b7f6..f27f6fc 100644 --- a/src/books/artAndDance/view/components/chapter001.vue +++ b/src/books/artAndDance/view/components/chapter001.vue @@ -54,13 +54,13 @@ <ul class="fl fl-cl al-cn audio-box"> <li class="fl al-cn"> <span class="wh-nr auido-text mr-8 ">鐢风闊�</span> - <audio :src="auidoPathOne" controls controlslist="noplaybackrate nodownload" class="audio" @play="audioPlay" ></audio> + <audio :src="auidoPathOne" controls controlslist="noplaybackrate nodownload" class="audio" ></audio> </li> <li class="fl al-cn mt-20 " > <span class="wh-nr auido-text mr-8 "> 濂崇闊� </span> - <audio :src="auidoPathTwo" controls controlslist="noplaybackrate nodownload" class="audio" @play="audioPlay"></audio> + <audio :src="auidoPathTwo" controls controlslist="noplaybackrate nodownload" class="audio" ></audio> </li> </ul> <h3 id="c003">榛勯工妤奸�佸瓱娴╃劧涔嬪箍闄�</h3> @@ -172,9 +172,6 @@ this.auidoPathOne = await getResourcePath("2c5f6c69b0f9f7a3c03e473cb8c977f5"); this.auidoPathTwo = await getResourcePath("e93c0fdde08be5a4386c8c863892a287"); }, - audioPlay(e) { - this.$emit('closeAudio',e.srcElement.currentSrc) - } }, }; </script> diff --git a/src/books/artAndDance/view/components/chapter002.vue b/src/books/artAndDance/view/components/chapter002.vue index e3c4ee7..392469b 100644 --- a/src/books/artAndDance/view/components/chapter002.vue +++ b/src/books/artAndDance/view/components/chapter002.vue @@ -69,13 +69,13 @@ <ul class="fl fl-cl al-cn audio-box"> <li class="fl al-cn"> <span class="wh-nr auido-text mr-8">鐢风闊�</span> - <audio :src="auidoPathOne" controls controlslist="noplaybackrate nodownload" class="audio" @play="audioPlay"></audio> + <audio :src="auidoPathOne" controls controlslist="noplaybackrate nodownload" class="audio" ></audio> </li> <li class="fl al-cn mt-20"> <span class="wh-nr auido-text mr-8"> 濂崇闊� </span> - <audio :src="auidoPathTwo" controls controlslist="noplaybackrate nodownload" class="audio" @play="audioPlay"></audio> + <audio :src="auidoPathTwo" controls controlslist="noplaybackrate nodownload" class="audio" ></audio> </li> </ul> <h3 id="c006">浜$緤琛ョ墷</h3> @@ -225,9 +225,6 @@ } },200) }, - audioPlay(e) { - this.$emit('closeAudio',e.srcElement.currentSrc) - } }, }; </script> diff --git a/src/books/artAndDance/view/components/chapter003.vue b/src/books/artAndDance/view/components/chapter003.vue index 85aa071..c31a403 100644 --- a/src/books/artAndDance/view/components/chapter003.vue +++ b/src/books/artAndDance/view/components/chapter003.vue @@ -54,13 +54,13 @@ <ul class="fl fl-cl al-cn audio-box"> <li class="fl al-cn"> <span class="wh-nr auido-text mr-8">鐢风闊�</span> - <audio :src="auidoPathOne" controls controlslist="noplaybackrate nodownload" class="audio" @play="audioPlay"></audio> + <audio :src="auidoPathOne" controls controlslist="noplaybackrate nodownload" class="audio" ></audio> </li> <li class="fl al-cn mt-20"> <span class="wh-nr auido-text mr-8"> 濂崇闊� </span> - <audio :src="auidoPathTwo" controls controlslist="noplaybackrate nodownload" class="audio" @play="audioPlay"></audio> + <audio :src="auidoPathTwo" controls controlslist="noplaybackrate nodownload" class="audio"></audio> </li> </ul> <h3 id="c009">灏忓効鍨傞挀</h3> @@ -171,9 +171,6 @@ this.auidoPathOne = await getResourcePath("85923e871441c541991be07fe4ce8771"); this.auidoPathTwo = await getResourcePath("c018f7a6434abfac0b0e0da1174d643a"); }, - audioPlay(e) { - this.$emit('closeAudio',e.srcElement.currentSrc) - } }, } </script> diff --git a/src/books/artAndDance/view/components/chapter004.vue b/src/books/artAndDance/view/components/chapter004.vue index 97ce204..ee3064c 100644 --- a/src/books/artAndDance/view/components/chapter004.vue +++ b/src/books/artAndDance/view/components/chapter004.vue @@ -60,13 +60,13 @@ <ul class="fl fl-cl al-cn audio-box"> <li class="fl al-cn"> <span class="wh-nr auido-text mr-8">鐢风闊�</span> - <audio :src="auidoPathOne" controls controlslist="noplaybackrate nodownload" class="audio" @play="audioPlay"></audio> + <audio :src="auidoPathOne" controls controlslist="noplaybackrate nodownload" class="audio" ></audio> </li> <li class="fl al-cn mt-20"> <span class="wh-nr auido-text mr-8"> 濂崇闊� </span> - <audio :src="auidoPathTwo" controls controlslist="noplaybackrate nodownload" class="audio" @play="audioPlay"></audio> + <audio :src="auidoPathTwo" controls controlslist="noplaybackrate nodownload" class="audio" ></audio> </li> </ul> <h3 id="c012">瀵婚殣鑰呬笉閬�</h3> @@ -175,9 +175,6 @@ this.auidoPathOne = await getResourcePath("a865ff99b91fa24d87ac81a883be54db"); this.auidoPathTwo = await getResourcePath("66f3cc00d272a120514201e13e87fb9d"); }, - audioPlay(e) { - this.$emit('closeAudio',e.srcElement.currentSrc) - } }, } </script> diff --git a/src/books/artAndDance/view/components/chapter005.vue b/src/books/artAndDance/view/components/chapter005.vue index e0fcfca..9b5dc90 100644 --- a/src/books/artAndDance/view/components/chapter005.vue +++ b/src/books/artAndDance/view/components/chapter005.vue @@ -66,11 +66,11 @@ <ul class="fl fl-cl al-cn audio-box"> <li class="fl al-cn"> <span class="wh-nr auido-text mr-8">鐢风闊�</span> - <audio :src="auidoPathOne" controls controlslist="noplaybackrate nodownload" class="audio" @play="audioPlay"></audio> + <audio :src="auidoPathOne" controls controlslist="noplaybackrate nodownload" class="audio" ></audio> </li> <li class="fl al-cn mt-20"> <span class="wh-nr auido-text mr-8"> 濂崇闊� </span> - <audio :src="auidoPathTwo" controls controlslist="noplaybackrate nodownload" class="audio" @play="audioPlay"></audio> + <audio :src="auidoPathTwo" controls controlslist="noplaybackrate nodownload" class="audio" ></audio> </li> </ul> <h3 id="c015">娓旀瓕瀛�</h3> @@ -219,9 +219,6 @@ } },200) }, - audioPlay(e) { - this.$emit('closeAudio',e.srcElement.currentSrc) - } }, }; </script> diff --git a/src/books/artAndDance/view/components/index.vue b/src/books/artAndDance/view/components/index.vue index 0840f20..e62755e 100644 --- a/src/books/artAndDance/view/components/index.vue +++ b/src/books/artAndDance/view/components/index.vue @@ -18,28 +18,23 @@ <chapterOne v-if="showCatalogList.indexOf(2) > -1" :showPageList="loadPageList" - @closeAudio="closeAudio" ></chapterOne> <chapterTwo v-if="showCatalogList.indexOf(3) > -1" :showPageList="loadPageList" - @closeAudio="closeAudio" > </chapterTwo> <chapterThree v-if="showCatalogList.indexOf(4) > -1" :showPageList="loadPageList" - @closeAudio="closeAudio" ></chapterThree> <chapterFour v-if="showCatalogList.indexOf(5) > -1" :showPageList="loadPageList" - @closeAudio="closeAudio" ></chapterFour> <chapterFive v-if="showCatalogList.indexOf(6) > -1" :showPageList="loadPageList" - @closeAudio="closeAudio" ></chapterFive> <chapterSix v-if="showCatalogList.indexOf(7) > -1" @@ -123,6 +118,7 @@ setTimeout(() => { this.initSwiper(); this.initViewer(); + this.closeAudio() }, 200); }, }, @@ -899,21 +895,27 @@ closeMiniAudio() { this.audioPath = ""; }, + // 鐐瑰嚮闊抽鎾斁锛屽叧闂叾浠栭煶棰� - closeAudio(path) { - let allVideo = ( + closeAudio() { + let allAudio = ( this.container ? this.container : document ).querySelectorAll(".audio"); - allVideo = Array.from(allVideo); - if(allVideo.length) { - for (let index = 0; index < allVideo.length; index++) { - const item = allVideo[index]; - if(item.currentSrc != path) { - item.pause() + for (let index = 0; index < allAudio.length; index++) { + const item = allAudio[index]; + item.addEventListener('play',() => { + console.log('鎾斁',item.src); + 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() + }) } - this.closeMiniAudio() } }, components: { -- Gitblit v1.9.1