
- 更新Yana项目文档,调整适用版本至iOS 17,确保与最新开发环境兼容。 - 在多个视图中重构代码,优化状态管理和视图逻辑,提升用户体验。 - 添加默认初始化器以简化状态管理,确保各个Feature的状态一致性。 - 更新视图组件,移除不必要的硬编码,增强代码可读性和维护性。 - 修复多个视图中的逻辑错误,确保功能正常运行。
79 lines
1.9 KiB
Swift
79 lines
1.9 KiB
Swift
enum AppEnvironment {
|
||
case development
|
||
case production
|
||
}
|
||
|
||
struct AppConfig {
|
||
static let current: AppEnvironment = {
|
||
#if DEBUG
|
||
return .development
|
||
#else
|
||
return .production
|
||
#endif
|
||
}()
|
||
|
||
static var baseURL: String {
|
||
switch current {
|
||
case .development:
|
||
// return "http://192.168.10.211:8080"
|
||
return "http://beta.api.molistar.xyz"
|
||
case .production:
|
||
return "https://api.epartylive.com"
|
||
}
|
||
}
|
||
|
||
/// Web页面路径前缀
|
||
/// - development环境: "/molistar"
|
||
/// - production环境: "/eparty"
|
||
static var webPathPrefix: String {
|
||
switch current {
|
||
case .development:
|
||
return "/molistar"
|
||
case .production:
|
||
return "/eparty"
|
||
}
|
||
}
|
||
|
||
// 添加更多环境变量
|
||
static var analyticsKey: String {
|
||
switch current {
|
||
case .development: return "dev_analytics_key"
|
||
case .production: return "prod_analytics_key"
|
||
}
|
||
}
|
||
|
||
// 运行时切换环境(用于测试)
|
||
// static func switchEnvironment(to env: Environment) {
|
||
// current = env
|
||
// }
|
||
|
||
// 网络调试配置
|
||
static var enableNetworkDebug: Bool {
|
||
switch current {
|
||
case .development:
|
||
return true
|
||
case .production:
|
||
return false
|
||
}
|
||
}
|
||
|
||
// 服务器信任配置
|
||
static var serverTrustPolicies: [String: ServerTrustEvaluating] {
|
||
switch current {
|
||
case .development:
|
||
return ["beta.api.molistar.xyz": DisabledTrustEvaluator()]
|
||
case .production:
|
||
return ["api.epartylive.com": PublicKeysTrustEvaluator()]
|
||
}
|
||
}
|
||
|
||
static var networkDebugEnabled: Bool {
|
||
switch current {
|
||
case .development:
|
||
return true
|
||
case .production:
|
||
return false
|
||
}
|
||
}
|
||
}
|