wechat-package
v1.0.5
Published
企业微信SDK工具包,提供用户验证、JS-SDK配置和语音处理功能
Maintainers
Readme
Wechat Enterprise SDK
企业微信SDK工具包,提供用户验证、JS-SDK配置和语音处理功能。
安装
npm install wechat-enterprise-sdk使用方法
基本使用
import { WechatEnterpriseSDK } from 'wechat-enterprise-sdk';
// 创建SDK实例
const sdk = new WechatEnterpriseSDK({
authUrl: 'https://your-auth-server.com',
devUserId: 'ZhangKeJie', // 开发环境用户ID
redirectUri: 'wechatai.gyjm.com.cn/auth-loading' // 重定向URI
});
// 用户验证
const userId = sdk.userValidate();
// 获取JS-SDK配置
const jsConfig = await sdk.getWechatJsConfig(window.location.href);
// 获取语音base64数据
const voiceData = await sdk.getVoiceBase64('media_id_here');函数式使用(兼容旧版本)
import { userValidate, getWechatJsConfig, getVoiceBase64 } from 'wechat-enterprise-sdk';
const options = {
authUrl: 'https://your-auth-server.com',
devUserId: 'ZhangKeJie',
redirectUri: 'wechatai.gyjm.com.cn/auth-loading'
};
const userId = userValidate(options);
const jsConfig = await getWechatJsConfig(options, window.location.href);
const voiceData = await getVoiceBase64(options, 'media_id_here');API 文档
WechatEnterpriseSDK
构造函数
new WechatEnterpriseSDK(options: WechatEnterpriseOptions)方法
userValidate(): UserValidationResult
用户验证方法,返回用户ID或跳转到授权页面。
getWechatJsConfig(url: string): Promise
获取企业微信JS-SDK配置签名。
getVoiceBase64(mediaId: string): Promise
获取企业微信语音素材的base64数据。
updateOptions(newOptions: Partial): void
更新配置选项。
getOptions(): WechatEnterpriseOptions
获取当前配置。
配置选项 (WechatEnterpriseOptions)
| 参数 | 类型 | 必填 | 描述 | |------|------|------|------| | authUrl | string | 是 | 认证服务器URL | | devUserId | string | 否 | 开发环境用户ID,默认 'ZhangKeJie' | | redirectUri | string | 否 | 重定向URI,默认 'wechatai.gyjm.com.cn/auth-loading' |
开发
# 安装依赖
npm install
# 开发模式(监听文件变化)
npm run dev
# 构建生产版本
npm run build
# 运行测试
npm run test发布
# 构建并发布到npm
npm run build
npm publish许可证
MIT License
支持
如有问题,请提交 Issue 或联系开发团队。
