feat(device): 完善远程操作指令并新增更多功能入口
This commit is contained in:
@@ -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}');
|
||||
|
||||
@@ -33,8 +33,8 @@ class DeviceRepositoryImpl implements DeviceRepository {
|
||||
_api.getRecentScreenshots(sn: sn);
|
||||
|
||||
@override
|
||||
Future<String?> sendDeviceOp(String sn, String op) =>
|
||||
_api.sendDeviceOp(sn, op);
|
||||
Future<String?> sendDeviceOp(String sn, String op, {Map<String, dynamic>? extra}) =>
|
||||
_api.sendDeviceOp(sn, op, extra: extra);
|
||||
|
||||
@override
|
||||
Future<String?> sendAppOp(String sn, String op, String packageName) =>
|
||||
|
||||
Reference in New Issue
Block a user