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

@realsee/miniprogram

v0.1.11

Published

如视微信小程序生态SDK集

Downloads

2

Readme

@realsee/miniprogram

如视小程序生态SDK集合

功能列表

  • [√] 如视Passport账号服务
  • [√] 如视小程序支付服务
  • [√] 如视小程序遥测服务
  • [√] 如视小程序VRWeview

接入指南

如视Passport账号服务
  1. 原生小程序用法
import { Passport } from '@realsee/miniprogram';

const passport = new Passport({ appId: '这个是开放平台的AppID' })

// 在获取用户手机号的回调里处理登录
const onGetUserPhoneNumber = async (ev) => {
  const getUserPhoneNumberResult = ev.detail
  const loginResult = await new Promise((resolve) => wx.login({ success: (res) => resolve(res) }))
  const result = await passport.login({ loginResult, getUserPhoneNumberResult })

  if (result !== false) {
    // 登录成功
    const userInfo = result
    console.log(userInfo)
  } else {
    // 登录失败
    console.error('登录失败')
  }
}

// 获取当前的token和当前的用户信息
const token = passport.token
const userInfo = passport.userInfo

// 获取最新的用户数据,调用成功会刷新passport.userInfo
const userInfo = await passport.getUserInfo()
  1. Taro示例
import { Button } from '@tarojs/components'
import Taro from '@tarojs/taro'
import { Passport } from '@realsee/miniprogram'
import { useCallback } from 'react'

const passport = new Passport({ appKey: '如视Gateway的AppID' })

const Page = () => {
  const onGetPhoneNumber = useCallback(async ev => {
    if (ev.detail.code) {
      const getPhoneNumberResult = ev.detail
      const loginResult = await Taro.login()
      const user = await passport.login({ loginResult, getPhoneNumberResult })
      if (user !== false) {
        console.log('登录成功', user)
      } else {
        console.log('登录失败')
      }
    }
  }, [])

  return (
    <>
      <Button type='primary' openType='getPhoneNumber' onGetPhoneNumber={onGetPhoneNumber}>
        授权手机号登录
      </Button>
    </>
  )
}

export default Page
如视小程序支付服务
import { WechatPaymentOriginParams, WechatPaymentResult, requestWechatPayment } from '@realsee/miniprogram'

/**
 * 原始入参
 */
export interface WechatPaymentOriginParams {
  timeStamp: string
  nonceStr: string
  packageValue: string
  sign: string
  partnerId: string
  prepayId: string
  appId: string
  paySign: string
  signType: 'MD5' | 'HMAC-SHA256' | 'RSA'
}

/**
 * 返回结果
 */
export type WechatPaymentResult = { isSuccess: boolean; msg: string; params: WechatPaymentOriginParams }


/**
 * 调用示例
 */
try {
  const result = await requestWechatPayment(params: WechatPaymentOriginParams)
  if (result.isSuccess) {
    console.log('支付成功', msg)
  } else {
    console.log('支付失败', msg)
  }
} catch(e) {
  // 发生错误
  console.error(e)
}
如视小程序遥测服务
import { setRealseeTelemetryConfig, pushRealseeTelemetryEvent } from '@realsee/miniprogram'

// 进行配置
setRealseeTelemetryConfig({ appKey: '如视Gateway的AppID' })

// 上报数据
pushRealseeTelemetryEvent({ id: '事件id', name: '事件名', data: { foo: 'bar' } })
如视小程序VRWeview

参见如视开放平台文档:小程序容器