Skip to content

Commit

Permalink
feat: 删除navigateToMiniProgram相关实现
Browse files Browse the repository at this point in the history
  • Loading branch information
licunhao1 committed Jun 12, 2024
1 parent 7212f9d commit 4da04e0
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 77 deletions.
30 changes: 3 additions & 27 deletions examples/mini-program-example/src/pages/api/redirection/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import React from 'react'
import Taro from '@tarojs/taro'
import { View, Text } from '@tarojs/components'
import { TestConsole } from '@/util/util'
import { View } from '@tarojs/components'
import ButtonList from '@/components/buttonList'
import './index.scss'

Expand All @@ -22,30 +20,8 @@ export default class Index extends React.Component {
func: null,
},
{
id: 'navigateToMiniProgram',
inputData: {
appId: 'com.advanced.temp1',
path: 'EntryAbility:///pages/api/framework/index?paramA=good',
extraData: {
paramB: 'morning',
paramC: 'erveryone',
},
},
func: (apiIndex, data) => {
TestConsole.consoleTest('Taro.navigateToMiniProgram')
Taro.navigateToMiniProgram({
...data,
success: (res) => {
TestConsole.consoleSuccess.call(this, res, apiIndex)
},
fail: (res) => {
TestConsole.consoleFail.call(this, res, apiIndex)
},
complete: (res) => {
TestConsole.consoleComplete.call(this, res, apiIndex)
},
})
},
id: 'navigateToMiniProgram暂不支持',
func: null,
},
{
id: 'navigateBackMiniProgram',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,6 @@ export class NativeApi {
@(syncAndRelease)
getAppAuthorizeSetting (): any {}

// @ts-ignore
@(syncAndRelease)
navigateToMiniProgram (options: any) {
return options
}

// @ts-ignore
@(syncAndRelease)
setNavigationBarColor (options: any) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,48 +1,5 @@
import Taro from '@tarojs/api'
import { navigateTo as navigateToH5, showModal } from '@tarojs/taro-h5'

import native from '../NativeApi'
import { shouldBeObject } from '../utils'
import { MethodHandler } from '../utils/handler'

/**
* 打开另一个小程序
*
* @canUse navigateToMiniProgram
* @__object [appId, path, extraData]
*/
export const navigateToMiniProgram: typeof Taro.navigateToMiniProgram = (options) => {
const apiName = 'navigateToMiniProgram'
// options must be an Object
const isObject = shouldBeObject(options)
if (!isObject.flag) {
const res = { errMsg: `${apiName}:fail ${isObject.msg}` }
return Promise.reject(res)
}
return new Promise((resolve, reject) => {
const { success, fail, complete } = options as Exclude<typeof options, undefined>
const handle = new MethodHandler({ name: apiName, success, fail, complete })

showModal({
content: `即将打开${options.appId}应用`,
showCancel: true,
cancelText: '取消',
cancelColor: '#000',
confirmText: '允许',
confirmColor: '#0000ff',
fail: () => {
handle.fail({ errMsg: 'showModal error' }, { resolve, reject })
},
success: (res) => {
if (res.confirm) {
native.navigateToMiniProgram(options)
} else {
handle.fail({ errMsg: 'cancel' }, { resolve, reject })
}
},
})
})
}
import { navigateTo as navigateToH5 } from '@tarojs/taro-h5'

const delay = 300
let lastExecuteTime = 0
Expand Down

0 comments on commit 4da04e0

Please sign in to comment.