version.js 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.canIUseGetUserProfile = exports.canIUseCanvas2d = exports.canIUseNextTick = exports.canIUseGroupSetData = exports.canIUseAnimate = exports.canIUseFormFieldButton = exports.canIUseModel = void 0;
  4. var utils_1 = require("./utils");
  5. function compareVersion(v1, v2) {
  6. v1 = v1.split('.');
  7. v2 = v2.split('.');
  8. var len = Math.max(v1.length, v2.length);
  9. while (v1.length < len) {
  10. v1.push('0');
  11. }
  12. while (v2.length < len) {
  13. v2.push('0');
  14. }
  15. for (var i = 0; i < len; i++) {
  16. var num1 = parseInt(v1[i], 10);
  17. var num2 = parseInt(v2[i], 10);
  18. if (num1 > num2) {
  19. return 1;
  20. }
  21. if (num1 < num2) {
  22. return -1;
  23. }
  24. }
  25. return 0;
  26. }
  27. function gte(version) {
  28. var system = utils_1.getSystemInfoSync();
  29. return compareVersion(system.SDKVersion, version) >= 0;
  30. }
  31. function canIUseModel() {
  32. return gte('2.9.3');
  33. }
  34. exports.canIUseModel = canIUseModel;
  35. function canIUseFormFieldButton() {
  36. return gte('2.10.3');
  37. }
  38. exports.canIUseFormFieldButton = canIUseFormFieldButton;
  39. function canIUseAnimate() {
  40. return gte('2.9.0');
  41. }
  42. exports.canIUseAnimate = canIUseAnimate;
  43. function canIUseGroupSetData() {
  44. return gte('2.4.0');
  45. }
  46. exports.canIUseGroupSetData = canIUseGroupSetData;
  47. function canIUseNextTick() {
  48. return wx.canIUse('nextTick');
  49. }
  50. exports.canIUseNextTick = canIUseNextTick;
  51. function canIUseCanvas2d() {
  52. return gte('2.9.0');
  53. }
  54. exports.canIUseCanvas2d = canIUseCanvas2d;
  55. function canIUseGetUserProfile() {
  56. return !!wx.getUserProfile;
  57. }
  58. exports.canIUseGetUserProfile = canIUseGetUserProfile;