feat: add community post categories and channels

This commit is contained in:
hajimi
2026-08-02 17:39:52 +08:00
parent 95f03af60e
commit b0b278d11f
18 changed files with 1132 additions and 12 deletions
+4 -8
View File
@@ -184,12 +184,6 @@ const shouldHidePost = (post: any) => {
const isAbortError = (error: any) => String(error?.errMsg || error?.message || error || '').includes('abort')
const rankHotPosts = (items: any[]) => [...items].sort((left, right) => {
const leftScore = (Number(left.is_hot) * 1000000) + Number(left.view_count || 0) + Number(left.like_count || 0) * 8 + Number(left.comment_count || 0) * 12
const rightScore = (Number(right.is_hot) * 1000000) + Number(right.view_count || 0) + Number(right.like_count || 0) * 8 + Number(right.comment_count || 0) * 12
return rightScore - leftScore
})
const fetchPosts = async (reset = false) => {
if (reset) {
page.value = 1
@@ -202,14 +196,16 @@ const fetchPosts = async (reset = false) => {
try {
const params: Record<string, any> = { page_no: page.value, page_size: pageSize }
if (activeFeed.value === 'recommend') params.is_recommend = 1
if (activeFeed.value === 'follow') params.follow = 1
if (activeFeed.value === 'hot') params.is_hot = 1
if (activeFeed.value === 'topic') params.is_topic = 1
if (activeTagId.value > 0) params.tag_id = activeTagId.value
const response = await getCommunityPosts(params)
const rawList = response?.lists || []
if (requestId !== fetchRequestId.value) return
const list = rawList.filter((item: any) => !shouldHidePost(item))
const normalizedList = activeFeed.value === 'hot' ? rankHotPosts(list) : list
postList.value = reset || page.value === 1 ? normalizedList : [...postList.value, ...normalizedList]
postList.value = reset || page.value === 1 ? list : [...postList.value, ...list]
if (rawList.length < pageSize) finished.value = true
page.value++
} catch (error) {