-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: update util core is to functions
- Loading branch information
Mr.Mao
committed
Dec 9, 2023
1 parent
d31008d
commit 3b50f2a
Showing
1 changed file
with
14 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,29 @@ | ||
declare const WXEnvironment: any | ||
|
||
export const isBrowser = typeof window !== 'undefined' | ||
export const isBrowser = () => typeof window !== 'undefined' | ||
|
||
export const isWeex = typeof WXEnvironment !== 'undefined' && !!WXEnvironment.platform | ||
export const isWeex = () => typeof WXEnvironment !== 'undefined' && !!WXEnvironment.platform | ||
|
||
export const weexPlatform = isWeex && WXEnvironment.platform.toLowerCase() | ||
export const weexPlatform = () => isWeex() && WXEnvironment.platform.toLowerCase() | ||
|
||
export const UA = isBrowser && window.navigator.userAgent.toLowerCase() | ||
export const UA = () => (isBrowser() && window.navigator.userAgent.toLowerCase()) || '' | ||
|
||
export const isIE = UA && /msie|trident/.test(UA) | ||
export const isIE = () => UA() && /msie|trident/.test(UA()) | ||
|
||
export const isIE9 = UA && UA.indexOf('msie 9.0') > 0 | ||
export const isIE9 = () => UA() && UA().indexOf('msie 9.0') > 0 | ||
|
||
export const isIE11 = isBrowser && navigator.userAgent.includes('Trident') && navigator.userAgent.includes('rv:11.0') | ||
export const isIE11 = () => isBrowser() && navigator.userAgent.includes('Trident') && navigator.userAgent.includes('rv:11.0') | ||
|
||
export const isEdge = UA && UA.indexOf('edge/') > 0 | ||
export const isEdge = () => UA() && UA().indexOf('edge/') > 0 | ||
|
||
export const isAndroid = (UA && UA.indexOf('android') > 0) || weexPlatform === 'android' | ||
export const isAndroid = () => (UA() && UA().indexOf('android') > 0) || weexPlatform() === 'android' | ||
|
||
export const isIOS = (UA && /iphone|ipad|ipod|ios/.test(UA)) || weexPlatform === 'ios' | ||
export const isIOS = () => (UA() && /iphone|ipad|ipod|ios/.test(UA())) || weexPlatform() === 'ios' | ||
|
||
export const isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge | ||
export const isChrome = () => UA() && /chrome\/\d+/.test(UA()) && !isEdge() | ||
|
||
export const isPhantomJS = UA && /phantomjs/.test(UA) | ||
export const isPhantomJS = () => UA() && /phantomjs/.test(UA()) | ||
|
||
export const isFF = typeof UA == 'string' && UA.match(/firefox\/(\d+)/) | ||
export const isFF = () => typeof UA() === 'string' && UA().match(/firefox\/(\d+)/) | ||
|
||
export const isMobile = isBrowser && navigator.userAgent.toLowerCase().includes('mobile') | ||
export const isMobile = () => isBrowser() && navigator.userAgent.toLowerCase().includes('mobile') |