From 2667cd0a40f8816d486d97b6ef0d8e779eecee02 Mon Sep 17 00:00:00 2001 From: Wang Hui Date: Wed, 27 Jul 2022 15:52:46 +0800 Subject: [PATCH] Implement the function of saving offline web pages. Add new api WebAsyncController.saveWebArchive(baseName: string, autoName: boolean): Promise; WebAsyncController.saveWebArchive(baseName: string, autoName: boolean, callback?: (result: string) => void). Signed-off-by: Wang Hui --- api/@ohos.web.d.ts | 48 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/api/@ohos.web.d.ts b/api/@ohos.web.d.ts index 3d462d0bfa..d67dd55aaa 100644 --- a/api/@ohos.web.d.ts +++ b/api/@ohos.web.d.ts @@ -122,6 +122,52 @@ declare namespace web { */ static saveHttpAuthCredentials(host: string, realm: string, username: string, password: string): void; } + + /** + * Provides asynchronous methods for manage the NWeb. + * + * @since 9 + */ + class WebAsyncController { + /** + * Constructor. + * + * @param controller WebAsyncController needs a WebController to associate with corresponding nweb. + * + * @since 9 + */ + constructor(controller: WebController); + + /** + * Saves the current page as a web archive. + * + * @param baseName the filename where the archive should be placed,This value cannot be null. + * @param autoName if false, takes basename to be a file. If true, basename is assumed to be + * a directory in which a filename will be chosen according to the URL of the + * current page. + * @returns a promise resolved after the web archive has been saved. The parameter will either + * be the filename under which the file was saved, or empty if saving the file failed. + * + * @since 9 + */ + storeWebArchive(baseName: string, autoName: boolean): Promise; + + /** + * Saves the current page as a web archive. + * + * @param baseName the filename where the archive should be placed,This value cannot be null. + * @param autoName if false, takes basename to be a file. If true, basename is assumed to be + * a directory in which a filename will be chosen according to the URL of the + * current page. + * @param callback called after the web archive has been saved. The parameter will either be + * the filename under which the file was saved, or empty if saving + * the file failed. + * + * @since 9 + */ + storeWebArchive(baseName: string, autoName: boolean, callback : AsyncCallback): void; + } + } -export default web; \ No newline at end of file +export default web; -- Gitee