feat: 更新Swift助手样式和动态视图组件
- 在swift-assistant-style.mdc中更新上下文信息,简化描述并保留关键信息。 - 在swift-swiftui-dev-rules.mdc中将alwaysApply设置为false,调整开发规则。 - 在Info.plist中移除冗余的CFBundleDisplayName和CFBundleName键,保持文件整洁。 - 在FeedFeature.swift中添加调试日志,增强API响应的可追踪性。 - 在HomeFeature.swift中新增Feed状态和相关actions,优化状态管理。 - 在FeedView.swift中直接使用store状态,提升组件性能和可读性。 - 在HomeView.swift中更新FeedView的store传递方式,确保状态一致性。 - 更新Xcode项目配置,调整代码签名和Swift版本,确保兼容性。
This commit is contained in:
@@ -74,32 +74,50 @@ struct FeedFeature {
|
||||
case let .momentsResponse(.success(response)):
|
||||
state.isLoading = false
|
||||
|
||||
// 添加调试日志
|
||||
debugInfo("📱 FeedFeature: API 响应成功")
|
||||
debugInfo("📱 FeedFeature: response.code = \(response.code)")
|
||||
debugInfo("📱 FeedFeature: response.message = \(response.message)")
|
||||
debugInfo("📱 FeedFeature: response.data = \(response.data != nil ? "有数据" : "无数据")")
|
||||
|
||||
// 检查响应状态
|
||||
guard response.code == 200, let data = response.data else {
|
||||
state.error = response.message.isEmpty ? "获取动态失败" : response.message
|
||||
let errorMsg = response.message.isEmpty ? "获取动态失败" : response.message
|
||||
state.error = errorMsg
|
||||
debugError("❌ FeedFeature: API 响应失败 - code: \(response.code), message: \(errorMsg)")
|
||||
return .none
|
||||
}
|
||||
|
||||
// 添加数据调试日志
|
||||
debugInfo("📱 FeedFeature: data.dynamicList.count = \(data.dynamicList.count)")
|
||||
debugInfo("📱 FeedFeature: data.nextDynamicId = \(data.nextDynamicId)")
|
||||
|
||||
// 判断是刷新还是加载更多
|
||||
let isRefresh = state.nextDynamicId == 0
|
||||
debugInfo("📱 FeedFeature: isRefresh = \(isRefresh)")
|
||||
|
||||
if isRefresh {
|
||||
// 刷新:替换所有数据
|
||||
state.moments = data.dynamicList
|
||||
debugInfo(" FeedFeature: 刷新数据,moments.count = \(state.moments.count)")
|
||||
} else {
|
||||
// 加载更多:追加到现有数据
|
||||
let oldCount = state.moments.count
|
||||
state.moments.append(contentsOf: data.dynamicList)
|
||||
debugInfo(" FeedFeature: 加载更多,moments.count: \(oldCount) -> \(state.moments.count)")
|
||||
}
|
||||
|
||||
// 更新分页状态
|
||||
state.nextDynamicId = data.nextDynamicId
|
||||
state.hasMoreData = !data.dynamicList.isEmpty
|
||||
|
||||
debugInfo("📱 FeedFeature: 更新完成 - nextDynamicId: \(state.nextDynamicId), hasMoreData: \(state.hasMoreData)")
|
||||
return .none
|
||||
|
||||
case let .momentsResponse(.failure(error)):
|
||||
state.isLoading = false
|
||||
state.error = error.localizedDescription
|
||||
debugError("❌ FeedFeature: API 请求失败 - \(error.localizedDescription)")
|
||||
return .none
|
||||
|
||||
case .clearError:
|
||||
|
Reference in New Issue
Block a user