feat: 完善 Release 接口日志与未报备提示

This commit is contained in:
2026-11-02 16:59:23 +08:00
parent 2d86ec8cd7
commit 687088326c
12 changed files with 288 additions and 34 deletions
@@ -50,7 +50,8 @@ final class DroneDockPreparationViewModel {
/// 召唤失败与创建失败分开表达,保留已经创建的任务。
var summonFailure: DroneDockPreparationFailure? {
guard let message = shootErrorMessage else { return nil }
return DroneDockPreparationFailure(message: message, stage: .summon, outcomeUnknown: summonOutcomeUnknown)
return DroneDockPreparationFailure(message: message, stage: .summon,
outcomeUnknown: summonOutcomeUnknown, code: shootErrorCode)
}
private let service: any DroneDockPreparationServing
@@ -67,6 +68,7 @@ final class DroneDockPreparationViewModel {
private var creationContextInvalidated = false
private var summonGeneration = 0
private var didSendSummon = false
private var shootErrorCode: Int?
private var hasSubmittedSummon = false
private var primaryActionGeneration = 0
private var isPerformingPrimaryAction = false
@@ -165,6 +167,7 @@ final class DroneDockPreparationViewModel {
isSummoning = true
didSendSummon = false
shootErrorMessage = nil
shootErrorCode = nil
onStateChange()
defer {
if summonGeneration == requestGeneration {
@@ -190,9 +193,10 @@ final class DroneDockPreparationViewModel {
guard acceptsSummon(requestGeneration, taskID: taskID) else { return }
if error is DeviceCommandDebugBlockedError {
shootErrorMessage = DeviceCommandDebugPolicy.blockedMessage
} else if case APIError.serverCode = error {
shootErrorMessage = error.localizedDescription
summonRequiresTaskReview = DroneDockPreparationFailure.requiresTaskReview(error.localizedDescription)
} else if case let APIError.serverCode(code, message) = error {
shootErrorCode = code
shootErrorMessage = message
summonRequiresTaskReview = DroneDockPreparationFailure.requiresTaskReview(message)
} else {
markSummonUnknown(reason: error.localizedDescription)
}
@@ -211,6 +215,7 @@ final class DroneDockPreparationViewModel {
if creationContextInvalidated {
shootResponse = nil
shootErrorMessage = nil
shootErrorCode = nil
summonRequiresTaskReview = false
}
}
@@ -575,6 +580,7 @@ final class DroneDockPreparationViewModel {
private func markSummonUnknown(reason: String? = nil) {
DroneDockDiagnostics.event("summon.outcome_unknown", taskID: createdTask?.taskID)
summonOutcomeUnknown = true
shootErrorCode = nil
shootErrorMessage = (reason.map { "\($0)。" } ?? "") + "召唤结果待核对,请先核对任务状态,勿重复提交"
}