提交 5e07520d 编写于 作者: fxy060608's avatar fxy060608

feat(app): add navigateToMiniProgram

上级 9b11b78b
......@@ -6856,8 +6856,7 @@ var serviceContext = (function (vue) {
function sendNativeEvent(event, data, callback) {
// 实时获取weex module(weex可能会变化,比如首页nvue加速显示时)
return requireNativePlugin('plus').sendNativeEvent(event, data, callback);
}
const sendHostEvent = sendNativeEvent;
}
const getClipboardData = defineAsyncApi(API_GET_CLIPBOARD_DATA, (_, { resolve, reject }) => {
const clipboard = requireNativePlugin('clipboard');
......@@ -12136,6 +12135,17 @@ var serviceContext = (function (vue) {
__uniConfig.serviceReady = true;
}
const sendHostEvent = sendNativeEvent;
const API_NAVIGATE_TO_MINI_PROGRAM = 'navigateToMiniProgram';
const navigateToMiniProgram = defineAsyncApi(API_NAVIGATE_TO_MINI_PROGRAM, (data, { resolve, reject }) => {
sendHostEvent(API_NAVIGATE_TO_MINI_PROGRAM, data, (res) => {
if (res.errMsg && res.errMsg.indexOf(':ok') === -1) {
return reject(res.errMsg.split(' ')[1]);
}
resolve();
});
});
const EventType = {
load: 'load',
close: 'close',
......@@ -12898,9 +12908,10 @@ var serviceContext = (function (vue) {
requestPayment: requestPayment,
requireNativePlugin: requireNativePlugin,
sendNativeEvent: sendNativeEvent,
sendHostEvent: sendHostEvent,
__vuePlugin: index$1,
restoreGlobal: restoreGlobal,
sendHostEvent: sendHostEvent,
navigateToMiniProgram: navigateToMiniProgram,
createRewardedVideoAd: createRewardedVideoAd,
createFullScreenVideoAd: createFullScreenVideoAd,
createInterstitialAd: createInterstitialAd,
......
......@@ -63,6 +63,7 @@ export * from './plugin/requestPayment'
export * from './plugin/requireNativePlugin'
export * from './plugin/vuePlugin'
export * from './plugin/restoreGlobal'
export * from './plugin/sdk'
export * from './ad/rewardedVideoAd'
export * from './ad/fullScreenVideoAd'
......
......@@ -17,5 +17,3 @@ export function sendNativeEvent(
// 实时获取weex module(weex可能会变化,比如首页nvue加速显示时)
return requireNativePlugin('plus').sendNativeEvent(event, data, callback)
}
export const sendHostEvent = sendNativeEvent
import { defineAsyncApi } from '@dcloudio/uni-api'
import { sendNativeEvent } from './requireNativePlugin'
export const sendHostEvent = sendNativeEvent
const API_NAVIGATE_TO_MINI_PROGRAM = 'navigateToMiniProgram'
interface NavigateToMiniProgramOpitons {
success?: (result: any) => void
fail?: (result: any) => void
complete?: (result: any) => void
}
type API_TYPE_NAVIGATE_TO_MINI_PROGRAM = (
options: NavigateToMiniProgramOpitons
) => void
export const navigateToMiniProgram =
defineAsyncApi<API_TYPE_NAVIGATE_TO_MINI_PROGRAM>(
API_NAVIGATE_TO_MINI_PROGRAM,
(data, { resolve, reject }) => {
sendHostEvent(
API_NAVIGATE_TO_MINI_PROGRAM,
data,
(res: { errMsg: string }) => {
if (res.errMsg && res.errMsg.indexOf(':ok') === -1) {
return reject(res.errMsg.split(' ')[1])
}
resolve()
}
)
}
)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册