zax-device
v4.0.2
Published
zax-device
Downloads
9
Readme
Zax Device
support SSR & Miniprogram & Browser side
util module
Browsers support
| IE / Edge | Firefox | Chrome | Safari | iOS Safari | Opera | | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | IE8+ Edge+ | last 10 versions | last 10 versions | last 2 versions | last 2 versions | last 2 versions |
Install
npm i zax-device -S
usage
import ZaxDevice,{ isWechat, isAlipay, isToutiao, isDouyin, isApp, isMiniApp, isAndroid, isIOS, isClientSide, isServerSide, isWechatMiniApp, isAlipayMiniApp, isBytedanceMiniApp, isBaiduMiniApp } from 'zax-device'
let device = new ZaxDevice({
ua: 'CUSTOM UA OR NULL',
appMapping: {
dax: 'WEBVIEW_FLAG'
}
})
// client side
// or
import { device } from 'zax-device'
device.setAppMapping('dax', 'DAX_REGEX_FLAG') //
device.setUA(ctx.reqeust.header['user-agent']) // set server ua
isWechat() //
isWechat() //
isAlipay() //
isToutiao() //
isDouyin() //
isApp() //
isApp('douyin') // same as isDouyin()
isMiniApp() //
isAndroid() //
isIOS() //
isClientSide() //
isServerSide() //
isWechatMiniApp() //
isAlipayMiniApp() //
isBytedanceMiniApp() //
isBaiduMiniApp() //
//server side
isIOS(ctx.reqeust.header['user-agent'])