From 13da87104096c3f4a1de33bfdd967075ed5b1e57 Mon Sep 17 00:00:00 2001 From: kongxiaojun Date: Thu, 11 Jul 2024 14:02:18 +0800 Subject: [PATCH 1/3] =?UTF-8?q?fix:=20[harmony-hybrid]=20exitMiniProgram?= =?UTF-8?q?=20api=E8=B0=83=E7=94=A8=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/pages/api/redirection/index.tsx | 5 ++++- .../build/config/harmony-definition.json | 7 ++++++- .../src/api/apis/NativeApi.ts | 5 +++++ .../src/api/apis/comments.ts | 6 ------ .../src/api/apis/navigate/index.ts | 11 +++++++++++ 5 files changed, 26 insertions(+), 8 deletions(-) diff --git a/examples/mini-program-example/src/pages/api/redirection/index.tsx b/examples/mini-program-example/src/pages/api/redirection/index.tsx index d9b32456a96a..0fae968e580a 100644 --- a/examples/mini-program-example/src/pages/api/redirection/index.tsx +++ b/examples/mini-program-example/src/pages/api/redirection/index.tsx @@ -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' /** * 跳转 @@ -29,7 +30,9 @@ export default class Index extends React.Component { }, { id: 'exitMiniProgram', - func: null, + func: () => { + Taro.exitMiniProgram() + }, }, ], } diff --git a/packages/taro-platform-harmony-hybrid/build/config/harmony-definition.json b/packages/taro-platform-harmony-hybrid/build/config/harmony-definition.json index 0fb07aec6f0c..817537f12991 100644 --- a/packages/taro-platform-harmony-hybrid/build/config/harmony-definition.json +++ b/packages/taro-platform-harmony-hybrid/build/config/harmony-definition.json @@ -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, diff --git a/packages/taro-platform-harmony-hybrid/src/api/apis/NativeApi.ts b/packages/taro-platform-harmony-hybrid/src/api/apis/NativeApi.ts index 0c85c4dd2355..e1ed2f0cc34f 100644 --- a/packages/taro-platform-harmony-hybrid/src/api/apis/NativeApi.ts +++ b/packages/taro-platform-harmony-hybrid/src/api/apis/NativeApi.ts @@ -622,6 +622,11 @@ export class NativeApi { @(asyncAndNotRelease) onNativeNavigate (_options: any): void {} + + @(asyncAndRelease) + exitMiniProgram (option?: any): any { + return option + } } export interface Status { diff --git a/packages/taro-platform-harmony-hybrid/src/api/apis/comments.ts b/packages/taro-platform-harmony-hybrid/src/api/apis/comments.ts index e86e430d641b..3e68b6b0db70 100644 --- a/packages/taro-platform-harmony-hybrid/src/api/apis/comments.ts +++ b/packages/taro-platform-harmony-hybrid/src/api/apis/comments.ts @@ -607,12 +607,6 @@ * @canNotUse editImage */ -/** - * 退出当前小程序 - * - * @canNotUse exitMiniProgram - */ - /** * 退出(销毁)实时语音通话 * diff --git a/packages/taro-platform-harmony-hybrid/src/api/apis/navigate/index.ts b/packages/taro-platform-harmony-hybrid/src/api/apis/navigate/index.ts index e1855051d5a1..df83798bac14 100644 --- a/packages/taro-platform-harmony-hybrid/src/api/apis/navigate/index.ts +++ b/packages/taro-platform-harmony-hybrid/src/api/apis/navigate/index.ts @@ -1,5 +1,6 @@ import Taro from '@tarojs/api' import { navigateTo as navigateToH5 } from '@tarojs/taro-h5' +import native from '../NativeApi' const delay = 300 let lastExecuteTime = 0 @@ -22,3 +23,13 @@ export function navigateTo (option: Taro.navigateTo.Option) { lastUrl = targetUrl return navigateToH5(option) } + +/** + * 退出当前小程序。必须有点击行为才能调用成功。 + * + * @canUse exitMiniProgram + * @__object [url, events] + */ +export function exitMiniProgram (option?: any) { + native.exitMiniProgram(option) +} From f4f33f98edbc77098ff8c7a9af3e393a17de30f0 Mon Sep 17 00:00:00 2001 From: kongxiaojun Date: Thu, 11 Jul 2024 15:17:48 +0800 Subject: [PATCH 2/3] fix: [harmony-hybrid] Run autofix to sort these imports --- .../src/api/apis/navigate/index.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/taro-platform-harmony-hybrid/src/api/apis/navigate/index.ts b/packages/taro-platform-harmony-hybrid/src/api/apis/navigate/index.ts index df83798bac14..9695bb0e5260 100644 --- a/packages/taro-platform-harmony-hybrid/src/api/apis/navigate/index.ts +++ b/packages/taro-platform-harmony-hybrid/src/api/apis/navigate/index.ts @@ -2,6 +2,8 @@ import Taro from '@tarojs/api' import { navigateTo as navigateToH5 } from '@tarojs/taro-h5' import native from '../NativeApi' +import native from '../NativeApi' + const delay = 300 let lastExecuteTime = 0 let lastUrl @@ -28,7 +30,6 @@ export function navigateTo (option: Taro.navigateTo.Option) { * 退出当前小程序。必须有点击行为才能调用成功。 * * @canUse exitMiniProgram - * @__object [url, events] */ export function exitMiniProgram (option?: any) { native.exitMiniProgram(option) From 8a27de368ca822ee7412682f8e71e17712f7ee26 Mon Sep 17 00:00:00 2001 From: kongxiaojun Date: Thu, 11 Jul 2024 15:18:48 +0800 Subject: [PATCH 3/3] =?UTF-8?q?fix:=20[harmony-hybrid]=20exitMiniProgram?= =?UTF-8?q?=20=E5=AF=BC=E5=85=A5=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../taro-platform-harmony-hybrid/src/api/apis/navigate/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/taro-platform-harmony-hybrid/src/api/apis/navigate/index.ts b/packages/taro-platform-harmony-hybrid/src/api/apis/navigate/index.ts index 9695bb0e5260..76ab98acdfa2 100644 --- a/packages/taro-platform-harmony-hybrid/src/api/apis/navigate/index.ts +++ b/packages/taro-platform-harmony-hybrid/src/api/apis/navigate/index.ts @@ -1,6 +1,5 @@ import Taro from '@tarojs/api' import { navigateTo as navigateToH5 } from '@tarojs/taro-h5' -import native from '../NativeApi' import native from '../NativeApi'