-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbrowser
23 lines (23 loc) · 1.01 KB
/
browser
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/**
* 判断浏览器内核、所处客户端
*/
export const browser = {
versions: (function() {
const UA = navigator.userAgent;
return {
trident: UA.includes('Trident'), //IE内核
presto: UA.includes('Presto'), //opera内核
webKit: UA.includes('AppleWebKit'), //苹果、谷歌内核
gecko: UA.includes('Gecko') && !UA.includes('KHTML'), //火狐内核
mobile: !!UA.match(/AppleWebKit.*Mobile.*/), //是否为移动终端
ios: !!UA.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //iOS终端
android: UA.includes('Android') || UA.includes('Adr'), //Android终端
iPhone: UA.includes('iPhone'), //是否为iPhone或者QQHD浏览器
iPad: UA.includes('iPad'), //是否iPad
webApp: !UA.includes('Safari'), //是否web应该程序,没有头部与底部
weChat: UA.includes('MicroMessenger'), //是否微信
qywxChat: UA.includes('MicroMessenger') && UA.includes('wxwork'), //是否企业微信
qq: UA.match(/\sQQ/i) == ' qq', //是否QQ
};
})(),
};