-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeviceType.js
More file actions
94 lines (85 loc) · 2.3 KB
/
deviceType.js
File metadata and controls
94 lines (85 loc) · 2.3 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
export default {
isWechat(UA) {
return /MicroMessenger/i.test(UA) ? true : false;
},
isWeibo(UA) {
return /Weibo/i.test(UA) ? true : false;
},
isQQ(UA) {
return /QQ/i.test(UA) ? true : false;
},
isMobile(UA) {
return /(Android|webOS|iPhone|iPod|tablet|BlackBerry|Mobile)/i.test(UA)
? true
: false;
},
isIOS(UA) {
return /iPhone|iPad|iPod/i.test(UA) ? true : false;
},
isAndroid(UA) {
return /Android/i.test(UA) ? true : false;
},
deviceType(UA) {
if (isMoible(UA)) {
if (isIOS(UA)) {
if (isWechat(UA)) {
return {
type: "ios",
env: "wechat",
masklayer: true,
};
}
if (isWeibo(UA)) {
return {
type: "ios",
env: "weibo",
masklayer: true,
};
}
if (isQQ(UA)) {
return {
type: "ios",
env: "qq",
masklayer: true,
};
}
return {
type: "ios",
};
}
if (isAndroid(UA)) {
if (isWechat(UA)) {
return {
type: "android",
env: "wechat",
masklayer: true,
};
}
if (isWeibo(UA)) {
return {
type: "android",
env: "weibo",
masklayer: true,
};
}
if (isQQ(UA)) {
return {
type: "android",
env: "qq",
masklayer: true,
};
}
return {
type: "android",
};
}
return {
type: "mobile",
};
} else {
return {
type: "pc",
};
}
}
}