85 lines
2.1 KiB
Swift
85 lines
2.1 KiB
Swift
//
|
|
// URLManager.swift
|
|
// SHECommunity
|
|
//
|
|
// Created by 林 on 2024/11/26.
|
|
//
|
|
|
|
import Foundation
|
|
import SwiftyUserDefaults
|
|
import RxSwift
|
|
|
|
extension DefaultsKeys {
|
|
|
|
}
|
|
|
|
@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://smartdrive.zuom8.cn/jisu/Agreement.html" }
|
|
/// 隐私政策
|
|
var privacyPolicyUrl: String { "https://smartdrive.zuom8.cn/jisu/Privacy-ios.html" }
|
|
/// 儿童
|
|
var kidsPrivacyUrl: String { "https://smartdrive.zuom8.cn/jisu/KidsPrivacy.html" }
|
|
/// 注销须知
|
|
var cancellationNoticeUrl: String { "https://smartdrive.zuom8.cn/jisu/Cancellation.html" }
|
|
|
|
private override init() {
|
|
super.init()
|
|
self.setupNetworkMode()
|
|
}
|
|
|
|
func setupNetworkMode() {
|
|
setupApiEnv(1)
|
|
openIM_API = "https://imapi.zuom8.cn"
|
|
openIM_WS = "ws://imws.zuom8.cn"
|
|
}
|
|
|
|
private func setupApiEnv(_ env: Int) {
|
|
apiServerURL = apiServerURL(apiEnv)
|
|
}
|
|
|
|
// MARK: - 接口地址
|
|
func apiServerURL(_ env: Int) -> String {
|
|
switch env {
|
|
case 1: // 正式
|
|
return "https://speed.batiao8.com/"
|
|
case -1: // UAT
|
|
return "https://speed.batiao8.com/"
|
|
default: // SIT
|
|
return "https://speed.batiao8.com/"
|
|
}
|
|
}
|
|
|
|
static func normalizedServerURL(_ raw: String) -> String {
|
|
var url = raw.trimmingCharacters(in: .whitespacesAndNewlines)
|
|
guard !url.isEmpty else { return "" }
|
|
if !url.contains("://") {
|
|
url = "http://" + url
|
|
}
|
|
if !url.hasSuffix("/") {
|
|
url += "/"
|
|
}
|
|
return url
|
|
}
|
|
|
|
// MARK: - 大对象服务器地址
|
|
func uploadServerURL() -> String {
|
|
return ""
|
|
}
|
|
}
|