解决过滤清理的问题
This commit is contained in:
parent
9873d293f0
commit
9b67af6323
|
|
@ -58,6 +58,8 @@ const fetchArticles = async () => {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 监听分页变化
|
||||
watch(page, () => {
|
||||
fetchArticles()
|
||||
|
|
@ -66,8 +68,9 @@ watch(page, () => {
|
|||
})
|
||||
|
||||
// 监听查询参数变化
|
||||
watch(() => route.query.code, (newCode) => {
|
||||
if (!newCode && newCode !== code.value) {
|
||||
watch(() => route.query.code, (newCode, oldCode) => {
|
||||
// 当 code 参数发生变化时(包括从有值变为无值,或从一个值变为另一个值)
|
||||
if (newCode !== oldCode) {
|
||||
page.value = 1
|
||||
fetchArticles()
|
||||
}
|
||||
|
|
@ -90,7 +93,7 @@ onMounted(() => {
|
|||
<div class="inline-flex items-center gap-2 px-4 py-2 bg-blue-50 text-blue-700 rounded-lg">
|
||||
<span>当前筛选:{{ articleTypeMap[code] || code }}</span>
|
||||
<button
|
||||
@click="router.push('/article')"
|
||||
@click="router.push('/article') "
|
||||
class="text-blue-600 hover:text-blue-800 underline text-sm"
|
||||
>
|
||||
清除筛选
|
||||
|
|
@ -123,11 +126,14 @@ onMounted(() => {
|
|||
root:'group',
|
||||
container: 'relative grid lg:grid-cols-[1fr_4fr] gap-8 p-6',
|
||||
}"
|
||||
class="hover:shadow-2xl hover:scale-105 hover:translate-x-8"
|
||||
class="hover:shadow-2xl hover:scale-105 hover:translate-x-8 [--spotlight-size:188px]"
|
||||
orientation="horizontal"
|
||||
reverse
|
||||
spotlight
|
||||
spotlight-color="primary"
|
||||
highlight
|
||||
highlight-color="primary"
|
||||
|
||||
>
|
||||
<!-- 默认图片占位 -->
|
||||
<div class="object-cover aspect-[4/3] w-full bg-gradient-to-br from-blue-100 to-blue-200 flex items-center justify-center rounded-lg">
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user