CNLiveEnvironment.swift 7.68 KB
//
//  CNLiveEnvironment.swift
//  metaCode
//
//  Created by daojian on 2023/6/15.
//

import Foundation
import CNLiveEnvironment

///当前应用的APPID
let APPId: String  = CNLiveMCEnvironmentManager.shared.appId
///当前应用的APPKey
let APPKey: String = CNLiveMCEnvironmentManager.shared.appKey
///网家家应用的APPID
let APPId_wjj: String  = CNLiveMCEnvironmentManager.shared.appId_wjj
///网家家应用的APPKey
let APPKey_wjj: String = CNLiveMCEnvironmentManager.shared.appKey_wjj
///网家家B端应用的APPID
let APPId_wjj_b: String  = CNLiveMCEnvironmentManager.shared.appId_wjj_b
///网家家B端应用的APPKey
let APPKey_wjj_b: String = CNLiveMCEnvironmentManager.shared.appKey_wjj_b
///当前应用的登录请求域名
let APPLoginHost: String = CNLiveMCEnvironmentManager.shared.loginHost
///当前应用的Secret
let APPSecret: String = CNLiveMCEnvironmentManager.shared.appSecret
///当前应用的部分请求接口
let APPBaseMCUrl: String = CNLiveMCEnvironmentManager.shared.base_mc_url
/// 网家家内接口
let APPBaseWjjUrl: String = CNLiveMCEnvironmentManager.shared.base_wjj_url
/// 网家家B端内接口
let APPBaseWjjBUrl: String = CNLiveMCEnvironmentManager.shared.base_wjj_b_url
/// 网家家内电商接口
let APPBaseWjjShopUrl: String = CNLiveMCEnvironmentManager.shared.base_mjj_shop_url
/// cms接口
let APPBaseCMSUrl: String = CNLiveMCEnvironmentManager.shared.base_cms_url
/// 用户云接口
let APPBaseTokenUrl: String = CNLiveMCEnvironmentManager.shared.img_token_url
/// cms_api接口
let APPBaseCMSClassUrl: String = CNLiveMCEnvironmentManager.shared.base_cms_class_url
///当前APP的环境
let APPCurrentEnvironment: CNLiveEnvironment = CNLiveMCEnvironmentManager.shared.currentEnvironment

///是否是开发环境
let IsDevEnvironment: Bool = (CNLiveMCEnvironmentManager.shared.currentEnvironment == .development)
///是否是testFlight 环境
let IsTestFlightEnvironment: Bool = (CNLiveMCEnvironmentManager.shared.currentEnvironment == .testFlight)
///是否是线上环境
let IsProductionEnvironment: Bool = (CNLiveMCEnvironmentManager.shared.currentEnvironment == .production)

//UniversalLink地址
let universalLinkURL: String = "https://metacode.cnlive.com"
//腾讯 appId
let tencentAppId: String = "1112336586"
//微信 appId
let wxAppId: String = "wx82209bed331a549b"

///APP 环境类型
enum CNLiveEnvironment {
    ///开发环境
    case development
    ///testFlight 环境
    case testFlight
    ///线上环境
    case production
    
}

class CNLiveMCEnvironmentManager: NSObject{
    
    //单例类
    static let shared = CNLiveMCEnvironmentManager()
    
    var appId: String
    var appKey: String
    var appId_wjj: String
    var appKey_wjj: String
    var appSecret: String
    var appId_wjj_b: String
    var appKey_wjj_b: String
    ///登录接口域名
    var loginHost: String
    /// 码云项目的主域名
    var base_mc_url: String
    /// 网家家域名请求
    var base_wjj_url: String
    /// 网家家B端接口
    var base_wjj_b_url: String
    /// 获取IM token 请求域名
    var img_token_url: String
    /// 网家家电商域名请求
    var base_mjj_shop_url: String
    /// 元码webViewUA设置
    var base_web_UA: String = "yuanma"
    /// cms域名请求
    var base_cms_url: String
    /// UGC视频请求地址
    var base_cms_class_url: String
    
    ///当前环境
    var currentEnvironment: CNLiveEnvironment
    
    //重新init方法为私有,不让外部调用
    private override init() {
        self.appId = ""
        self.appKey = ""
        self.appId_wjj = ""
        self.appKey_wjj = ""
        self.loginHost = ""
        self.appSecret = ""
        self.appId_wjj_b = ""
        self.appKey_wjj_b = ""
        self.base_mc_url = ""
        self.img_token_url = ""
        self.base_wjj_url = ""
        self.base_wjj_b_url = ""
        self.base_mjj_shop_url = ""
        self.base_cms_url = ""
        self.base_cms_class_url = ""
        self.currentEnvironment = .development
    }
    //重新copy 和 mutableCopy 方法
    override func copy() -> Any {
        return self
    }
    
    override func mutableCopy() -> Any {
        return self
    }
    
    //配置环境
    func setupEnvironment(environment: CNLiveEnvironment){
        
        self.currentEnvironment = environment
        
        switch environment {
        case .development:
            self.developmentEnvironment()
            CNLiveEnvironmentManager.setEnvironment(.debugInHouse, isNewHomePage: true)
        case .testFlight:
            self.testFlightEnvironment()
            CNLiveEnvironmentManager.setEnvironment(.testFlight, isNewHomePage: true)
        case .production:
            self.productionEnvironment()
            CNLiveEnvironmentManager.setEnvironment(.productionAppStore, isNewHomePage: true)
        }
    }
    
    //开发环境配置
    func developmentEnvironment(){
        self.appId = "802_li40qhp922"
        self.appKey = "ae3a7ad3e4b9beb7cfe2078db648ebb89aa249ca2e82ac"
        self.appId_wjj = "802_jhlqbq4475"
        self.appKey_wjj = "d25cf0dce30e7d7ddc7c857b85ab0dde670d491fc2ffe4"
        self.appId_wjj_b = "769_jnjxdh3w53"
        self.appKey_wjj_b = "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCpeLgK0vk5POU5PQ"
        self.appSecret = "3cc9f12db322a3d3656012ef929604cf6d6847471535f9"
        self.loginHost = "https://api.cnlive.com"
        self.img_token_url = "https://api.cnlive.com/open/api2"
        self.base_mc_url = "https://metacode.cnlive.com/api"
        self.base_wjj_b_url = "https://managemall.cnlive.com:8080"
        self.base_wjj_url = "https://apiwjj.cnlive.com"
        self.base_mjj_shop_url = "https://manageshop.cnlive.com"
        self.base_cms_url = "https://cmsapi.cnlive.com"
        self.base_cms_class_url = "https://cmstest.cnlive.com"
    }
    //testFlight 环境配置
    func testFlightEnvironment(){
        self.appId = "802_li40qhp922"
        self.appKey = "ae3a7ad3e4b9beb7cfe2078db648ebb89aa249ca2e82ac"
        self.appId_wjj = "769_jetj7bq525"
        self.appKey_wjj = "0d57b045ec0c3988a682d94c644e66b9b8e0d2b8ef937d"
        self.appId_wjj_b = "769_jnjxdh3w53"
        self.appKey_wjj_b = "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCpeLgK0vk5POU5PQ"
        self.appSecret = "3cc9f12db322a3d3656012ef929604cf6d6847471535f9"
        self.loginHost = "https://api.cnlive.com"
        self.img_token_url = "https://api.cnlive.com/open/api2"
        self.base_mc_url = "https://metacode.cnlive.com/api"
        self.base_wjj_b_url = "https://managemall.cnlive.com:8080"
        self.base_wjj_url = "https://apiwjj.cnlive.com"
        self.base_mjj_shop_url = "https://manageshop.cnlive.com"
        self.base_cms_url = "https://cmsapi.cnlive.com"
        self.base_cms_class_url = "https://cms.cnlive.com/api"
    }
    //production 生产环境配置
    func productionEnvironment(){
        self.appId = "769_li40lrkt53"
        self.appKey = "064f392f84dfe7bbe9f1eabeda53ea02044213019b0406"
        self.appId_wjj = "769_jetj7bq525"
        self.appKey_wjj = "0d57b045ec0c3988a682d94c644e66b9b8e0d2b8ef937d"
        self.appId_wjj_b = "769_jnjxdh3w53"
        self.appKey_wjj_b = "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCpeLgK0vk5POU5PQ"
        self.appSecret = "68b5cc42fbdb466d56c2e22b00b1494feec8149f9dd32e"
        self.loginHost = "https://api.cnlive.com"
        self.img_token_url = "https://api.cnlive.com/open/api2"
        self.base_mc_url = "https://metacode.cnlive.com/api"
        self.base_wjj_b_url = "https://managemall.cnlive.com:8080"
        self.base_wjj_url = "https://apiwjj.cnlive.com"
        self.base_mjj_shop_url = "https://manageshop.cnlive.com"
        self.base_cms_url = "https://cmsapi.cnlive.com"
        self.base_cms_class_url = "https://cms.cnlive.com/api"
    }
    
}