diff --git a/app/pages/search.vue b/app/pages/search.vue index 3b5c97f..8311224 100644 --- a/app/pages/search.vue +++ b/app/pages/search.vue @@ -29,39 +29,75 @@
-
-
-

- {{ getIndexLabel(section.indexUid) }} - {{ - $t('search.result-count', { count: section.estimatedTotalHits }) - }} -

-
-
- + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + - - {{ getHitTitle(hit) }} - -

{{ getHitTitle(hit) }}

-

- {{ getHitSummary(hit) }} -

-
-
-
+ {{ getHitTitle(hit.content) }} + +

{{ getHitTitle(hit.content) }}

+

+ {{ getHitSummary(hit.content) }} +

+

+ 内容类型: + {{ getIndexLabel(hit.type) }} +

+ +
+ + +
+ +
([]); const localeSections = computed(() => sections.value.map((section) => ({ @@ -105,6 +143,16 @@ const filteredSections = computed(() => localeSections.value.filter((section) => section.hits.length > 0) ); + const hits = computed(() => + filteredSections.value.flatMap((item) => + item.hits.map((content) => ({ content, type: item.indexUid })) + ) + ); + const paginatedHits = computed(() => { + const start = (currentPage.value - 1) * pageSize.value; + const end = currentPage.value * pageSize.value; + return hits.value.slice(start, end); + }); const activeRequestId = ref(0); const indexLabels = computed>(() => ({ @@ -204,8 +252,8 @@ if (requestId === activeRequestId.value) { sections.value = results; } - console.log(results); - console.log(localeSections.value); + console.log('hits:', hits.value); + console.log('paginatedHits:', paginatedHits.value); } catch (error) { console.error('Failed to perform search', error); if (requestId === activeRequestId.value) { @@ -234,16 +282,16 @@ }; } - // const handleInput = debounce((value: string) => { - // performSearch(value); - // }, 300); - const handleClear = () => { keyword.value = ''; sections.value = []; router.replace(localePath({ path: '/search' })); }; + const handleCurrentChange = (page: number) => { + currentPage.value = page; + }; + watch( () => route.query.query, (newQuery) => { @@ -367,16 +415,26 @@ font-size: 1.2rem; font-weight: 600; color: var(--el-color-primary); - margin-bottom: 0.5rem; display: inline-block; } .result-summary { font-size: 0.95rem; color: var(--el-text-color-regular); + margin-bottom: 0.5rem; line-height: 1.6; } + .result-type { + font-size: 0.8rem; + color: var(--el-text-color-secondary); + } + + .result-type-name { + margin-left: 4px; + color: var(--el-color-primary); + } + @media (max-width: 640px) { .search-page { padding: 2rem 1rem;