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

@webank/trident-plugin-webview

v1.0.0

Published

trident plugin - WebView

Downloads

8

Readme

WebView - WeTrident Plugin

WeTrident 项目的 WebView 插件,支持以下特性

  • 页面标题自动切换
  • JS SDK,可自定义处理api
  • 错误重试视图

Install

$ tdt plugin add @webank/trident-plugin-webview

Usage

页面加载

AppNavigator.tridentPluginWebview.WebViewScene({
  url: 'https://www.webank.com'
})

JS SDK

WeTrident WebView 会在 window 上挂载WeTridentWebViewBridge属性,通过该属性可以调用 WebView 的内置 api 与自定义 api。

内置 API

Toast

TridentWebViewBridge.send('toast', {
  text: 'hello world'
}, res => {
  console.log('调用成功', res)
}, err => {
  console.log('调用失败', err)
})

Loading

显示/隐藏 trident 的Loading组件

  • show: [Boolean] - 显示/隐藏Loading组件
TridentWebViewBridge.send('loading', {
  show: true
}, res => {
  console.log('调用成功', res)
}, err => {
  console.log('调用失败', err)
})

setNavBarRightButton

自定义导航栏右边按钮

  • show: [Boolean] - 显示/隐藏导航栏右边按钮
  • text: [String] - 导航栏按钮文字,默认显示为···
TridentWebViewBridge.send('setNavBarRightButton', {
  show: true,
  text: '完成'
}, res => {
  console.log('点击导航栏', res)
})

自定义 API

import WebViewService from '@webank/trident-plugin-webview/services/WebViewService'

开发者可以增加 WebView 处理的 api 列表,通过WebViewService.addApiHandlerWebViewService.addAsyncApiHandler进行注册 api。

1. WebViewService.addApiHandler(key:String, handler:function)

添加同步处理 api,WebView 调用后立即返回结果

// in trident proj
WebViewService.addApiHandler('syncApi', args => {
  console.log('接收api参数', args)
})


// in web
TridentWebViewBridge.send('syncApi', {
  params: 'test'
}, res => {
  console.log('调用成功', res)
})

2. WebViewService.addAsyncApiHandler(key:String, handler:function)

添加异步处理 api,hanlder返回promise

// in trident proj
WebViewService.addAsyncApiHandler('asyncApi', args => {
  return new Promise((resolve, reject) => {
    setTimeout(() => {
      resolve('OK')
    }, 3000)
  })
})


// in web
TridentWebViewBridge.send('asyncApi', {
  params: 'test'
}, res => {
  console.log('promise.resolve', res)
}, err => {
  console.log('promise.reject', err)
})