npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

tbm-ua

v1.0.2

Published

UA检测

Downloads

3

Readme

tbm-ua

UA 组件,判断不同的平台和设备及容器

demo 地址

Install

$ tnpm i @ali/tbm-ua --save

Usage

<h2>UA用法展示</h2>
<button id="btn">判断该platform</button>
<button id="btn1">该platform是淘宝么</button>
import ua from '@ali/tbm-ua';

var oBtn = document.querySelector('#btn');
var oBtn1 = document.querySelector('#btn1');

oBtn.addEventListener(
  'click',
  function () {
    alert(ua);
  },
  false
);

oBtn1.addEventListener(
  'click',
  function () {
    if (ua.isTB) {
      alert('是');
    } else {
      alert('不是');
    }
  },
  false
);

//做个示范 判断平台是不是淘宝
//if(ua.isTB){}

API

若 UA 匹配成功,则返回匹配后的数组,若匹配失败,则返回 null。
若 UA 匹配成功,则返回匹配后的数组,若匹配失败,则返回 null。

| 平台 | Api 名称 | 返回值类型 | 备注 | | ---------------- | ---------- | ------------------------- | ------------------------------------------------------------------------------------ | | UC 容器 U4 内核 | isUCU4 | True: /False: null | | | UC 容器 U3 内核 | isUCU3 | True: /False: null | | | IOS | isIOS | True: /False: null | | | Android | isAndroid | True: /False: null | | | WindVane 容器 | isWindVane | True: /False: null | 需组合 window.WindVane && window.WindVane.isAvailable ; 手淘专有 API 应判断 isTB | | WindVane 和 钱包 | isMV | True: /False: null | DY & WindVane | | TBMovie 和钱包 | isDY | True: /False: null | DY & Nebula | | AliTrip | isAT | True: /False: null | 飞猪 | | 淘宝 | isTB | True: /False: null | 手淘 | | 钱包 | isAP | True: /False: null | 钱包客户端 | | 口碑 | isKB | True: /False: null | 口碑客户端 | | 淘票票专业版 | isMVP | True: /False: null | | | 微博 | isWB | True: /False: null | | | 微博电影 | isWBM | True: /False: null | | | 高德 | isGD | True: /False: null | | | 虾米音乐 | isXM | True: /False: null | | | 优酷 | isYK | True: /False: null | | | 神马搜索 | isSM | True: /False: null | | | 搜狗 | isSG | True: /False: null | | | 大麦 | isDM | True: /False: null | | | 天猫 | isTM | True: /False: null | | | 快应用 | isQuickApp | True: /False: null | | | 微信 H5 | isWX | True: /False: null | 仅匹配微信 H5,若是微信小程序中的 webview,则返回 null | | 微信小程序 | isWXApp | True: /False: null | 仅匹配微信小程序 |

FAQ

UA 组件只提供不同平台和设备及容器的判断,不涉及容器版本的判断,如果需要判断容器版本做特殊的处理,可以参考如下的使用方法:

// 主客版本大于 7.9.0 做特殊处理
UA.isDY && TBM.getVersion(TBM.clientInfo['client.version']) >= TBM.getVersion('7.9.0'))

// 钱包版本大于 9.5.3 做特殊处理
UA.isAP && TBM.clientInfo && TBM.getVersion(TBM.clientInfo['client.version']) >= TBM.getVersion('9.5.3');