Просмотр исходного кода

merge feature/1002473 into main

merge "feature/1002473" into "main"
1002473

Created-by: lizi
Author-id: 7030146
MR-id: 7048
Commit-by: lizi
Merged-by: Kevin
Description: merge "feature/1002473" into "main"
1002473

See merge request: zhcqdn00001/front!43
Kevin лет назад: 2
Родитель
Сommit
9dbfc9bab7

+ 11 - 0
src/client/searchHistory.client.ts

@@ -0,0 +1,11 @@
+import httpClient from "@/services/httpClient";
+import type { Response } from "@/types/response.types";
+import * as urlHelper from "@/libs/url.lib"
+import type { HotKeyword } from "@/types/searchHistory.types";
+
+const _url = urlHelper.withPrefix("/gw/user/searchHistory");
+
+export async function getHoyKeyword(size: number): Promise<HotKeyword[]> {
+  const resp = await httpClient.get<Response<HotKeyword[]>>(_url(`/getHotKeyword?size=${size}`))
+  return resp.data.data
+}

+ 6 - 0
src/services/searchHistory.service.ts

@@ -0,0 +1,6 @@
+import * as SearchHistoryClient from "@/client/SearchHistory.client"
+import type { HotKeyword } from "@/types/searchHistory.types";
+
+export async function getHoyKeyword(size: number): Promise<HotKeyword[]> {
+  return SearchHistoryClient.getHoyKeyword(size)
+}

+ 4 - 0
src/types/searchHistory.types.ts

@@ -0,0 +1,4 @@
+export interface HotKeyword {
+  expression: String;
+  conut: number;
+}

+ 39 - 2
src/views/search/SearchView.vue

@@ -1,12 +1,15 @@
 <script setup lang="ts">
 import { message, type SelectProps } from "ant-design-vue";
-import { ref, watch } from "vue";
+import { ref, watch, onMounted } from "vue";
 import { routeToSearch } from "@/router";
+import * as searchHistoryService from "@/services/searchHistory.service"
 
 const keyword = ref("");
 
 const field = ref("TP");
-const placeholder = ref("请输入文献主题") 
+const placeholder = ref("请输入文献主题")
+
+const hotWords = ref(['建筑工程','工程设计','BIM'])
 
 const onSearch = () => {
   const kwd = keyword.value.trim();
@@ -42,6 +45,27 @@ watch(field, (newValue) => {
   }
 });
 
+onMounted(() => {
+  searchHistoryService.getHoyKeyword(5).then((resp) => {
+    const words: any = resp;
+    for (let item of words) {
+        var expression = item.expression;
+        var _expression = expression.match(/\((.+)\)/g); 
+        var index = hotWords.value.indexOf(RegExp.$1); 
+        
+        if (hotWords.value.length == 5) {
+            break;
+        }
+
+        if (index == -1) {
+          hotWords.value.push(RegExp.$1)
+        }
+    }
+  })
+  
+
+})
+
 
 </script>
 
@@ -69,6 +93,13 @@ watch(field, (newValue) => {
         />
       </a-col>
     </a-row>
+    <a-row class="search-hotword">
+      热门关键词:
+      <span v-for="item in hotWords">
+        {{item}}&nbsp;&nbsp;
+      </span>
+
+    </a-row>
   </div>
 </template>
 
@@ -83,5 +114,11 @@ watch(field, (newValue) => {
     text-align: center;
   }
 
+  .search-hotword{
+    margin-top: 30px;
+    > sapn{
+      magin-left: 20px;
+    }
+  }
 }
 </style>