version.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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;