完善机巢任务实时同步并开放双构建真实操作
订阅明确无缓存时使用新发起的有效 HTTP 全量响应衔接首包,保留任务、批次和版本校验。 移除 Debug/Release 的设备指令、图传和 RTC 构建拦截,保留后端权限、身份、防重复提交及结果未知保护。 更新开发约定并补充隔离传输、飞控状态和页面回归测试。 验证:iPhone 真机 500 项相关测试通过;iOS Release 无签名编译通过。
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import Foundation
|
||||
|
||||
/// 任务与工作台状态使用缓存读数;设备操作和准备页电量保留调用方请求。
|
||||
enum DroneDockReadRequestPolicy {
|
||||
/// Debug 与 Release 使用相同规则,不改写创建、飞控或图传请求。
|
||||
static func prepare(_ request: URLRequest) throws -> URLRequest {
|
||||
guard request.httpMethod == "GET", let url = request.url else { return request }
|
||||
let path = "/" + url.path.split(separator: "/").joined(separator: "/")
|
||||
let liveKey: String
|
||||
switch path {
|
||||
case "/api/app/airport/shooting": liveKey = "live_battery"
|
||||
case "/api/app/airport/status": liveKey = "live_metrics"
|
||||
default: return request
|
||||
}
|
||||
guard var components = URLComponents(url: url, resolvingAgainstBaseURL: false) else { throw APIError.invalidURL }
|
||||
var items = components.queryItems ?? []
|
||||
items.removeAll { $0.name == liveKey }
|
||||
items.append(URLQueryItem(name: liveKey, value: "0"))
|
||||
components.queryItems = items
|
||||
guard let cachedURL = components.url else { throw APIError.invalidURL }
|
||||
var cachedRequest = request
|
||||
cachedRequest.url = cachedURL
|
||||
return cachedRequest
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user