|
|
@@ -1,9 +1,10 @@
|
|
|
<script setup lang="ts">
|
|
|
-import type { PropType } from "vue";
|
|
|
+// import type { PropType } from "vue";
|
|
|
import type { SearchResultDoc } from "@/types/search.types";
|
|
|
import type { ResultMode } from "@/types/search.types";
|
|
|
+import { type PropType, onMounted } from "vue"
|
|
|
|
|
|
-defineProps({
|
|
|
+const props = defineProps({
|
|
|
data: {
|
|
|
type: Object as PropType<SearchResultDoc>,
|
|
|
required: true,
|
|
|
@@ -21,6 +22,24 @@ function getAuthorAndUnit(scholar_name: string, unit_name: string) {
|
|
|
}
|
|
|
return str
|
|
|
}
|
|
|
+
|
|
|
+function highlight(name: string, content: string){
|
|
|
+ if (props.data.highlight) {
|
|
|
+ let highlight = JSON.parse(JSON.stringify(props.data.highlight));
|
|
|
+ let reg = new RegExp('<em>(.*?)<\\/em>', 'g')
|
|
|
+ let hlTitles: string[] = []
|
|
|
+ let hlTitleOrigins: string[] = []
|
|
|
+ console.log(highlight,"highlight")
|
|
|
+ if (highlight) {
|
|
|
+ hlTitles = highlight[name] || highlight[name+'.exact']
|
|
|
+ for (let index in hlTitles) {
|
|
|
+ hlTitleOrigins[index] = hlTitles[index].replace(reg, '$1')
|
|
|
+ content = content.replace(hlTitleOrigins[index], hlTitles[index])
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return content;
|
|
|
+}
|
|
|
</script>
|
|
|
|
|
|
<template>
|
|
|
@@ -37,23 +56,23 @@ function getAuthorAndUnit(scholar_name: string, unit_name: string) {
|
|
|
{{ getAuthorAndUnit(item.scholar_name, item.unit_name) }}
|
|
|
</span>
|
|
|
</div>
|
|
|
- <div v-if="data.keywords.length > 0">关键词:{{ data.keywords.join(",") }}</div>
|
|
|
+ <div v-if="data.keywords.length > 0">关键词:<span v-html="highlight('keywords', data.keywords.join(','))"></span></div>
|
|
|
<div>
|
|
|
<span>时间:{{ data.year }}</span>
|
|
|
<span>,被引量:{{ data.cited }}</span>
|
|
|
</div>
|
|
|
</div>
|
|
|
- <p v-if="mode != 'brief'">摘要:<span v-html="data.abstract.replace('摘要:', '')"></span></p>
|
|
|
+ <p v-if="mode != 'brief'">摘要:<span v-html="highlight('abstract', data.abstract.replace('摘要:', ''))"></span></p>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
+
|
|
|
.item-wrap {
|
|
|
padding: 5px;
|
|
|
-
|
|
|
.metadata {
|
|
|
padding-bottom: 5px;
|
|
|
-
|
|
|
+
|
|
|
.author-item {
|
|
|
margin-left: 1em;
|
|
|
|