From c423f2815ccef658450fd2d744c71faf2292f27a Mon Sep 17 00:00:00 2001 From: "ester.zhou" Date: Wed, 30 Aug 2023 18:14:23 +0800 Subject: [PATCH] Update docs (23016) Signed-off-by: ester.zhou --- .../reference/apis/js-apis-webview.md | 5 +- .../arkui-ts/ts-basic-components-web.md | 57 ++++++++++++------- 2 files changed, 36 insertions(+), 26 deletions(-) diff --git a/en/application-dev/reference/apis/js-apis-webview.md b/en/application-dev/reference/apis/js-apis-webview.md index d0b51d00e6..25b0ec59fd 100644 --- a/en/application-dev/reference/apis/js-apis-webview.md +++ b/en/application-dev/reference/apis/js-apis-webview.md @@ -518,7 +518,7 @@ export default class EntryAbility extends UIAbility { onCreate(want, launchParam) { console.log("EntryAbility onCreate") try { - web_webview.WebviewController.setHttpDns(web_webview.SecureDnsMode.Auto, "https://example1.test") + web_webview.WebviewController.setHttpDns(web_webview.SecureDnsMode.AUTO, "https://example1.test") } catch(error) { console.error(`ErrorCode: ${error.code}, Message: ${error.message}`); } @@ -6493,9 +6493,6 @@ Describes the mode in which the **\** component uses HTTPDNS. | Name | Value| Description | | ------------- | -- |----------------------------------------- | -| Off(deprecated) | 0 |HTTPDNS is not used. This value can be used to revoke the previously used HTTPDNS configuration.
This API is deprecated since API version 10. You are advised to use **OFF** instead.| -| Auto(deprecated) | 1 |HTTPDNS is used in automatic mode. When the specified HTTPDNS server is unavailable for resolution, the component will fall back to the system DNS server.
This API is deprecated since API version 10. You are advised to use **AUTO** instead.| -| SecureOnly(deprecated) | 2 |The specified HTTPDNS server is forcibly used for DNS resolution.
This API is deprecated since API version 10. You are advised to use **SECURE_ONLY** instead.| | OFF | 0 |HTTPDNS is not used. This value can be used to revoke the previously used HTTPDNS configuration.| | AUTO | 1 |HTTPDNS is used in automatic mode. When the specified HTTPDNS server is unavailable for resolution, the component will fall back to the system DNS server.| | SECURE_ONLY | 2 |The specified HTTPDNS server is forcibly used for DNS resolution.| diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-web.md b/en/application-dev/reference/arkui-ts/ts-basic-components-web.md index b3c50c96f5..2327181293 100644 --- a/en/application-dev/reference/arkui-ts/ts-basic-components-web.md +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-web.md @@ -107,7 +107,7 @@ Web(options: { src: ResourceStr, controller: WebviewController | WebController}) ``` 2. Modify the **EntryAbility.ts** file. - The following uses **filesDir** as an example to describe how to obtain the path of the sandbox. For details about how to obtain other paths, see [Obtaining Application File Paths](../../application-models/application-context-stage.md#obtaining-application-file-paths). + The following uses **filesDir** as an example to describe how to obtain the path of the sandbox. For details about how to obtain other paths, see [Obtaining Application File Paths](../../application-models/application-context-stage.md#obtaining-application-file-paths). ```ts // xxx.ts import UIAbility from '@ohos.app.ability.UIAbility'; @@ -809,12 +809,16 @@ Sets the scale factor of the entire page. The default value is 100%. } ``` -### userAgent +### userAgent(deprecated) userAgent(userAgent: string) Sets the user agent. +> **NOTE** +> +> This API is supported since API version 8 and deprecated since API version 10. You are advised to use [setCustomUserAgent](../apis/js-apis-webview.md#setcustomuseragent10)10+ instead. + **Parameters** | Name | Type | Mandatory | Default Value | Description | @@ -2194,7 +2198,8 @@ Called to process an HTML form whose input type is **file**, in response to the ```ts // xxx.ets - import web_webview from '@ohos.web.webview' + import web_webview from '@ohos.web.webview'; + import picker from '@ohos.file.picker'; @Entry @Component @@ -2203,24 +2208,18 @@ Called to process an HTML form whose input type is **file**, in response to the build() { Column() { - Web({ src: 'www.example.com', controller: this.controller }) + Web({ src: $rawfile('index.html'), controller: this.controller }) .onShowFileSelector((event) => { - AlertDialog.show({ - title: event.fileSelector.getTitle(), - message: 'isCapture:' + event.fileSelector.isCapture() + " mode:" + event.fileSelector.getMode() + 'acceptType:' + event.fileSelector.getAcceptType(), - confirm: { - value: 'upload', - action: () => { - let fileList: Array = [ - '/data/storage/el2/base/test', - ] - event.result.handleFileList(fileList) - } - }, - cancel: () => { - let fileList: Array = [] - event.result.handleFileList(fileList) - } + console.log('MyFileUploader onShowFileSelector invoked') + const documentSelectOptions = new picker.DocumentSelectOptions(); + let uri = null; + const documentViewPicker = new picker.DocumentViewPicker(); + documentViewPicker.select(documentSelectOptions).then((documentSelectResult) => { + uri = documentSelectResult[0]; + console.info('documentViewPicker.select to file succeed and uri is:' + uri); + event.result.handleFileList([uri]); + }).catch((err) => { + console.error(`Invoke documentViewPicker.select failed, code is ${err.code}, message is ${err.message}`); }) return true }) @@ -2229,6 +2228,19 @@ Called to process an HTML form whose input type is **file**, in response to the } ``` + HTML file to be loaded: + ```html + + + + + + +
+ + + ``` + ### onResourceLoad9+ onResourceLoad(callback: (event: {url: string}) => void) @@ -3512,8 +3524,9 @@ Called to indicate the offset by which the web page overscrolls. onControllerAttached(callback: () => void) -Called when the controller is successfully bound to the **\** component. The controller must be WebviewController. -As the web page is not yet loaded when this callback is called, APIs for operating the web page cannot be used in the callback, for example, [zoomIn](../apis/js-apis-webview.md#zoomin) and [zoomOut]. (../apis/js-apis-webview.md#zoomout). Other APIs, such as [loadUrl] (../apis/js-apis-webview.md#loadurl) and [getWebId] (../apis/js-apis-webview.md#getwebid), which do not involve web page operations, can be used properly. +Called when the controller is successfully bound to the **\** component. The controller must be WebviewController. + +As the web page is not yet loaded when this callback is called, APIs for operating the web page cannot be used in the callback, for example, [zoomIn](../apis/js-apis-webview.md#zoomin) and [zoomOut](../apis/js-apis-webview.md#zoomout). Other APIs, such as [loadUrl](../apis/js-apis-webview.md#loadurl) and [getWebId](../apis/js-apis-webview.md#getwebid), which do not involve web page operations, can be used properly. **Example** -- GitLab