8e57e4c5-ec99-4493-87d2-a2f4e7040805.js 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  1. "use strict";
  2. cc._RF.push(module, '8e57eTF7JlEk4fSovTnBAgF', 'PlatUtils');
  3. // common-plugin/Scripts/PlatUtils.ts
  4. "use strict";
  5. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  6. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  7. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  8. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  9. return c > 3 && r && Object.defineProperty(target, key, r), r;
  10. };
  11. Object.defineProperty(exports, "__esModule", { value: true });
  12. var Utils_1 = require("./Utils");
  13. var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
  14. var PlatUtils = /** @class */ (function () {
  15. function PlatUtils() {
  16. }
  17. PlatUtils_1 = PlatUtils;
  18. Object.defineProperty(PlatUtils, "IsNativeAndroid", {
  19. /**
  20. * 原生安卓平台
  21. */
  22. get: function () {
  23. // jsb and android
  24. return (cc.sys.os == cc.sys.OS_ANDROID && CC_JSB);
  25. },
  26. enumerable: false,
  27. configurable: true
  28. });
  29. Object.defineProperty(PlatUtils, "IsNativeIOS", {
  30. get: function () {
  31. return (cc.sys.os == cc.sys.OS_IOS && CC_JSB);
  32. },
  33. enumerable: false,
  34. configurable: true
  35. });
  36. Object.defineProperty(PlatUtils, "ISUC", {
  37. /**
  38. * uc平台
  39. */
  40. get: function () {
  41. //@ts-ignore
  42. return window.uc;
  43. },
  44. enumerable: false,
  45. configurable: true
  46. });
  47. Object.defineProperty(PlatUtils, "ISCocos", {
  48. /**s
  49. * cocos平台
  50. */
  51. get: function () {
  52. //@ts-ignore
  53. return (window.loadRuntime && !this.IsOPPO && !this.IsVIVO && !window.kwaigame && !this.IsWiFi && !this.IsHuaWei);
  54. },
  55. enumerable: false,
  56. configurable: true
  57. });
  58. Object.defineProperty(PlatUtils, "IsAndroid", {
  59. /**
  60. * 安卓系统
  61. */
  62. get: function () {
  63. return cc.sys.os == cc.sys.OS_ANDROID;
  64. },
  65. enumerable: false,
  66. configurable: true
  67. });
  68. Object.defineProperty(PlatUtils, "IsIOS", {
  69. /**
  70. * IOS系统
  71. */
  72. get: function () {
  73. return cc.sys.os == cc.sys.OS_IOS;
  74. },
  75. enumerable: false,
  76. configurable: true
  77. });
  78. Object.defineProperty(PlatUtils, "IsWechat", {
  79. /**
  80. * 微信平台
  81. */
  82. get: function () {
  83. return cc.sys.platform == cc.sys.WECHAT_GAME && !this.IsDouyin && !this.IsQQ && !this.IsKwai;
  84. },
  85. enumerable: false,
  86. configurable: true
  87. });
  88. Object.defineProperty(PlatUtils, "IsOPPO", {
  89. /**
  90. * OPPO快游戏
  91. */
  92. get: function () {
  93. return cc.sys.platform == cc.sys.OPPO_GAME;
  94. },
  95. enumerable: false,
  96. configurable: true
  97. });
  98. Object.defineProperty(PlatUtils, "IsBaidu", {
  99. /**
  100. * 百度小游戏
  101. */
  102. get: function () {
  103. // return cc.sys.os == cc.sys.OS_ANDROID && cc.sys.platform == cc.sys.BAIDU_GAME;
  104. cc.sys.FB_PLAYABLE_ADS;
  105. return cc.sys.platform == cc.sys.BAIDU_GAME;
  106. },
  107. enumerable: false,
  108. configurable: true
  109. });
  110. Object.defineProperty(PlatUtils, "IsVIVO", {
  111. /**
  112. * VIVO小游戏
  113. */
  114. get: function () {
  115. return cc.sys.platform == cc.sys.VIVO_GAME;
  116. },
  117. enumerable: false,
  118. configurable: true
  119. });
  120. Object.defineProperty(PlatUtils, "IsDouyin", {
  121. /**
  122. * 抖音小游戏
  123. */
  124. get: function () {
  125. //@ts-ignorett
  126. return window.tt;
  127. },
  128. enumerable: false,
  129. configurable: true
  130. });
  131. Object.defineProperty(PlatUtils, "IsQQ", {
  132. /**
  133. * QQ小游戏
  134. * @returns 是否QQ平台
  135. */
  136. get: function () {
  137. //@ts-ignore
  138. return window.qq;
  139. },
  140. enumerable: false,
  141. configurable: true
  142. });
  143. Object.defineProperty(PlatUtils, "IsQTT", {
  144. /**
  145. * 趣头条
  146. * @returns 是否趣头条平台
  147. */
  148. get: function () {
  149. //@ts-ignore
  150. return window.qttGame;
  151. },
  152. enumerable: false,
  153. configurable: true
  154. });
  155. Object.defineProperty(PlatUtils, "IsXiaoMi", {
  156. /**
  157. * 小米
  158. * @returns 是否小米平台
  159. */
  160. get: function () {
  161. //@ts-ignore
  162. if (!PlatUtils_1.IsOPPO && !PlatUtils_1.IsVIVO && !PlatUtils_1.IsHuaWei && window.qg) {
  163. return true;
  164. }
  165. else {
  166. return false;
  167. }
  168. },
  169. enumerable: false,
  170. configurable: true
  171. });
  172. Object.defineProperty(PlatUtils, "Is4399", {
  173. /**
  174. * h5-4399
  175. * @returns 是否4399-h5平台
  176. */
  177. get: function () {
  178. //@ts-ignore
  179. return window.h5api;
  180. },
  181. enumerable: false,
  182. configurable: true
  183. });
  184. Object.defineProperty(PlatUtils, "IsBili", {
  185. /**
  186. * 是否bili平台
  187. * @returns 是否bili平台
  188. */
  189. get: function () {
  190. //@ts-ignore
  191. return window.bl;
  192. },
  193. enumerable: false,
  194. configurable: true
  195. });
  196. Object.defineProperty(PlatUtils, "IsKwai", {
  197. /**
  198. * 是否快手平台
  199. * @returns 是否快手平台
  200. */
  201. get: function () {
  202. //@ts-ignore
  203. return typeof KSGameGlobal != 'undefined';
  204. },
  205. enumerable: false,
  206. configurable: true
  207. });
  208. Object.defineProperty(PlatUtils, "IsWiFi", {
  209. /**
  210. * 是否连尚平台
  211. * @returns 是否连尚平台
  212. */
  213. get: function () {
  214. //@ts-ignore
  215. return window.wuji;
  216. },
  217. enumerable: false,
  218. configurable: true
  219. });
  220. Object.defineProperty(PlatUtils, "IsHago", {
  221. /**
  222. * 是否Hago平台
  223. * @returns 是否Hago平台
  224. */
  225. get: function () {
  226. //@ts-ignore
  227. return window.hg;
  228. },
  229. enumerable: false,
  230. configurable: true
  231. });
  232. Object.defineProperty(PlatUtils, "IsHuaWei", {
  233. /**
  234. * 是否华为平台
  235. * @returns 是否华为平台
  236. */
  237. get: function () {
  238. //@ts-ignore
  239. return window.hbs;
  240. },
  241. enumerable: false,
  242. configurable: true
  243. });
  244. Object.defineProperty(PlatUtils, "IsTest", {
  245. /**
  246. * 是否测试平台
  247. * @returns 是否测试平台
  248. */
  249. get: function () {
  250. //@ts-ignore
  251. return false;
  252. },
  253. enumerable: false,
  254. configurable: true
  255. });
  256. Object.defineProperty(PlatUtils, "IsFaceBook", {
  257. /**
  258. * 是否facebook小游戏
  259. */
  260. get: function () {
  261. //@ts-ignore
  262. return window.FB !== undefined || window.minigame_sdk !== undefined;
  263. },
  264. enumerable: false,
  265. configurable: true
  266. });
  267. Object.defineProperty(PlatUtils, "androidChannel", {
  268. /**
  269. * 获取安卓当前的渠道号
  270. */
  271. get: function () {
  272. if (Utils_1.utils.config && Utils_1.utils.config.nativeAndroidConfig) {
  273. return Utils_1.utils.config.nativeAndroidConfig.channel;
  274. }
  275. return "";
  276. },
  277. enumerable: false,
  278. configurable: true
  279. });
  280. Object.defineProperty(PlatUtils, "IsAndroidChuanYin", {
  281. /**
  282. * 是否安卓传音平台
  283. */
  284. get: function () {
  285. if (this.androidChannel == "chuanyin") {
  286. return true;
  287. }
  288. return false;
  289. },
  290. enumerable: false,
  291. configurable: true
  292. });
  293. Object.defineProperty(PlatUtils, "IsAndroidOppo", {
  294. /**
  295. * 是否安卓OPPO平台
  296. */
  297. get: function () {
  298. if (this.androidChannel == "oppo") {
  299. return true;
  300. }
  301. return false;
  302. },
  303. enumerable: false,
  304. configurable: true
  305. });
  306. Object.defineProperty(PlatUtils, "IsAndroidVivo", {
  307. /**
  308. * 是否安卓VIVO平台
  309. */
  310. get: function () {
  311. if (this.androidChannel == "vivo") {
  312. return true;
  313. }
  314. return false;
  315. },
  316. enumerable: false,
  317. configurable: true
  318. });
  319. Object.defineProperty(PlatUtils, "IsAndroidDouYin", {
  320. /**
  321. * 是否安卓抖音平台
  322. */
  323. get: function () {
  324. if (this.androidChannel == "douyin") {
  325. return true;
  326. }
  327. return false;
  328. },
  329. enumerable: false,
  330. configurable: true
  331. });
  332. Object.defineProperty(PlatUtils, "IsAndroidHuaWei", {
  333. /**
  334. * 是否安卓华为平台
  335. */
  336. get: function () {
  337. if (this.androidChannel.indexOf("huawei") > -1) {
  338. return true;
  339. }
  340. return false;
  341. },
  342. enumerable: false,
  343. configurable: true
  344. });
  345. Object.defineProperty(PlatUtils, "IsGoogleWeb", {
  346. /**
  347. * 是否谷歌Web游戏
  348. */
  349. get: function () {
  350. //@ts-ignore
  351. if (window.googleApi) {
  352. return true;
  353. }
  354. return false;
  355. },
  356. enumerable: false,
  357. configurable: true
  358. });
  359. var PlatUtils_1;
  360. PlatUtils = PlatUtils_1 = __decorate([
  361. ccclass
  362. ], PlatUtils);
  363. return PlatUtils;
  364. }());
  365. exports.default = PlatUtils;
  366. cc._RF.pop();