UNPKG

@tslsmart/magic-applet

Version:

特斯联移动端统一接口,抹平h5和wgt的差异

19 lines (18 loc) 570 B
import type { ActionParams } from '../types' export const action = (action: ActionParams) => { const { actionType, appid, targetUrl, data } = action return new Promise((resolve, reject) => { if (actionType === 'navigate' && !appid) { reject('跳转应用必须传入目标应用的appid') } else { try { uni.sendNativeEvent(actionType, { appid, targetUrl, data }, (e?: any) => { resolve(e) console.log('wgt receive app params' + JSON.stringify(e)) }) } catch (e) { reject(e) } } }) }