Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | 6x 6x 6x 2x 2x 4x 6x | import { inBrowser } from './inBrowser' import { inMiniProgram } from './inMiniProgram' let yes!: boolean /** * 检查是否在 iOS 设备中。 * * @returns 返回检查结果 * @example * ```typescript * if (inIOS()) { * console.log('你在 iOS 设备中') * } * ``` */ export function inIOS(): boolean { if (yes == null) { const mp = inMiniProgram() if (mp) { const sysInfo = mp.getSystemInfoSync() yes = sysInfo.platform === 'ios' || /iOS/i.test(sysInfo.system) } else { yes = inBrowser() && typeof window.navigator === 'object' && /iPad|iPhone|iPod/i.test(window.navigator.platform || '') } } return yes } |