修正按讚、儀表板彙總 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

@@ -424,8 +424,6 @@ export function AuthProvider({ children }: { children: ReactNode }) {
if (!user) return false
try {
const isCurrentlyLiked = userLikes[user.id]?.includes(appId) || false
const response = await fetch(`/api/apps/${appId}/interactions`, {
method: 'POST',
headers: {
@@ -440,13 +438,14 @@ export function AuthProvider({ children }: { children: ReactNode }) {
if (response.ok) {
const data = await response.json()
if (data.success) {
// 更新應用統計數據
setAppStats(prev => ({
...prev,
[appId]: data.data
}))
// 更新用戶的按讚狀態
const newLikedState = !isCurrentlyLiked
// 使用 API 返回的按讚狀態更新本地狀態
const newLikedState = data.data.userLiked
setUserLikes(prev => ({
...prev,
[user.id]: newLikedState