RQConfigureManager.m 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. //
  2. // RQConfigureManager.m
  3. // RQCommon
  4. //
  5. // Created by 张嵘 on 2018/11/23.
  6. // Copyright © 2018 张嵘. All rights reserved.
  7. //
  8. #import "RQConfigureManager.h"
  9. ///
  10. static NSString *is_formal_setting = nil;
  11. static NSString *is_use_https = nil;
  12. static NSString *is_appStore_formal_setting = nil;
  13. /// (AppStore环境的key)
  14. static NSString * const RQApplicationAppStoreFormalSettingKey = @"RQApplicationAppStoreFormalSettingKey";
  15. /// 正式环境key
  16. static NSString * const RQApplicationFormalSettingKey = @"RQApplicationFormalSettingKey";
  17. /// 使用Httpskey
  18. static NSString * const RQApplicationUseHttpsKey = @"RQApplicationUseHttpsKey";
  19. @implementation RQConfigureManager
  20. /// 公共配置
  21. + (void)configure{
  22. /// 初始化一些公共配置...
  23. }
  24. + (void)setApplicationFormalSetting:(BOOL)formalSetting{
  25. is_formal_setting = formalSetting?@"1":@"0";
  26. [[NSUserDefaults standardUserDefaults] setObject:is_formal_setting forKey:RQApplicationFormalSettingKey];
  27. [[NSUserDefaults standardUserDefaults] synchronize];
  28. }
  29. + (BOOL)applicationFormalSetting {
  30. #if DEBUG
  31. if (!is_formal_setting) {
  32. is_formal_setting = [[NSUserDefaults standardUserDefaults] objectForKey:RQApplicationFormalSettingKey];
  33. is_formal_setting = [is_formal_setting rq_stringValueExtension];
  34. }
  35. return (is_formal_setting.integerValue == 0);
  36. #else
  37. /// Release 模式下默认
  38. return YES;
  39. #endif
  40. }
  41. + (void)setApplicationAppStoreFormalSetting:(BOOL)formalSetting{
  42. is_appStore_formal_setting = formalSetting?@"1":@"0";
  43. [[NSUserDefaults standardUserDefaults] setObject:is_appStore_formal_setting forKey:RQApplicationAppStoreFormalSettingKey];
  44. [[NSUserDefaults standardUserDefaults] synchronize];
  45. }
  46. + (BOOL)applicationAppStoreFormalSetting{
  47. #if DEBUG
  48. if (!is_appStore_formal_setting) {
  49. is_appStore_formal_setting = [[NSUserDefaults standardUserDefaults] objectForKey:RQApplicationAppStoreFormalSettingKey];
  50. is_appStore_formal_setting = [is_appStore_formal_setting rq_stringValueExtension];
  51. }
  52. return (is_appStore_formal_setting.integerValue == 1);
  53. #else
  54. /// Release 默认是AppStore环境
  55. return YES;
  56. #endif
  57. }
  58. + (void)setApplicationUseHttps:(BOOL)useHttps{
  59. is_use_https = useHttps?@"1":@"0";
  60. [[NSUserDefaults standardUserDefaults] setObject:is_use_https forKey:RQApplicationUseHttpsKey];
  61. [[NSUserDefaults standardUserDefaults] synchronize];
  62. }
  63. +(BOOL)applicationUseHttps{
  64. #if DEBUG
  65. if (!is_use_https) {
  66. is_use_https = [[NSUserDefaults standardUserDefaults] objectForKey:RQApplicationUseHttpsKey];
  67. /// 正式环境
  68. if ([self applicationFormalSetting]) {
  69. /// 默认如果是nil 则加载Http
  70. if (is_use_https == nil) {
  71. is_use_https = @"0";
  72. }
  73. }
  74. is_use_https = [is_use_https rq_stringValueExtension];
  75. }
  76. return (is_use_https.integerValue == 1);
  77. #else
  78. /// Release 默认是AppStore环境
  79. return YES;
  80. #endif
  81. }
  82. /// 请求的baseUrl
  83. + (NSString *)requestBaseUrl {
  84. if ([self applicationFormalSetting]) {
  85. /// 注意:这里针对你项目中请求baseUrl来处理....
  86. if ([self applicationAppStoreFormalSetting]) {
  87. /// AppStore正式环境
  88. NSLog(@"¥¥¥¥¥¥¥¥ AppStore正式环境 ¥¥¥¥¥¥¥¥");
  89. return RQ_COMMON_MANAGER.JSJP_DOMIAN_NAME_IS_OLD ? @"http://fj.jppt.com.cn/appservice/" : @"http://121.46.4.11:18081/";
  90. } else {
  91. /// 测试正式环境
  92. NSLog(@"¥¥¥¥¥¥¥¥ 测试正式环境 ¥¥¥¥¥¥¥¥");
  93. return RQ_COMMON_MANAGER.JSJP_DOMIAN_NAME_IS_OLD ? @"http://fj.jppt.com.cn/appservice/" : @"http://121.46.4.11:18081/";
  94. }
  95. } else {
  96. /// 测试环境
  97. NSLog(@"¥¥¥¥¥¥¥¥ 测试环境 ¥¥¥¥¥¥¥¥");
  98. return [self applicationUseHttps] ? @"http://192.168.8.97:8080/xmappservice2/" : @"http://192.168.8.97:8080/xmappservice2/";
  99. }
  100. }
  101. /// http://121.46.4.11:18081/
  102. /// http://fj.jppt.com.cn/appservice/
  103. @end