checkIPhoneX.js 601 B

123456789101112131415161718192021222324252627282930
  1. /**
  2. * 获取系统信息
  3. */
  4. let systemInfo = null
  5. export const getSystemInfo = (isForce) => {
  6. if (!systemInfo || isForce) {
  7. try {
  8. systemInfo = wx.getSystemInfoSync()
  9. } catch(e) { /* Ignore */ }
  10. }
  11. return systemInfo
  12. }
  13. // iPhoneX 竖屏安全区域
  14. export const safeAreaInset = {
  15. top: 88, // StatusBar & NavBar
  16. left: 0,
  17. right: 0,
  18. bottom: 34, // Home Indicator
  19. }
  20. const isIPhoneX = ({ model, platform }) => {
  21. return /iPhone X/.test(model) && platform === 'ios'
  22. }
  23. export const checkIPhoneX = (isForce) => isIPhoneX(getSystemInfo(isForce))