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 🙏

© 2025 – Pkg Stats / Ryan Hefner

tw-bridge

v1.0.6

Published

tw bridge

Downloads

282

Readme

天蛙bridge js-sdk

说明: 天蛙移动端bridge,方便H5、原生、微信环境下调用类似功能,统一接口

安装:

npm install tw-bridge

使用:

  import 'tw-bridge'

  var wx = window.TwBridge;
  wx.share(param).then((res)=>{ console.log(res) })

获取运行环境

  window.TwBridge.env
  // 判断环境 天蛙云APP:'native';微信:'weixin';钉钉:'dingtalk';网页:'h5'

获取签名图片地址

  window.TwBridge.signActivity().then((result) => {
    console.log(result)
  })

获取当前经纬度

  window.TwBridge.getLocation().then((result) => {
    // result:{ latitude: string,longitude: string }
    // latitude(经度)
    // longitude(纬度)
    console.log(result)
  })

获取当前设备UUID

  window.TwBridge.deviceId().then((result) => {
    // result:'uuid字符串'
    console.log(result)
  })

调用手机扫码功能

  // QrCodeScanParam:{ actionType:'read',title:'' }
  window.TwBridge.qrCodeScan(param:QrCodeScanParam).then((result) => {
    // result:'url字符串'
    console.log(result)
  })

上传文件

  // UploadParam:{ uuid: string,fileSrc: string,limit?:number }
  // fileSrc(文件存放路径,一般用应用名); limit(图片数量限制)
  window.TwBridge.upload(param:UploadParam).then((result) => {
    console.log(result)
  })

上传视频文件

  // UploadParam:{ uuid: string,fileSrc: string,limit?:number }
  // fileSrc(文件存放路径,一般用应用名); limit(图片数量限制)
  window.TwBridge.uploadVideo(param:UploadParam).then((result) => {
    // result:{ fileName: string,fileSize: string,filePath: string,coverUrl: string,id: string }
    console.log(result)
  })

上传多图片文件

  // UploadParam:{ uuid: string,fileSrc: string,limit?:number }
  // fileSrc(文件存放路径,一般用应用名); limit(图片数量限制)
  window.TwBridge.uploadImages(param:UploadParam).then((result) => {
    // result:{ fileName: string,fileSize: string,filePath: string,coverUrl: string,id: string }
    console.log(result)
  })

附件查看

  // param:'url地址'
  window.TwBridge.preview(param:string)

视频播放

  // UploadParam:{ resId: string,resType: string,videos:Array<Videos> }
  // resId(资源id);
  // resType(资源类型(classCombine:三个课堂;niceClass:精品课堂;commonPlay:网红素材))
  // videos(视频资源列表,包含视频名称,地址,大小) [{ name:'名称',url:'地址',size:100 }]
  window.TwBridge.videoPlay(param:VideoParam)

视频编辑

  window.TwBridge.videoEdit(param:VideoEdit).then((result) => {
    console.log(result)
  })

选择人员(新)

  // 建议在工程内直接应用组件“SelectStaff”,支持新旧选择人员功能,参数一致
  // param:{ id:'视频Id' }
  window.TwBridge.selectExecutor(param:SelectExecutor).then((result) => {
    // result:{ id: string,name: string }
    // id(人员id);
    // name(人员名称)
    console.log(result)
  })

设置个人资料

  window.TwBridge.setProfile(param:any)

绑定消息事件监听

  // MessageType= { messageType: 'SOURCE_CLASS_COMBINE' | 'SOURCE_CQES' }
  // 业务类型  SOURCE_CLASS_COMBINE(三个课堂)、SOURCE_CQES(综合素质评价)
  window.TwBridge.bindMessageListener(param:MessageType).then((result) => {
    // result:{ event: string }
    console.log(result)
  })

关闭当前WebView同 window.TwBridge.webViewClose()

  window.TwBridge.back()

关闭当前WebView同 window.TwBridge.back()

  window.TwBridge.webViewClose()

设置头部导航栏是否可见:

  //  ToolbarParam:{ visible:true,title:'标题' } | String
  window.TwBridge.showToolbar(param:ToolbarParam | string)

toolbar 绑定点击事件(绑定一次,点击后即失效):

  //  param:Function
  window.TwBridge.bindToolbarListener(param:Function)
  // vue2中调用,".call(this)"可以把作用域指向到vue中,例如:
  // window.TwBridge.bindToolbarListener(() => {
  //   this.navbarClick.call(this)
  // })

设置当前页面标题(只有在显示手机端标题下生效)

  window.TwBridge.setTitle(param:string)

设置当前页面头部颜色(只有在显示手机端标题下生效)

  //  ToolbarColor:{ statusBarColor:'#F2F2F2',toolBarColor:'#F2F2F2',titleColor:'#000000',backIconColor:'1' }
  //  toolBarColor(标题栏背景颜色:"#000000")
  //  statusBarColor(状态栏背景颜色:"#000000")
  //  titleColor(标题文字颜色)
  //  backIconColor(返回的icon的颜色:0是白色,1是黑色)
  window.TwBridge.setToolbarColor(param:ToolbarColor)

获取天蛙云平台请求头

  window.TwBridge.getHeader().then((result) => {
    // result:{ AccessToken:'',AppKey:'' }
    console.log(result)
  })

退出登录

  window.TwBridge.logout()

分享

  // ShareParam:{ title:'',desc:'',content:'',url:'',link:'',type:'link',icon:'' }
  window.TwBridge.share(param:ShareParam)

绑定生命周期监听

  //
  window.TwBridge.bindWebViewLifecycle(param?:string).then((result) => {
    console.log(result)
  })

跳转一个全新页面,无底部tab栏

  // ToActivityParam:{ url:'',name:'' }
  // url(跳转地址全路径)
  // name(新页面名称)
  window.TwBridge.toActivity(param:ToActivityParam).then((result) => {
    console.log(result)
  })