From 7a73c3c09ca78596d3e766a63378146cb1ddc336 Mon Sep 17 00:00:00 2001 From: Lin Date: Thu, 5 Jun 2025 11:20:48 +0800 Subject: [PATCH] Add onLoadStarted/onLoadFinished interface --- api/@internal/component/ets/web.d.ts | 67 ++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/api/@internal/component/ets/web.d.ts b/api/@internal/component/ets/web.d.ts index ade286994b..df04421937 100644 --- a/api/@internal/component/ets/web.d.ts +++ b/api/@internal/component/ets/web.d.ts @@ -5430,6 +5430,42 @@ declare interface OnPageBeginEvent { url: string; } +/** + * Defines the triggered function at the begin of web page loading. + * + * @typedef OnLoadStartedEvent + * @syscap SystemCapability.Web.Webview.Core + * @since 20 + */ +declare interface OnLoadStartedEvent { + /** + * The url to be loaded. + * + * @type { string } + * @syscap SystemCapability.Web.Webview.Core + * @since 20 + */ + url: string; +} + +/** + * Defines the triggered function at the end of web page loading. + * + * @typedef OnLoadFinishedEvent + * @syscap SystemCapability.Web.Webview.Core + * @since 20 + */ +declare interface OnLoadFinishedEvent { + /** + * The url to be loaded. + * + * @type { string } + * @syscap SystemCapability.Web.Webview.Core + * @since 20 + */ + url: string; +} + /** * Defines the triggered function when the page loading progress changes. * @@ -7610,6 +7646,37 @@ declare class WebAttribute extends CommonMethod { */ onPageBegin(callback: Callback): WebAttribute; + /** + * Triggered at the begin of web page loading. This method is called once for each main frame load. Embedded frame + * changes, i.e. clicking a link whose target is an iframe and fragment navigations (navigations to #fragment_id) + * will not trigger this callback. + * + *

API Note:
+ * Different from onPageBegin, onLoadStarted is triggered only once if the mainframe is automatically redirected + * before the page is completely loaded. OnPageBegin is triggered every navigation. + *

+ * + * @param { Callback } callback The triggered function at the begin of web page loading. + * @returns { WebAttribute } + * @syscap SystemCapability.Web.Webview.Core + * @since 20 + */ + onLoadStarted(callback: Callback): WebAttribute; + + /** + * Notify the host application that a page has finished loading. This method is called only for main frame. + * + *

API Note:
+ * Different from onPageEnd, fragment navigation also triggers onLoadFinished. + *

+ * + * @param { Callback } callback The triggered function at the end of web page loading. + * @returns { WebAttribute } + * @syscap SystemCapability.Web.Webview.Core + * @since 20 + */ + onLoadFinished(callback: Callback): WebAttribute; + /** * Triggered when the page loading progress changes. * -- Gitee