Skip to content

Commit

Permalink
Merge pull request #16087 from kongxiaojun/f-exit-api-kxj
Browse files Browse the repository at this point in the history
fix: [harmony-hybrid] exitMiniProgram api调用实现
  • Loading branch information
qican777 authored Jul 12, 2024
2 parents dd90463 + cc6b950 commit d5bd870
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react'
import { View } from '@tarojs/components'
import ButtonList from '@/components/buttonList'
import './index.scss'
import Taro from '@tarojs/taro'

/**
* 跳转
Expand Down Expand Up @@ -29,7 +30,9 @@ export default class Index extends React.Component {
},
{
id: 'exitMiniProgram',
func: null,
func: () => {
Taro.exitMiniProgram()
},
},
],
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,12 @@
"TARO_ENV": true,
"USER_DATA_PATH": true
},
"exitMiniProgram": false,
"exitMiniProgram": {
"object": {
"url": true,
"events": true
}
},
"exitVoIPChat": false,
"faceDetect": false,
"faceVerifyForPay": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,11 @@ export class NativeApi {

@(asyncAndNotRelease)
onNativeNavigate (_options: any): void {}

@(asyncAndRelease)
exitMiniProgram (option?: any): any {
return option
}
}

export interface Status {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -607,12 +607,6 @@
* @canNotUse editImage
*/

/**
* 退出当前小程序
*
* @canNotUse exitMiniProgram
*/

/**
* 退出(销毁)实时语音通话
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import Taro from '@tarojs/api'
import { navigateTo as navigateToH5 } from '@tarojs/taro-h5'

import native from '../NativeApi'

const delay = 300
let lastExecuteTime = 0
let lastUrl
Expand All @@ -22,3 +24,12 @@ export function navigateTo (option: Taro.navigateTo.Option) {
lastUrl = targetUrl
return navigateToH5(option)
}

/**
* 退出当前小程序。必须有点击行为才能调用成功。
*
* @canUse exitMiniProgram
*/
export function exitMiniProgram (option?: any) {
native.exitMiniProgram(option)
}

0 comments on commit d5bd870

Please sign in to comment.