const userAgent = navigator.userAgent.toLowerCase();
const browserEnv = {
isWeixin: /MicroMessenger/i.test(userAgent),
isGenie:/\(TGenie\/([\d\.]+)\)/i.test(userAgent), //天猫精灵
isIos: /(iPhone|iPad|iPod|iOS)/i.test(userAgent),
isWeibo: /WeiBo/i.test(userAgent),
isQQ: userAgent.indexOf('qq') > -1 || userAgent.indexOf('mqqbrowser') === -1,
isAlipay: /alipay/gi.test(userAgent),
isDingDing: userAgent.indexOf('dingtalk') > -1,
isTrident: userAgent.indexOf('Trident') > -1, //IE内核
isPresto: userAgent.indexOf('Presto') > -1, //opera内核
isWebKit: u.indexOf('AppleWebKit') > -1, //苹果、谷歌内核
isGecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1, //火狐内核
isMobile: !!u.match(/AppleWebKit.*Mobile.*/), //是否为移动终端
ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端
android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, //android终端或uc浏览器
iPhone: u.indexOf('iPhone') > -1, //是否为iPhone或者QQHD浏览器
iPad: u.indexOf('iPad') > -1, //是否iPad
webApp: u.indexOf('Safari') == -1, //是否web应该程序,没有头部与底部
};
网友评论