|
|
@@ -1,8 +1,11 @@
|
|
|
<script setup lang="ts">
|
|
|
import { message, type SelectProps } from "ant-design-vue";
|
|
|
-import { ref, watch, onMounted } from "vue";
|
|
|
+import { ref, watch, onMounted, h } from "vue";
|
|
|
import { routeToSearch } from "@/router";
|
|
|
import * as searchHistoryService from "@/services/searchHistory.service"
|
|
|
+import * as searchService from "@/services/search.service"
|
|
|
+import { LoadingOutlined } from '@ant-design/icons-vue';
|
|
|
+import SearchResultItem from "./components/SearchResultItem.vue";
|
|
|
|
|
|
const keyword = ref("");
|
|
|
|
|
|
@@ -10,6 +13,8 @@ const field = ref("TP");
|
|
|
const placeholder = ref("请输入文献主题")
|
|
|
|
|
|
const hotWords = ref(['建筑工程','工程设计','BIM'])
|
|
|
+const spinning = ref(true);
|
|
|
+const searchResult: any = ref(null)
|
|
|
|
|
|
const onSearch = () => {
|
|
|
const kwd = keyword.value.trim();
|
|
|
@@ -46,27 +51,52 @@ watch(field, (newValue) => {
|
|
|
});
|
|
|
|
|
|
onMounted(() => {
|
|
|
- searchHistoryService.getHoyKeyword(5).then((resp) => {
|
|
|
+ getHoyKeyword(5);
|
|
|
+ recommendsearch();
|
|
|
+})
|
|
|
+
|
|
|
+function getHoyKeyword(size: number){
|
|
|
+ searchHistoryService.getHoyKeyword(size).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);
|
|
|
+ var _expression = expression.match(/\((.+)\)/g);
|
|
|
+ var $1 = RegExp.$1
|
|
|
+ var index = hotWords.value.indexOf($1);
|
|
|
|
|
|
if (hotWords.value.length == 5) {
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
if (index == -1) {
|
|
|
- hotWords.value.push(RegExp.$1)
|
|
|
+ if ($1.length > 1) {
|
|
|
+ hotWords.value.push($1)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
-
|
|
|
+}
|
|
|
|
|
|
-})
|
|
|
+function recommendsearch() {
|
|
|
+ spinning.value = true;
|
|
|
+ const fullYear = new Date().getFullYear();
|
|
|
+ let request = {
|
|
|
+ from: 0,
|
|
|
+ size: 10,
|
|
|
+ sort: {cited: "desc"},
|
|
|
+ filter: " PY=("+fullYear+" "+ (fullYear - 2)+ " "+(fullYear - 1)+")"
|
|
|
+ }
|
|
|
|
|
|
+ searchService.search(request).then((resp) => {
|
|
|
+ searchResult.value = resp
|
|
|
+ spinning.value = false;
|
|
|
+ })
|
|
|
+}
|
|
|
|
|
|
+function search(kwd: string){
|
|
|
+ routeToSearch({ type: 'simple', kw: kwd, field: 'TP' });
|
|
|
+}
|
|
|
+
|
|
|
</script>
|
|
|
|
|
|
<template>
|
|
|
@@ -95,10 +125,17 @@ onMounted(() => {
|
|
|
</a-row>
|
|
|
<a-row class="search-hotword">
|
|
|
热门关键词:
|
|
|
- <span v-for="item in hotWords">
|
|
|
- {{item}}
|
|
|
+ <span v-for="item in hotWords" @click="search(item)" style="cursor: pointer;">
|
|
|
+ {{item}}
|
|
|
</span>
|
|
|
-
|
|
|
+ </a-row>
|
|
|
+ <a-row type="flex" class="search-result">
|
|
|
+ <a-spin :spinning="spinning" :indicator="h(LoadingOutlined, { style: { fontSize: '24px', }, spin: true, })">
|
|
|
+ 最新文献推荐
|
|
|
+ <div v-for="(doc, index) in searchResult.docs" :key="index" v-if="searchResult" class="search-result-content">
|
|
|
+ <SearchResultItem :data="doc"/>
|
|
|
+ </div>
|
|
|
+ </a-spin>
|
|
|
</a-row>
|
|
|
</div>
|
|
|
</template>
|
|
|
@@ -120,5 +157,15 @@ onMounted(() => {
|
|
|
magin-left: 20px;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ .search-result{
|
|
|
+ margin-top: 30px;
|
|
|
+ }
|
|
|
+ .search-result-content {
|
|
|
+ > div {
|
|
|
+ border: 1px gray solid;
|
|
|
+ margin-bottom: 8px;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
</style>
|