APP远程遥控推出页面释放权限集成-待测试

This commit is contained in:
2026-04-16 10:49:45 +08:00
parent c45f8ee867
commit 407bcf026c
5 changed files with 102 additions and 9 deletions

View File

@@ -70,4 +70,47 @@ class RemoteHttpDatasource {
return false;
}
}
///app退出远程控制后释放权限
Future<bool> releaseRemoteControlViaHttp( String platform) async {
_logger.logWithLevel("app退出远程控制后释放权限 开始");
final user = await _userStorage.getUser();
if (user == null) {
return false;
}
final token = user.token;
final response = await _dio.post(
'/forward/device/releaseControl',
options: Options(
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer ${token}',
},
),
data: {'platform': "app"});
try {
final responseData = response.data as Map<String, dynamic>;
//debugPrint("📊 [HTTP 响应] 完整数据:$responseData");
_logger.log("releaseRemoteControlViaHttp 响应] 完整数据:$responseData");
// 🔥 关键:先获取响应的 data 字段,再获取 remoteControl
final dataField = responseData['data'] as Map<String, dynamic>?;
if (dataField != null) {
final bool hasRemoteControl = dataField['remoteControl'] as bool? ?? false;
//debugPrint("✅ [HTTP 响应] remoteControl=$hasRemoteControl");
_logger.log("releaseRemoteControlViaHttp响应] remoteControl=$hasRemoteControl");
// 🔥 直接返回 remoteControl 的布尔值
return hasRemoteControl;
} else {
//debugPrint("❌ [HTTP 响应] 缺少 data 字段");
_logger.log("❌ [HTTP 响应] 缺少 data 字段");
return false;
}
} catch (e) {
// debugPrint('❌ [RemoteHttp] 解析响应失败:$e');
_logger.log('❌ [RemoteHttp] 解析响应失败:$e');
return false;
}
}
}