From c8daf100bf448c0c5abebe73f1dbc9b61cedc7a7 Mon Sep 17 00:00:00 2001 From: zhongshujie <2862698242@qq.com> Date: 星期三, 14 五月 2025 17:56:27 +0800 Subject: [PATCH] 修改 --- src/views/achievements/details.vue | 453 +++++++++++++++++++++++++++++++++++++------------------- 1 files changed, 298 insertions(+), 155 deletions(-) diff --git a/src/views/achievements/details.vue b/src/views/achievements/details.vue index e3708e1..c27f752 100644 --- a/src/views/achievements/details.vue +++ b/src/views/achievements/details.vue @@ -7,7 +7,9 @@ <ul class="page-main"> <li class="page-main-name"> <p> - <el-button icon="el-icon-arrow-left" @click="goBack()">杩斿洖</el-button> + <el-button icon="el-icon-arrow-left" @click="goBack()" + >杩斿洖</el-button + > </p> <p>{{ details.name }}</p> </li> @@ -20,38 +22,76 @@ </li> <li class="page-main-title"> <p> - <span v-for="(item, index) in details.author" :key="index">{{ item }}</span> + <span v-for="(item, index) in details.author" :key="index">{{ + item + }}</span> </p> <p v-if="details.cleanAbstract"> <span class="abstract-title">鎽樿锛�</span> - <span class="page-main-abstract-main" v-html="details.cleanAbstract"></span> + <span + class="page-main-abstract-main" + v-html="details.cleanAbstract" + ></span> </p> <p v-if="details.keyWords && details.keyWords.length > 0"> <span>鍏抽敭璇嶏細</span> - <span class="page-main-keyword" v-for="(item, index) in details.keyWords" :key="index">{{ item - }}</span> + <span + class="page-main-keyword" + v-for="(item, index) in details.keyWords" + :key="index" + >{{ item }}</span + > </p> - <p v-if="details.cmsItemType != 'video' && details.cmsItemType != 'audio'"> + <p + v-if=" + details.cmsItemType != 'video' && details.cmsItemType != 'audio' + " + > <el-button @click="openPdf(details.name)">鏌ョ湅鍏ㄦ枃</el-button> </p> <p class="page-main-video" v-if="details.cmsItemType == 'video'"> - <video :src="details.src" controls autoplay class="video" width="70%"></video> + <video + :src="details.src" + controls + autoplay + class="video" + width="70%" + ></video> </p> <p class="page-main-audio" v-if="details.cmsItemType == 'audio'"> - <audio :src="details.src" controls autoplay class="video" width="100%"></audio> + <audio + :src="details.src" + controls + autoplay + class="video" + width="100%" + ></audio> </p> </li> <li class="page-main-literature"> <p class="literature-header">鐩稿叧鏂囩尞</p> - <div class="content-right" v-loading="loading" element-loading-text="妫�绱㈢粨鏋滃姞杞戒腑" - element-loading-spinner="el-icon-loading" element-loading-background="rgba(0, 0, 0, 0)"> + <div + class="content-right" + v-loading="loading" + element-loading-text="妫�绱㈢粨鏋滃姞杞戒腑" + element-loading-spinner="el-icon-loading" + element-loading-background="rgba(0, 0, 0, 0)" + > <!-- 缁撴灉灞曠ず --> - <ul class="right-main" v-for="(item, index) in resultList" :key="index"> + <ul + class="right-main" + v-for="(item, index) in resultList" + :key="index" + @click="goPage(item.id)" + > <li class="main-name"> <p>{{ item.name }}</p> <p> - <el-button @click="goPage(item.id)">璇︽儏</el-button> - <el-button>AI鏅鸿兘闃呰</el-button> + <!-- <el-button>璇︽儏</el-button> --> + <el-button + @click.stop="openAiReading(item.AIReading, item.name)" + >AI鏅鸿兘闃呰</el-button + > </p> </li> <li class="main-sources"> @@ -63,13 +103,27 @@ <li class="main-author"> {{ item.author }} </li> - <li class="main-title" :title="item.abstract" v-if="item.cleanAbstract"> + <li + class="main-title" + :title="item.cleanAbstract" + v-if="item.cleanAbstract" + > <span>鎽樿: </span> - <span class="page-main-abstract" v-html="item.cleanAbstract"></span> + <span + class="page-main-abstract" + v-html="item.cleanAbstract" + ></span> </li> - <li class="main-keyword" v-if="item.keyWords && item.keyWords.length > 0"> + <li + class="main-keyword" + v-if="item.keyWords && item.keyWords.length > 0" + > <span>鍏抽敭璇嶏細</span> - <span class="keyWord" v-for="(citem, cindex) in item.keyWords" :key="cindex"> + <span + class="keyWord" + v-for="(citem, cindex) in item.keyWords" + :key="cindex" + > {{ citem }} </span> </li> @@ -79,16 +133,58 @@ </ul> </div> <el-empty v-if="!loading && details == ''"></el-empty> - <el-dialog v-model="dialogVisible" :title="pdfName" width="60vw" top="3vh" bottom="2vh" - :visible.sync="dialogVisible" class="custom-dialog"> - <div class="pdfInfoBox" v-loading="pdfLoading" element-loading-text="鍥剧墖鍔犺浇涓�" - element-loading-spinner="el-icon-loading" element-loading-background="rgba(0, 0, 0, 0)"> - <div v-for="(item, index) in pdfList" :key="index" class="pdfItem" :page="index + 1"> - <img :src="item.showSrc" alt="" style="min-height: 550px" loading="lazy" /> - <el-divider content-position="center"> 绗� {{ index + 1 }} 椤� </el-divider> + <el-dialog + v-model="dialogVisible" + :title="pdfName" + width="60vw" + top="3vh" + bottom="2vh" + :visible.sync="dialogVisible" + class="custom-dialog" + > + <div + class="pdfInfoBox" + v-loading="pdfLoading" + element-loading-text="鍥剧墖鍔犺浇涓�" + element-loading-spinner="el-icon-loading" + element-loading-background="rgba(0, 0, 0, 0)" + > + <div + v-for="(item, index) in pdfList" + :key="index" + class="pdfItem" + :page="index + 1" + > + <img + :src="item.showSrc" + alt="" + style="min-height: 550px" + loading="lazy" + /> + <el-divider content-position="center"> + 绗� {{ index + 1 }} 椤� + </el-divider> </div> </div> <el-empty v-if="!pdfLoading && !pdfList.length"></el-empty> + </el-dialog> + <el-dialog + v-model="dialogVisibleAI" + :title="aIName" + width="60vw" + top="3vh" + bottom="2vh" + :visible.sync="dialogVisibleAI" + class="custom-dialog" + > + <div + class="AIReadingBox" + element-loading-spinner="el-icon-loading" + element-loading-background="rgba(0, 0, 0, 0)" + > + <div class="richTextInitBox" v-if="AIReading" v-html="AIReading"></div> + <div class="richTextInitError" v-else>缃戠粶绻佸繖锛岃绋嶅悗鍐嶈瘯銆�</div> + </div> </el-dialog> </div> </template> @@ -101,6 +197,9 @@ export default { data() { return { + dialogVisibleAI: false, + aIName: "", + AIReading: "", observer: null, pdfName: "", dialogVisible: false, @@ -165,62 +264,61 @@ if (this.details.keyWords && this.details.keyWords.length) { for (let i = 0; i < this.details.keyWords.length; i++) { const item = this.details.keyWords[i]; - this.inputValue = item - this.inputType = "keyWords" - await this.getItemListOne() + this.inputValue = item; + this.inputType = "keyWords"; + await this.getItemListOne(); } this.loading = false; console.log(this.resultList, "澶勭悊濂界殑"); } else { - this.getItemList() + this.getItemList(); } if (this.resultList.length == 0) { - this.getItemList() + this.getItemList(); } //澶勭悊鏂囦欢 - if (this.details.cmsItemType == "video" || this.details.cmsItemType == "audio") { + if ( + this.details.cmsItemType == "video" || + this.details.cmsItemType == "audio" + ) { if (this.details.file != "") { - this.details.src = await this.getResourcePath(this.details.file) + this.details.src = await this.getResourcePath(this.details.file); console.log(this.details.src, "瑙嗛鍦板潃"); } } - - - this.observer = new IntersectionObserver(this.pageChangeCallback, { root: null, // 鎸囧畾鏍瑰厓绱狅紝杩欓噷璁句负 null锛岃〃绀洪�夊彇鏁翠釜瑙嗙獥浣滀负鏍瑰厓绱犮�� - rootMargin: '0px', // 鎸囧畾鏍瑰厓绱犵殑杈圭晫锛岃繖閲岃涓� "0px"锛岃〃绀烘牴鍏冪礌鐨勮竟鐣屽拰瑙嗙獥鐨勮竟鐣岄噸鍚� - threshold: 0.1 // 鎸囧畾浜ゅ弶姣斾緥锛岃繖閲岃涓� 0.5锛岃〃绀哄綋鐩爣鍏冪礌涓�鍗婃垨鏇村鏄剧ず鍦ㄨ绐椾腑鏃惰Е鍙戝洖璋冨嚱鏁般�� - }) + rootMargin: "0px", // 鎸囧畾鏍瑰厓绱犵殑杈圭晫锛岃繖閲岃涓� "0px"锛岃〃绀烘牴鍏冪礌鐨勮竟鐣屽拰瑙嗙獥鐨勮竟鐣岄噸鍚� + threshold: 0.1, // 鎸囧畾浜ゅ弶姣斾緥锛岃繖閲岃涓� 0.5锛岃〃绀哄綋鐩爣鍏冪礌涓�鍗婃垨鏇村鏄剧ず鍦ㄨ绐椾腑鏃惰Е鍙戝洖璋冨嚱鏁般�� + }); }, methods: { // 鏍规嵁id璇锋眰璇ラ〉闈㈡暟鎹� async getContent(id) { this.loading = true; - const res = await MG.resource - .getItem({ - path: "*", - queryType: "*", - fields: { - cmsType: ["cmsItem"], - "Id=": [id + ""], - source: [], - isbn: [], - year: [], - abstract: [], - keyWords: [], - author: [], - DOI: [], - AIReading: [], - file: [], - IssueNumber: [], - }, - }) + const res = await MG.resource.getItem({ + path: "*", + queryType: "*", + fields: { + cmsType: ["cmsItem"], + "Id=": [id + ""], + source: [], + isbn: [], + year: [], + abstract: [], + keyWords: [], + author: [], + DOI: [], + AIReading: [], + file: [], + IssueNumber: [], + }, + }); res.datas.forEach((item) => { - item.year = moment(item.year).format("YYYY-MM-DD") - if (typeof item.keyWords === 'string') { + item.year = moment(item.year).format("YYYY-MM-DD"); + if (typeof item.keyWords === "string") { item.keyWords = item.keyWords.split(";;"); } else { // 璁剧疆涓�涓粯璁ゅ�兼垨鑰呰繘琛屽叾浠栭敊璇鐞� @@ -233,10 +331,12 @@ item.cleanAbstract = item.abstract.replace(/<[^>]+>/g, ""); } - const foundItem = this.category.list.find((citem) => citem.value == item.cmsItemType); - item.resourceTypeName = foundItem ? foundItem.name : ''; - }) - this.details = res.datas[0] + const foundItem = this.category.list.find( + (citem) => citem.value == item.cmsItemType + ); + item.resourceTypeName = foundItem ? foundItem.name : ""; + }); + this.details = res.datas[0]; }, // 鍦ㄦ鐐瑰嚮璇︽儏 @@ -248,30 +348,33 @@ if (this.details.keyWords && this.details.keyWords.length) { for (let i = 0; i < this.details.keyWords.length; i++) { const item = this.details.keyWords[i]; - this.inputValue = item - this.inputType = "keyWords" - this.getItemListOne() + this.inputValue = item; + this.inputType = "keyWords"; + this.getItemListOne(); } } else { - this.getItemList() + this.getItemList(); } if (this.resultList.length == 0) { - this.getItemList() + this.getItemList(); } //澶勭悊鏂囦欢 - if (this.details.cmsItemType == "video" || this.details.cmsItemType == "audio") { + if ( + this.details.cmsItemType == "video" || + this.details.cmsItemType == "audio" + ) { if (this.details.file != "") { - this.details.src = await this.getResourcePath(this.details.file) + this.details.src = await this.getResourcePath(this.details.file); } } // 婊氬姩鍒伴〉闈㈤《閮� this.$nextTick(() => { - const pageMain = document.querySelector('.page-main-father'); + const pageMain = document.querySelector(".page-main-father"); if (pageMain) { pageMain.scrollTo({ top: 0, - behavior: 'smooth' + behavior: "smooth", }); } }); @@ -308,42 +411,48 @@ // 鑾峰彇鐩稿叧璧勬簮 async getPDFInfo(md5) { const res = await this.MG.file.getPdfInfo({ - md5 - }) - if (!res || !res.totalPages) return (this.pdfList = []) + md5, + }); + if (!res || !res.totalPages) return (this.pdfList = []); for (let index = 0; index < res.totalPages; index++) { const src = - requestCtx + '/file/GetPdfPageImage?md5=' + md5 + '&index=' + (index + 1) + '&dpi=300' + '&width=800' + requestCtx + + "/file/GetPdfPageImage?md5=" + + md5 + + "&index=" + + (index + 1) + + "&dpi=300" + + "&width=800"; this.pdfList.push({ src, - showSrc: '' - }) + showSrc: "", + }); } this.pdfLoading = false; // 鍚姩椤电爜瑙傚療 setTimeout(() => { - this.initObservation() - }, 500) + this.initObservation(); + }, 500); }, initObservation() { - const sections = document.querySelectorAll('.pdfItem') + const sections = document.querySelectorAll(".pdfItem"); sections.forEach((section) => { // observer 瑙傚療姣忎釜鍏冪礌锛屼互渚垮湪瀹冧滑杩涘叆鎴栫寮�瑙嗙獥鏃惰Е鍙戝洖璋冨嚱鏁般�� - const isObserver = section.getAttribute('observer') + const isObserver = section.getAttribute("observer"); if (!isObserver) { - this.observer.observe(section) + this.observer.observe(section); - section.setAttribute('observer', '1') + section.setAttribute("observer", "1"); } - }) + }); // 棰勫姞杞藉墠鍑犻〉璧勬簮 - const preloadPages = 3 + const preloadPages = 3; for (let i = 0; i < Math.min(preloadPages, sections.length); i++) { - const section = sections[i] - const page = section.getAttribute('page') - if (this.pdfList[page - 1].showSrc == '') { - this.pdfList[page - 1].showSrc = this.pdfList[page - 1].src + const section = sections[i]; + const page = section.getAttribute("page"); + if (this.pdfList[page - 1].showSrc == "") { + this.pdfList[page - 1].showSrc = this.pdfList[page - 1].src; } } }, @@ -353,17 +462,15 @@ entries.forEach((entry) => { //entry.isIntersecting锛氭鏌ュ綋鍓嶇洰鏍囧厓绱犳槸鍚︿笌鏍瑰厓绱犵浉浜ゃ�� if (entry.isIntersecting) { - const target = entry.target + const target = entry.target; //entry.target锛氳幏鍙栧綋鍓嶇洰鏍囧厓绱� - const page = target.getAttribute('page') - if (this.pdfList[page - 1].showSrc == '') { - this.pdfList[page - 1].showSrc = this.pdfList[page - 1].src + const page = target.getAttribute("page"); + if (this.pdfList[page - 1].showSrc == "") { + this.pdfList[page - 1].showSrc = this.pdfList[page - 1].src; } } - }) + }); }, - - //鑾峰彇涓嬫媺閫夋嫨妗嗙殑鍐呭 async getSelectData() { @@ -375,10 +482,9 @@ this.category.list = resourceListResult.option; if (this.category.list && this.category.list.length) { this.category.list.forEach((item) => { - this.resourceTypeValueList.push(item.value) + this.resourceTypeValueList.push(item.value); }); } - } catch (error) { console.error("鑾峰彇涓嬫媺妗嗘暟鎹け璐�:", error); } @@ -392,7 +498,8 @@ .then((res) => { const selestList = JSON.parse(res[0].config); return selestList; - }).catch((error) => { + }) + .catch((error) => { console.error("鑾峰彇閫夋嫨鍐呭澶辫触:", error); return null; }); @@ -401,19 +508,25 @@ // 澶嶅埗涓�浠� async getItemListOne() { let searchData = {}; // 鍒濆鍖栦竴涓┖瀵硅薄鏉ュ瓨鍌ㄦ悳绱㈡暟鎹� - if (this.inputValue) { // 濡傛灉杈撳叆鍊煎瓨鍦� - if (this.inputType != "all") { // 濡傛灉杈撳叆绫诲瀷涓嶆槸"all" + if (this.inputValue) { + // 濡傛灉杈撳叆鍊煎瓨鍦� + if (this.inputType != "all") { + // 濡傛灉杈撳叆绫诲瀷涓嶆槸"all" // 灏嗚緭鍏ュ�间笌杈撳叆绫诲瀷鍏宠仈锛屽苟娣诲姞涓�涓槦鍙�(*)浣滀负鍚庣紑 searchData[this.inputType + "*"] = this.inputValue; - } else { // 濡傛灉杈撳叆绫诲瀷鏄�"all" + } else { + // 濡傛灉杈撳叆绫诲瀷鏄�"all" // 閬嶅巻杈撳叆閫夐」 for (let index = 0; index < this.inputOptions.length; index++) { const item = this.inputOptions[index]; // 鑾峰彇褰撳墠閫夐」 - if (item.value !== "all") { // 濡傛灉褰撳墠閫夐」鐨勫�间笉鏄�"all" - if (!Object.keys(searchData).length) { // 濡傛灉searchData鏄┖鐨� + if (item.value !== "all") { + // 濡傛灉褰撳墠閫夐」鐨勫�间笉鏄�"all" + if (!Object.keys(searchData).length) { + // 濡傛灉searchData鏄┖鐨� // 灏嗙涓�涓�夐」鐨勫�间笌杈撳叆鍊煎叧鑱旓紝骞舵坊鍔犱竴涓槦鍙�(*)浣滀负鍚庣紑 searchData[item.value + "*"] = this.inputValue; - } else { // 濡傛灉searchData涓嶆槸绌虹殑 + } else { + // 濡傛灉searchData涓嶆槸绌虹殑 // 浣跨敤"||"浣滀负鍓嶇紑锛屽皢鍚庣画閫夐」鐨勫�间笌杈撳叆鍊煎叧鑱旓紝骞舵坊鍔犱竴涓槦鍙�(*)浣滀负鍚庣紑 // 杩欓�氬父鐢ㄤ簬鏋勫缓涓�涓�昏緫鎴栵紙OR锛夋煡璇� searchData["||" + item.value + "*"] = this.inputValue; @@ -422,33 +535,32 @@ } } } - const res = await MG.resource - .getItem({ - path: "*", - queryType: "*", - paging: { - size: 99999 - }, - fields: { - cmsType: ["cmsItem"], - // 'id=':[this.$route.params.key], - "resourceType*": this.resourceTypeValueList, - source: [], - isbn: [], - year: [], - abstract: [], - keyWords: [], - author: [], - DOI: [], - AIReading: [], - file: [], - IssueNumber: [], - ...searchData, - }, - }) + const res = await MG.resource.getItem({ + path: "*", + queryType: "*", + paging: { + size: 99999, + }, + fields: { + cmsType: ["cmsItem"], + // 'id=':[this.$route.params.key], + "resourceType*": this.resourceTypeValueList, + source: [], + isbn: [], + year: [], + abstract: [], + keyWords: [], + author: [], + DOI: [], + AIReading: [], + file: [], + IssueNumber: [], + ...searchData, + }, + }); res.datas.forEach((item) => { - item.year = moment(item.year).format("YYYY-MM-DD") - if (typeof item.keyWords === 'string') { + item.year = moment(item.year).format("YYYY-MM-DD"); + if (typeof item.keyWords === "string") { item.keyWords = item.keyWords.split(";;"); } else { // 璁剧疆涓�涓粯璁ゅ�兼垨鑰呰繘琛屽叾浠栭敊璇鐞� @@ -457,11 +569,17 @@ if (item.abstract) { item.cleanAbstract = item.abstract.replace(/<[^>]+>/g, ""); } - const foundItem = this.category.list.find((citem) => citem.value == item.cmsItemType); - item.resourceTypeName = foundItem ? foundItem.name : ''; + const foundItem = this.category.list.find( + (citem) => citem.value == item.cmsItemType + ); + item.resourceTypeName = foundItem ? foundItem.name : ""; console.log(this.details.id, ""); - if (!this.resultList.find(citem => citem.id === item.id) && item.id != this.details.id && this.resultList.length < 11) { + if ( + !this.resultList.find((citem) => citem.id === item.id) && + item.id != this.details.id && + this.resultList.length < 11 + ) { this.resultList.push(item); } }); @@ -469,7 +587,7 @@ async openPdf(name) { this.pdfLoading = true; - this.pdfList = [] + this.pdfList = []; this.pdfName = name; this.dialogVisible = true; await this.getPDFInfo(this.details.file); @@ -482,7 +600,7 @@ path: "*", queryType: "*", paging: { - size: 5 + size: 5, }, fields: { cmsType: ["cmsItem"], @@ -501,8 +619,8 @@ }) .then((res) => { res.datas.forEach((item) => { - item.year = moment(item.year).format("YYYY-MM-DD") - if (typeof item.keyWords === 'string') { + item.year = moment(item.year).format("YYYY-MM-DD"); + if (typeof item.keyWords === "string") { item.keyWords = item.keyWords.split(";;"); } else { // 璁剧疆涓�涓粯璁ゅ�兼垨鑰呰繘琛屽叾浠栭敊璇鐞� @@ -511,12 +629,16 @@ if (item.abstract) { item.cleanAbstract = item.abstract.replace(/<[^>]+>/g, ""); } - const foundItem = this.category.list.find((citem) => citem.value == item.cmsItemType); - item.resourceTypeName = foundItem ? foundItem.name : ''; - }) - this.resultList = res.datas + const foundItem = this.category.list.find( + (citem) => citem.value == item.cmsItemType + ); + item.resourceTypeName = foundItem ? foundItem.name : ""; + }); + this.resultList = res.datas; + this.loading = false; - }).catch((err) => { + }) + .catch((err) => { console.log("鏇挎崲鏁版嵁璇锋眰澶辫触"); }); }, @@ -524,13 +646,19 @@ //鍘婚噸 uniqueById(array) { const uniqueItems = new Map(); - array.forEach(item => { + array.forEach((item) => { if (!uniqueItems.has(item.id)) { uniqueItems.set(item.id, item); } }); return Array.from(uniqueItems.values()); - } + }, + + openAiReading(text, name) { + this.AIReading = text; + this.aIName = name; + this.dialogVisibleAI = true; + }, }, }; </script> @@ -578,7 +706,6 @@ padding-top: 2%; padding-bottom: 2%; } - .page-main { background-color: #fcfaf3; @@ -699,7 +826,6 @@ font-size: 14px; color: #333333; } - } p:nth-child(3) { @@ -743,7 +869,8 @@ display: flex; justify-content: center; - audio {} + audio { + } } .page-main-literature { @@ -818,11 +945,15 @@ } } - .right-main { margin-bottom: 20px; padding: 19px 30px 15px 30px; border: 1px solid #decaac; + + &:hover { + cursor: pointer; + border: 1px solid #937950; + } .main-name { display: flex; @@ -854,7 +985,6 @@ background-color: #87a8b9; color: #fff; margin-right: 10px; - } span:nth-child(2) { @@ -863,7 +993,6 @@ font-weight: 350; padding-right: 10px; color: #333; - } span:nth-child(3) { @@ -931,7 +1060,6 @@ } .keyWord { - padding: 5px 10px; color: #937950; border: 1px solid #937950; @@ -947,7 +1075,6 @@ } } - .pdfInfoBox { height: 85vh; margin-top: 20px; @@ -961,6 +1088,23 @@ box-shadow: 0px 0px 10px 1px rgba(0, 0, 0, 0.1); object-fit: contain; } +} + +.AIReadingBox { + height: 85vh; + min-height: 600px; + padding: 20px 10px; +} + +.richTextInitBox { + height: 100%; + overflow: auto; +} +.richTextInitError { + height: 100%; + display: flex; + align-items: center; + justify-content: center; } ::v-deep .el-loading-spinner { @@ -1000,7 +1144,6 @@ } } - .el-dialog__title, .el-dialog__headerbtn .el-dialog__close { color: #fff; @@ -1009,4 +1152,4 @@ } } } -</style> \ No newline at end of file +</style> -- Gitblit v1.9.1