feat(drone-dock): 接入火山实时图传并保留禁飞保护

This commit is contained in:
2026-11-02 11:01:02 +08:00
parent c1fd2d0859
commit b21a3b6cb6
204 changed files with 112972 additions and 3274 deletions
@@ -1,7 +1,9 @@
import Foundation
/// 禁飞期间的 Debug 请求边界;模拟器和测试环境均不能视为没有真实设备副作用。
/// 禁飞期间的请求边界;正式包仅允许用户手动图传,不允许创建或飞控。
enum DeviceCommandDebugPolicy {
/// 飞控与真实待飞任务在所有构建中关闭,不因打 Release 包而解除禁飞。
static let blocksFlightRequests = true
/// 所有 Debug 构建禁止真实设备操作,没有启动参数或设置开关可临时放行。
static var blocksLiveRequests: Bool {
#if DEBUG
@@ -16,13 +18,15 @@ enum DeviceCommandDebugPolicy {
/// 在日志和传输之前阻断操作请求;允许的状态读取关闭实时设备采集。
static func prepare(_ request: URLRequest, isLocalSimulation: Bool) throws -> URLRequest {
guard blocksLiveRequests, !isLocalSimulation, let url = request.url else { return request }
guard !isLocalSimulation, let url = request.url else { return request }
let path = "/" + url.path.split(separator: "/").joined(separator: "/")
// 创建虽不直接起飞,但会改变真实订单状态;禁飞调试使用本地待飞任务。
if path == "/api/yf-handset-app/photog/multi-plane/tasks/create" {
throw DeviceCommandDebugBlockedError()
}
guard path == "/api/app/airport" || path.hasPrefix("/api/app/airport/") else { return request }
// 2026-11-02 仅为用户后续手动图传测试提供 Release 入口;Debug 仍禁止开流。
if request.httpMethod == "GET", path == "/api/app/airport/live", !blocksLiveRequests { return request }
let readablePaths: Set<String> = [
"/api/app/airport/home", "/api/app/airport/plane-status",
"/api/app/airport/shooting", "/api/app/airport/status"