UNPKG

fastman3-dfyjapp-jsbridge

Version:

a jsbridge module for dfyj app

67 lines (66 loc) 3.13 kB
import { GoReq, BackReq, DynamicLinkReq, NavigationBarReq } from "./types"; import AppAuthorize from "./models/appAuthorize"; /** * 桥接准备,在使用桥接指令前需要先注册成功 * 客户端:建立桥接模式后直接执行回调 * 小程序端:目前直接执行回调 * 微信:直接执行回调(还额外包含微信用户信息恢复的逻辑处理) */ declare const ready: () => Promise<string>; /** * 通信鉴权 * 客户端:向客户端获取token等用户信息凭证后执行回调,并将必要的用户信息存储在 AppAuthorize 实例中 * 小程序端:目前直接执行回调 * 微信端:必要时调用 IF156008 恢复用户信息,并将必要的用户信息存储在 AppAuthorize 实例中,可额外获取 openid 和用户微信昵称 */ declare const oauth: () => Promise<string>; /** * 页面前进 * 客户端:打开一个新的 webview 容器打开页面 * 小程序端:调用自建路由模块(type 这个参数只适用于小程序端,一种是 router.navigate 的形式,另一种是打开一个新的小程序的形式) * 微信端:使用原生函数 location.href 进行跳转 */ declare const go: (params: GoReq) => void; /** * 页面后退 * 客户端:调用后将返回到栈的最外层,它并不会返回到前一个栈,如果需要返回前一个栈请使用history.back()来实现 * 小程序端:使用 Taro.navigateBack API 来实现 * 微信端:当step没有定义时调用history.back(), 否则调用history.go(-1 * step) */ declare const back: (params?: BackReq) => void; /** * 原生跳转 * 客户端:以一个新的 webview 方式打开原生开发的功能 * 小程序端:触发 fail 失败回调 * 微信端:触发 fail 失败回调 */ declare const dynamicLink: (params: DynamicLinkReq) => void; /** * 业务指令调用(暂未实现) * @param type Request消息类型 * @param payload Request消息结构,即输入参数 * @param success 用于处理成功回调的函数,success(输出消息结构中的payload) * @param error 用于处理失败回调的函数,error(输出消息结构中的info) */ declare const onRequest: (type: string, payload?: Object, success?: ((res: any) => void) | undefined, error?: ((err: any) => void) | undefined) => void; /** * 小程序端 设置导航头 【小程序只支持设置标题名称】 */ declare const navigationBar: (params: NavigationBarReq) => void; /** * 小程序: 直接调用Taro.useDidShow * APP: view将于出现时触发的回调函数(v3使用) * 其它: 马上回调 * 该指令中如果调用服务接口请务必自行处理接口的onAuthError回调 * @supported — dfyjapp */ declare const willAppear: (_callback?: () => void) => void; /** * 检查App通知权限开启状态 */ declare const onCheckAppNotification: (options: any) => void; /** * 跳转至App通知权限系统页 */ declare const onGoToCheckAppNotification: (options: any) => void; export { AppAuthorize, ready, oauth, go, back, dynamicLink, onRequest, navigationBar, willAppear, onCheckAppNotification, onGoToCheckAppNotification, };