LauncherConfig.cs 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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 SQL_FILE_NAME = "excelConfig.sqlite.bytes";
  22. public const string LAST_LOGIN_IS_AGREE_KEY = "LAST_LOGIN_IS_AGREE_KEY_6"; //上次登录是否同意隐私政策
  23. public static string CDN_ROOT;
  24. public static string launcherRootUrl;
  25. public static string cfgUrl;
  26. //平台id
  27. public static int platformId = 1;
  28. //渠道id
  29. public static int ChannelId = 101;
  30. public static string logApiRootUrl; //上报普通日志接口
  31. public static string logApiReportLauncherUrl; //上报节点日志接口
  32. public static string apkVersion;
  33. //0 正常,1 维护中
  34. public static int serverStatus;
  35. public static string statusPrompt;
  36. //0 关闭所有log界面,1 开启后台log界面, 2 开启弹窗log界面
  37. public static int onDebug;
  38. //AB资源版本
  39. public static string manifest_v;
  40. //隐私政策文件地址模版
  41. public static string privacy_v;
  42. public static string updateAppPrompt;
  43. public static string updateResPrompt;
  44. public static int promptSizeMB;
  45. public static string updateUrl;
  46. public static long updateEndTime; //强制更新期限,毫秒级时间戳
  47. //新发行给的adId
  48. public static string douYouAdId;
  49. public static void InitScriptCompilation()
  50. {
  51. launcherRootUrl = "http://gfg-client.obs.cn-north-4.myhuaweicloud.com/";
  52. #if PT_DEV
  53. //外网dev版本
  54. netType = EnumNetType.LOCAL;
  55. cfgName = "cfg_dev19";
  56. ChannelId = (int)ChannelID.Test;
  57. #elif PT_DouYouDev
  58. netType = EnumNetType.LOCAL;
  59. cfgName = "cfg_douYouDev";
  60. ChannelId = (int)ChannelID.DouYouDev;
  61. #elif PT_TAPTAP
  62. netType = EnumNetType.PUBLIC;
  63. cfgName = "cfg_taptap";
  64. ChannelId = (int)ChannelID.TapTap;
  65. #elif PT_DOUYOU
  66. netType = EnumNetType.PUBLIC;
  67. cfgName = "cfg_douYou12";
  68. ChannelId = (int)ChannelID.DouYou;
  69. #elif PT_DouYouTap
  70. netType = EnumNetType.PUBLIC;
  71. cfgName = "cfg_douYouTap";
  72. ChannelId = (int)ChannelID.DouYou;
  73. #elif PT_IOS
  74. netType = EnumNetType.PUBLIC;
  75. cfgName = "cfg_ios";
  76. platformId = 2;
  77. ChannelId = (int)ChannelID.AppStore;
  78. #elif PT_TISHEN
  79. netType = EnumNetType.TISHEN;
  80. cfgName = "cfg_ts";
  81. #else
  82. netType = EnumNetType.LOCAL;
  83. cfgName = "cfg_local";
  84. ChannelId = (int)ChannelID.Test;
  85. #endif
  86. cfgUrl = launcherRootUrl + "platform/{cfgName}.json";
  87. }
  88. public static void InitPlatform(string json)
  89. {
  90. var result = JsonMapper.ToObject<Result>(json);
  91. LauncherConfig.CDN_ROOT = result.cdnRoot;
  92. LauncherConfig.logApiRootUrl = result.logApiUrl;
  93. LauncherConfig.logApiReportLauncherUrl = LauncherConfig.logApiRootUrl + "ReportNode";
  94. LauncherConfig.apkVersion = result.apkVersion;
  95. if (!string.IsNullOrEmpty(result.serverStatus))
  96. {
  97. LauncherConfig.serverStatus = int.Parse(result.serverStatus);
  98. }
  99. if (!string.IsNullOrEmpty(result.onDebug))
  100. {
  101. LauncherConfig.onDebug = int.Parse(result.onDebug);
  102. }
  103. if (!string.IsNullOrEmpty(result.douYouAdId))
  104. {
  105. LauncherConfig.douYouAdId = result.douYouAdId;
  106. }
  107. LauncherConfig.manifest_v = result.manifest_v;
  108. LauncherConfig.privacy_v = result.privacy_v;
  109. LauncherConfig.statusPrompt = result.statusPrompt;
  110. LauncherConfig.updateAppPrompt = result.updateAppPrompt;
  111. LauncherConfig.updateResPrompt = result.updateResPrompt;
  112. LauncherConfig.updateUrl = result.updateUrl;
  113. if (!string.IsNullOrEmpty(result.updateEndTime))
  114. {
  115. LauncherConfig.updateEndTime = LauncherTimeUtil.GetTimestamp(result.updateEndTime);
  116. }
  117. if (!string.IsNullOrEmpty(result.promptSizeMB))
  118. {
  119. LauncherConfig.promptSizeMB = int.Parse(result.promptSizeMB);
  120. }
  121. }
  122. private struct Result
  123. {
  124. public string cdnRoot;
  125. public string logApiUrl;
  126. public string apkVersion;
  127. public string serverStatus;
  128. public string onDebug;
  129. public string manifest_v;
  130. public string privacy_v;
  131. public string statusPrompt;
  132. public string updateAppPrompt;
  133. public string updateResPrompt;
  134. public string promptSizeMB;
  135. public string updateUrl;
  136. public string douYouAdId;
  137. public string updateEndTime; //更新最后时间
  138. }
  139. }
  140. }