From 353170e07f146f1358f59acdec55abb826c050e2 Mon Sep 17 00:00:00 2001 From: xuhangqi Date: Thu, 24 Jul 2025 15:11:31 +0800 Subject: [PATCH] Refactor overload ohos.window2 Issue: https://gitee.com/openharmony/interface_sdk-js/issues/ICOJB4 Signed-off-by: xuhangqi Change-Id: I808f642d7a6d328eeea6f6c9466b501e7345b8c4 --- api/@ohos.window.d.ts | 259 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 235 insertions(+), 24 deletions(-) diff --git a/api/@ohos.window.d.ts b/api/@ohos.window.d.ts index d3fffd2bfd..490826ee40 100644 --- a/api/@ohos.window.d.ts +++ b/api/@ohos.window.d.ts @@ -3415,11 +3415,29 @@ declare namespace window { * @throws { BusinessError } 1300003 - This window manager service works abnormally. * @syscap SystemCapability.WindowManager.WindowManager.Core * @systemapi Hide this for inner system use. - * @since arkts {'1.1':'12', '1.2':'20'} - * @arkts 1.1&1.2 + * @since 12 + * */ function minimizeAll(id: long, callback: AsyncCallback): void; + /** + * Minimize all app windows. + * + * @param { long } id - ID of the display. + * @param { AsyncCallback } callback - Callback used to return the result. + * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. + * @throws { BusinessError } 401 - Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; + * 2. Incorrect parameter types; + * 3. Parameter verification failed. + * @throws { BusinessError } 801 - Capability not supported. Failed to call the API due to limited device capabilities. + * @throws { BusinessError } 1300003 - This window manager service works abnormally. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @systemapi Hide this for inner system use. + * @since 20 + * @arkts 1.2 + */ + function minimizeAllWithCallback(id: long, callback: AsyncCallback): void; + /** * Minimize all app windows. * @@ -3446,11 +3464,35 @@ declare namespace window { * @throws { BusinessError } 1300003 - This window manager service works abnormally. * @syscap SystemCapability.WindowManager.WindowManager.Core * @systemapi Hide this for inner system use. - * @since arkts {'1.1':'12', '1.2':'20'} - * @arkts 1.1&1.2 + * @since 12 + * */ function minimizeAll(id: long): Promise; + /** + * Minimize all app windows. + * + * @param { long } id - ID of the display. + * @returns { Promise } Promise that returns no value. + * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. + * @throws { BusinessError } 401 - Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; + * 2. Incorrect parameter types; + * 3. Parameter verification failed. + * @throws { BusinessError } 801 - Capability not supported. Failed to call the API due to limited device capabilities. + * @throws { BusinessError } 1300003 - This window manager service works abnormally. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @systemapi Hide this for inner system use. + * @since 20 + * @arkts 1.2 + */ + function minimizeAllReturnPromise(id: long): Promise; + + /** + * @since 20 + * @arkts 1.2 + */ + overload minimizeAll { minimizeAllWithCallback, minimizeAllReturnPromise }; + /** * Toggle shown state for all app windows. Minimize or restore all app windows. * @@ -4938,11 +4980,24 @@ declare namespace window { * @syscap SystemCapability.WindowManager.WindowManager.Core * @crossplatform * @atomicservice - * @since arkts {'1.1':'11', '1.2':'20'} - * @arkts 1.1&1.2 + * @since 11 + * */ showWindow(callback: AsyncCallback): void; + /** + * Shows this window. This API uses an asynchronous callback to return the result. + * This API takes effect only for a system window or an application child window. + * For the main window of an application, this API moves it at the top when the main window is already displayed. + * + * @param { AsyncCallback } callback - Callback used to return the result. + * @throws { BusinessError } 1300002 - This window state is abnormal. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 20 + * @arkts 1.2 + */ + showWindowWithCallback(callback: AsyncCallback): void; + /** * Show window. * @@ -4970,11 +5025,30 @@ declare namespace window { * @syscap SystemCapability.WindowManager.WindowManager.Core * @crossplatform * @atomicservice - * @since arkts {'1.1':'11', '1.2':'20'} - * @arkts 1.1&1.2 + * @since 11 + * */ showWindow(): Promise; + /** + * Shows this window. This API uses a promise to return the result. + * This API takes effect only for a system window or an application child window. + * For the main window of an application, this API moves it at the top when the main window is already displayed. + * + * @returns { Promise } Promise that returns no value. + * @throws { BusinessError } 1300002 - This window state is abnormal. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 20 + * @arkts 1.2 + */ + showWindowReturnPromise(): Promise; + + /** + * @since 20 + * @arkts 1.2 + */ + overload showWindow { showWindowWithCallback, showWindowReturnPromise }; + /** * Show window. * @@ -5093,11 +5167,23 @@ declare namespace window { * @syscap SystemCapability.WindowManager.WindowManager.Core * @crossplatform * @atomicservice - * @since arkts {'1.1':'11', '1.2':'20'} - * @arkts 1.1&1.2 + * @since 11 + * */ destroyWindow(callback: AsyncCallback): void; + /** + * Destroys this window. This API uses an asynchronous callback to return the result. + * This API takes effect only for a system window or an application child window. + * + * @param { AsyncCallback } callback - Callback used to return the result. + * @throws { BusinessError } 1300002 - This window state is abnormal. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 20 + * @arkts 1.2 + */ + destroyWindowWithCallback(callback: AsyncCallback): void; + /** * Destroy the window. * @@ -5125,11 +5211,29 @@ declare namespace window { * @syscap SystemCapability.WindowManager.WindowManager.Core * @crossplatform * @atomicservice - * @since arkts {'1.1':'11', '1.2':'20'} - * @arkts 1.1&1.2 + * @since 11 + * */ destroyWindow(): Promise; + /** + * Destroys this window. This API uses an asynchronous callback to return the result. + * This API takes effect only for a system window or an application child window. + * + * @returns { Promise } Promise that returns no value. + * @throws { BusinessError } 1300002 - This window state is abnormal. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 20 + * @arkts 1.2 + */ + destroyWindowReturnPromise(): Promise; + + /** + * @since 20 + * @arkts 1.2 + */ + overload destroyWindow { destroyWindowWithCallback, destroyWindowReturnPromise }; + /** * Set the position of a window. * @@ -6521,11 +6625,28 @@ declare namespace window { * @syscap SystemCapability.WindowManager.WindowManager.Core * @crossplatform * @atomicservice - * @since arkts {'1.1':'11', '1.2':'20'} - * @arkts 1.1&1.2 + * @since 11 + * */ setUIContent(path: string, callback: AsyncCallback): void; + /** + * Loads the content of a page, with its path in the current project specified, to this window. + * This API uses an asynchronous callback to return the result. + * + * @param { string } path - Path of the page from which the content will be loaded. + * In the stage model, the path is configured in the main_pages.json file of the project. + * In the FA model, the path is configured in the config.json file of the project. + * @param { AsyncCallback } callback - Callback used to return the result. + * @throws { BusinessError } 401 - Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; + * 2. Incorrect parameter types. + * @throws { BusinessError } 1300002 - This window state is abnormal. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 20 + * @arkts 1.2 + */ + setUIContentWithCallback(path: string, callback: AsyncCallback): void; + /** * Loads content * @@ -6564,11 +6685,34 @@ declare namespace window { * @syscap SystemCapability.WindowManager.WindowManager.Core * @crossplatform * @atomicservice - * @since arkts {'1.1':'11', '1.2':'20'} - * @arkts 1.1&1.2 + * @since 11 + * */ setUIContent(path: string): Promise; + /** + * Loads the content of a page, with its path in the current project specified, to this window. + * This API uses a promise to return the result. + * + * @param { string } path - Path of the page from which the content will be loaded. + * In the stage model, the path is configured in the main_pages.json file of the project. + * In the FA model, the path is configured in the config.json file of the project. + * @returns { Promise } Promise that returns no value. + * @throws { BusinessError } 401 - Parameter error. Possible cause: 1. Mandatory parameters are left unspecified; + * 2. Incorrect parameter types. + * @throws { BusinessError } 1300002 - This window state is abnormal. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 20 + * @arkts 1.2 + */ + setUIContentReturnPromise(path: string): Promise; + + /** + * @since 20 + * @arkts 1.2 + */ + overload setUIContent { setUIContentWithCallback, setUIContentReturnPromise }; + /** * Loads the content of a named route page to this window, and transfers the state attribute to the page through a local storage. * This API uses an asynchronous callback to return the result. You are advised to call this API during UIAbility startup. @@ -9558,11 +9702,26 @@ declare namespace window { * @throws { BusinessError } 1300003 - This window manager service works abnormally. * @syscap SystemCapability.Window.SessionManager * @atomicservice - * @since arkts {'1.1':'12', '1.2':'20'} - * @arkts 1.1&1.2 + * @since 12 + * */ minimize(callback: AsyncCallback): void; + /** + * Minimizes the main window if the caller is the main window. The main window can be restored in the dock bar. For 2-in-1 devices, it can be restored by calling restore(). + * Hides the child window if the caller is a child window. The child window cannot be restored in the dock bar. It can be made visible again by calling showWindow(). + * + * + * @param { AsyncCallback } callback - Callback used to return the result. + * @throws { BusinessError } 801 - Capability not supported. Failed to call the API due to limited device capabilities. + * @throws { BusinessError } 1300002 - This window state is abnormal. + * @throws { BusinessError } 1300003 - This window manager service works abnormally. + * @syscap SystemCapability.Window.SessionManager + * @since 20 + * @arkts 1.2 + */ + minimizeWithCallback(callback: AsyncCallback): void; + /** * Minimize app main window and hide app subWindow. * @@ -9583,11 +9742,31 @@ declare namespace window { * @throws { BusinessError } 1300003 - This window manager service works abnormally. * @syscap SystemCapability.Window.SessionManager * @atomicservice - * @since arkts {'1.1':'12', '1.2':'20'} - * @arkts 1.1&1.2 + * @since 12 + * */ minimize(): Promise; + /** + * Minimizes the main window if the caller is the main window. The main window can be restored in the dock bar. For 2-in-1 devices, it can be restored by calling restore(). + * Hides the child window if the caller is a child window. The child window cannot be restored in the dock bar. It can be made visible again by calling showWindow(). + * + * @returns { Promise } - Promise that returns no value. + * @throws { BusinessError } 801 - Capability not supported. Failed to call the API due to limited device capabilities. + * @throws { BusinessError } 1300002 - This window state is abnormal. + * @throws { BusinessError } 1300003 - This window manager service works abnormally. + * @syscap SystemCapability.Window.SessionManager + * @since 20 + * @arkts 1.2 + */ + minimizeReturnPromise(): Promise; + + /** + * @since 20 + * @arkts 1.2 + */ + overload minimize { minimizeWithCallback, minimizeReturnPromise }; + /** * Maximize app main window. * @param { MaximizePresentation } presentation - set window presentation when maximize. @@ -11213,10 +11392,23 @@ declare namespace window { * @StageModelOnly * @crossplatform * @atomicservice - * @since arkts {'1.1':'11', '1.2':'20'} - * @arkts 1.1&1.2 + * @since 11 + * */ getMainWindow(): Promise; + + /** + * Obtains the main window of this window stage. This API uses a promise to return the result. + * + * @returns { Promise } Promise used to return the main window. + * @throws { BusinessError } 1300002 - This window state is abnormal. + * @throws { BusinessError } 1300005 - This window stage is abnormal. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @StageModelOnly + * @since 20 + * @arkts 1.2 + */ + getMainWindowReturnPromise(): Promise; /** * Get main window of the stage. * @@ -11248,10 +11440,29 @@ declare namespace window { * @StageModelOnly * @crossplatform * @atomicservice - * @since arkts {'1.1':'11', '1.2':'20'} - * @arkts 1.1&1.2 + * @since 11 + * */ getMainWindow(callback: AsyncCallback): void; + + /** + * Obtains the main window of this window stage. This API uses an asynchronous callback to return the result. + * + * @param { AsyncCallback } callback Callback used to return the main window. + * @throws { BusinessError } 1300002 - This window state is abnormal. + * @throws { BusinessError } 1300005 - This window stage is abnormal. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @StageModelOnly + * @since 20 + * @arkts 1.2 + */ + getMainWindowWithCallback(callback: AsyncCallback): void; + + /** + * @since 20 + * @arkts 1.2 + */ + overload getMainWindow { getMainWindowReturnPromise, getMainWindowWithCallback }; /** * Get main window of the stage. * -- Gitee