feat: 更新依赖和项目配置,优化代码结构
- 在Package.swift中注释掉旧的swift-composable-architecture依赖,并添加swift-case-paths依赖。 - 在Podfile中将iOS平台版本更新至16.0,并移除QCloudCOSXML/Transfer依赖,改为使用QCloudCOSXML。 - 更新Podfile.lock以反映依赖变更,确保项目依赖的准确性。 - 新增架构分析需求文档,明确项目架构评估和改进建议。 - 在多个文件中实现async/await语法,提升异步操作的可读性和性能。 - 更新日志输出方法,确保在调试模式下提供一致的调试信息。 - 优化多个视图组件,提升用户体验和代码可维护性。
This commit is contained in:
@@ -85,40 +85,36 @@ struct APIConfiguration {
|
||||
/// - 用户认证信息(如果已登录)
|
||||
///
|
||||
/// 这些头部会自动添加到每个请求中,确保服务器能够正确处理请求
|
||||
static var defaultHeaders: [String: String] {
|
||||
static func defaultHeaders() async -> [String: String] {
|
||||
var headers = [
|
||||
"Content-Type": "application/json",
|
||||
"Accept": "application/json",
|
||||
"Accept-Encoding": "gzip, br",
|
||||
"Accept-Language": Locale.current.languageCode ?? "en",
|
||||
"Accept-Language": Locale.current.language.languageCode?.identifier ?? "en",
|
||||
"App-Version": Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "1.0.0",
|
||||
"User-Agent": "YuMi/20.20.61 (iPhone; iOS 16.4; Scale/2.00)"
|
||||
]
|
||||
|
||||
// 检查用户认证状态并添加相关 headers
|
||||
let authStatus = UserInfoManager.checkAuthenticationStatus()
|
||||
|
||||
let authStatus = await UserInfoManager.checkAuthenticationStatus()
|
||||
if authStatus.canAutoLogin {
|
||||
// 添加用户认证相关 headers(仅在 AccountModel 有效时)
|
||||
if let userId = UserInfoManager.getCurrentUserId() {
|
||||
if let userId = await UserInfoManager.getCurrentUserId() {
|
||||
headers["pub_uid"] = userId
|
||||
#if DEBUG
|
||||
debugInfo("🔐 添加认证 header: pub_uid = \(userId)")
|
||||
debugInfoSync("🔐 添加认证 header: pub_uid = \(userId)")
|
||||
#endif
|
||||
}
|
||||
|
||||
if let userTicket = UserInfoManager.getCurrentUserTicket() {
|
||||
if let userTicket = await UserInfoManager.getCurrentUserTicket() {
|
||||
headers["pub_ticket"] = userTicket
|
||||
#if DEBUG
|
||||
debugInfo("🔐 添加认证 header: pub_ticket = \(userTicket.prefix(20))...")
|
||||
debugInfoSync("🔐 添加认证 header: pub_ticket = \(userTicket.prefix(20))...")
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
#if DEBUG
|
||||
debugInfo("🔐 跳过认证 header 添加 - 认证状态: \(authStatus.description)")
|
||||
debugInfoSync("🔐 跳过认证 header 添加 - 认证状态: \(authStatus.description)")
|
||||
#endif
|
||||
}
|
||||
|
||||
return headers
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user