|
|
@@ -1,5 +1,5 @@
|
|
|
<script setup lang="ts">
|
|
|
-import { onUnmounted, ref, computed, type Ref, onMounted, reactive } from "vue";
|
|
|
+import { onUnmounted, ref, computed, type Ref, onMounted, reactive, provide } from "vue";
|
|
|
import { useRoute } from "vue-router";
|
|
|
import { useSideBarStore } from "@/stores/side-bar";
|
|
|
import SearchBox from "./components/SearchBox.vue";
|
|
|
@@ -8,7 +8,7 @@ import SearchResultList from "./components/SearchResultList.vue";
|
|
|
import type { SearchRequest } from "@/types/request.types";
|
|
|
import { useSearchStore } from "@/stores/search.store";
|
|
|
import { routeToSearch, type SearchRouteParam } from "./search.helper";
|
|
|
-import type { Sort } from "./search-component.type";
|
|
|
+import type { ResultMode, Sort } from "./search-component.type";
|
|
|
|
|
|
const sideBarStore = useSideBarStore();
|
|
|
|
|
|
@@ -38,6 +38,8 @@ const authorAggResult = computed(() => searchStore.authorAggResult);
|
|
|
|
|
|
const searchType: Ref<'simple' | 'advanced'> = ref('simple');
|
|
|
|
|
|
+const resultMode: Ref<ResultMode> = ref('detail');
|
|
|
+
|
|
|
const query = ref('');
|
|
|
|
|
|
interface SearchParams {
|
|
|
@@ -49,6 +51,10 @@ interface SearchParams {
|
|
|
size?: number;
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * 根据搜索状态数据执行搜索
|
|
|
+ * @param searchParams 搜索状态数据
|
|
|
+ */
|
|
|
function performSearch(searchParams: SearchParams) {
|
|
|
let sortParam: Object = { "Relevance": "Relevance" };
|
|
|
if (searchParams.sort) {
|
|
|
@@ -126,6 +132,8 @@ function doSearch() {
|
|
|
query: query.value,
|
|
|
yearSelected: yearChecked.value,
|
|
|
authorSelected: authorChecked.value,
|
|
|
+ page: pagination.page,
|
|
|
+ size: pagination.size,
|
|
|
sort: sort.value,
|
|
|
};
|
|
|
performSearch(searchParams);
|
|
|
@@ -216,6 +224,10 @@ function onPaginationChange(page: any, pageSize: any) {
|
|
|
doSearch();
|
|
|
}
|
|
|
|
|
|
+function onModeChange(mode: ResultMode) {
|
|
|
+ resultMode.value = mode;
|
|
|
+}
|
|
|
+
|
|
|
function changeYearChecked() {
|
|
|
pagination.page = 1;
|
|
|
doSearch();
|
|
|
@@ -274,13 +286,14 @@ onUnmounted(() => {
|
|
|
<a-col :span="19">
|
|
|
<SearchResultToolbar
|
|
|
v-if="searchResult"
|
|
|
- @update:sort="changeSort"
|
|
|
:data="searchResult"
|
|
|
v-model:sort="sort"
|
|
|
v-model:pagination="pagination"
|
|
|
+ @update:sort="changeSort"
|
|
|
@paginationChange="onPaginationChange"
|
|
|
+ @modeChange="onModeChange"
|
|
|
/>
|
|
|
- <SearchResultList :data="searchResult" v-if="searchResult" />
|
|
|
+ <SearchResultList :data="searchResult" :mode="resultMode" v-if="searchResult" />
|
|
|
</a-col>
|
|
|
</a-row>
|
|
|
</div>
|