From fd82e68712135fb4589b0586c26d8ea0865766e5 Mon Sep 17 00:00:00 2001 From: zhongshujie <2862698242@qq.com> Date: 星期一, 28 四月 2025 16:21:55 +0800 Subject: [PATCH] 搜索优化 --- src/views/chronology/index.vue | 139 ++++++++++++--------------------------------- 1 files changed, 38 insertions(+), 101 deletions(-) diff --git a/src/views/chronology/index.vue b/src/views/chronology/index.vue index ba47e3f..3165ba5 100644 --- a/src/views/chronology/index.vue +++ b/src/views/chronology/index.vue @@ -49,14 +49,10 @@ class="gradchild" v-for="(citem, cindex) in item.list" :style="{ background: citem.color }" - @click.self="showDetail(index, cindex, 1, $event)" + @click.stop="showDetail(index, cindex, 1, $event)" :key="cindex" > - <div - class="detailDialog" - :style="popupStyle" - v-if="citem.showChildDetail" - > + <div class="detailDialog" v-if="citem.showDetail"> <div class="closeBtn" @click.stop="closeDetail(index, cindex, 0)" @@ -95,9 +91,7 @@ import moment from "moment"; import floatingWindow from "./floatingWindow.vue"; import yearWindow from "./yearWindow.vue"; -import { nextTick } from "vue"; -import fileApi from "@/assets/js/middleGround/api/file"; -import { requestCtx, appRefCode } from "@/assets/js/config"; + export default { components: { floatingWindow, @@ -115,10 +109,6 @@ audio: "#b9a587", newspaper: "#8d77b3", other: "#009f9f", - }, - popupStyle: { - left: "0", - top: "0", }, }; }, @@ -159,21 +149,17 @@ }, }) .then(async (res) => { - console.log(res, "res"); for (let i = 0; i < res.datas.length; i++) { const item = res.datas[i]; this.$set(item, "showDetail", false); const listData = await this.getYearResource(item); if (listData.length > 0) { this.$set(item, "list", listData); - for (let j = 0; j < listData.length; j++) { - const element = listData[j]; - this.$set(element, "showChildDetail", false); - } console.log(item, "item"); } } + console.log(this.contentList, "this.contentList"); this.contentList = res.datas; this.showList = true; }); @@ -206,12 +192,13 @@ const filterList = yearDataList.datas.filter((item) => { return item.cmsItemType != "chronology" && item.cmsItemType != "AWARD"; }); + if (filterList && filterList.length > 0) { for (let i = 0; i < filterList.length; i++) { const item = filterList[i]; if (item.file) { - const requestCtx = await this.getResourcePath(item.file); - console.log(requestCtx, "requestCtx"); + const requestCtx = + this.config.requestCtx + `/file/api/ApiDownload?md5=${item.file}`; this.$set(item, "fileLink", requestCtx); } this.$set(item, "showDetail", false); @@ -224,79 +211,35 @@ } return filterList; }, - - // 鑾峰彇闃块噷浜戝姞閫熷湴鍧� (瑙嗛锛岄煶棰�) - async getResourcePath(md5) { - try { - // 濡傛灉杩斿洖鐨勬暟鎹负绌烘垨鏈畾涔夛紝鍒欐嫾鎺ラ粯璁や笅杞借矾寰� - return requestCtx + "/file/api/ApiDownload?md5=" + md5; - } catch (error) { - // 鎹曡幏寮傚父骞舵墦鍗伴敊璇棩蹇� - console.error("鑾峰彇璧勬簮璺緞澶辫触:", error); - // 杩斿洖涓�涓粯璁ゅ�兼垨鎶涘嚭閿欒锛堟牴鎹笟鍔¢渶姹傦級 - return requestCtx + "/file/api/ApiDownload?md5=" + md5; - } - }, - closeDetail(index, cindex, type) { for (let i = 0; i < this.contentList.length; i++) { const item = this.contentList[i]; - if (item && item.list?.length > 0) { + if (item && item.length > 0) { for (let j = 0; j < item.list.length; j++) { const citem = item.list[j]; - this.$set(citem, "showChildDetail", false); + this.$set(citem, "showDetail", false); } } } this.contentList[index].list[cindex].showDetail = false; - - console.log( - this.contentList[index].list, - "this.contentList[index].list[cindex]" - ); }, showDetail(index, cindex, type, event) { - const rect = event.target.getBoundingClientRect(); - const screenWidth = window.innerWidth; - const popupWidth = 542; // 鍋囪寮规瀹藉害涓�200px - // 鍒ゆ柇瑙﹀彂鍏冪礌浣嶇疆 - if (rect.left + rect.width / 2 < screenWidth / 2) { - // 宸︿晶鏄剧ず寮规鍦ㄥ彸渚� - this.popupStyle = { - left: `${rect.right}px`, - top: `${rect.bottom - 150}px`, - }; - } else { - // 鍙充晶鏄剧ず寮规鍦ㄥ乏渚� - this.popupStyle = { - left: `${rect.left - popupWidth}px`, - top: `${rect.bottom - 150}px`, - }; - } - console.log(this.popupStyle.top, "this.top"); - console.log(this.popupStyle.left, "this.left"); - // if (rect.left - popupWidth < 0) { - // // 宸︿晶绌洪棿涓嶈冻鏃跺己鍒跺彸渚ф樉绀� - // this.popupStyle.left = `${rect.right}px`; - // } else if (rect.right + popupWidth > screenWidth) { - // // 鍙充晶绌洪棿涓嶈冻鏃跺己鍒跺乏渚ф樉绀� - // this.popupStyle.left = `${rect.left - popupWidth}px`; - // } + console.log(event, "event"); for (let i = 0; i < this.contentList.length; i++) { const item = this.contentList[i]; - if (item && item.list?.length > 0) { + if (item && item.length > 0) { for (let j = 0; j < item.list.length; j++) { const citem = item.list[j]; - if (citem.showChildDetail) { - this.contentList[i].list[j].showDetail = false; - citem.showChildDetail = false; - } + this.$set(citem, "showDetail", false); + item.showDetail = false; } } } + if (this.contentList[index].list[cindex].type) { - this.contentList[index].list[cindex].showChildDetail = true; + this.contentList[index].list[cindex].showDetail = true; } + console.log(this.contentList[index].list, "this.contentList[index].list[cindex]"); }, }, }; @@ -311,7 +254,6 @@ display: flex; flex-direction: column; overflow: auto; - font-family: Source Han Sans; } .pageBox { @@ -422,18 +364,13 @@ position: relative; } -// .gradchild :hover { -// transform: scale(1.1); -// z-index: 999; -// } - -/* 閲嶇疆瀛愬厓绱犵殑鏍峰紡 */ -// .gradchild:hover .detailDialog { -// transform: scale(1); -// z-index: 999; -// } -.item-circle :hover ::before { - background-color: #b9a587 !important; +.gradchild:hover { + width: 25px; + height: 25px; + margin-top: 2px; + margin-right: 2px; + cursor: pointer; + position: relative; } .item-circle { width: 100%; @@ -476,7 +413,10 @@ align-items: center; } .detailDialog { - position: fixed; + position: absolute; + top: -700%; + transform: translateY(20%); + transform: translateX(-50%); width: 524px; z-index: 9999; cursor: pointer; @@ -484,11 +424,7 @@ border: 2px solid #cbbeaa; box-shadow: 2px 2px 4px 1px rgba(0, 0, 0, 0.5); } -video { - border-radius: 10px; - border: 1px solid #dcdcdc; - box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.1); -} + .yaerWindow { position: absolute; left: -54px; @@ -500,15 +436,15 @@ border: 2px solid #cbbeaa; box-shadow: 2px 2px 4px 1px rgba(0, 0, 0, 0.5); } -// .detailDialog .dialogContent { -// width: 100%; -// height: 100%; -// background-color: #fff; -// position: relative; -// padding: 5px; -// z-index: 20; -// box-sizing: border-box; -// } +.detailDialog .dialogContent { + width: 100%; + height: 100%; + background-color: #fff; + position: relative; + padding: 5px; + z-index: 20; + box-sizing: border-box; +} .closeBtn { position: absolute; width: 20px; @@ -529,4 +465,5 @@ color: #937950; } } + </style> -- Gitblit v1.9.1