UNPKG

xfyun-sdk

Version:

科大讯飞语音识别 SDK,支持浏览器中实时语音听写功能

48 lines (47 loc) 1.22 kB
/** * 共享组件类型定义 * * 提供所有 xfyun-sdk React 组件共享的基础类型 */ import type { CSSProperties } from 'react'; /** * 所有 xfyun-sdk 组件共享的基础属性 */ export interface BaseComponentProps { /** 讯飞应用 ID */ appId: string; /** 讯飞 API Key */ apiKey: string; /** 讯飞 API Secret */ apiSecret: string; /** 组件根容器的 CSS 类名 */ className?: string; /** 按钮的 CSS 类名 */ buttonClassName?: string; /** 输入框的 CSS 类名 */ inputClassName?: string; /** 开始时的回调 */ onStart?: () => void; /** 停止时的回调 */ onStop?: () => void; /** 错误时的回调 */ onError?: (error: unknown) => void; } /** * 组件状态类型 */ export type ComponentState = 'idle' | 'connecting' | 'connected' | 'active' | 'stopped' | 'error'; /** * 状态文本映射类型 */ export type StateTextMap<T extends ComponentState> = Record<T, string>; /** * 共享样式对象类型 */ export interface SharedComponentStyles { container: CSSProperties; button: CSSProperties; buttonActive: CSSProperties; buttonDisabled: CSSProperties; status: CSSProperties; }