version.js 761 B

12345678910111213141516171819202122232425262728293031
  1. import { getSystemInfoSync } from './utils';
  2. function compareVersion(v1, v2) {
  3. v1 = v1.split('.');
  4. v2 = v2.split('.');
  5. const len = Math.max(v1.length, v2.length);
  6. while (v1.length < len) {
  7. v1.push('0');
  8. }
  9. while (v2.length < len) {
  10. v2.push('0');
  11. }
  12. for (let i = 0; i < len; i++) {
  13. const num1 = parseInt(v1[i], 10);
  14. const num2 = parseInt(v2[i], 10);
  15. if (num1 > num2) {
  16. return 1;
  17. }
  18. if (num1 < num2) {
  19. return -1;
  20. }
  21. }
  22. return 0;
  23. }
  24. export function canIUseModel() {
  25. const system = getSystemInfoSync();
  26. return compareVersion(system.SDKVersion, '2.9.3') >= 0;
  27. }
  28. export function canIUseFormFieldButton() {
  29. const system = getSystemInfoSync();
  30. return compareVersion(system.SDKVersion, '2.10.3') >= 0;
  31. }