import type { RobotGroup } from '@api/robot'; import http from '@core/http'; import type { SceneDetail, SceneInfo } from './type'; const enum API { 获取场景 = '/scene/getById', 保存场景 = '/scene/saveById', 获取组场景 = '/scene/getByGroupId', } export async function getSceneById(id: SceneInfo['id']): Promise { if (!id) return null; type B = { id: string }; type D = SceneDetail; try { const body = { id }; const data = await http.post(API.获取场景, body); return data ?? null; } catch (error) { console.debug(error); return null; } } export async function saveSceneById(id: SceneInfo['id'], json: string): Promise { if (!id) return false; type B = { id: string; json: string }; type D = void; try { const body = { id, json }; await http.post(API.保存场景, body); return true; } catch (error) { console.debug(error); return false; } } export async function getSceneByGroupId(id: RobotGroup['id'], sid: RobotGroup['sid']): Promise { if (!id) return null; type B = { id: string; sid?: string }; type D = SceneDetail; try { const body = { id, sid }; const data = await http.post(API.获取场景, body); return data ?? null; } catch (error) { console.debug(error); return null; } }