feat: 为搜索条目添加细分类型

- 类型细分:有原先的四大分类添加细分类型,例如产品(原纸分切机)
- 接口调整:原先的type分类改为sectionType并将type作为细分类型使用
This commit is contained in:
2025-12-05 16:49:09 +08:00
parent 36d24a4740
commit f1398a5545
7 changed files with 48 additions and 25 deletions

View File

@ -6,9 +6,12 @@
<p v-if="item.summary" class="result-summary">
{{ item.summary }}
</p>
<p v-if="item.type" class="result-type">
<p v-if="item.sectionType" class="result-type">
<span>{{ $t('search.section') }}: </span>
<span class="result-type-name">{{ typeLabel }}</span>
<span v-if="item.type" class="result-type-name"
>({{ item.type }})</span
>
</p>
</el-col>
<el-col :span="12" class="image-col">

View File

@ -3,10 +3,13 @@
<div class="search-results">
<NuxtLink
v-for="hit in paginatedHits"
:key="`${hit.type}-${hit.id}`"
:key="`${hit.sectionType}-${hit.id}`"
:to="localePath(resolveHitLink(hit))"
>
<search-result-card :item="hit" :type-label="getIndexLabel(hit.type)" />
<search-result-card
:item="hit"
:type-label="getIndexLabel(hit.sectionType)"
/>
</NuxtLink>
</div>
@ -63,7 +66,7 @@
const items = props.searchItems;
const filteredHits = computed(() => {
if (props.category) {
return items.filter((item) => item.type === props.category);
return items.filter((item) => item.sectionType === props.category);
} else {
return items;
}
@ -107,19 +110,19 @@
const slug = String(slugCandidate);
if (item.type === 'product') {
if (item.sectionType === 'product') {
return localePath({ path: `/products/${slug}` });
}
if (item.type === 'solution') {
if (item.sectionType === 'solution') {
return localePath({ path: `/solutions/${slug}` });
}
if (item.type === 'document') {
if (item.sectionType === 'document') {
return localePath({ path: `/download/${slug}` });
}
if (item.type === 'question') {
if (item.sectionType === 'question') {
return localePath({ path: `/support/faq`, query: { focus: slug } });
}

View File

@ -32,7 +32,7 @@
const resultCount = computed(() => {
const map: Record<string, number> = { all: props.searchItems.length };
for (const item of props.searchItems) {
map[item.type] = (map[item.type] ?? 0) + 1;
map[item.sectionType] = (map[item.sectionType] ?? 0) + 1;
}
return map;
});