LauncherConfig.cs 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. using LitJson;
  2. namespace GFGGame
  3. {
  4. public class LauncherConfig
  5. {
  6. public enum EnumNetType
  7. {
  8. DEV,
  9. LOCAL,
  10. TEMP,
  11. TISHEN,
  12. PUBLIC
  13. }
  14. public static EnumNetType netType = EnumNetType.LOCAL;
  15. public static string cfgName;
  16. //热更代码存放位置
  17. public const string DllDirHotfix = "Assets/ResIn/Dll/Update/";
  18. public const string DllDirAOT = "Assets/ResIn/Dll/AOT/";
  19. public const int HTTP_GET_TIME_OUT = 3;
  20. public const int HTTP_POST_TIME_OUT = 15;
  21. public const string LAST_LOGIN_IS_AGREE_KEY = "LAST_LOGIN_IS_AGREE_KEY_6"; //上次登录是否同意隐私政策
  22. public static string CDN_ROOT;
  23. public static string launcherRootUrl;
  24. public static string cfgUrl;
  25. //平台id
  26. public static int platformId = 1;
  27. //渠道id
  28. public static int ChannelId = 101;
  29. public static string logApiRootUrl; //上报普通日志接口
  30. public static string logApiReportLauncherUrl; //上报节点日志接口
  31. public static string apkVersion;
  32. //0 正常,1 维护中
  33. public static int serverStatus;
  34. public static string statusPrompt;
  35. //0 关闭所有log界面,1 开启后台log界面, 2 开启弹窗log界面
  36. public static int onDebug;
  37. //AB资源版本
  38. public static string manifest_v;
  39. //隐私政策文件地址模版
  40. public static string privacy_v;
  41. public static string updateAppPrompt;
  42. public static string updateResPrompt;
  43. public static int promptSizeMB;
  44. public static string updateUrl;
  45. public static long updateEndTime; //强制更新期限,毫秒级时间戳
  46. //新发行给的
  47. public static string showLog;
  48. public static string gameId;
  49. public static string douYouAdId;
  50. public static string vxSdkAppId = "wxd9772f42f126413f";
  51. //是否使用douYou的ios sdk 0不使用用douYouSdk 1使用douYouSdk
  52. public static string isUseDouYouIos;
  53. public static bool isHttps;
  54. public static string rechargeAddress;
  55. public static bool IsTest = true;
  56. public static void InitScriptCompilation()
  57. {
  58. launcherRootUrl = "https://cdn.goufuguiwxw.com/";
  59. #if PT_DEV
  60. //外网dev版本
  61. netType = EnumNetType.LOCAL;
  62. cfgName = "cfg_dev19";
  63. ChannelId = (int)ChannelID.Test;
  64. #elif PT_DouYouDev
  65. netType = EnumNetType.LOCAL;
  66. cfgName = "cfg_douYouDev";
  67. ChannelId = (int)ChannelID.DouYouDev;
  68. #elif PT_TAPTAP
  69. netType = EnumNetType.PUBLIC;
  70. cfgName = "cfg_taptap";
  71. ChannelId = (int)ChannelID.TapTap;
  72. #elif PT_DOUYOU
  73. netType = EnumNetType.PUBLIC;
  74. cfgName = "cfg_gfg";
  75. ChannelId = (int)ChannelID.DouYou;
  76. #elif PT_IOS
  77. netType = EnumNetType.PUBLIC;
  78. cfgName = "cfg_ios";
  79. platformId = 2;
  80. ChannelId = (int)ChannelID.GFG;
  81. #elif PT_IosLocal
  82. netType = EnumNetType.PUBLIC;
  83. cfgName = "cfg_ios2";
  84. platformId = 2;
  85. isUseDouYouIos = "1";
  86. ChannelId = (int)ChannelID.GFG;
  87. #else
  88. netType = EnumNetType.PUBLIC;
  89. cfgName = "cfg_webgllocal";
  90. ChannelId = (int)ChannelID.H5;
  91. #endif
  92. cfgUrl = launcherRootUrl + "platform/{cfgName}.json";
  93. }
  94. public static void InitPlatform(string json)
  95. {
  96. var result = JsonMapper.ToObject<Result>(json);
  97. LauncherConfig.CDN_ROOT = result.cdnRoot;
  98. LauncherConfig.logApiRootUrl = result.logApiUrl;
  99. LauncherConfig.logApiReportLauncherUrl = LauncherConfig.logApiRootUrl + "ReportNode";
  100. LauncherConfig.apkVersion = result.apkVersion;
  101. if (!string.IsNullOrEmpty(result.serverStatus))
  102. {
  103. LauncherConfig.serverStatus = int.Parse(result.serverStatus);
  104. }
  105. if (!string.IsNullOrEmpty(result.onDebug))
  106. {
  107. LauncherConfig.onDebug = int.Parse(result.onDebug);
  108. }
  109. if (!string.IsNullOrEmpty(result.showLog))
  110. {
  111. LauncherConfig.showLog = result.showLog;
  112. }
  113. if (!string.IsNullOrEmpty(result.gameId))
  114. {
  115. LauncherConfig.gameId = result.gameId;
  116. }
  117. if (!string.IsNullOrEmpty(result.douYouAdId))
  118. {
  119. LauncherConfig.douYouAdId = result.douYouAdId;
  120. }
  121. if (!string.IsNullOrEmpty(result.rechargeAddress))
  122. {
  123. LauncherConfig.rechargeAddress = result.rechargeAddress;
  124. }
  125. LauncherConfig.manifest_v = result.manifest_v;
  126. LauncherConfig.privacy_v = result.privacy_v;
  127. LauncherConfig.statusPrompt = result.statusPrompt;
  128. LauncherConfig.updateAppPrompt = result.updateAppPrompt;
  129. LauncherConfig.updateResPrompt = result.updateResPrompt;
  130. LauncherConfig.updateUrl = result.updateUrl;
  131. if (!string.IsNullOrEmpty(result.updateEndTime))
  132. {
  133. LauncherConfig.updateEndTime = LauncherTimeUtil.GetTimestamp(result.updateEndTime);
  134. }
  135. if (!string.IsNullOrEmpty(result.isHttps))
  136. {
  137. LauncherConfig.isHttps = result.isHttps == "1";
  138. }
  139. if (!string.IsNullOrEmpty(result.promptSizeMB))
  140. {
  141. LauncherConfig.promptSizeMB = int.Parse(result.promptSizeMB);
  142. }
  143. }
  144. private struct Result
  145. {
  146. public string cdnRoot;
  147. public string logApiUrl;
  148. public string apkVersion;
  149. public string serverStatus;
  150. public string onDebug;
  151. public string manifest_v;
  152. public string privacy_v;
  153. public string statusPrompt;
  154. public string updateAppPrompt;
  155. public string updateResPrompt;
  156. public string promptSizeMB;
  157. public string updateUrl;
  158. public string douYouAdId;
  159. public string gameId;
  160. public string showLog;
  161. public string updateEndTime; //更新最后时间
  162. public string isUseDouYouIos;
  163. public string isHttps;
  164. public string rechargeAddress;
  165. }
  166. }
  167. }