不写死
This commit is contained in:
parent
103b70f5e5
commit
4b16f93930
@ -358,19 +358,19 @@ export function generateDiceRobots(payload: DiceGenerateRobotsPayload) {
|
|||||||
).then((result) => ({ ...result, items: (result.items || []).map(normalizeDiceRobot) }));
|
).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;
|
const endpoint = API_ENDPOINTS.setDiceRobotStatus;
|
||||||
return apiRequest<DiceRobotDto, { status: string }>(
|
return apiRequest<DiceRobotDto, { status: string }>(
|
||||||
apiEndpointPath(API_OPERATIONS.setDiceRobotStatus, { user_id: userId }),
|
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);
|
).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;
|
const endpoint = API_ENDPOINTS.deleteDiceRobot;
|
||||||
return apiRequest<{ deleted: boolean }>(apiEndpointPath(API_OPERATIONS.deleteDiceRobot, { user_id: userId }), {
|
return apiRequest<{ deleted: boolean }>(apiEndpointPath(API_OPERATIONS.deleteDiceRobot, { user_id: userId }), {
|
||||||
method: endpoint.method,
|
method: endpoint.method,
|
||||||
query: { gameId },
|
query: gameId ? { gameId } : undefined,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -50,7 +50,7 @@ export function GameRobotPage() {
|
|||||||
async (cursor = "", append = false) => {
|
async (cursor = "", append = false) => {
|
||||||
setLoading(!append);
|
setLoading(!append);
|
||||||
try {
|
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 || []));
|
setItems((current) => (append ? [...current, ...(result.items || [])] : result.items || []));
|
||||||
setNextCursor(result.nextCursor || "");
|
setNextCursor(result.nextCursor || "");
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@ -70,7 +70,7 @@ export function GameRobotPage() {
|
|||||||
async (robot, checked) => {
|
async (robot, checked) => {
|
||||||
setLoadingAction(`status-${robot.userId}`);
|
setLoadingAction(`status-${robot.userId}`);
|
||||||
try {
|
try {
|
||||||
await setDiceRobotStatus(robot.userId, checked ? "active" : "disabled", robot.gameId);
|
await setDiceRobotStatus(robot.userId, checked ? "active" : "disabled");
|
||||||
await load("", false);
|
await load("", false);
|
||||||
showToast("机器人状态已更新", "success");
|
showToast("机器人状态已更新", "success");
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@ -95,7 +95,7 @@ export function GameRobotPage() {
|
|||||||
}
|
}
|
||||||
setLoadingAction(`delete-${robot.userId}`);
|
setLoadingAction(`delete-${robot.userId}`);
|
||||||
try {
|
try {
|
||||||
await deleteDiceRobot(robot.userId, robot.gameId || "dice");
|
await deleteDiceRobot(robot.userId);
|
||||||
await load("", false);
|
await load("", false);
|
||||||
showToast("全站机器人已删除", "success");
|
showToast("全站机器人已删除", "success");
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user