From fdd1ae09294a653b28a0a7c4c068103b702abbb7 Mon Sep 17 00:00:00 2001 From: congsh Date: Sat, 18 Apr 2026 20:40:55 +0800 Subject: [PATCH] fix: add $autoCancel:false to games API calls GamesLibrary auto-cancellation error was caused by missing $autoCancel:false on all games.ts PocketBase SDK calls. Co-Authored-By: Claude Opus 4.7 --- frontend/src/api/games.ts | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/frontend/src/api/games.ts b/frontend/src/api/games.ts index b857a50..8f49f30 100644 --- a/frontend/src/api/games.ts +++ b/frontend/src/api/games.ts @@ -15,7 +15,8 @@ export async function getGroupGames(groupId: string, options?: { const result = await pb.collection('games').getList(page, limit, { filter, - sort: '-created' + sort: '-created', + $autoCancel: false }) return { items: result.items as unknown as Game[], total: result.totalItems } } @@ -33,12 +34,12 @@ export async function addGame(groupId: string, data: { group: groupId, addedBy: user?.id, popularCount: 0 - }) + }, { $autoCancel: false }) } // 删除游戏 export async function deleteGame(gameId: string) { - return pb.collection('games').delete(gameId) + return pb.collection('games').delete(gameId, { $autoCancel: false }) } // 导入游戏(批量添加) @@ -64,7 +65,8 @@ export async function importGames(groupId: string, games: Array<{ export async function exportGames(groupId: string): Promise { const result = await pb.collection('games').getFullList({ filter: `group="${groupId}"`, - sort: '-created' + sort: '-created', + $autoCancel: false }) return result as unknown as Game[] } @@ -75,17 +77,18 @@ export async function toggleFavorite(gameId: string): Promise { if (!user) throw new Error('未登录') const existing = await pb.collection('game_favorites').getList(1, 1, { - filter: `game="${gameId}" && user="${user.id}"` + filter: `game="${gameId}" && user="${user.id}"`, + $autoCancel: false }) if (existing.items.length > 0) { - await pb.collection('game_favorites').delete(existing.items[0].id) + await pb.collection('game_favorites').delete(existing.items[0].id, { $autoCancel: false }) return false } else { await pb.collection('game_favorites').create({ game: gameId, user: user.id - }) + }, { $autoCancel: false }) return true } } @@ -96,7 +99,8 @@ export async function isFavorite(gameId: string): Promise { if (!user) return false const result = await pb.collection('game_favorites').getList(1, 1, { - filter: `game="${gameId}" && user="${user.id}"` + filter: `game="${gameId}" && user="${user.id}"`, + $autoCancel: false }) return result.items.length > 0 } @@ -111,7 +115,7 @@ export async function addComment(gameId: string, content: string, rating?: numbe author: user.id, content, rating - }) + }, { $autoCancel: false }) } // 获取游戏评论 @@ -119,7 +123,8 @@ export async function getGameComments(gameId: string): Promise { const result = await pb.collection('game_comments').getList(1, 50, { filter: `game="${gameId}"`, sort: '-created', - expand: 'author' + expand: 'author', + $autoCancel: false }) return result.items as unknown as GameComment[] } @@ -137,7 +142,8 @@ export async function searchGames(query: string, groupId?: string, limit = 20): const result = await pb.collection('games').getList(1, limit, { filter, - sort: '-popularCount' + sort: '-popularCount', + $autoCancel: false }) return result.items as unknown as Game[] } @@ -147,9 +153,9 @@ export async function getPopularGames(limit = 10): Promise { const user = pb.authStore.model if (!user) return [] - // 获取用户所在群组的游戏 const result = await pb.collection('games').getList(1, limit, { - sort: '-popularCount' + sort: '-popularCount', + $autoCancel: false }) return result.items as unknown as Game[] }