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://beta.api.pekolive.com" 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 } } }