feat(device): 完善远程操作指令并新增更多功能入口

This commit is contained in:
TongTongStudio
2026-08-24 08:41:30 +08:00
parent 98de1e1132
commit 26190c1005
9 changed files with 380 additions and 25 deletions

View File

@@ -100,18 +100,21 @@ class DeviceApi {
}
}
/// 向设备下发操作指令(重启/关机/截屏/刷新/定位等)。
/// 向设备下发操作指令(重启/关机/截屏/刷新/定位/拍照等)。
///
/// [op] 为后端操作标识,如 `reboot` / `shutdown` / `screenshot` / `refresh` / `locate`
/// [op] 为后端操作标识,如 `reboot` / `shutdown` / `screenshot` / `refresh` / `locate` / `take_photo`
/// 对应接口路径 `/api/v1/client/sn/ops/{op}?sn=xxx`。
/// [extra] 为可选的附加 query 参数(如远程拍照时的 `camera``0` 后置 / `1` 前置)。
/// 成功返回 null失败返回后台错误提示。
Future<String?> sendDeviceOp(String sn, String op) async {
Future<String?> sendDeviceOp(String sn, String op, {Map<String, dynamic>? extra}) async {
try {
final queryParameters = <String, dynamic>{'sn': sn};
if (extra != null) queryParameters.addAll(extra);
final data = await DioClient.post(
'v1/client/sn/ops/$op',
queryParameters: {'sn': sn},
queryParameters: queryParameters,
);
debugPrint('[DeviceApi] sendDeviceOp op=$op sn=$sn data=$data');
debugPrint('[DeviceApi] sendDeviceOp op=$op sn=$sn extra=$extra data=$data');
return null;
} on ApiException catch (e) {
debugPrint('[DeviceApi] sendDeviceOp op=$op sn=$sn failed: ${e.message}');