// // URLManager.swift // SHECommunity // // Created by 林 on 2024/11/26. // import Foundation import SwiftyUserDefaults import RxSwift extension DefaultsKeys { // 接口环境 0:测试环境 1:正式环境 var apiEnvKey: DefaultsKey { .init("ApiEnvKey", defaultValue: -99) } // 接口地址 var apiServerURL: DefaultsKey { .init("ApiServerURL", defaultValue: "") } } @objcMembers class URLManager: NSObject { static let shared = URLManager() // -1: UAT 0: 开发 1: 正式 var apiEnv: Int = 0 /// 接口地址 var apiServerURL: String = "" { didSet { AppNetworkConfig.shared.baseURL = apiServerURL } } /// OpenIM SDK var openIM_API = "" var openIM_WS = "" /// 用户协议 var userAgreementUrl: String { "https://sd.zuom8.cn/Agreement.html" } /// 隐私政策 var privacyPolicyUrl: String { "https://sd.zuom8.cn/Privacy.html" } /// 注销须知 var cancellationNoticeUrl: String { "https://h5.yiwen618.com.cn/yiwen_h5_logoff.html" } private override init() { super.init() self.setupNetworkMode() } func setupNetworkMode() { #if DEBUG setupApiEnv(1) openIM_API = "https://imapi.zuom8.cn" openIM_WS = "ws://imws.zuom8.cn" #elseif AdHoc setupApiEnv(-1) openIM_API = "http://38.207.176.65:10002" openIM_WS = "ws://38.207.176.65:10010" #else setupApiEnv(1) openIM_API = "http://38.207.176.65:10002" openIM_WS = "ws://38.207.176.65:10010" #endif } private func setupApiEnv(_ env: Int) { // env if Defaults[\.apiEnvKey] != -99 { apiEnv = Defaults[\.apiEnvKey] } else { apiEnv = env } // api if Defaults[\.apiServerURL].isEmpty { apiServerURL = apiServerURL(apiEnv) } else { apiServerURL = Defaults[\.apiServerURL] } } // MARK: - 接口地址 func apiServerURL(_ env: Int) -> String { switch env { case 1: // 正式 return "https://jsapi.zuom8.cn/" case -1: // UAT return "https://jsapi.zuom8.cn/" default: // SIT return "https://jsapi.zuom8.cn/" } } // MARK: - 大对象服务器地址 func uploadServerURL() -> String { //#if DEBUG // return "" //#else return "" //#endif } }