From d7807870c5baf48b644c34f207039702f3656d0a Mon Sep 17 00:00:00 2001
From: XiaoMo <a1300399510@qq.com>
Date: Thu, 6 Apr 2023 12:20:11 +0800
Subject: [PATCH] =?UTF-8?q?a1300399510@qq.com=20=E6=8F=90=E4=BA=A4?=
 =?UTF-8?q?=E4=BA=8E=202023/04/06=20-12:20:01?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 src/components/SearchBox.vue                  | 19 +++++++++++++------
 .../search/searchResult/SearchResult.vue      | 15 +++++++++++++--
 2 files changed, 26 insertions(+), 8 deletions(-)

diff --git a/src/components/SearchBox.vue b/src/components/SearchBox.vue
index 8c121fb..5599c8b 100755
--- a/src/components/SearchBox.vue
+++ b/src/components/SearchBox.vue
@@ -18,19 +18,18 @@
 				<div class="search-close" @click="searchClose()">取消</div>
 			</div>
 			<!-- 历史搜索 -->
-			<div class="search-content flexcolumn">
+			<div class="search-content flexcolumn" v-if="historicalSearch.length != 0">
 				<div class="search-text">历史搜索</div>
 				<div class="search-label">
-					<span>香港大学</span>
-					<span>香港大学</span>
-					<span>香港大学</span>
+					<span v-for="(item, index) in  historicalSearch" :key="index">香港大学</span>
 				</div>
 			</div>
 			<!-- 热门搜索 -->
 			<div class="search-content">
 				<div class="search-text">热门搜索</div>
 				<div class="search-label">
-					<span v-for="(item, index) in hotSearchkeywords" :key="index" @click="toSearchResult(item)">{{ item }}</span>
+					<span v-for="(item, index) in hotSearchkeywords" :key="index" @click="toSearchResult(item)">{{ item
+					}}</span>
 				</div>
 			</div>
 		</div>
@@ -45,10 +44,18 @@ export default {
 			searchWinShow: false,//显示搜索弹窗
 			searchText: '',
 			showClear: false, //显示清除按钮
+			historicalSearch: [], // 历史搜索
 		}
 	},
 	props: ["issearch", "hotSearchkeywords"],
 
+	mounted() {
+		let hotSearchkeywords = ["香港大学","香港大学"]
+		var cachedData = localStorage.setItem('hotSearchkeywords',[]) || [];
+
+		// var cachedData = localStorage.getItem('hotSearchkeywords') || [];
+	},
+
 	methods: {
 		collapseClick() {
 			if (this.collapseShow == true) this.collapseShow = false;
@@ -75,7 +82,7 @@ export default {
 		},
 
 		// 跳转搜索结果
-		toSearchResult(kw){
+		toSearchResult(kw) {
 			this.$router.push(`/searchResult?kw=${kw}`)
 		},
 	},
diff --git a/src/views/search/searchResult/SearchResult.vue b/src/views/search/searchResult/SearchResult.vue
index c3efbf8..83c8dc6 100755
--- a/src/views/search/searchResult/SearchResult.vue
+++ b/src/views/search/searchResult/SearchResult.vue
@@ -109,17 +109,24 @@ export default {
 		getSearchResult() {
 			if (this.searchResultState) return
 			this.searchResultState = true
+			let kw = this.kw
 			this.$http.post("/api/search", {
-				keyword: this.kw,
+				keyword: kw,
 				page: this.page,
 				limit: this.limit
 			}).then(res => {
 				let data = res.data
 
-				console.log(data.data);
+				// console.log(data.data);
+				// console.log(kw);
+				// data.data.forEach(el => {
+				// 	console.log(el.subject);
+				// })
+
 				this.list = data.data
 				this.count = data.count
 				this.limit = data.limit
+
 				document.documentElement.scrollTop = 0;
 				document.body.scrollTop = 0;
 				this.searchResultState = false
@@ -236,6 +243,10 @@ export default {
 					font-size: 0.37333rem;
 					line-height: 0.65rem;
 					display: inline;
+
+					/deep/ em {
+						color: #F95D5D;
+					}
 				}
 
 			}