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

@fekit/message

v1.0.0

Published

环境查询插件,包括系统(OS),客户端(APP)以及浏览器(Browser)等类型的查询。

Downloads

3

Readme

@za/zafe-env

环境查询插件,包括系统(OS),客户端(APP)以及浏览器(Browser)等类型的查询。

安装

npm i @za/zafe-env

yarn add @za/zafe-env

使用

import env, { isWecart, isZAXD, ... } from '@za/zafe-env'

console.log(env.os) // => ios

// 判断是否在众安小贷APP客户端内
if (env.app === 'zaxd') {
  console.log('是在众安小贷内')
} else {
  console.log('不在众安小贷内')
}

// 判断当前页面是否运行在苹果手机
if (env.os === 'ios') {
  // 当前页面是运行在苹果手机
}

// 判断当前页面是否运行在微信客户端
if (env.app === 'wx') {
  // 当前是在微信中
}

// 即用判断
if (isWecart) {
  console.log('是在微信内')
}

文档

默认导出的 env 是一个对象,下面有 os,app 和 browser 三个属性

os

| 返回值 | 类型 | 说明 | | :------ | ------ | -------- | | mac | String | MacOS | | win | String | windows | | ios | String | IOS | | android | String | 安卓 | | null | Null | 其它未知 |

app

| 返回值 | 类型 | 说明 | | :----- | ------ | -------------- | | zaxd | String | 众安小贷客户端 | | zadd | String | 众安点点客户端 | | wx | String | 微信客户端 | | qq | String | QQ 客户端 | | weibo | String | 微博客户端 | | null | Null | 其它未知 |

browser

| 返回值 | 类型 | 说明 | | :------ | ------ | ------------ | | uc | String | UC 浏览器 | | firefox | String | 火狐浏览器 | | baidu | String | 百度浏览器 | | chrome | String | 谷歌浏览器 | | maxthon | String | 傲游浏览器 | | qq | String | QQ 浏览器 | | opera | String | Opera 浏览器 | | chrome | String | 谷歌浏览器 | | safari | String | 苹果浏览器 | | null | Null | 其它未知 |

即用判断

| 返回值 | 类型 | 说明 | | :------------ | ------- | --------------------------------------------------------------------------------------------------------- | | isAPP | Boolean | 当前是否运行在某个 APP 内,与 isBrowser 正好相反 | | isZAAPP | Boolean | 当前是否运行在某个众安的 APP 内 (众安小贷或众安点点) | | isBrowser | Boolean | 当前是否运行在浏览器内,与 isAPP 正好相反 | | isRealMac | Boolean | 当前是否运行在苹果电脑系统 MacOS(通过 platform 判断的真实的平台信息,无法修改 userAgent 模拟环境) | | isRealWin | Boolean | 当前是否运行在微软系统 Windows (通过 platform 判断的真实的平台信息,无法修改 userAgent 模拟环境) | | isRealIOS | Boolean | 当前是否运行在苹果手机系统 IOS(通过 platform 判断的真实的平台信息,无法修改 userAgent 模拟环境) | | isRealAndroid | Boolean | 当前是否运行在 安卓系统 Android (通过 platform 判断的真实的平台信息,无法修改 userAgent 模拟环境) | | isAndroid | Boolean | 当前是否为安卓设备 (通过 userAgent 判断,可以模拟环境) | | isIPhone | Boolean | 当前是否为苹果手机设备 | | isIPad | Boolean | 当前是否为苹果平板设备 | | isZAXD | Boolean | 当前是否运行在众安小贷 APP 内 | | isZADD | Boolean | 当前是否运行在众安点点 APP 内 | | isWechat | Boolean | 当前是否运行在微信 | | isQQ | Boolean | 当前是否运行在 QQ | | isWeibo | Boolean | 当前是否运行在微博 |

import {
  isAPP,
  isZAAPP,
  isBrowser,
  isRealMac,
  isRealWin,
  isRealIOS,
  isRealAndroid,
  isAndroid,
  isIPhone,
  isIPad
  isZAXD,
  isZADD,
  isWechat,
  isQQ,
  isWeibo,
} from '@fekit/env'

版本

v0.1.2
1、原isMac,isWin,isIOS,isAndroid改为isRealMac,isRealWin,isRealIOS,isRealAndroid,os信息通过 platform 判断无法模拟
2、新增手机设备环境识别 env.device 有 iphone, ipad 和 android,新增isAndroid,isIPhone,isIPad。可以通过修改调工台 userAgent 进行模拟
v0.1.0
1、实现核心功能