platform.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.isMiniProgramPlatform = exports.getPlatformDir = exports.getPlatforms = exports.registerPlatform = void 0;
  4. const BUILT_IN_PLATFORMS = [
  5. 'app',
  6. 'app-plus',
  7. 'h5',
  8. 'web',
  9. 'mp-360',
  10. 'mp-alipay',
  11. 'mp-baidu',
  12. 'mp-jd',
  13. 'mp-kuaishou',
  14. 'mp-lark',
  15. 'mp-qq',
  16. 'mp-toutiao',
  17. 'mp-weixin',
  18. 'quickapp-webview',
  19. 'quickapp-webview-huawei',
  20. 'quickapp-webview-union',
  21. ];
  22. const platforms = [...BUILT_IN_PLATFORMS];
  23. function registerPlatform(platform) {
  24. if (!platforms.includes(platform)) {
  25. platforms.push(platform);
  26. }
  27. }
  28. exports.registerPlatform = registerPlatform;
  29. function getPlatforms() {
  30. return platforms;
  31. }
  32. exports.getPlatforms = getPlatforms;
  33. function getPlatformDir() {
  34. return process.env.UNI_SUB_PLATFORM || process.env.UNI_PLATFORM;
  35. }
  36. exports.getPlatformDir = getPlatformDir;
  37. function isMiniProgramPlatform() {
  38. return !['app', 'app-plus', 'h5', 'web'].includes(process.env.UNI_PLATFORM);
  39. }
  40. exports.isMiniProgramPlatform = isMiniProgramPlatform;