feat(training): 为请求操作接入通用Loading

This commit is contained in:
2026-10-14 18:07:55 +08:00
parent 8c8ba00778
commit ce6cccf2b7
12 changed files with 1396 additions and 44 deletions
@@ -64,6 +64,7 @@ actor TrainingDataStub: TrainingDataServing {
var sectionsHandler: (@Sendable (String?) async throws -> TrainingCursorPage<TrainingSectionInfo>)?
var sectionHandler: (@Sendable (String) async throws -> TrainingSectionContent)?
var attachmentsHandler: (@Sendable (String?) async throws -> TrainingCursorPage<TrainingAttachmentInfo>)?
var attachmentURLHandler: (@Sendable (String) async throws -> TrainingAttachmentLink)?
var startReadingHandler: (@Sendable (String) async throws -> TrainingStudySession)?
var heartbeatHandler: (@Sendable (HeartbeatCall) async throws -> TrainingHeartbeatConfirmation)?
var questionsHandler: (@Sendable (Int, Int) async throws -> TrainingQuestionPage)?
@@ -151,6 +152,7 @@ actor TrainingDataStub: TrainingDataServing {
/// 返回用于 Safari 的授权 HTTPS URL。
func attachmentURL(courseID: String, attachmentID: String, taskID: String) async throws -> TrainingAttachmentLink {
calls.append(Call(name: "attachmentURL", taskID: taskID))
if let handler = configuration.attachmentURLHandler { return try await handler(attachmentID) }
return TrainingAttachmentLink(id: attachmentID, name: "培训附件", url: URL(string: "https://example.test/training.pdf")!, expiresAt: TrainingRemoteFixtures.now.addingTimeInterval(3600))
}
/// 只返回权威读时。