LauncherConfig.cs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. using LitJson;
  2. namespace GFGGame
  3. {
  4. public class LauncherConfig
  5. {
  6. public enum EnumNetType { DEV, LOCAL, TEMP, TISHEN, PUBLIC }
  7. public static EnumNetType netType = EnumNetType.LOCAL;
  8. public static string cfgName;
  9. //热更代码存放位置
  10. public const string DllDirHotfix = "Assets/ResIn/Dll/Update/";
  11. public const string DllDirAOT = "Assets/ResIn/Dll/AOT/";
  12. public const int HTTP_GET_TIME_OUT = 3;
  13. public const int HTTP_POST_TIME_OUT = 15;
  14. public const string SQL_FILE_NAME = "excelConfig.sqlite.bytes";
  15. public const string LAST_LOGIN_IS_AGREE_KEY = "LAST_LOGIN_IS_AGREE_KEY_6";//上次登录是否同意隐私政策
  16. public static string CDN_ROOT;
  17. public static string launcherRootUrl;
  18. public static string cfgUrl;
  19. //平台id
  20. public static int platformId = 1;
  21. //渠道id
  22. public static int ChannelId = 101;
  23. public static string logApiRootUrl;//上报普通日志接口
  24. public static string logApiReportLauncherUrl;//上报节点日志接口
  25. public static string apkVersion;
  26. //0 正常,1 维护中
  27. public static int serverStatus;
  28. public static string statusPrompt;
  29. //0 关闭所有log界面,1 开启后台log界面, 2 开启弹窗log界面
  30. public static int onDebug;
  31. //AB资源版本
  32. public static string manifest_v;
  33. //隐私政策文件地址模版
  34. public static string privacy_v;
  35. public static string updateAppPrompt;
  36. public static string updateResPrompt;
  37. public static int promptSizeMB;
  38. public static string updateUrl;
  39. public static void InitScriptCompilation()
  40. {
  41. launcherRootUrl = "http://cdn.wanshijing.com/";
  42. #if PT_DEV
  43. //外网dev版本
  44. netType = EnumNetType.PUBLIC;
  45. cfgName = "cfg_dev";
  46. #elif PT_TAPTAP
  47. netType = EnumNetType.PUBLIC;
  48. cfgName = "cfg_taptap";
  49. ChannelId = (int)ChannelID.TapTap;
  50. #elif PT_QUICK
  51. netType = EnumNetType.PUBLIC;
  52. cfgName = "cfg_quick";
  53. var quickChannel = QuickSDK.getInstance().channelType();
  54. ChannelId = ChannelIDUtil.GetGameChannelID(quickChannel);
  55. #elif PT_IOS
  56. netType = EnumNetType.PUBLIC;
  57. cfgName = "cfg_ios";
  58. platformId = 2;
  59. ChannelId = (int)ChannelID.AppStore;
  60. #elif PT_TISHEN
  61. netType = EnumNetType.TISHEN;
  62. cfgName = "cfg_ts";
  63. #else
  64. netType = EnumNetType.LOCAL;
  65. cfgName = "cfg_local";
  66. launcherRootUrl = "http://10.108.64.189:81/";
  67. #endif
  68. cfgUrl = launcherRootUrl + "platform/{cfgName}.json";
  69. }
  70. public static void InitPlatform(string json)
  71. {
  72. var result = JsonMapper.ToObject<Result>(json);
  73. LauncherConfig.CDN_ROOT = result.cdnRoot;
  74. // CDN_ROOT = "http://10.108.64.143/";
  75. LauncherConfig.logApiRootUrl = result.logApiUrl;
  76. //LauncherConfig.logApiRootUrl = "http://10.108.64.106:8080/api/Log/";
  77. LauncherConfig.logApiReportLauncherUrl = LauncherConfig.logApiRootUrl + "ReportNode";
  78. LauncherConfig.apkVersion = result.apkVersion;
  79. if(!string.IsNullOrEmpty(result.serverStatus))
  80. {
  81. LauncherConfig.serverStatus = int.Parse(result.serverStatus);
  82. }
  83. if(!string.IsNullOrEmpty(result.onDebug))
  84. {
  85. LauncherConfig.onDebug = int.Parse(result.onDebug);
  86. }
  87. LauncherConfig.manifest_v = result.manifest_v;
  88. LauncherConfig.privacy_v = result.privacy_v;
  89. LauncherConfig.statusPrompt = result.statusPrompt;
  90. LauncherConfig.updateAppPrompt = result.updateAppPrompt;
  91. LauncherConfig.updateResPrompt = result.updateResPrompt;
  92. LauncherConfig.updateUrl = result.updateUrl;
  93. if(!string.IsNullOrEmpty(result.promptSizeMB))
  94. {
  95. LauncherConfig.promptSizeMB = int.Parse(result.promptSizeMB);
  96. }
  97. }
  98. private struct Result
  99. {
  100. public string cdnRoot;
  101. public string logApiUrl;
  102. public string apkVersion;
  103. public string serverStatus;
  104. public string onDebug;
  105. public string manifest_v;
  106. public string privacy_v;
  107. public string statusPrompt;
  108. public string updateAppPrompt;
  109. public string updateResPrompt;
  110. public string promptSizeMB;
  111. public string updateUrl;
  112. }
  113. }
  114. }