fix: 修复详情页空白和海报图片错误

- DetailViewModel 添加 @MainActor 确保状态更新在主线程
- DetailView 消除空白初始状态,ProgressView 作为默认兜底
- 取消时保留加载状态避免页面闪回空白
- 使用 .task(id:) 确保切换条目时任务重新触发
- 海报优先从 JSON-LD image 字段获取,HTML fallback 改用正确选择器

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-27 11:33:22 +08:00
parent 03b7a8bf25
commit 1da412e637
3 changed files with 25 additions and 19 deletions

View File

@@ -12,22 +12,22 @@ struct DetailView: View {
var body: some View {
Group {
if viewModel.isLoading {
ProgressView()
.frame(maxWidth: .infinity, maxHeight: .infinity)
} else if let error = viewModel.error {
errorView(error)
} else if let detail = viewModel.detail {
if let detail = viewModel.detail {
ScrollView {
detailContent(detail)
}
} else if let error = viewModel.error {
errorView(error)
} else {
ProgressView()
.frame(maxWidth: .infinity, maxHeight: .infinity)
}
}
.navigationTitle(item.title)
#if os(iOS)
.navigationBarTitleDisplayMode(.inline)
#endif
.task {
.task(id: item.id) {
if viewModel.detail == nil {
await viewModel.loadDetail(path: item.detailURL)
}