UNPKG

yidea-jssdk-adapter

Version:

Yidea H5 client adapter for Wechat, Wework, Feishu and Dingtalk.

186 lines (170 loc) 3.84 kB
declare interface ChooseImageParam { /** * 选择数量, 默认9 * @default 9 */ count: number; /** * 指定是原图还是压缩图,默认二者都有 * @default ['original','compressed'] */ sizeType: string[]; /** * 指定来源是相册还是相机,默认二者都有 * @default ['album','camera'] */ sourceType: string[]; /** * 回调时传回的额外参数,默认可以不设置 */ state: any; } declare interface ChooseImageResult { /** * 图片的BASE64列表 */ images: string[]; /** * 回调时传回的额外参数,与调用时传入的参数一致 */ state: any; } declare interface GetLocationParam { /** * 回调时传回的额外参数,默认可以不设置 */ state: any; } declare interface GetLocationResult { /** * 纬度 */ latitude: number; /** * 经度 */ longitude: number; /** * 回调时传回的额外参数,与调用时传入的参数一致 */ state: any; } declare interface ScanQRCodeParam { /** * 回调时传回的额外参数,默认可以不设置 */ state: any; } declare interface ScanQRCodeResult { /** * 扫码结果 */ code: string; /** * 回调时传回的额外参数,与调用时传入的参数一致 */ state: any; } /** * 签名算法结果 */ declare interface GenSignatureResult { /** * 签名 */ signature: string; /** * 时间戳 */ timestamp: number; /** * 随机串 */ nonceStr: string; } declare interface Adapter { /** * 客户端类型 */ get type(): string; /** * 是否在APP中打开 * @default false */ get isApp(): boolean /** * 是否支持退出登录 * @default false */ get supportLogout(): boolean; /** * 计算签名 * @param ticket js ticket * @param url 当前url */ genSignature(ticket: string, url: string): GenSignatureResult /** * JS-SDK鉴权 * @param url 当前页面url * @returns 结果 */ config(url: string): Promise<void>; /** * 拍照或从手机相册中选图接口 * @param param 参数 * @returns 照片地址数组 */ chooseImage(param: ChooseImageParam): Promise<ChooseImageResult>; /** * 获取地理位置接口 * @param param 参数 * @returns 经纬度 */ getLocation(param: GetLocationParam): Promise<GetLocationResult>; /** * 调起扫一扫接口 * @param param 参数,可不传参数 * @returns 扫码结果 */ scanQRCode(param: ScanQRCodeParam): Promise<ScanQRCodeResult>; /** * 退出登录 * @param idp 登录站点地址 */ logout(idp): void; /** * 设置页面标题 */ setTitle(title: string): void; } declare interface EnvConfig { /** * Auth地址 */ AUTH_URL: string; /** * 获取token的lambda表达式 * @constructor */ TOKEN_STORE: () => string; } declare class AdapterFactory { /** * 产品版本默认不调用,仅在私有云部署使用 * @param config 环境变量配置 */ constructor(config: EnvConfig); /** * 创建当前环境的适配器实例 */ create(): Adapter; } declare interface VueInstaller { /** * 安装Vue插件 * @param Vue Vue类 * @param adapter adapter实例 */ install(Vue, adapter: Adapter); } export { AdapterFactory, VueInstaller }