tt-mp
Version:
一套组件化、可复用、易扩展的头条小程序 UI 组件库
32 lines (25 loc) • 582 B
JavaScript
/**
* 获取系统信息
*/
let systemInfo = null
export const getSystemInfo = (isForce) => {
if (!systemInfo || isForce) {
try {
systemInfo = tt.getSystemInfoSync()
} catch (e) {
/* Ignore */
}
}
return systemInfo
}
// iPhoneX 竖屏安全区域
export const safeAreaInset = {
top: 88, // StatusBar & NavBar
left: 0,
right: 0,
bottom: 34, // Home Indicator
}
const isIPhoneX = ({ model, platform }) => {
return /iPhone X/.test(model) && platform === 'ios'
}
export const checkIPhoneX = (isForce) => isIPhoneX(getSystemInfo(isForce))