Add ranking filtering by tags and categories

This commit is contained in:
Tim
2025-07-09 21:13:50 +08:00
parent 57a8bfeac6
commit e0efca7edf
5 changed files with 113 additions and 6 deletions

View File

@@ -142,7 +142,16 @@ export default {
}
const buildRankUrl = () => {
return `${API_BASE_URL}/api/posts/ranking?page=${page.value}&pageSize=${pageSize}`
let url = `${API_BASE_URL}/api/posts/ranking?page=${page.value}&pageSize=${pageSize}`
if (selectedCategory.value) {
url += `&categoryId=${selectedCategory.value}`
}
if (selectedTags.value.length) {
selectedTags.value.forEach(t => {
url += `&tagIds=${t}`
})
}
return url
}
const fetchPosts = async (reset = false) => {
@@ -239,6 +248,8 @@ export default {
watch([selectedCategory, selectedTags], () => {
if (selectedTopic.value === '最新') {
fetchPosts(true)
} else if (selectedTopic.value === '排行榜') {
fetchRanking(true)
}
})