diff --git a/src/features/games/api.ts b/src/features/games/api.ts index 8e9972d..bd705df 100644 --- a/src/features/games/api.ts +++ b/src/features/games/api.ts @@ -358,19 +358,19 @@ export function generateDiceRobots(payload: DiceGenerateRobotsPayload) { ).then((result) => ({ ...result, items: (result.items || []).map(normalizeDiceRobot) })); } -export function setDiceRobotStatus(userId: string, status: string, gameId = "dice") { +export function setDiceRobotStatus(userId: string, status: string, gameId = "") { const endpoint = API_ENDPOINTS.setDiceRobotStatus; return apiRequest( apiEndpointPath(API_OPERATIONS.setDiceRobotStatus, { user_id: userId }), - { body: { status }, method: endpoint.method, query: { gameId } }, + { body: { status }, method: endpoint.method, query: gameId ? { gameId } : undefined }, ).then(normalizeDiceRobot); } -export function deleteDiceRobot(userId: string, gameId = "dice"): Promise<{ deleted: boolean }> { +export function deleteDiceRobot(userId: string, gameId = ""): Promise<{ deleted: boolean }> { const endpoint = API_ENDPOINTS.deleteDiceRobot; return apiRequest<{ deleted: boolean }>(apiEndpointPath(API_OPERATIONS.deleteDiceRobot, { user_id: userId }), { method: endpoint.method, - query: { gameId }, + query: gameId ? { gameId } : undefined, }); } diff --git a/src/features/games/pages/GameRobotPage.jsx b/src/features/games/pages/GameRobotPage.jsx index 329082e..1bb946b 100644 --- a/src/features/games/pages/GameRobotPage.jsx +++ b/src/features/games/pages/GameRobotPage.jsx @@ -50,7 +50,7 @@ export function GameRobotPage() { async (cursor = "", append = false) => { setLoading(!append); try { - const result = await listDiceRobots({ gameId: "dice", status, cursor, pageSize: 50 }); + const result = await listDiceRobots({ status, cursor, pageSize: 50 }); setItems((current) => (append ? [...current, ...(result.items || [])] : result.items || [])); setNextCursor(result.nextCursor || ""); } catch (err) { @@ -70,7 +70,7 @@ export function GameRobotPage() { async (robot, checked) => { setLoadingAction(`status-${robot.userId}`); try { - await setDiceRobotStatus(robot.userId, checked ? "active" : "disabled", robot.gameId); + await setDiceRobotStatus(robot.userId, checked ? "active" : "disabled"); await load("", false); showToast("机器人状态已更新", "success"); } catch (err) { @@ -95,7 +95,7 @@ export function GameRobotPage() { } setLoadingAction(`delete-${robot.userId}`); try { - await deleteDiceRobot(robot.userId, robot.gameId || "dice"); + await deleteDiceRobot(robot.userId); await load("", false); showToast("全站机器人已删除", "success"); } catch (err) {