From 718bf18c61be8e88d8f13edd2d3bea1d9b7b1cba Mon Sep 17 00:00:00 2001 From: gaojianhao Date: Thu, 11 Apr 2024 13:59:25 +0800 Subject: [PATCH 1/6] New interface WarmupServiceWorker docs files. Signed-off-by: gaojianhao --- .../reference/apis-arkweb/js-apis-webview.md | 44 ++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/zh-cn/application-dev/reference/apis-arkweb/js-apis-webview.md b/zh-cn/application-dev/reference/apis-arkweb/js-apis-webview.md index 87f48c9c044..3dd6083e44c 100644 --- a/zh-cn/application-dev/reference/apis-arkweb/js-apis-webview.md +++ b/zh-cn/application-dev/reference/apis-arkweb/js-apis-webview.md @@ -13091,4 +13091,46 @@ Web组件预编译JavaScript生成字节码缓存的配置对象,用于控制 | 名称 | 类型 | 可读 | 可写 |说明 | | ----------- | ------ | -----|------|------------------- | -| responseHeaders | Array<[WebHeader](#webheader)> | 是 | 是 | 请求此JavaScript文件时服务器返回的响应头,用于标识文件版本,判断是否需要更新。 | \ No newline at end of file +| responseHeaders | Array<[WebHeader](#webheader)> | 是 | 是 | 请求此JavaScript文件时服务器返回的响应头,用于标识文件版本,判断是否需要更新。 | + +### warmupServiceWorker12+ + +static WarmupServiceWorker(url: string): void + +预热ServiceWorker,再夹在url之前调用此API。 + +**系统能力:** SystemCapability.Web.Webview.Core + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ---------------| ------- | ---- | ------------- | +| url | string | 是 | 需要预热ServiceWorker的url。| + +**错误码:** + +以下错误码的详细介绍请参见[webview错误码](errorcode-webview.md). + +| 错误码ID | 错误信息 | +| -------- | ------------------------------------------------------------ | +| 17100002 | Invalid url. | + +**示例:** + +```ts +// xxx.ts +import UIAbility from '@ohos.app.ability.UIAbility'; +import web_webview from '@ohos.web.webview'; +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import Want from '@ohos.app.ability.Want'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) { + console.log("EntryAbility onCreate"); + web_webview.WebviewController.initializeWebEngine(); + // 预热ServiceWorker时,需要將'https://www.example.com'替换成一个真实的网站地址。 + webview.WebviewController.warmupServiceWorker("https://www.example.com"); + AppStorage.setOrCreate("abilityWant", want); + } +} +``` \ No newline at end of file -- Gitee From a57fde9dc4a54157ba7c53cf249f64c5fbaa25cb Mon Sep 17 00:00:00 2001 From: gaojianhao Date: Thu, 11 Apr 2024 14:03:38 +0800 Subject: [PATCH 2/6] New interface WarmupServiceWorker docs files. Signed-off-by: gaojianhao --- .../reference/apis-arkweb/js-apis-webview.md | 65 ++++++++++--------- 1 file changed, 33 insertions(+), 32 deletions(-) diff --git a/zh-cn/application-dev/reference/apis-arkweb/js-apis-webview.md b/zh-cn/application-dev/reference/apis-arkweb/js-apis-webview.md index 3dd6083e44c..07ef1e8cd6b 100644 --- a/zh-cn/application-dev/reference/apis-arkweb/js-apis-webview.md +++ b/zh-cn/application-dev/reference/apis-arkweb/js-apis-webview.md @@ -13061,37 +13061,6 @@ struct WebComponent { } } ``` -### onRequestStop12+ - -onRequestStop(callback: Callback\): void - -当请求完成时的回调,仅当前面onRequestStart中回调决定拦截此请求中触发。触发的时机有以下两点: - -1.WebResourceHandler调用didFail或者didFinish。 - -2.此请求因为其他原因中断。 - -**系统能力:** SystemCapability.Web.Webview.Core - -**参数**: - -| 参数名 | 类型 | 必填 | 说明 | -| -------- | -------------------- | ---- | ---------- | -| callback | Callback\ | 是 | 对应请求结束的回调函数。 | - -**示例:** - -完整示例代码参考[onRequestStart](#onrequeststart12)。 - -## CacheOptions12+ - -Web组件预编译JavaScript生成字节码缓存的配置对象,用于控制字节码缓存更新。 - -**系统能力:** SystemCapability.Web.Webview.Core - -| 名称 | 类型 | 可读 | 可写 |说明 | -| ----------- | ------ | -----|------|------------------- | -| responseHeaders | Array<[WebHeader](#webheader)> | 是 | 是 | 请求此JavaScript文件时服务器返回的响应头,用于标识文件版本,判断是否需要更新。 | ### warmupServiceWorker12+ @@ -13133,4 +13102,36 @@ export default class EntryAbility extends UIAbility { AppStorage.setOrCreate("abilityWant", want); } } -``` \ No newline at end of file +``` + +### onRequestStop12+ + +onRequestStop(callback: Callback\): void + +当请求完成时的回调,仅当前面onRequestStart中回调决定拦截此请求中触发。触发的时机有以下两点: + +1.WebResourceHandler调用didFail或者didFinish。 + +2.此请求因为其他原因中断。 + +**系统能力:** SystemCapability.Web.Webview.Core + +**参数**: + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------- | ---- | ---------- | +| callback | Callback\ | 是 | 对应请求结束的回调函数。 | + +**示例:** + +完整示例代码参考[onRequestStart](#onrequeststart12)。 + +## CacheOptions12+ + +Web组件预编译JavaScript生成字节码缓存的配置对象,用于控制字节码缓存更新。 + +**系统能力:** SystemCapability.Web.Webview.Core + +| 名称 | 类型 | 可读 | 可写 |说明 | +| ----------- | ------ | -----|------|------------------- | +| responseHeaders | Array<[WebHeader](#webheader)> | 是 | 是 | 请求此JavaScript文件时服务器返回的响应头,用于标识文件版本,判断是否需要更新。 | \ No newline at end of file -- Gitee From daa247ae98acb97f7ff37cad1e08cf1e101b0068 Mon Sep 17 00:00:00 2001 From: gaojianhao Date: Wed, 17 Apr 2024 10:04:56 +0800 Subject: [PATCH 3/6] Fix dts examples. Signed-off-by: gaojianhao --- .../reference/apis-arkweb/js-apis-webview.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/zh-cn/application-dev/reference/apis-arkweb/js-apis-webview.md b/zh-cn/application-dev/reference/apis-arkweb/js-apis-webview.md index 07ef1e8cd6b..7cad185cf29 100644 --- a/zh-cn/application-dev/reference/apis-arkweb/js-apis-webview.md +++ b/zh-cn/application-dev/reference/apis-arkweb/js-apis-webview.md @@ -13064,9 +13064,9 @@ struct WebComponent { ### warmupServiceWorker12+ -static WarmupServiceWorker(url: string): void +static warmupServiceWorker(url: string): void -预热ServiceWorker,再夹在url之前调用此API。 +预热ServiceWorker,在加载url之前调用此API。 **系统能力:** SystemCapability.Web.Webview.Core @@ -13089,7 +13089,7 @@ static WarmupServiceWorker(url: string): void ```ts // xxx.ts import UIAbility from '@ohos.app.ability.UIAbility'; -import web_webview from '@ohos.web.webview'; +import webview from '@ohos.web.webview'; import AbilityConstant from '@ohos.app.ability.AbilityConstant'; import Want from '@ohos.app.ability.Want'; @@ -13097,7 +13097,6 @@ export default class EntryAbility extends UIAbility { onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) { console.log("EntryAbility onCreate"); web_webview.WebviewController.initializeWebEngine(); - // 预热ServiceWorker时,需要將'https://www.example.com'替换成一个真实的网站地址。 webview.WebviewController.warmupServiceWorker("https://www.example.com"); AppStorage.setOrCreate("abilityWant", want); } -- Gitee From 826e7ed2406c8026972b77dd4009c1064e68468a Mon Sep 17 00:00:00 2001 From: gaojianhao Date: Wed, 17 Apr 2024 11:35:40 +0800 Subject: [PATCH 4/6] Add api fix reason. Signed-off-by: gaojianhao --- zh-cn/application-dev/reference/apis-arkweb/js-apis-webview.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zh-cn/application-dev/reference/apis-arkweb/js-apis-webview.md b/zh-cn/application-dev/reference/apis-arkweb/js-apis-webview.md index 7cad185cf29..d2d54b577a5 100644 --- a/zh-cn/application-dev/reference/apis-arkweb/js-apis-webview.md +++ b/zh-cn/application-dev/reference/apis-arkweb/js-apis-webview.md @@ -13066,7 +13066,7 @@ struct WebComponent { static warmupServiceWorker(url: string): void -预热ServiceWorker,在加载url之前调用此API。 +预热ServiceWorker,以提升首屏页面的加载速度(仅限于会使用ServiceWorker的页面)。在加载url之前调用此API。 **系统能力:** SystemCapability.Web.Webview.Core -- Gitee From 8cc7217d8c68089e1a79a0cb8a270ec5c9403185 Mon Sep 17 00:00:00 2001 From: gaojianhao1 Date: Tue, 7 May 2024 15:08:32 +0800 Subject: [PATCH 5/6] add docs for interface. Signed-off-by: gaojianhao1 --- zh-cn/application-dev/reference/apis-arkweb/js-apis-webview.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zh-cn/application-dev/reference/apis-arkweb/js-apis-webview.md b/zh-cn/application-dev/reference/apis-arkweb/js-apis-webview.md index 34c515529a4..953fe2391e3 100644 --- a/zh-cn/application-dev/reference/apis-arkweb/js-apis-webview.md +++ b/zh-cn/application-dev/reference/apis-arkweb/js-apis-webview.md @@ -5357,7 +5357,7 @@ static setConnectionTimeout(timeout: number): void | 参数名 | 类型 | 必填 | 说明 | | ---------------| ------- | ---- | ------------- | -| timeout | number | 是 | socket连接超时时间,以秒为单位。 | +| timeout | number | 是 | socket连接超时时间,以秒为单位,socket必须为大于0的整数。 | **示例:** -- Gitee From e555bb0feb4811f15271b98279a69340f781b852 Mon Sep 17 00:00:00 2001 From: gaojianhao1 Date: Sat, 11 May 2024 17:03:16 +0800 Subject: [PATCH 6/6] Add interface warmupServiceWorekr docs. Signed-off-by: gaojianhao1 --- zh-cn/application-dev/reference/apis-arkweb/js-apis-webview.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zh-cn/application-dev/reference/apis-arkweb/js-apis-webview.md b/zh-cn/application-dev/reference/apis-arkweb/js-apis-webview.md index 68d3936624c..98f1d2a6403 100644 --- a/zh-cn/application-dev/reference/apis-arkweb/js-apis-webview.md +++ b/zh-cn/application-dev/reference/apis-arkweb/js-apis-webview.md @@ -13879,7 +13879,7 @@ import Want from '@ohos.app.ability.Want'; export default class EntryAbility extends UIAbility { onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) { console.log("EntryAbility onCreate"); - web_webview.WebviewController.initializeWebEngine(); + webview.WebviewController.initializeWebEngine(); webview.WebviewController.warmupServiceWorker("https://www.example.com"); AppStorage.setOrCreate("abilityWant", want); } -- Gitee