fix: 修复导出诊断包点击后黑屏问题
将 .sheet(isPresented:) + if let 改为 .sheet(item:) 模式, 消除 feedbackPackageURL 与 showingShareSheet 的状态时序竞争。 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -13,8 +13,7 @@ struct SettingsView: View {
|
||||
@State private var cacheSize: String = String(localized: "common.calculating")
|
||||
@State private var showingClearCacheAlert = false
|
||||
@State private var showingClearRecentWorksAlert = false
|
||||
@State private var feedbackPackageURL: URL?
|
||||
@State private var showingShareSheet = false
|
||||
@State private var feedbackPackageURL: IdentifiableURL?
|
||||
@State private var showingLanguageChangeAlert = false
|
||||
@State private var showingFeedbackConfirmAlert = false
|
||||
@State private var pendingLanguage: LanguageManager.Language?
|
||||
@@ -182,10 +181,8 @@ struct SettingsView: View {
|
||||
} message: {
|
||||
Text(String(localized: "settings.feedbackConfirmMessage"))
|
||||
}
|
||||
.sheet(isPresented: $showingShareSheet) {
|
||||
if let url = feedbackPackageURL {
|
||||
ShareSheet(activityItems: [url])
|
||||
}
|
||||
.sheet(item: $feedbackPackageURL) { item in
|
||||
ShareSheet(activityItems: [item.url])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -299,8 +296,7 @@ struct SettingsView: View {
|
||||
let url = await createFeedbackPackage()
|
||||
await MainActor.run {
|
||||
if let url {
|
||||
feedbackPackageURL = url
|
||||
showingShareSheet = true
|
||||
feedbackPackageURL = IdentifiableURL(url: url)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -425,6 +421,12 @@ extension PHAuthorizationStatus: @retroactive CustomStringConvertible {
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Identifiable URL Wrapper
|
||||
struct IdentifiableURL: Identifiable {
|
||||
let id = UUID()
|
||||
let url: URL
|
||||
}
|
||||
|
||||
// MARK: - Share Sheet
|
||||
struct ShareSheet: UIViewControllerRepresentable {
|
||||
let activityItems: [Any]
|
||||
|
||||
Reference in New Issue
Block a user