LauncherConfig.cs 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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. //新发行给的
  48. public static string showLog;
  49. public static string gameId;
  50. public static string douYouAdId;
  51. public static string vxSdkAppId = "wxd9772f42f126413f";
  52. //是否使用douYou的ios sdk 0不使用用douYouSdk 1使用douYouSdk
  53. public static string isUseDouYouIos;
  54. public static bool isHttps;
  55. public static void InitScriptCompilation()
  56. {
  57. launcherRootUrl = "https://cdn.goufuguiwxw.com/";
  58. #if PT_DEV
  59. //外网dev版本
  60. netType = EnumNetType.LOCAL;
  61. cfgName = "cfg_dev19";
  62. ChannelId = (int)ChannelID.Test;
  63. #elif PT_DouYouDev
  64. netType = EnumNetType.LOCAL;
  65. cfgName = "cfg_douYouDev";
  66. ChannelId = (int)ChannelID.DouYouDev;
  67. #elif PT_TAPTAP
  68. netType = EnumNetType.PUBLIC;
  69. cfgName = "cfg_taptap";
  70. ChannelId = (int)ChannelID.TapTap;
  71. #elif PT_DOUYOU
  72. netType = EnumNetType.PUBLIC;
  73. cfgName = "cfg_gfg";
  74. ChannelId = (int)ChannelID.DouYou;
  75. #elif PT_IOS
  76. netType = EnumNetType.PUBLIC;
  77. cfgName = "cfg_ios";
  78. platformId = 2;
  79. ChannelId = (int)ChannelID.GFG;
  80. #elif PT_IosLocal
  81. netType = EnumNetType.PUBLIC;
  82. cfgName = "cfg_ios2";
  83. platformId = 2;
  84. isUseDouYouIos = "1";
  85. ChannelId = (int)ChannelID.GFG;
  86. #else
  87. netType = EnumNetType.LOCAL;
  88. cfgName = "cfg_webgllocal";
  89. ChannelId = (int)ChannelID.Test;
  90. #endif
  91. cfgUrl = launcherRootUrl + "platform/{cfgName}.json";
  92. }
  93. public static void InitPlatform(string json)
  94. {
  95. var result = JsonMapper.ToObject<Result>(json);
  96. LauncherConfig.CDN_ROOT = result.cdnRoot;
  97. LauncherConfig.logApiRootUrl = result.logApiUrl;
  98. LauncherConfig.logApiReportLauncherUrl = LauncherConfig.logApiRootUrl + "ReportNode";
  99. LauncherConfig.apkVersion = result.apkVersion;
  100. if (!string.IsNullOrEmpty(result.serverStatus))
  101. {
  102. LauncherConfig.serverStatus = int.Parse(result.serverStatus);
  103. }
  104. if (!string.IsNullOrEmpty(result.onDebug))
  105. {
  106. LauncherConfig.onDebug = int.Parse(result.onDebug);
  107. }
  108. if (!string.IsNullOrEmpty(result.showLog))
  109. {
  110. LauncherConfig.showLog = result.showLog;
  111. }
  112. if (!string.IsNullOrEmpty(result.gameId))
  113. {
  114. LauncherConfig.gameId = result.gameId;
  115. }
  116. if (!string.IsNullOrEmpty(result.douYouAdId))
  117. {
  118. LauncherConfig.douYouAdId = result.douYouAdId;
  119. }
  120. LauncherConfig.manifest_v = result.manifest_v;
  121. LauncherConfig.privacy_v = result.privacy_v;
  122. LauncherConfig.statusPrompt = result.statusPrompt;
  123. LauncherConfig.updateAppPrompt = result.updateAppPrompt;
  124. LauncherConfig.updateResPrompt = result.updateResPrompt;
  125. LauncherConfig.updateUrl = result.updateUrl;
  126. if (!string.IsNullOrEmpty(result.updateEndTime))
  127. {
  128. LauncherConfig.updateEndTime = LauncherTimeUtil.GetTimestamp(result.updateEndTime);
  129. }
  130. if (!string.IsNullOrEmpty(result.isHttps))
  131. {
  132. LauncherConfig.isHttps = result.isHttps == "1";
  133. }
  134. if (!string.IsNullOrEmpty(result.promptSizeMB))
  135. {
  136. LauncherConfig.promptSizeMB = int.Parse(result.promptSizeMB);
  137. }
  138. }
  139. private struct Result
  140. {
  141. public string cdnRoot;
  142. public string logApiUrl;
  143. public string apkVersion;
  144. public string serverStatus;
  145. public string onDebug;
  146. public string manifest_v;
  147. public string privacy_v;
  148. public string statusPrompt;
  149. public string updateAppPrompt;
  150. public string updateResPrompt;
  151. public string promptSizeMB;
  152. public string updateUrl;
  153. public string douYouAdId;
  154. public string gameId;
  155. public string showLog;
  156. public string updateEndTime; //更新最后时间
  157. public string isUseDouYouIos;
  158. public string isHttps;
  159. }
  160. }
  161. }