feat: 完善机巢模拟调试与素材交付交互

增加禁飞期间的设备指令拦截及本地模拟拍摄流程;适配订单素材库和景区空境库,完善素材筛选、预览与下载;订单交付入口改为方式选择弹窗并复用云端上传。补充单元测试、接口记录和模拟器截图。
This commit is contained in:
2026-10-30 09:59:11 +08:00
parent e827bf8725
commit b95b251de1
100 changed files with 7256 additions and 500 deletions
@@ -26,12 +26,15 @@ final class DroneDockRemotePreparationViewController: BaseViewController {
private var isApplicationActive = false
private var automaticallyOpenedTaskID: Int?
private let taskControllerFactory: @MainActor (Int, DroneDockHomeOrder, DroneDockHomeContext) -> UIViewController
private let simulationRecordsProvider: (@MainActor () -> String)?
/// 注入准备页业务状态和轮询等待,便于验证任务创建及页面生命周期。
init(viewModel: DroneDockPreparationViewModel,
taskControllerFactory: (@MainActor (Int, DroneDockHomeOrder, DroneDockHomeContext) -> UIViewController)? = nil,
simulationRecordsProvider: (@MainActor () -> String)? = nil,
planeStatusPollDelay: @escaping @Sendable (UInt64) async throws -> Void = { try await Task.sleep(nanoseconds: $0) }) {
self.viewModel = viewModel
self.simulationRecordsProvider = simulationRecordsProvider
self.taskControllerFactory = taskControllerFactory ?? { taskID, order, context in
DroneDockShootingTaskEntry.makeController(taskID: taskID, order: order, context: context)
}
@@ -51,8 +54,42 @@ final class DroneDockRemotePreparationViewController: BaseViewController {
}
override func setupNavigationBar() {
title = "拍摄准备"
title = simulationRecordsProvider == nil ? "拍摄准备" : "拍摄准备 · 本地模拟"
navigationItem.backButtonDisplayMode = .minimal
if simulationRecordsProvider != nil {
let records = UIBarButtonItem(image: UIImage(systemName: "doc.text"), style: .plain,
target: self, action: #selector(showSimulationRecords))
records.accessibilityLabel = "查看模拟接口回执"
records.accessibilityIdentifier = "drone.preparation.mock.recordsButton"
navigationItem.rightBarButtonItem = records
}
#if DEBUG
if simulationRecordsProvider == nil, DeviceCommandDebugPolicy.blocksLiveRequests,
viewModel.isTaskSubmissionBlocked {
let simulation = UIBarButtonItem(title: "本地模拟", style: .plain,
target: self, action: #selector(openLocalSimulation))
simulation.accessibilityIdentifier = "drone.preparation.mock.entry"
navigationItem.rightBarButtonItem = simulation
}
#endif
}
#if DEBUG
/// 打开独立模拟订单,不沿用真实会话、服务或当前订单创建任务。
@objc private func openLocalSimulation() {
guard !isStartingCreation, !viewModel.isCreatingTask, !viewModel.isSummoning,
let navigationController, navigationController.topViewController === self,
let controller = DroneDockStartShootSimulation.makePreparationController() else { return }
navigationController.pushViewController(controller, animated: true)
}
#endif
/// 显示内存传输记录,并明确说明其不是后端真实回执。
@objc private func showSimulationRecords() {
guard let simulationRecordsProvider, presentedViewController == nil,
!isStartingCreation, !viewModel.isCreatingTask, !viewModel.isSummoning else { return }
let controller = DroneDockSimulationRecordsViewController(records: simulationRecordsProvider())
present(UINavigationController(rootViewController: controller), animated: true)
}
override func setupUI() {
@@ -200,7 +237,8 @@ final class DroneDockRemotePreparationViewController: BaseViewController {
if viewModel.errorMessage != nil {
applySnapshot(animated: false)
} else {
footerView.apply(preparationViewModel: viewModel, isRefreshing: isRefreshing || isStartingCreation)
footerView.apply(preparationViewModel: viewModel, isRefreshing: isRefreshing || isStartingCreation,
isLocalSimulation: simulationRecordsProvider != nil)
}
return viewModel.pollIntervalNanoseconds
}
@@ -214,7 +252,8 @@ final class DroneDockRemotePreparationViewController: BaseViewController {
@objc private func applicationWillResignActive() {
isApplicationActive = false
stopPlaneStatusPolling()
footerView.apply(preparationViewModel: viewModel, isRefreshing: isRefreshing || isStartingCreation)
footerView.apply(preparationViewModel: viewModel, isRefreshing: isRefreshing || isStartingCreation,
isLocalSimulation: simulationRecordsProvider != nil)
}
@objc private func applicationDidBecomeActive() {
@@ -290,6 +329,7 @@ final class DroneDockRemotePreparationViewController: BaseViewController {
}
private func applySnapshot(animated: Bool, completion: (() -> Void)? = nil) {
navigationItem.rightBarButtonItem?.isEnabled = !isStartingCreation && !viewModel.isCreatingTask && !viewModel.isSummoning
guard dataSource != nil else { return }
let previous = dataSource.snapshot()
let existing = Set(previous.itemIdentifiers)
@@ -312,7 +352,8 @@ final class DroneDockRemotePreparationViewController: BaseViewController {
snapshot.appendItems([.shootResult], toSection: .shootResult)
}
snapshot.reconfigureItems(snapshot.itemIdentifiers.filter { existing.contains($0) })
footerView.apply(preparationViewModel: viewModel, isRefreshing: isRefreshing || isStartingCreation)
footerView.apply(preparationViewModel: viewModel, isRefreshing: isRefreshing || isStartingCreation,
isLocalSimulation: simulationRecordsProvider != nil)
let previousPointCount = previous.sectionIdentifiers.contains(.points) ? previous.numberOfItems(inSection: .points) : 0
let previousRouteCount = previous.sectionIdentifiers.contains(.routes) ? previous.numberOfItems(inSection: .routes) : 0
let layoutChanged = previousPointCount != snapshot.numberOfItems(inSection: .points)