123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- //
- // RQConfigureManager.m
- // RQCommon
- //
- // Created by 张嵘 on 2018/11/23.
- // Copyright © 2018 张嵘. All rights reserved.
- //
- #import "RQConfigureManager.h"
- ///
- static NSString *is_formal_setting = nil;
- static NSString *is_use_https = nil;
- static NSString *is_appStore_formal_setting = nil;
- /// (AppStore环境的key)
- static NSString * const RQApplicationAppStoreFormalSettingKey = @"RQApplicationAppStoreFormalSettingKey";
- /// 正式环境key
- static NSString * const RQApplicationFormalSettingKey = @"RQApplicationFormalSettingKey";
- /// 使用Httpskey
- static NSString * const RQApplicationUseHttpsKey = @"RQApplicationUseHttpsKey";
- @implementation RQConfigureManager
- /// 公共配置
- + (void)configure{
- /// 初始化一些公共配置...
-
- }
- + (void)setApplicationFormalSetting:(BOOL)formalSetting{
- is_formal_setting = formalSetting?@"1":@"0";
- [[NSUserDefaults standardUserDefaults] setObject:is_formal_setting forKey:RQApplicationFormalSettingKey];
- [[NSUserDefaults standardUserDefaults] synchronize];
- }
- + (BOOL)applicationFormalSetting {
- #if DEBUG
- if (!is_formal_setting) {
- is_formal_setting = [[NSUserDefaults standardUserDefaults] objectForKey:RQApplicationFormalSettingKey];
- is_formal_setting = [is_formal_setting rq_stringValueExtension];
- }
- return (is_formal_setting.integerValue == 0);
- #else
- /// Release 模式下默认
- return YES;
- #endif
- }
- + (void)setApplicationAppStoreFormalSetting:(BOOL)formalSetting{
- is_appStore_formal_setting = formalSetting?@"1":@"0";
- [[NSUserDefaults standardUserDefaults] setObject:is_appStore_formal_setting forKey:RQApplicationAppStoreFormalSettingKey];
- [[NSUserDefaults standardUserDefaults] synchronize];
- }
- + (BOOL)applicationAppStoreFormalSetting{
- #if DEBUG
- if (!is_appStore_formal_setting) {
- is_appStore_formal_setting = [[NSUserDefaults standardUserDefaults] objectForKey:RQApplicationAppStoreFormalSettingKey];
- is_appStore_formal_setting = [is_appStore_formal_setting rq_stringValueExtension];
- }
- return (is_appStore_formal_setting.integerValue == 1);
- #else
- /// Release 默认是AppStore环境
- return YES;
- #endif
- }
- + (void)setApplicationUseHttps:(BOOL)useHttps{
- is_use_https = useHttps?@"1":@"0";
- [[NSUserDefaults standardUserDefaults] setObject:is_use_https forKey:RQApplicationUseHttpsKey];
- [[NSUserDefaults standardUserDefaults] synchronize];
- }
- +(BOOL)applicationUseHttps{
- #if DEBUG
- if (!is_use_https) {
- is_use_https = [[NSUserDefaults standardUserDefaults] objectForKey:RQApplicationUseHttpsKey];
- /// 正式环境
- if ([self applicationFormalSetting]) {
- /// 默认如果是nil 则加载Http
- if (is_use_https == nil) {
- is_use_https = @"0";
- }
- }
- is_use_https = [is_use_https rq_stringValueExtension];
- }
- return (is_use_https.integerValue == 1);
- #else
- /// Release 默认是AppStore环境
- return YES;
- #endif
- }
- /// 请求的baseUrl
- + (NSString *)requestBaseUrl {
- if ([self applicationFormalSetting]) {
- /// 注意:这里针对你项目中请求baseUrl来处理....
- if ([self applicationAppStoreFormalSetting]) {
- /// AppStore正式环境
- NSLog(@"¥¥¥¥¥¥¥¥ AppStore正式环境 ¥¥¥¥¥¥¥¥");
- return RQ_COMMON_MANAGER.JSJP_DOMIAN_NAME_IS_OLD ? @"http://fj.jppt.com.cn/appservice/" : @"http://121.46.4.11:18081/";
- } else {
- /// 测试正式环境
- NSLog(@"¥¥¥¥¥¥¥¥ 测试正式环境 ¥¥¥¥¥¥¥¥");
- return RQ_COMMON_MANAGER.JSJP_DOMIAN_NAME_IS_OLD ? @"http://fj.jppt.com.cn/appservice/" : @"http://121.46.4.11:18081/";
- }
- } else {
- /// 测试环境
- NSLog(@"¥¥¥¥¥¥¥¥ 测试环境 ¥¥¥¥¥¥¥¥");
- return [self applicationUseHttps] ? @"http://192.168.8.97:8080/xmappservice2/" : @"http://192.168.8.97:8080/xmappservice2/";
- }
- }
- /// http://121.46.4.11:18081/
- /// http://fj.jppt.com.cn/appservice/
- @end
|