feat: 更新API相关逻辑及视图结构
- 在Info.plist中新增API签名密钥配置。 - 将Splash视图替换为SplashV2,优化启动逻辑和用户体验。 - 更新API请求中的User-Agent逻辑,使用UserAgentProvider提供的动态值。 - 在APILogger中添加敏感信息脱敏处理,增强安全性。 - 新增CreateFeedPage视图,支持用户发布动态功能。 - 更新MainPage和Splash视图的导航逻辑,整合统一的AppRoute管理。 - 移除冗余的SplashFeature视图,提升代码整洁性和可维护性。
This commit is contained in:
54
yana/Utils/Network/DeviceContext.swift
Normal file
54
yana/Utils/Network/DeviceContext.swift
Normal file
@@ -0,0 +1,54 @@
|
||||
import Foundation
|
||||
import UIKit
|
||||
|
||||
@MainActor
|
||||
struct DeviceContext: Sendable {
|
||||
let languageCode: String
|
||||
let osName: String
|
||||
let osVersion: String
|
||||
let deviceModel: String
|
||||
let deviceId: String
|
||||
let appName: String
|
||||
let appVersion: String
|
||||
let channel: String
|
||||
let screenScale: String
|
||||
|
||||
static let shared: DeviceContext = {
|
||||
// 仅在主线程读取一次 UIKit/Bundle 信息
|
||||
let language = Locale.current.language.languageCode?.identifier ?? "en"
|
||||
let osName = "iOS"
|
||||
let osVersion = UIDevice.current.systemVersion
|
||||
let deviceModel = UIDevice.current.model
|
||||
let deviceId = UIDevice.current.identifierForVendor?.uuidString ?? UUID().uuidString
|
||||
let appName = Bundle.main.infoDictionary?["CFBundleName"] as? String ?? "eparty"
|
||||
let appVersion = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "1.0.0"
|
||||
#if DEBUG
|
||||
let channel = "molistar_enterprise"
|
||||
#else
|
||||
let channel = "appstore"
|
||||
#endif
|
||||
let scale = String(format: "%.2f", Double(UIScreen.main.scale))
|
||||
|
||||
return DeviceContext(
|
||||
languageCode: language,
|
||||
osName: osName,
|
||||
osVersion: osVersion,
|
||||
deviceModel: deviceModel,
|
||||
deviceId: deviceId,
|
||||
appName: appName,
|
||||
appVersion: appVersion,
|
||||
channel: channel,
|
||||
screenScale: scale
|
||||
)
|
||||
}()
|
||||
}
|
||||
|
||||
enum UserAgentProvider {
|
||||
@MainActor
|
||||
static func userAgent() -> String {
|
||||
let ctx = DeviceContext.shared
|
||||
return "\(ctx.appName)/\(ctx.appVersion) (\(ctx.deviceModel); \(ctx.osName) \(ctx.osVersion); Scale/\(ctx.screenScale))"
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user