CNLiveEnvironment.swift
5.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
//
// CNLiveEnvironment.swift
// metaCode
//
// Created by daojian on 2023/6/15.
//
import Foundation
///当前应用的APPID
let APPId: String = CNLiveEnvironmentManager.shared.appId
///当前应用的APPKey
let APPKey: String = CNLiveEnvironmentManager.shared.appKey
///网家家应用的APPID
let APPId_wjj: String = CNLiveEnvironmentManager.shared.appId_wjj
///网家家应用的APPKey
let APPKey_wjj: String = CNLiveEnvironmentManager.shared.appKey_wjj
///当前应用的登录请求域名
let APPLoginHost: String! = CNLiveEnvironmentManager.shared.loginHost
///当前应用的Secret
let APPSecret: String = CNLiveEnvironmentManager.shared.appSecret
///当前应用的部分请求接口
let APPBaseMCUrl: String = CNLiveEnvironmentManager.shared.base_mc_url
/// 网家家内接口
let APPBaseWjjUrl: String = CNLiveEnvironmentManager.shared.base_wjj_url
/// 网家家内电商接口
let APPBaseWjjShopUrl: String = CNLiveEnvironmentManager.shared.base_mjj_shop_url
///当前APP的环境
let APPCurrentEnvironment: CNLiveEnvironment = CNLiveEnvironmentManager.shared.currentEnvironment
///是否是开发环境
let IsDevEnvironment: Bool = (CNLiveEnvironmentManager.shared.currentEnvironment == .development)
///是否是testFlight 环境
let IsTestFlightEnvironment: Bool = (CNLiveEnvironmentManager.shared.currentEnvironment == .testFlight)
///是否是线上环境
let IsProductionEnvironment: Bool = (CNLiveEnvironmentManager.shared.currentEnvironment == .production)
///APP 环境类型
enum CNLiveEnvironment {
///开发环境
case development
///testFlight 环境
case testFlight
///线上环境
case production
}
class CNLiveEnvironmentManager: NSObject{
//单例类
static let shared = CNLiveEnvironmentManager()
var appId: String
var appKey: String
var appId_wjj: String
var appKey_wjj: String
var appSecret: String
///登录接口域名
var loginHost: String
/// 码云项目的主域名
var base_mc_url: String
/// 网家家域名请求
var base_wjj_url: String
/// 获取IM token 请求域名
var img_token_url: String
/// 网家家电商域名请求
var base_mjj_shop_url: String
/// 元码webViewUA设置
var base_web_UA: String = "yuanma"
///当前环境
var currentEnvironment: CNLiveEnvironment
//重新init方法为私有,不让外部调用
private override init() {
self.appId = ""
self.appKey = ""
self.appId_wjj = ""
self.appKey_wjj = ""
self.loginHost = ""
self.appSecret = ""
self.base_mc_url = ""
self.img_token_url = ""
self.base_wjj_url = ""
self.base_mjj_shop_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()
case .testFlight:
self.testFlightEnvironment()
case .production:
self.productionEnvironment()
}
}
//开发环境配置
func developmentEnvironment(){
self.appId = "802_li40qhp922"
self.appKey = "ae3a7ad3e4b9beb7cfe2078db648ebb89aa249ca2e82ac"
self.appId_wjj = "769_jetj7bq525"
self.appKey_wjj = "0d57b045ec0c3988a682d94c644e66b9b8e0d2b8ef937d"
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_url = "https://apiwjj.cnlive.com"
self.base_mjj_shop_url = "https://manageshop.cnlive.com"
}
//testFlight 环境配置
func testFlightEnvironment(){
self.appId = "802_li40qhp922"
self.appKey = "ae3a7ad3e4b9beb7cfe2078db648ebb89aa249ca2e82ac"
self.appId_wjj = "769_jetj7bq525"
self.appKey_wjj = "0d57b045ec0c3988a682d94c644e66b9b8e0d2b8ef937d"
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_url = "https://apiwjj.cnlive.com"
self.base_mjj_shop_url = "https://manageshop.cnlive.com"
}
//production 生产环境配置
func productionEnvironment(){
self.appId = "769_li40lrkt53"
self.appKey = "064f392f84dfe7bbe9f1eabeda53ea02044213019b0406"
self.appId_wjj = "769_jetj7bq525"
self.appKey_wjj = "0d57b045ec0c3988a682d94c644e66b9b8e0d2b8ef937d"
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_url = "https://apiwjj.cnlive.com"
self.base_mjj_shop_url = "https://manageshop.cnlive.com"
}
}