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

web-page-confirm-environment

v0.0.6

Published

一个非常轻量的JS插件 , 主要用于帮助我们快速确认当前网页所运行环境.

Downloads

12

Readme

说明

短小而强悍的工具插件 , 用于帮助我们快速确认当前网页所运行环境.

安装

方式1: 通过 CDN 安装

最简单的方法是直接在 html 文件中引入 CDN 链接

<script src="https://cdn.jsdelivr.net/npm/web-page-confirm-environment/dist/index.umd.min.js"></script>

方式2: 通过 npm 安装

npm install -S web-page-confirm-environment

使用

script CDN方式引入

const environment = webPageConfirmEnvironment();

// 是否在微信
console.log(environment.isWechat)

NPM方式

import webPageConfirmEnvironment from 'web-page-confirm-environment'

const environment = webPageConfirmEnvironment();

// 是否在微信
console.log(environment.isWechat)

判断是否在自家APP内

const environment = webPageConfirmEnvironment({
    // 跟自家客户端 协商好,往 页面设置的UA标识。
    ios: 'very-good-ios',
    android: 'very-good-android'
});

// 是否在自家安卓APP内
console.log(environment.isInnerAdr)

// 是否在自家IOS APP内
console.log(environment.isInnerAdr)

// 判断是否在自家APP内
console.log(environment.isInnerApp)

自定义UA

const environment = webPageConfirmEnvironment({
    // 跟自家客户端 协商好,往 页面设置的UA标识。
    ios: 'very-good-ios',
    android: 'very-good-android',
    ua: 'xx-xxx-xxxx'
});

// 打印UA
console.log(environment.printUa()) // -> xx-xxx-xxxx

config

参数 | 说明 | 是否必传 | 类型 | ----------|-------------------------------------------|-----------|-------| iosUa |跟IOS客户端协商好 往前端页面塞入的UA标识 | 否 |string | androidUa |跟Android客户端协商好 往前端页面塞入的UA标识 | 否 |string | ua |自定义的UA标识 | 否 |string |

api

参数 | 说明 | ----------|-------------------| isPC |是否正在PC端内 | isIos |是否是iosAPP内 | isAndroid |是否是安卓APP内 | isWechat |是否是在微信生浏览器中 | isWxWork |是否在企业微信中 | isWxmp |是否在微信小程序 | isDingding|是否是钉钉内 | isFs |是否是飞书浏览器中 | isInnerAdr|是否是自家安卓app | isInnerIos|是否是自家ios app | isInnerApp|是否是自家app |

events

参数 | 说明 | 类型 | ----------|------------|----------- printUa |输出ua信息 |Function |