import http from '@core/http'; import type { RobotDetail, RobotInfo } from './type'; const enum API { 获取所有机器人 = '/robot/getAll', 注册机器人 = '/robot/register', 批量抢占控制权 = '/robot/seizeByIds', } export async function getAllRobots(): Promise> { type D = RobotInfo[]; const data = await http.post(API.获取所有机器人); return data ?? []; } export async function registerRobot(robot: Omit): Promise { type B = Omit; type D = RobotInfo; const body = robot; const data = await http.post(API.注册机器人, body); return data ?? null; } export async function seizeRobotByIds(ids: Array): Promise { if (!ids.length) return false; type B = { ids: string[] }; type D = void; try { const body = { ids }; await http.post(API.批量抢占控制权, body); return true; } catch (error) { console.debug(error); return false; } }