fix view
This commit is contained in:
parent
6b3273ad2f
commit
d0209d298b
@ -61,6 +61,13 @@ struct API {
|
||||
return await doRequest(request: request, as: T.self)
|
||||
}
|
||||
|
||||
// 获取用户的关注数
|
||||
static func getFlowNum<T: Codable>(userId: String, as: T.Type) async -> APIResponse<T> {
|
||||
let request = URLRequest(url: URL(string: baseUrl + "/api/follow_num?user_id=\(userId)")!)
|
||||
|
||||
return await doRequest(request: request, as: T.self)
|
||||
}
|
||||
|
||||
// 前后刷新获取数据
|
||||
static func loadMoreUpdateDramas<T: Codable>(userId: String, mode: LoadMode, id: Int, as: T.Type) async -> APIResponse<T> {
|
||||
let request = URLRequest(url: URL(string: baseUrl + "/api/load_more_dramas?user_id=\(userId)&mode=\(mode.rawValue)&id=\(id)")!)
|
||||
|
||||
@ -28,7 +28,7 @@ struct FlexImage: View {
|
||||
|
||||
let cacheManager = CacheManager.shared
|
||||
if let data = cacheManager.readFileContents(urlString: urlString) {
|
||||
print("url: \(urlString), hit cache")
|
||||
//print("url: \(urlString), hit cache")
|
||||
self.mode = .local(data)
|
||||
} else {
|
||||
self.mode = .remote(urlString)
|
||||
|
||||
@ -52,6 +52,9 @@ struct IndexMainView: View {
|
||||
}
|
||||
)
|
||||
.zIndex(1)
|
||||
.task {
|
||||
await indexModel.reloadFollowNum(userId: userId)
|
||||
}
|
||||
}
|
||||
.padding([.leading, .trailing], 15)
|
||||
.frame(height: 50)
|
||||
|
||||
@ -145,6 +145,19 @@ final class IndexModel {
|
||||
self.isLoaded = true
|
||||
}
|
||||
|
||||
func reloadFollowNum(userId: String) async {
|
||||
let response = await API.getFlowNum(userId: userId, as: Int.self)
|
||||
switch response {
|
||||
case .error(let code, let message):
|
||||
print("reloadFollowNum get error: \(code), message: \(message)")
|
||||
case .result(let follow_num):
|
||||
await MainActor.run {
|
||||
self.follow_num = follow_num >= 100 ? "99+" : "\(follow_num)"
|
||||
}
|
||||
}
|
||||
self.isLoaded = true
|
||||
}
|
||||
|
||||
func setFixedDrameGroup(groupId: String) {
|
||||
if let newFixedDramaGroup = self.updateDramaGroups.first(where: {$0.group_id == groupId}),
|
||||
newFixedDramaGroup.group_id != self.fixedDramaGroup?.group_id {
|
||||
|
||||
@ -146,9 +146,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
|
||||
willPresent notification: UNNotification,
|
||||
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
|
||||
|
||||
//let userInfo = notification.request.content.userInfo
|
||||
let userInfo = notification.request.content.userInfo
|
||||
// 处理通知数据
|
||||
//handleRemoteNotification(userInfo: userInfo)
|
||||
handleRemoteNotification(userInfo: userInfo)
|
||||
|
||||
// 设置如何显示通知
|
||||
completionHandler([.banner, .sound])
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user