environment.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import compareVersion from './compare-version.js'
  2. const TAG_NAME = 'TRTC-ROOM'
  3. const env = wx ? wx : qq
  4. if (!env) {
  5. console.error(TAG_NAME, '不支持当前小程序环境')
  6. }
  7. const systemInfo = env.getSystemInfoSync()
  8. const safeArea = systemInfo.safeArea
  9. if (systemInfo.system === 'iOS 13.3' || (systemInfo.model === 'iPhoneX' && systemInfo.system === 'iOS 13.3.1') ) {
  10. // audio-volume-type = media
  11. console.log('use media audio volume type')
  12. }
  13. console.log(TAG_NAME, 'SystemInfo', systemInfo)
  14. let isNewVersion
  15. if (typeof qq !== 'undefined') {
  16. isNewVersion = true
  17. } else if (typeof wx !== 'undefined') {
  18. if (compareVersion(systemInfo.version, '7.0.8') >= 0 || // mobile pc
  19. (compareVersion(systemInfo.version, '2.4.0') >= 0 && compareVersion(systemInfo.version, '6.0.0') < 0) && // mac os
  20. compareVersion(systemInfo.SDKVersion, '2.10.0') >= 0) {
  21. isNewVersion = true
  22. } else {
  23. isNewVersion = false
  24. }
  25. }
  26. export const IS_TRTC = isNewVersion
  27. export const IS_QQ = typeof qq !== 'undefined'
  28. export const IS_WX = typeof wx !== 'undefined'
  29. export const IS_IOS = /iOS/i.test(systemInfo.system)
  30. export const IS_ANDROID = /Android/i.test(systemInfo.system)
  31. export const IS_MAC = /mac/i.test(systemInfo.system)
  32. export const APP_VERSION = systemInfo.version
  33. export const LIB_VERSION = (function() {
  34. if (systemInfo.SDKBuild) {
  35. return systemInfo.SDKVersion + '-' + systemInfo.SDKBuild
  36. }
  37. return systemInfo.SDKVersion
  38. })()
  39. let isFullscreenDevie = false
  40. if (systemInfo.screenHeight > safeArea.bottom) {
  41. // if (/iphone\s{0,}x/i.test(systemInfo.model)) {
  42. isFullscreenDevie = true
  43. }
  44. export const IS_FULLSCREEN_DEVICE = isFullscreenDevie
  45. console.log(TAG_NAME, 'APP_VERSION:', APP_VERSION, ' LIB_VERSION:', LIB_VERSION, ' is new version:', IS_TRTC)