feat: update app workflows and permissions

This commit is contained in:
2026-07-09 17:34:00 +08:00
parent 43e6133c21
commit 8e356973bd
44 changed files with 2944 additions and 307 deletions

View File

@ -291,7 +291,6 @@ final class WildPhotographerReportSubmitViewModel {
guard !isSubmitting else { return }
isSubmitting = true
submitProgressText = "正在上传证据"
notifyStateChange()
defer {
isSubmitting = false
@ -303,19 +302,13 @@ final class WildPhotographerReportSubmitViewModel {
let evidenceRequests = try await uploadAttachments(
images + videos,
uploader: uploader,
scenicId: scenicId,
progressPrefix: "正在上传现场证据"
scenicId: scenicId
)
let paymentRequests = try await uploadAttachments(
paymentImages,
uploader: uploader,
scenicId: scenicId,
progressPrefix: "正在上传支付截图",
completedOffset: evidenceRequests.count,
totalOverride: evidenceRequests.count + paymentImages.count
scenicId: scenicId
)
submitProgressText = "正在提交举报"
notifyStateChange()
let submitResponse = try await api.submitReport(buildSubmitRequest(
scenicId: scenicId,
@ -447,27 +440,17 @@ final class WildPhotographerReportSubmitViewModel {
private func uploadAttachments(
_ attachments: [WildReportAttachment],
uploader: any WildReportAttachmentUploading,
scenicId: Int,
progressPrefix: String,
completedOffset: Int = 0,
totalOverride: Int? = nil
scenicId: Int
) async throws -> [WildReportEvidenceRequest] {
var requests: [WildReportEvidenceRequest] = []
let total = totalOverride ?? attachments.count
for (index, attachment) in attachments.enumerated() {
let current = completedOffset + index + 1
submitProgressText = "\(progressPrefix) \(current)/\(max(total, current))"
notifyStateChange()
for attachment in attachments {
let data = try attachment.uploadData()
let url = try await uploader.uploadWildReportAttachment(
data: data,
fileName: attachment.fileName,
fileType: attachment.fileType,
scenicId: scenicId
) { [weak self] progress in
self?.submitProgressText = "\(progressPrefix) \(current)/\(max(total, current)) · \(progress)%"
self?.notifyStateChange()
}
) { _ in }
requests.append(WildReportEvidenceRequest(
fileURL: url,
fileType: attachment.fileType,
@ -666,9 +649,21 @@ final class WildPhotographerReportDetailViewModel {
showActionMessage("举报位置:\(record.location)")
}
///
func shareReport() {
showActionMessage("已生成举报 \(record.id) 的分享信息,可发送给景区处理人员查看进度。")
///
func shareReport(api: any WildPhotographerReportServing) async -> WeChatMiniProgramSharePayload? {
guard let serverID = record.serverID, serverID > 0 else {
showActionMessage("当前举报暂未同步到服务器,无法分享")
return nil
}
do {
let shareData = try await api.reportShare(id: String(serverID))
return shareData.payload
} catch is CancellationError {
return nil
} catch {
showActionMessage(error.localizedDescription)
return nil
}
}
private func showActionMessage(_ message: String) {
@ -782,11 +777,27 @@ final class WildPhotographerReportListViewModel {
}
}
///
func shareReport(_ record: WildReportRecord) {
shareMessage = "已生成举报 \(record.id) 的分享信息,可发送给景区处理人员查看进度。"
onShowMessage?(shareMessage ?? "")
notifyStateChange()
///
func shareReport(_ record: WildReportRecord, api: any WildPhotographerReportServing) async -> WeChatMiniProgramSharePayload? {
guard let serverID = record.serverID, serverID > 0 else {
shareMessage = "当前举报暂未同步到服务器,无法分享"
onShowMessage?(shareMessage ?? "")
notifyStateChange()
return nil
}
do {
let shareData = try await api.reportShare(id: String(serverID))
shareMessage = nil
notifyStateChange()
return shareData.payload
} catch is CancellationError {
return nil
} catch {
shareMessage = error.localizedDescription
onShowMessage?(shareMessage ?? "")
notifyStateChange()
return nil
}
}
private func reload(api: any WildPhotographerReportServing, scenicId: Int?) async {
@ -907,7 +918,6 @@ final class WildReportSupplementEvidenceViewModel {
guard !isSubmitting else { return }
isSubmitting = true
submitProgressText = evidenceCount > 0 ? "正在上传补充证据" : "正在提交补充证据"
notifyStateChange()
defer {
isSubmitting = false
@ -921,8 +931,6 @@ final class WildReportSupplementEvidenceViewModel {
uploader: uploader,
scenicId: scenicId
)
submitProgressText = "正在提交补充证据"
notifyStateChange()
try await api.supplementReport(WildReportSupplementRequest(
id: serverID ?? 0,
@ -980,20 +988,14 @@ final class WildReportSupplementEvidenceViewModel {
scenicId: Int
) async throws -> [WildReportEvidenceRequest] {
var requests: [WildReportEvidenceRequest] = []
for (index, attachment) in attachments.enumerated() {
let current = index + 1
submitProgressText = "正在上传补充证据 \(current)/\(attachments.count)"
notifyStateChange()
for attachment in attachments {
let data = try attachment.uploadData()
let url = try await uploader.uploadWildReportAttachment(
data: data,
fileName: attachment.fileName,
fileType: attachment.fileType,
scenicId: scenicId
) { [weak self] progress in
self?.submitProgressText = "正在上传补充证据 \(current)/\(attachments.count) · \(progress)%"
self?.notifyStateChange()
}
) { _ in }
requests.append(WildReportEvidenceRequest(
fileURL: url,
fileType: attachment.fileType,