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

kit-devicecheck-web

v1.0.11

Published

会前检测组件

Downloads

16

Readme

Kit-DeviceCheck-Web

会前检测组件

下载依赖

$ npm install kit-devicecheck-web react react-dom antd --save

使用

import { DeviceCheck } from 'kit-devicecheck-web'

const App = () => {
  return (
    <DeviceCheck {...props}/>
  )
}

// props声明:
interface DeviceCheckProps {
  cameraId: string // 摄像头设备id
  microphoneId: string // 麦克风设备id
  speakerId: string // 扬声器设备id
  appkey?: string // 音视频appkey
  debug?: boolean // 是否开启debug
  header?: React.ReactChild // 自定义header
  okText?: string // 底部确定按钮文案
  onOk?: () => void // 底部确定按钮点击事件
  auidoUrl?: string // 扬声器检测音频地址
  onCameraChange?: (deviceId: string) => void // 摄像头切换事件
  onMicrophoneChange?: (deviceId: string) => void // 麦克风切换事件
  onSpeakerChange?: (deviceId: string) => void // 扬声器切换事件
  onCameraOptionChange?: (old: Device[], cur: Device[]) => void // 摄像头插拔事件
  onMicrophoneOptionChange?: (old: Device[], cur: Device[]) => void // 麦克风插拔事件
  onSpeakerOptionChange?: (old: Device[], cur: Device[]) => void // 扬声器插拔事件
  onError?: (err: { code: number; msg: string }) => void // 错误事件
  theme?: { // 主题定制
    footerStyle?: React.CSSProperties // 底部footer样式
  }
}

其他方法

import { render, getDefaultDevices } from 'kit-devicecheck-web'

// render 用于在非react框架中渲染
const view = document.getElementById('view')
render(view: HTMLElement, props: DeviceCheckProps)

// getDefaultDevices 获取默认的设备,一般用于初始化时传入到组件中
getDefaultDevices().then(res => {
  console.log(res.cameraId)
  console.log(res.microphoneId)
  console.log(res.speakerId)
})

除此之外,组件还提供了 commonjs 与 umd 的输出方式。

// commonjs
const {
  DeviceCheck,
  render,
  getDefaultDevices,
} = require('kit-devicecheck-web')

// umd
const { DeviceCheck, render, getDefaultDevices } = window.NEDeviceCheck

onError 错误码

const errors = {
  GET_CAMERAS_FAIL: {
    code: 100,
    msg: '获取摄像头失败',
  },

  GET_MICROPHONES_FAIL: {
    code: 101,
    msg: '获取麦克风失败',
  },

  GET_SPEAKERS_FAIL: {
    code: 102,
    msg: '获取扬声器失败',
  },

  INIT_STREAM_FAIL: {
    code: 103,
    msg: '初始化stream失败',
  },

  SWITCH_DEVICE_FAIL: {
    code: 104,
    msg: '切换设备失败',
  },

  PLAY_AUDIO_FAIL: {
    code: 105,
    msg: '播放音频失败',
  },

  STOP_AUDIO_FAIL: {
    code: 106,
    msg: '停止播放音频失败',
  },

  PLAY_VIDEO_FAIL: {
    code: 107,
    msg: '播放视频失败',
  },

  STOP_VIDEO_FAIL: {
    code: 108,
    msg: '停止播放视频失败',
  },
}

定制主题

组件使用了 antd 来开发 UI,因为 antd 是外置依赖,所以可以直接在工程中通过设置 antd 的主题来设置组件的主题。 具体参考:antd 主题定制

FAQ

如果遇到样式丢失问题,需要手动导入 antd 的样式

import 'antd/dist/index.less'

组件预览

preview