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[]; try { const data = await http.post(API.获取所有机器人); return data ?? []; } catch (error) { console.debug(error); return []; } } export async function registerRobot(robot: Omit): Promise { type B = Omit; type D = RobotInfo; try { const body = robot; const data = await http.post(API.注册机器人, body); return data ?? null; } catch (error) { console.debug(error); return null; } } export async function seizeRobotByIds(ids: Array): Promise> { if (!ids.length) return []; type B = { ids: string[] }; type D = string[]; try { const body = { ids }; const data = await http.post(API.批量抢占控制权, body); return data ?? []; } catch (error) { console.debug(error); return []; } }