feat: 修改搜索页的鼠标指针行为 & 调整搜索页组件样式
- 当鼠标指针进入搜索条目卡片时,鼠标指针修改为pointer样式 - 调整分页组件大小
This commit is contained in:
@ -1,30 +1,31 @@
|
|||||||
<template>
|
<template>
|
||||||
<div v-if="hasResults">
|
<div v-if="hasResults">
|
||||||
<div class="search-results">
|
<div class="search-results">
|
||||||
<el-card
|
<NuxtLink
|
||||||
v-for="(hit, hitIndex) in paginatedHits"
|
v-for="(hit, hitIndex) in paginatedHits"
|
||||||
:key="`${getHitIdentifier(hit.content, hitIndex)}`"
|
:key="`${getHitIdentifier(hit.content, hitIndex)}`"
|
||||||
class="result-card"
|
:to="localePath(resolveHitLink(hit.content))"
|
||||||
@click="navigateTo(resolveHitLink(hit.content))"
|
|
||||||
>
|
>
|
||||||
<h3 class="result-title">{{ getHitTitle(hit.content) }}</h3>
|
<el-card class="result-card">
|
||||||
<p v-if="getHitSummary(hit.content)" class="result-summary">
|
<h3 class="result-title">{{ getHitTitle(hit.content) }}</h3>
|
||||||
{{ getHitSummary(hit.content) }}
|
<p v-if="getHitSummary(hit.content)" class="result-summary">
|
||||||
</p>
|
{{ getHitSummary(hit.content) }}
|
||||||
<p v-if="hit.type" class="result-type">
|
</p>
|
||||||
<span>内容类型: </span>
|
<p v-if="hit.type" class="result-type">
|
||||||
<span class="result-type-name">{{ getIndexLabel(hit.type) }}</span>
|
<span>内容类型: </span>
|
||||||
</p>
|
<span class="result-type-name">{{ getIndexLabel(hit.type) }}</span>
|
||||||
</el-card>
|
</p>
|
||||||
|
</el-card>
|
||||||
|
</NuxtLink>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 分页组件 -->
|
<!-- 分页组件 -->
|
||||||
<div class="pagination-container text-align-center mt-12">
|
<div class="pagination-container text-align-center mt-12">
|
||||||
<el-pagination
|
<el-pagination
|
||||||
|
v-model:current-page="page"
|
||||||
class="justify-center"
|
class="justify-center"
|
||||||
layout="prev, pager, next"
|
layout="prev, pager, next"
|
||||||
hide-on-single-page
|
hide-on-single-page
|
||||||
:current-page="currentPage"
|
|
||||||
:page-size="pageSize"
|
:page-size="pageSize"
|
||||||
:total="filteredHits.length"
|
:total="filteredHits.length"
|
||||||
@current-change="handleCurrentChange"
|
@current-change="handleCurrentChange"
|
||||||
@ -50,9 +51,12 @@
|
|||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
hitItems: HitItem[];
|
hitItems: HitItem[];
|
||||||
|
currentPage: number;
|
||||||
category?: string;
|
category?: string;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
|
const emit = defineEmits(['update:current-page']);
|
||||||
|
|
||||||
// i18n相关
|
// i18n相关
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
|
||||||
@ -61,7 +65,12 @@
|
|||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
|
||||||
// 分页相关
|
// 分页相关
|
||||||
const currentPage = ref(1);
|
const page = computed({
|
||||||
|
get: () => props.currentPage,
|
||||||
|
set: (val) => {
|
||||||
|
emit('update:current-page', val);
|
||||||
|
},
|
||||||
|
});
|
||||||
const pageSize = ref(5);
|
const pageSize = ref(5);
|
||||||
|
|
||||||
// 搜索相关
|
// 搜索相关
|
||||||
@ -74,8 +83,8 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
const paginatedHits = computed(() => {
|
const paginatedHits = computed(() => {
|
||||||
const start = (currentPage.value - 1) * pageSize.value;
|
const start = (page.value - 1) * pageSize.value;
|
||||||
const end = currentPage.value * pageSize.value;
|
const end = page.value * pageSize.value;
|
||||||
return filteredHits.value.slice(start, end);
|
return filteredHits.value.slice(start, end);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -173,9 +182,7 @@
|
|||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleCurrentChange = (page: number) => {
|
const handleCurrentChange = () => {};
|
||||||
currentPage.value = page;
|
|
||||||
};
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
@ -217,4 +224,31 @@
|
|||||||
margin-left: 4px;
|
margin-left: 4px;
|
||||||
color: var(--el-color-primary);
|
color: var(--el-color-primary);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
:deep(.el-pagination) {
|
||||||
|
.btn-prev,
|
||||||
|
.btn-next {
|
||||||
|
.el-icon {
|
||||||
|
font-size: 24px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.el-pager {
|
||||||
|
gap: 0.5rem;
|
||||||
|
}
|
||||||
|
.el-pager li {
|
||||||
|
font-size: 1rem;
|
||||||
|
/* border: 1px solid #409eff; */
|
||||||
|
border-radius: 50%;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background-color: #ecf5ff;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.is-active {
|
||||||
|
background-color: var(--el-color-primary);
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@ -28,31 +28,50 @@
|
|||||||
<div v-else-if="hasResults" class="search-results">
|
<div v-else-if="hasResults" class="search-results">
|
||||||
<el-tabs v-model="activeTab">
|
<el-tabs v-model="activeTab">
|
||||||
<el-tab-pane :label="`全部(${resultCount['all']})`" name="all">
|
<el-tab-pane :label="`全部(${resultCount['all']})`" name="all">
|
||||||
<search-results :hit-items="hits" />
|
<search-results
|
||||||
|
v-model:current-page="currentPage"
|
||||||
|
:hit-items="hits"
|
||||||
|
/>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
<el-tab-pane
|
<el-tab-pane
|
||||||
:label="`产品(${resultCount['production'] || 0})`"
|
:label="`产品(${resultCount['production'] || 0})`"
|
||||||
name="production"
|
name="production"
|
||||||
>
|
>
|
||||||
<search-results :hit-items="hits" category="production" />
|
<search-results
|
||||||
|
v-model:current-page="currentPage"
|
||||||
|
:hit-items="hits"
|
||||||
|
category="production"
|
||||||
|
/>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
<el-tab-pane
|
<el-tab-pane
|
||||||
:label="`解决方案(${resultCount['solution'] || 0})`"
|
:label="`解决方案(${resultCount['solution'] || 0})`"
|
||||||
name="solution"
|
name="solution"
|
||||||
>
|
>
|
||||||
<search-results :hit-items="hits" category="solution" />
|
<search-results
|
||||||
|
v-model:current-page="currentPage"
|
||||||
|
:hit-items="hits"
|
||||||
|
category="solution"
|
||||||
|
/>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
<el-tab-pane
|
<el-tab-pane
|
||||||
:label="`相关问题(${resultCount['question'] || 0})`"
|
:label="`相关问题(${resultCount['question'] || 0})`"
|
||||||
name="question"
|
name="question"
|
||||||
>
|
>
|
||||||
<search-results :hit-items="hits" category="question" />
|
<search-results
|
||||||
|
v-model:current-page="currentPage"
|
||||||
|
:hit-items="hits"
|
||||||
|
category="question"
|
||||||
|
/>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
<el-tab-pane
|
<el-tab-pane
|
||||||
:label="`文档资料(${resultCount['document'] || 0})`"
|
:label="`文档资料(${resultCount['document'] || 0})`"
|
||||||
name="document"
|
name="document"
|
||||||
>
|
>
|
||||||
<search-results :hit-items="hits" category="document" />
|
<search-results
|
||||||
|
v-model:current-page="currentPage"
|
||||||
|
:hit-items="hits"
|
||||||
|
category="document"
|
||||||
|
/>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
</el-tabs>
|
</el-tabs>
|
||||||
</div>
|
</div>
|
||||||
@ -118,6 +137,9 @@
|
|||||||
return map;
|
return map;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 分类控制
|
||||||
|
const currentPage = ref(1);
|
||||||
|
|
||||||
const hasResults = computed(() =>
|
const hasResults = computed(() =>
|
||||||
filteredSections.value.some((section) => section.hits.length > 0)
|
filteredSections.value.some((section) => section.hits.length > 0)
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user