enum Environment { case development case production } struct AppConfig { static var current: Environment = { #if DEBUG return .development #else return .production #endif }() static var baseURL: String { switch current { case .development: return "http://beta.api.molistar.xyz" case .production: return "https://api.hfighting.com" } } // 添加更多环境变量 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 { #if DEBUG return true #else return false #endif } // 添加服务器信任配置 static var serverTrustPolicies: [String: ServerTrustEvaluating] { #if DEBUG return ["beta.api.molistar.xyz": DisabledTrustEvaluator()] #else return ["api.hfighting.com": PublicKeysTrustEvaluator()] #endif } static var networkDebugEnabled: Bool { #if DEBUG return true #else return false #endif } }