From 27f2dd3ccfa512f6dcd11c544452740977a11f92 Mon Sep 17 00:00:00 2001 From: zhangzezhong Date: Mon, 1 Sep 2025 09:54:03 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=83=E8=83=BD=E5=8A=9BCompletionHandler?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=90=911.2=E5=BC=80=E6=94=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhangzezhong --- api/@ohos.app.ability.CompletionHandler.d.ts | 53 +++++++++++++++++++- api/@ohos.app.ability.StartOptions.d.ts | 3 +- 2 files changed, 52 insertions(+), 4 deletions(-) diff --git a/api/@ohos.app.ability.CompletionHandler.d.ts b/api/@ohos.app.ability.CompletionHandler.d.ts index 835510b073..ed48691a07 100644 --- a/api/@ohos.app.ability.CompletionHandler.d.ts +++ b/api/@ohos.app.ability.CompletionHandler.d.ts @@ -20,6 +20,31 @@ import { ElementName } from './bundleManager/ElementName'; +/** + * Notify the success result of startAbility. + * + * @typedef { function } + * @param { ElementName } elementName - Indicates the component to start. + * @param { string } message - Indicates the message of the request result. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 20 + * @arkts 1.2 + */ +type OnRequestSuccessFn = (elementName: ElementName, message: string) => void; +/** + * Notify the failure result of startAbility. + * + * @typedef { function } + * @param { ElementName } elementName - Indicates the component to start. + * @param { string } message - Indicates the message of the request result. + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 20 + * @arkts 1.2 + */ +type OnRequestFailureFn = (elementName: ElementName, message: string) => void; + /** * CompletionHandler is a handler to handle the completion events of start ability. * @@ -27,8 +52,9 @@ import { ElementName } from './bundleManager/ElementName'; * @stagemodelonly * @atomicservice * @since 20 + * @arkts 1.1&1.2 */ -export default class CompletionHandler { +declare class CompletionHandler { /** * Notify the success result of startAbility. * @@ -52,4 +78,27 @@ export default class CompletionHandler { * @since 20 */ onRequestFailure(elementName: ElementName, message: string): void; -} \ No newline at end of file + + /** + * Notify the success result of startAbility. + * + * @type { OnRequestSuccessFn } + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 20 + * @arkts 1.2 + */ + onRequestSuccess: OnRequestSuccessFn; + + /** + * Notify the failure result of startAbility. + * + * @type { OnRequestFailureFn } + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @stagemodelonly + * @since 20 + * @arkts 1.2 + */ + onRequestFailure: OnRequestFailureFn; +} +export default CompletionHandler; \ No newline at end of file diff --git a/api/@ohos.app.ability.StartOptions.d.ts b/api/@ohos.app.ability.StartOptions.d.ts index 07b51995b5..f634f021e4 100644 --- a/api/@ohos.app.ability.StartOptions.d.ts +++ b/api/@ohos.app.ability.StartOptions.d.ts @@ -20,9 +20,7 @@ import contextConstant from "./@ohos.app.ability.contextConstant"; import image from "./@ohos.multimedia.image"; import bundleManager from './@ohos.bundle.bundleManager'; -/*** if arkts 1.1 */ import CompletionHandler from './@ohos.app.ability.CompletionHandler'; -/*** endif */ /** * StartOptions is the basic communication component of the system. @@ -253,6 +251,7 @@ export default class StartOptions { * @stagemodelonly * @atomicservice * @since 20 + * @arkts 1.1&1.2 */ completionHandler?: CompletionHandler; -- Gitee