修正按讚、儀表板彙總 BUG

This commit is contained in:
2025-09-23 17:16:52 +08:00
parent 36b3e45499
commit 6f3b56d494
6 changed files with 446 additions and 152 deletions

View File

@@ -70,24 +70,18 @@ export async function POST(
)
}
if (result) {
// 重新獲取更新後的統計數據
const stats = await appService.getAppStats(appId)
return NextResponse.json({
success: true,
data: {
likesCount: stats.likes_count || 0,
viewsCount: stats.views_count || 0,
rating: stats.average_rating || 0,
reviewsCount: stats.reviews_count || 0
}
})
} else {
return NextResponse.json(
{ success: false, error: '操作失敗' },
{ status: 500 }
)
}
// 重新獲取更新後的統計數據
const stats = await appService.getAppStats(appId, userId)
return NextResponse.json({
success: true,
data: {
likesCount: stats.likes_count || 0,
viewsCount: stats.views_count || 0,
rating: stats.average_rating || 0,
reviewsCount: stats.reviews_count || 0,
userLiked: stats.userLiked // 使用數據庫查詢的按讚狀態
}
})
} catch (error) {
console.error('更新應用統計數據錯誤:', error)
return NextResponse.json(