From 046834d9d7100c2cb6b61a32e7ab80bb198e56f4 Mon Sep 17 00:00:00 2001 From: anlicheng <244108715@qq.com> Date: Thu, 10 Apr 2025 16:59:12 +0800 Subject: [PATCH] fix index view --- dimensionhub/Views/Index/IndexMainView.swift | 7 ++--- dimensionhub/Views/Index/IndexModel.swift | 27 ++++++++++++-------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/dimensionhub/Views/Index/IndexMainView.swift b/dimensionhub/Views/Index/IndexMainView.swift index 908fdfe..dd6a245 100644 --- a/dimensionhub/Views/Index/IndexMainView.swift +++ b/dimensionhub/Views/Index/IndexMainView.swift @@ -62,7 +62,7 @@ struct IndexMainView: View { ScrollView(.vertical, showsIndicators: false) { Rectangle() - .frame(width: 0, height: 15) + .frame(width: 0, height: 10) // 基于日期的更新列表 LazyVStack(alignment: .center, spacing: 10) { @@ -85,9 +85,7 @@ struct IndexMainView: View { } }) - if self.footerRefreshing { - ProgressView() - } + ProgressView() } .frame(width: 370) .coordinateSpace(name: "indexScrollView") @@ -169,7 +167,6 @@ struct IndexMainView: View { .onDisappear { self.cancel?.cancel() } - } } diff --git a/dimensionhub/Views/Index/IndexModel.swift b/dimensionhub/Views/Index/IndexModel.swift index fa86fb8..5d423d0 100644 --- a/dimensionhub/Views/Index/IndexModel.swift +++ b/dimensionhub/Views/Index/IndexModel.swift @@ -60,6 +60,10 @@ final class IndexModel { @ObservationIgnored private var isLoaded = false + // 是否显示debug信息 + @ObservationIgnored + private var debug: Bool = false + init() { self.selectedDate = "" } @@ -103,14 +107,11 @@ final class IndexModel { if case let .result(groups) = response { if groups.count > 0 { - print("--------- before ------------") - displayDramaGroups(self.updateDramaGroups) + displayDramaGroups(self.updateDramaGroups, label: "before") await MainActor.run { self.updateDramaGroups = preappendMergeDramaGroups(groups: self.updateDramaGroups, mergeGroups: groups) } - print("--------- after ------------") - displayDramaGroups(self.updateDramaGroups) - print("--------- ------------") + displayDramaGroups(self.updateDramaGroups, label: "after") } } } @@ -119,15 +120,12 @@ final class IndexModel { let response = await API.loadMoreUpdateDramas(userId: userId, mode: mode, id: lastId, as: [UpdateDramaGroup].self) if case let .result(groups) = response { if groups.count > 0 { - print("--------- before ------------") - displayDramaGroups(self.updateDramaGroups) + displayDramaGroups(self.updateDramaGroups, label: "before") await MainActor.run { self.updateDramaGroups = appendMergeDramaGroups(groups: self.updateDramaGroups, mergeGroups: groups) } - print("----------after-----------") - displayDramaGroups(self.updateDramaGroups) - print("---------------------") + displayDramaGroups(self.updateDramaGroups, label: "after") } } } @@ -204,11 +202,18 @@ final class IndexModel { } } - private func displayDramaGroups(_ groups: [UpdateDramaGroup]) { + private func displayDramaGroups(_ groups: [UpdateDramaGroup], label: String = "") { + guard debug else { + return + } + + print("--------- \(label) ------------") for group in groups { let ids = group.items.map { $0.id} print("group_id: \(group.group_id), items: \(ids)") } + print("--------- \(label) END ------------") + print(" ") } }