@ecoding/helper.env
v0.0.9
Published
dev env
Downloads
2
Readme
环境判断类
基础环境判断
使用
import ugenv from "@ecoding/helper.env";
const clientInfo = ugenv.getClientInfo();
const envInfo = ugenv.getEnvInfo();
返回
(deviceUdID、deviceUdidToken、deviceId、ursAuth)来自客户端约定:旧的 App 是通过 URL 上的 querystirng 传递相关参数的。新版 App 将传参方式改成把参数挂到 window.appInfo 对象上(通过注入 js 脚本的方式)
注意:
客户端新开 webview 时才会注入 deviceUdID、deviceUdidToken、deviceId、ursAuth,如果时 webview 与 webview 之间跳转则不生效
// clientInfo
{
os: string;
network: string;
userAgent: string;
systemVersion: string;
iosSystemVersion: string | number;
kaolaVersion: string;
deviceUdID: string | null;
deviceUdidToken: string | null;
deviceId: string | null;
}
// envInfo
{
os: string; // ios | aos | wap
isapp: boolean; // 是否考拉app
isios: boolean; // 是否ios
isaos: boolean; // 是否安卓
iswx: boolean; // 是否微信(包括微信小程序)
isalipay: boolean; // 是否支付宝(包括小程序)
iswapqq: boolean; // 是否qq
iswaptaobao: boolean; // 是否手机淘宝
iswapdingding: boolean; // 是否手机钉钉
iswapweibo: boolean; // 是否微博
iswapyouku: boolean; // 是否优酷
iswapwx: boolean; // 是否微信(仅微信不包括微信小程序)
iswapalipay: boolean; // 是否支付宝(不包括小程序)
isminiwx: boolean; // 是否微信小程序
isminialipay: boolean; // 是否支付宝小程序
isminibaidu: boolean; // 是否百度小程序
isminibd: boolean; // 是否字节跳动旗下小程序
isminitt: boolean; // 是否 今日头条、今日头条极速版 小程序
isminidy: boolean; // 是否抖音小程序
isminixg: boolean; // 是否西瓜视频小程序
isanymini: boolean; // 是否小程序(包含微信、字节跳动旗下小程序、百度、支付宝)
now: "app" | "waptaobao" | "wapdingding" | "wapwx" | "wapqq" | "wapweibo" | "wapalipay" | "wapyouku" | "minialipay" | "miniwx" | "minibaidu" | "minitt" | "minidy" | "minixg" | "wap";
}