function osInfo() {
    const ua = navigator.userAgent
    const isiOS = !!ua.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)
    const isAndroid = ua.indexOf('Android') > -1 || ua.indexOf('Adr') > -1
    const dpr = window.devicePixelRatio <= 3 ? parseInt(window.devicePixelRatio, 10) : 3
    let os = ''
    let version = ''
    if (isiOS) {
        os = 'iOS'
        version = ua.match(/OS (\d+)_(\d+)_?(\d+)?/)
    } else if (isAndroid) {
        os = 'Android'
        version = ua.match(/Android\s([0-9]*)/)
    }
    version = version && version[1] && parseInt(version[1], 10)
    return {
        os: os,
        version: version,
        dpr: dpr,
    }
}
/**
 * 同步延迟器
 * @param { Number } timeout 延迟时间,ms
 */
async function sleep(timeout) {
    await new Promise((resolve) => {
        setTimeout(() => {
            resolve()
        }, timeout)
    })
}

export { osInfo, sleep }
