remove index prompt

This commit is contained in:
anlicheng 2025-03-03 21:58:01 +08:00
parent 23b6664c04
commit 466ff8e387

View File

@ -50,11 +50,6 @@ final class IndexModel {
let dramas: [DramaItem] let dramas: [DramaItem]
} }
enum LoadMoreResult {
case success
case error(String)
}
var dramas: [DramaItem] var dramas: [DramaItem]
var selectedDate: String var selectedDate: String
@ -79,7 +74,7 @@ final class IndexModel {
} }
@MainActor @MainActor
func loadMoreUpdateDramas(userId: String, mode: API.LoadMode) async -> LoadMoreResult { func loadMoreUpdateDramas(userId: String, mode: API.LoadMode) async {
// id // id
let dramaIds = self.getDramaIds(self.updateDramaGroups) let dramaIds = self.getDramaIds(self.updateDramaGroups)
print("current ids: \(dramaIds)") print("current ids: \(dramaIds)")
@ -98,13 +93,7 @@ final class IndexModel {
print("--------- after ------------") print("--------- after ------------")
displayDramaGroups(self.updateDramaGroups) displayDramaGroups(self.updateDramaGroups)
print("--------- ------------") print("--------- ------------")
return .success
} else {
return .error("没有更多数据")
} }
} else {
return .error("加载失败")
} }
} }
case .next: case .next:
@ -119,17 +108,10 @@ final class IndexModel {
print("----------after-----------") print("----------after-----------")
displayDramaGroups(self.updateDramaGroups) displayDramaGroups(self.updateDramaGroups)
print("---------------------") print("---------------------")
return .success
} else {
return .error("没有更多数据")
}
} else {
return .error("加载失败")
} }
} }
} }
return .success }
} }
// //
@ -294,7 +276,7 @@ extension IndexView {
@State private var showDateNavPopover: Bool = false @State private var showDateNavPopover: Bool = false
var body: some View { var body: some View {
VStack(alignment: .center) { VStack {
HStack(alignment: .center) { HStack(alignment: .center) {
Color.clear Color.clear
@ -305,8 +287,9 @@ extension IndexView {
} }
} }
.frame(height: 50) .frame(height: 50)
.background(Color(hex: "#F2F2F2"), ignoresSafeAreaEdges: .bottom) .background(Color(hex: "#F2F2F2"), ignoresSafeAreaEdges: .top)
VStack(alignment: .center) {
HStack(alignment: .center) { HStack(alignment: .center) {
Spacer() Spacer()
Text("番剧补完计划") Text("番剧补完计划")
@ -343,16 +326,7 @@ extension IndexView {
if screenBounds.height - frame.minY > 50 && contextFrame.minY > 0 && !isMoreLoading { if screenBounds.height - frame.minY > 50 && contextFrame.minY > 0 && !isMoreLoading {
Task { Task {
self.isMoreLoading = true self.isMoreLoading = true
let result = await self.indexModel.loadMoreUpdateDramas(userId: self.userId, mode: .next) await self.indexModel.loadMoreUpdateDramas(userId: self.userId, mode: .next)
switch result {
case .success:
()
case .error(let message):
DispatchQueue.main.async {
self.showPrompt = true
self.promptMessage = message
}
}
self.isMoreLoading = false self.isMoreLoading = false
} }
} }
@ -378,21 +352,13 @@ extension IndexView {
// //
self.isPrevLoading = true self.isPrevLoading = true
let result = await self.indexModel.loadMoreUpdateDramas(userId: self.userId, mode: .prev) await self.indexModel.loadMoreUpdateDramas(userId: self.userId, mode: .prev)
switch result {
case .success:
()
case .error(let message):
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
self.showPrompt = true
self.promptMessage = message
}
}
self.isPrevLoading = false self.isPrevLoading = false
} }
} }
.frame(width: 370) .frame(width: 370)
}
.ignoresSafeArea(edges: .bottom) .ignoresSafeArea(edges: .bottom)
.alert(isPresented: $showPrompt) { .alert(isPresented: $showPrompt) {
Alert(title: Text("提示"), message: Text(self.promptMessage), dismissButton: .default(Text("OK"))) Alert(title: Text("提示"), message: Text(self.promptMessage), dismissButton: .default(Text("OK")))