File tree Expand file tree Collapse file tree 3 files changed +16
-1
lines changed Expand file tree Collapse file tree 3 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -74,6 +74,18 @@ export const utsPlatform = env.UNI_UTS_PLATFORM as UtsPlatform
74
74
/** Detect if `process.env.UNI_PLATFORM` is `h5` or if `process.env.UNI_PLATFORM` is `web` */
75
75
export const isH5 = platform === 'h5' || platform === 'web'
76
76
77
+ /** Get user agent string for browser detection */
78
+ const userAgent = typeof navigator !== 'undefined' ? navigator . userAgent . toLowerCase ( ) : ''
79
+
80
+ /** Detect if running in WeChat browser in H5 environment */
81
+ export const isH5Weixin = isH5 && / m i c r o m e s s e n g e r / i. test ( userAgent )
82
+
83
+ /** Detect if running in Weibo client in H5 environment */
84
+ export const isH5Weibo = isH5 && / w e i b o / i. test ( userAgent )
85
+
86
+ /** Detect if running in Alipay client in H5 environment */
87
+ export const isH5Alipay = isH5 && / a l i p a y c l i e n t / i. test ( userAgent )
88
+
77
89
/** Detect if `process.env.UNI_PLATFORM` is `web` or if `process.env.UNI_PLATFORM` is `h5` */
78
90
export const isWeb = platform === 'web' || platform === 'h5'
79
91
Original file line number Diff line number Diff line change @@ -11,6 +11,9 @@ describe('uni-env', () => {
11
11
"subPlatform",
12
12
"utsPlatform",
13
13
"isH5",
14
+ "isH5Weixin",
15
+ "isH5Weibo",
16
+ "isH5Alipay",
14
17
"isWeb",
15
18
"isApp",
16
19
"isAppPlus",
Original file line number Diff line number Diff line change 1
1
{
2
2
"compilerOptions" : {
3
3
"target" : " esnext" ,
4
- "lib" : [" esnext" ],
4
+ "lib" : [" esnext" , " dom " ],
5
5
"module" : " esnext" ,
6
6
"moduleResolution" : " Bundler" ,
7
7
"resolveJsonModule" : true ,
You can’t perform that action at this time.
0 commit comments