From 3c3336804abaee7ce364cfb7be10d3849f6dd9cc Mon Sep 17 00:00:00 2001 From: zhongshujie <2862698242@qq.com> Date: 星期四, 08 八月 2024 16:05:44 +0800 Subject: [PATCH] 艺术戏剧(8.8) --- src/books/artAndDrama/view/components/chapter002.vue | 40 +++++++++++++++++++++++++++++++--------- 1 files changed, 31 insertions(+), 9 deletions(-) diff --git a/src/books/artAndDrama/view/components/chapter002.vue b/src/books/artAndDrama/view/components/chapter002.vue index 8c0f6b2..f982cfe 100644 --- a/src/books/artAndDrama/view/components/chapter002.vue +++ b/src/books/artAndDrama/view/components/chapter002.vue @@ -249,7 +249,7 @@ <span>瑙嗛锛氭儫濡欐儫鑲栫殑浜虹墿 </span> <el-tooltip class="item" effect="dark" :content="chapterData.isCollectVideo ? '鐐瑰嚮鍙栨秷' : '鐐瑰嚮鏀惰棌'" placement="top-start"> - <img :src="chapterData.isCollectVideo ? collectCheck : collectImg" alt="" class="collect-btn" + <img :src="collectResourceList.findIndex(item => item.id == 'a3c9b55ac8227e4c885384ff2fc6c0e7') > -1 ? collectCheck : collectImg" alt="" class="collect-btn" @click="handleCollect('video')" /> </el-tooltip> </p> @@ -267,6 +267,7 @@ <script> import drag from "@/components/dragQuestion/index.vue" import { getResourcePath } from "@/assets/methods/resources"; +import { getCollectResource, setCollectResource } from "@/assets/methods/resources"; export default { name: "chapterTwo", components: { drag }, @@ -276,12 +277,17 @@ }, }, //鍦ㄨ繖閲屽璋冪敤鐨勬柟娉曡繘琛屾寕杞� - mounted() { + async mounted() { this.getVidoePath(); const bookQuestion = localStorage.getItem("artAndDrama-book-question-two"); if (bookQuestion) { this.questionData = JSON.parse(bookQuestion); } + const data = localStorage.getItem("artAndDrama-chapter02-Data"); + if (data) { + this.chapterData = JSON.parse(data); + } + this.collectResourceList = await getCollectResource(this.config.activeBook.bookId) }, data() { return { @@ -294,6 +300,7 @@ auidoPathFour: "", auidoPathFive: "", isFocused: null, // 鐢ㄤ簬璺熻釜textarea鐨勮仛鐒︾姸鎬� + collectResourceList:[], chapterData: { isCollectImg: false, isCollectVideo: false, @@ -476,7 +483,6 @@ this.isFocused = null; // 褰搕extarea澶卞幓鐒︾偣鏃讹紝璁剧疆涓篺alse }, setBookQuestion() { - console.log("淇濆瓨"); localStorage.setItem( "artAndDrama-book-question-two", JSON.stringify(this.questionData) @@ -484,18 +490,34 @@ }, handleChapterData() { localStorage.setItem( - "math-chapterData", + "artAndDrama-chapter02-Data", JSON.stringify(this.chapterData) ); }, handleCollect(type) { - if (type == "img") { - this.chapterData.isCollectImg = !this.chapterData.isCollectImg; - } else if (type == "video") { - this.chapterData.isCollectVideo = !this.chapterData.isCollectVideo; - } + if (type == "video") { + this.handleCollectResource("a3c9b55ac8227e4c885384ff2fc6c0e7","a3c9b55ac8227e4c885384ff2fc6c0e7",'',"瑙嗛","bits",'瑙嗛锛氭儫濡欐儫鑲栫殑浜虹墿') + } this.handleChapterData(); }, + //璧勬簮鏀惰棌浜嬩欢 + handleCollectResource(id, md5, resourcePath, resourceType, source, resourceName) { + let list = this.collectResourceList + if (list.findIndex(item => item.id == id) > -1) { + list = list.filter(item => item.id != id) + } else { + list.push({ + id, + md5, + resourcePath, + resourceType, + source, + resourceName, + }) + } + this.collectResourceList = list + setCollectResource(this.config.activeBook.bookId, this.collectResourceList) + } }, }; </script> -- Gitblit v1.9.1