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

@bbtfe/deeplink

v1.4.2

Published

Web to App 手机打开网页,通过 scheme 方式,启动 APP || 打开 APP 内对应页面

Downloads

31

Readme

@bbtfe/deeplink

Web to App 手机打开网页,通过 scheme 方式,启动 APP || 打开 APP 内对应页面

1.2.0 新增 universe Link 1.2.2 新增 wta 的接口发送,以后调用这个版本,不需要再单独调用 wta

universe Link 支持范围: ios 系统 safari 浏览器 ios 系统 微信端 >=7.0.5

引用方式

文件被输出为 umd 格式,可以使用下面 3 种方式引用。

npm 引用

npm i @bbtfe/deeplink
import dp from '@bbtfe/deeplink';

script 引用

支持 HTTPS 和 HTTP,建议在通常页面中使用下面去掉协议头的形式引用即可。

<script src="//static02.babytreeimg.com/img/bca/bbtdeeplink/1.2.0/deeplink.min.js"></script>

PHP 引用方式

建议合并脚本

StaticFileControl::addXXX('/img/bca/bbtdeeplink/1.2.0/deeplink.min.js');

开发说明

  • 拉取源码到本地,源码目录:bbt-fe-comp/deeplink
  • npm i
  • 修改 index.js
  • npm run build
  • bbt-common-asset 项目下对应的 SDK 目录(bbt-common-asset/static/bbtdeeplink)新建版本号文件夹
  • 将 dist 下文件拷至 新版本号 目录里
  • 以 gittool 方法提交代码, 编译后的代码 bbt-common-asset,源码 bbt-fe-comp, 都需要提交
  • 项目中引入验证下

API

var deeplink = new Deeplink();

var dp = deeplink.init({
  autoDp: false, // [可选] 仅android浏览器、ios Safari可自动deeplink,如果自动deeplink设置为true
  el: document.getElementsByTagName('div')[0], // [可选] 触发click事件调起deeplink的元素,可以是一个node对象,也可以是由node对象组成的数组
  subdivideBrowser: false, // [v > 1.1.5] 若不细分环境仅支持:微信、QQ、微博,其余均归为浏览器。细分浏览器环境:额外支持钉钉(dingding)、UC(uc)、QQ浏览器(qqbrowser)、搜狗浏览器(sougou),其余均归为浏览器。不传默认false
  canPcDp: false, // [v > 1.1.5] PC端是否启用DP功能,不传默认false不启用
  download: {
    android:
      'http://pic11.babytreeimg.com/foto3/common_photo/original/2018/1129/a9be56a347822828.jpg',
    ios:
      'http://itunes.apple.com/cn/app/kuai-le-yun-qi-40zhou-quan/id523063187?mt=8'
  }, //可传参,不传的话,就是默认这2个下载链接
  coverImage: { ios: 'xxx', android: 'xxx', canClose: true }, // [可选] 如果使用默认孕育图片去掉该行配置即可;如果两个平台图片一样,填写为一个字符串;可配置是否显示关闭复层按钮
  wakeUp: {
    // 唤醒app有三种方式,直接唤醒app(direct),通过应用宝唤醒(yyb),蒙层引导浏览器打开页面(popup)
    popup: {
      // 蒙层引导浏览器打开
      app: [
        'android.weibo',
        'ios.weibo',
        'ios.weixin',
        'android.weixin',
        'ios.qq'
      ]
    },
    direct: {
      app: ['ios.browser', 'android.browser'],
      url: 'bbtrp://com.babytree.pregnancy/topic/topicpage?topicId=87468516',
      dpSuccessCallBack: () => {}, // dp成功回调 [v > 1.1.5]
      dpFailCallBack: () => {} // dp失败回调 [v > 1.1.5]
    },
    yyb: {
      // 应用宝
      app: ['android.qq'],
      url:
        'http://a.app.qq.com/o/simple.jsp?pkgname=com.babytree.apps.pregnancy&ckey=CK1351100144579'
    }
  },
  //universal link 参数, 2020-02-17开发,1.2.0(包含)版本后支持
  universalLink: true, //是否使用universalLink
  universalLinkConfig: {
    //universalLink配置参数
    url: '', //要打开app内页面的url
    refcode: 'm_y_share_tz_yuedu_20200206', //传给中间页的refcode
    downloadUrl: 'http://r.babytree.com/3euBLGm', //传给中间页的下载链接
    middlePageUrl: '', //中间页面的url,默认为: https://m.babytree.com/app/pregnancy/intro.php
    success: function () {
      //成功的回调
      console.log('universalLink success');
    },
    fail: function () {
      //失败的回调
      console.log('universalLink fail');
    }
  },
  w2aConfig: {
    //w2aConfig配置参数, 非必填,不填均为默认值
    appid: '11', //非必填,默认11,代表孕育。 如果不是11,其他APP需要找数据同学确认id
    bid: 'pregnancy_20200401', //非必填,不传为默认
    param: {}, // 非必填,业务参数
    tid: '' // 非必填,用于业务追踪
  }
});

// 得到的dp实例,可以通过trigger再次触发deeplink , 不推荐使用
setTimeout(function () {
  dp.trigger();
}, 10000);

dp 到原生页面:需传对应的路由地址 dp 到孕育中的 h5 页面,路由: babytree://webview?url=window.base64encode(要打开页面的 url) 注意:调用这个方法前 window.base64encode, 需加载 js://static02.babytreeimg.com/static/know/base64.js

附: [孕育 app 对外路由 url 列表|http://space.dayin.com/pages/viewpage.action?pageId=8490528] 附: [小时光 app 对外路由 url 列表|http://space.dayin.com/pages/viewpage.action?pageId=8490533] 附: [小时光 app 下载万能链接|http://r.babytree.com/dohbVTn]


### 测试结果

app|调起方式|结果
:--:|:--:|:-:
ios.weixin  |弹层引导浏览器打开|ok
ios.weibo   |弹层引导浏览器打开|ok
ios.qq      |直接唤醒调起|bad(策略变化,直接打开的AppStore,建议调整为浏览器打开)
ios.browser |直接唤醒调起|ok

android.weixin  |弹层引导浏览器打开|ok
android.weibo   |弹层引导浏览器打开|ok
android.qq      |应用宝|ok
android.browser |直接唤醒调起|ok