@@ -12,48 +12,52 @@ function getSystemInfoSync() {
12
12
const ua = userAgent . toLowerCase ( ) ;
13
13
let isIos = false ;
14
14
let isAndroid = false ;
15
- let system = undefined ;
16
- let platform = undefined ;
17
- let model = undefined ;
18
- const screenHeight = document . documentElement . clientHeight ;
19
- const screenWidth = document . documentElement . clientWidth ;
20
- const windowWidth = screenWidth ;
21
- const windowHeight = screenHeight - NAVIGATION_BAR_HEIGHT ;
15
+ let system = '' ;
16
+ let platform = '' ;
17
+ let model = '' ;
18
+ const screenHeight = window . screen . height ;
19
+ const screenWidth = window . screen . width ;
20
+ const windowWidth = document . documentElement . clientWidth ;
21
+ const windowHeight = document . documentElement . clientHeight - NAVIGATION_BAR_HEIGHT ;
22
22
23
23
if ( userAgent . indexOf ( 'Mac OS' ) > - 1 || userAgent . indexOf ( 'iPhone OS' ) > - 1 ) {
24
24
isIos = true ;
25
25
}
26
26
else if ( userAgent . indexOf ( 'Android' ) > - 1 ) {
27
27
isAndroid = true ;
28
28
}
29
+ // 兼容UC浏览器 UA
30
+ else if ( userAgent . indexOf ( 'iPhone' ) === - 1 && userAgent . indexOf ( 'UCBrowser' ) > - 1 ) {
31
+ isAndroid = true ;
32
+ }
29
33
30
34
if ( isIos ) {
31
35
let match = userAgent . match ( 'iPhone OS ([0-9,_]*) ' ) ;
32
36
system = match && match [ 1 ] && `iOS ${ match [ 1 ] . replace ( / _ / g, '.' ) } ` || undefined ;
33
37
platform = 'ios' ;
34
38
35
39
if ( screenHeight === 736 && screenWidth === 414 ) {
36
- model = 'iPhone6P, iPhone7P, iPhone8P' ;
37
- }
38
- else if ( screenHeight === 812 && screenWidth === 375 ) {
39
- model = 'iPhoneX' ;
40
+ model = 'iPhone 6 Plus, iPhone 7 Plus, iPhone 8 Plus' ;
40
41
}
41
42
else if ( screenHeight === 667 && screenWidth === 375 ) {
42
- model = 'iPhone6, iPhone7, iPhone8' ;
43
+ model = 'iPhone 6, iPhone 7, iPhone 8' ;
44
+ }
45
+ else if ( screenHeight >= 812 && screenWidth >= 375 ) {
46
+ model = 'iPhone X' ;
43
47
}
44
48
else if ( screenWidth > 320 ) {
45
49
model = 'iPhone' ;
46
50
}
47
51
else if ( screenHeight === 568 && screenWidth === 320 ) {
48
- model = 'iPhone5, iPhoneSE, iPhone5s ' ;
52
+ model = 'iPhone 5, iPhone SE, iPhone 5s ' ;
49
53
}
50
54
else {
51
- model = 'iPhone4s, iPhone4 ' ;
55
+ model = 'iPhone 4s, iPhone 4 ' ;
52
56
}
53
57
}
54
58
else if ( isAndroid ) {
55
59
let match = userAgent . match ( 'Android ([0-9,.]*)' ) ;
56
- system = match && match [ 0 ] || undefined ;
60
+ system = match && match [ 0 ] || 'Android' ;
57
61
platform = 'android' ;
58
62
const buildIndex = ua . indexOf ( 'build' ) ;
59
63
const fullResult = userAgent . substring ( 0 , buildIndex ) ;
0 commit comments