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

h5-openapp

v1.1.0

Published

> 网页唤醒 APP

Downloads

12

Readme

h5-openapp

网页唤醒 APP

场景

网页中点击按钮后, 可打开 app 并进入对应功能 (需 android, iOS 配合), 没有下载 app 则跳转至下载

安装

npm install h5-openapp

or

yarn add h5-openapp

使用

在 vue 中

<template>
  <div>
    <button @click="clickBtn"/>  
  <div>
<template>

<script>
import openapp from 'h5-openapp'

export default {
  methods: {
    clickBtn() {
      // ... 如果对参数有其它逻辑处理, 在调用前处理
      openapp({
        scheme: 'myapp:///mypath?key1=value1&key2=value2', // eg: myapp:///mypath?key1=value1&key2=value2
        deepLink: 'https://mydomain.com/mypath?key1=value1&key2=value2', // 用于 iOS universal links (iOS 9+) 当前页面域名与深链接域名需要不一致
        download: { // 默认 scheme 跳转无效,便前往下载, 设置 onTimeout 回调时, 不执行下载逻辑
          ios: '', // ios 下载链接
          android: '', // android 下载链接
          other: '' // 其他渠道 下载链接
        },
        delay: 3000, // 等待时间, 超时后执行 onTimeout,  default: 3000
        disabledScheme: [], // scheme 被禁用的 APP, eg: ['MicroMessenger', 'DingTalk', '...'] (iOS 9+ 深链接不会被禁)
        onDisabled: function(appTag) { // 当打开网页的 APP 为 disabledApp 中的任一个,并且未设置深链接时
          if (appTag === 'MicroMessenger') {
            console.log('微信不支持 scheme 跳转')
          } else if (appTag === 'DingTalk') {
            console.log('钉钉不支持 scheme 跳转')
          } else {
            console.log(appTag)
          }
        },
        onBeforeOpen: function() {
          // 在执行打开 app 逻辑前触发
        },
        onTimeout: function() { // 触发打开 app 逻辑, 并且超过等待时间时触发, 未设置的情况下, 如果设置了下载链接, 则默认跳转下载链接
          console.log('自定义超时处理')
        }
      })
    }
  }
}
</script>

在 jquery 中

<script src="openapp.min.js"></script>
<script>
$('.btn').click(function() {
  $openapp({
    // ... 省略参数
  })
})
</script>

事件

| 事件名称 | 说明 | 回调参数 | | ------ | ------ | ------ | | onDisabled | 不满足深链接跳转条件, 在 disabledScheme 参数中的 App 里打开时触发 | / | | onBeforeOpen | 在触发打开 App 逻辑前触发 | disabledScheme 参数中的对应标示 | | onTimeout | 触发打开 App 逻辑后, 并且等待时间超过 delay, 未设置时, 默认跳转下载, 下载链接也未设置, 超时则无响应 | / |

参数

| 参数 | 说明 | 类型 | 默认值 | | ------ | ------ | ------ | ----- | | scheme | scheme 跳转链接 (eg: myapp://path?key1=value1&key2=value2) | String | / | | deepLink | iOS universal links (iOS 9+) | String | / | | download | 默认超时会跳转下载链接 ({ ios: '', android: '', other: '' }) | Object | / | | delay | 等待时间 | Number | 3000 | | disabledScheme | scheme 被禁用的 App 的浏览器标示 | Array | / |