environment.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import compareVersion from "./compare-version";
  2. const env = wx ? wx : qq;
  3. if (!env) {
  4. console.error('不支持当前小程序环境');
  5. }
  6. const systemInfo = env.getSystemInfoSync();
  7. console.log('SystemInfo', systemInfo);
  8. let isNewVersion;
  9. if (typeof qq !== 'undefined') {
  10. isNewVersion = true;
  11. } else if (typeof wx !== 'undefined') {
  12. if (compareVersion(systemInfo.version, '7.0.8') >= 0 && compareVersion(systemInfo.SDKVersion, '2.10.0') >= 0) {
  13. isNewVersion = true;
  14. } else {
  15. isNewVersion = false;
  16. }
  17. }
  18. export const IS_TRTC = isNewVersion;
  19. export const IS_QQ = typeof qq !== 'undefined';
  20. export const IS_WX = typeof wx !== 'undefined';
  21. export const IS_IOS = /iOS/i.test(systemInfo.system);
  22. export const IS_ANDROID = /Android/i.test(systemInfo.system);
  23. export const APP_VERSION = systemInfo.version;
  24. export const LIB_VERSION = function () {
  25. if (systemInfo.SDKBuild) {
  26. return systemInfo.SDKVersion + '-' + systemInfo.SDKBuild;
  27. }
  28. return systemInfo.SDKVersion;
  29. }();
  30. console.log('APP_VERSION:', APP_VERSION, ' LIB_VERSION:', LIB_VERSION, ' is new version:', IS_TRTC);