From 80d0df4b605a5bb8a90b0c4c5a720e034b50dd67 Mon Sep 17 00:00:00 2001 From: kuangning <2540487435@qq.com> Date: Thu, 15 May 2025 19:22:18 +0800 Subject: [PATCH 1/2] =?UTF-8?q?ArkWebKit=E6=B7=BB=E5=8A=A0=E6=A0=87?= =?UTF-8?q?=E8=AF=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/ets/pages/ConfigSaveAsParameter.ets | 4 +- .../ets/pages/FullscreenPlayerSupport.ets | 4 +- .../src/main/ets/pages/UseAlertInWebview.ets | 22 +-- .../ets/pages/UseLabelAOpenPages_Four.ets | 59 ++++++ .../main/ets/pages/UseLabelAOpenPages_One.ets | 49 +++++ ...Pages.ets => UseLabelAOpenPages_Three.ets} | 179 +----------------- .../main/ets/pages/UseLabelAOpenPages_Two.ets | 30 +++ .../src/main/ets/pages/UseWebDownloadPdf.ets | 10 +- .../rawfile/UseAlertInWebview_Fragment.html | 36 ++++ .../UseLabelAOpenPages_Fragment_Five.html | 34 ++++ .../UseLabelAOpenPages_Fragment_Four.html | 37 ++++ .../UseLabelAOpenPages_Fragment_One.html | 36 ++++ .../UseLabelAOpenPages_Fragment_Three.html | 38 ++++ .../UseLabelAOpenPages_Fragment_Two.html | 36 ++++ .../resources/rawfile/WebDownloadPDF.html | 0 .../main/resources/rawfile/WebviewAlert.html | 0 .../src/main/resources/rawfile/hello.html | 0 .../src/main/resources/rawfile/test.html | 0 18 files changed, 368 insertions(+), 206 deletions(-) create mode 100644 ArkWebKit/entry/src/main/ets/pages/UseLabelAOpenPages_Four.ets create mode 100644 ArkWebKit/entry/src/main/ets/pages/UseLabelAOpenPages_One.ets rename ArkWebKit/entry/src/main/ets/pages/{UseLabelAOpenPages.ets => UseLabelAOpenPages_Three.ets} (31%) create mode 100644 ArkWebKit/entry/src/main/ets/pages/UseLabelAOpenPages_Two.ets create mode 100644 ArkWebKit/entry/src/main/resources/rawfile/UseAlertInWebview_Fragment.html create mode 100644 ArkWebKit/entry/src/main/resources/rawfile/UseLabelAOpenPages_Fragment_Five.html create mode 100644 ArkWebKit/entry/src/main/resources/rawfile/UseLabelAOpenPages_Fragment_Four.html create mode 100644 ArkWebKit/entry/src/main/resources/rawfile/UseLabelAOpenPages_Fragment_One.html create mode 100644 ArkWebKit/entry/src/main/resources/rawfile/UseLabelAOpenPages_Fragment_Three.html create mode 100644 ArkWebKit/entry/src/main/resources/rawfile/UseLabelAOpenPages_Fragment_Two.html create mode 100644 ArkWebKit/entry/src/main/resources/rawfile/WebDownloadPDF.html create mode 100644 ArkWebKit/entry/src/main/resources/rawfile/WebviewAlert.html create mode 100644 ArkWebKit/entry/src/main/resources/rawfile/hello.html create mode 100644 ArkWebKit/entry/src/main/resources/rawfile/test.html diff --git a/ArkWebKit/entry/src/main/ets/pages/ConfigSaveAsParameter.ets b/ArkWebKit/entry/src/main/ets/pages/ConfigSaveAsParameter.ets index 09c2a154..6bb0316e 100644 --- a/ArkWebKit/entry/src/main/ets/pages/ConfigSaveAsParameter.ets +++ b/ArkWebKit/entry/src/main/ets/pages/ConfigSaveAsParameter.ets @@ -17,7 +17,7 @@ * FAQ:如何设置request.agent.Config中saveas参数 */ -// DocsCode 1 +// [Start ConfigSaveAsParameter] import { webview } from '@kit.ArkWeb'; import { request } from '@kit.BasicServicesKit'; @@ -78,4 +78,4 @@ struct Index { } } } -// DocsCode 1 \ No newline at end of file +// [End ConfigSaveAsParameter] \ No newline at end of file diff --git a/ArkWebKit/entry/src/main/ets/pages/FullscreenPlayerSupport.ets b/ArkWebKit/entry/src/main/ets/pages/FullscreenPlayerSupport.ets index 33c937b6..b49bdf0d 100644 --- a/ArkWebKit/entry/src/main/ets/pages/FullscreenPlayerSupport.ets +++ b/ArkWebKit/entry/src/main/ets/pages/FullscreenPlayerSupport.ets @@ -17,7 +17,7 @@ * FAQ:如何适配网页内播放器全屏 */ -// DocsCode 1 +// [Start FullscreenPlayerSupport] import { mediaquery, window } from '@kit.ArkUI'; import { common } from '@kit.AbilityKit'; import { webview } from '@kit.ArkWeb'; @@ -82,4 +82,4 @@ struct WebPlayerFullScreen { .height('100%') } } -// DocsCode 1 \ No newline at end of file +// [End FullscreenPlayerSupport] \ No newline at end of file diff --git a/ArkWebKit/entry/src/main/ets/pages/UseAlertInWebview.ets b/ArkWebKit/entry/src/main/ets/pages/UseAlertInWebview.ets index dd75768b..2a1e9a95 100644 --- a/ArkWebKit/entry/src/main/ets/pages/UseAlertInWebview.ets +++ b/ArkWebKit/entry/src/main/ets/pages/UseAlertInWebview.ets @@ -17,7 +17,7 @@ * FAQ:如何在webview中使用H5中的alert */ -// DocsCode 1 +// [Start UseAlertInWebview] import { webview } from '@kit.ArkWeb'; @Entry @@ -57,22 +57,4 @@ struct WebviewAlert { } } } -// DocsCode 1 - -// DocsCode 2 - - - - - - -

WebView onAlert Demo

- - - - -// DocsCode 2 \ No newline at end of file +// [End UseAlertInWebview] \ No newline at end of file diff --git a/ArkWebKit/entry/src/main/ets/pages/UseLabelAOpenPages_Four.ets b/ArkWebKit/entry/src/main/ets/pages/UseLabelAOpenPages_Four.ets new file mode 100644 index 00000000..5a5c08db --- /dev/null +++ b/ArkWebKit/entry/src/main/ets/pages/UseLabelAOpenPages_Four.ets @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2024 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* +* FAQ:在Web组件的H5页面中,如何使用a标签实现打开各种页面 +*/ + +// [Start UseLabelAOpenPages_Four] +import { webview } from '@kit.ArkWeb' +import { common } from '@kit.AbilityKit'; +import { Want } from '@kit.AbilityKit'; +import { BusinessError } from '@kit.BasicServicesKit'; + +@Entry +@Component +struct WebComponent { + controller: webview.WebviewController = new webview.WebviewController(); + build() { + Column() { + Column() { + Web({ src: $rawfile('hello.html'), controller: this.controller }) + .onLoadIntercept((event) => { + let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; // UIAbilityContext + let want: Want = { + deviceId: '', // deviceId为空表示本设备 + bundleName: '***', // 想要跳转的三方应用的bundleName + moduleName: 'entry', // moduleName非必选 + abilityName: 'EntryAbility', + parameters: { + // 自定义参数传递页面信息 + router: 'index' + } + } + context.startAbility(want).then(() => { + console.log('success') + }).catch((err: BusinessError) => { + console.log('error:' + JSON.stringify(err)) + }); + return false; + }) + } + .layoutWeight(1) + } + + } +} +// [End UseLabelAOpenPages_Four] \ No newline at end of file diff --git a/ArkWebKit/entry/src/main/ets/pages/UseLabelAOpenPages_One.ets b/ArkWebKit/entry/src/main/ets/pages/UseLabelAOpenPages_One.ets new file mode 100644 index 00000000..d036dea2 --- /dev/null +++ b/ArkWebKit/entry/src/main/ets/pages/UseLabelAOpenPages_One.ets @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2024 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* +* FAQ:在Web组件的H5页面中,如何使用a标签实现打开各种页面 +*/ + +// [Start UseLabelAOpenPages_One] +import { webview } from '@kit.ArkWeb'; + +@Entry +@Component +struct WebComponent { + controller: webview.WebviewController = new webview.WebviewController(); + build() { + Column() { + Column() { + Web({ src: $rawfile('hello.html'), controller: this.controller }) + .onLoadIntercept((event) => { + if(event){ + let url = event.data.getRequestUrl(); + console.log(url); + if(url.indexOf('native://') === 0){ + this.getUIContext().getRouter().pushUrl({ url : url.substring(9)}) + return true; + } + } + return false; + }) + .width('100%') + .height('100%') + } + .layoutWeight(1) + } + } +} +// [End UseLabelAOpenPages_One] \ No newline at end of file diff --git a/ArkWebKit/entry/src/main/ets/pages/UseLabelAOpenPages.ets b/ArkWebKit/entry/src/main/ets/pages/UseLabelAOpenPages_Three.ets similarity index 31% rename from ArkWebKit/entry/src/main/ets/pages/UseLabelAOpenPages.ets rename to ArkWebKit/entry/src/main/ets/pages/UseLabelAOpenPages_Three.ets index 9e10b20a..b3b90ff7 100644 --- a/ArkWebKit/entry/src/main/ets/pages/UseLabelAOpenPages.ets +++ b/ArkWebKit/entry/src/main/ets/pages/UseLabelAOpenPages_Three.ets @@ -17,106 +17,7 @@ * FAQ:在Web组件的H5页面中,如何使用a标签实现打开各种页面 */ -// DocsCode 1 -import { webview } from '@kit.ArkWeb'; - -@Entry -@Component -struct WebComponent { - controller: webview.WebviewController = new webview.WebviewController(); - build() { - Column() { - Column() { - Web({ src: $rawfile('hello.html'), controller: this.controller }) - .onLoadIntercept((event) => { - if(event){ - let url = event.data.getRequestUrl(); - console.log(url); - if(url.indexOf('native://') === 0){ - this.getUIContext().getRouter().pushUrl({ url : url.substring(9)}) - return true; - } - } - return false; - }) - .width('100%') - .height('100%') - } - .layoutWeight(1) - } - } -} -// DocsCode 1 - -// DocsCode 2 -@Entry -@Component -struct Second { - build() { - Column() { - Text('这是本应用的第二个页面') - } - } -} -// DocsCode 2 - -// DocsCode 3 - - - - - - - Document - - -
- hello world!
- 跳转至本应用第二个arkts页面 -
- - -// DocsCode 3 - -// DocsCode 4 - - - - - - - Document - - -
- hello world!
- 跳转至本应用第二个H5页面 -
- - -// DocsCode 4 - -// DocsCode 5 - - - - - - - Document - - -
- hello world -
-
- 我是本应用的第二个H5页面 -
- - -// DocsCode 5 - -// DocsCode 6 +// [Start UseLabelAOpenPages_Three] import { webview } from '@kit.ArkWeb' import { common } from '@kit.AbilityKit'; import { Want } from '@kit.AbilityKit'; @@ -163,80 +64,4 @@ struct WebComponent { } } } -// DocsCode 6 - -// DocsCode 7 - - - - - - - Document - - - -
- hello world!
- 跳转至系统应用(以声音与震动为例) -
- - -// DocsCode 7 - -// DocsCode 8 -import { webview } from '@kit.ArkWeb' -import { common } from '@kit.AbilityKit'; -import { Want } from '@kit.AbilityKit'; -import { BusinessError } from '@kit.BasicServicesKit'; - -@Entry -@Component -struct WebComponent { - controller: webview.WebviewController = new webview.WebviewController(); - build() { - Column() { - Column() { - Web({ src: $rawfile('hello.html'), controller: this.controller }) - .onLoadIntercept((event) => { - let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; // UIAbilityContext - let want: Want = { - deviceId: '', // deviceId为空表示本设备 - bundleName: '***', // 想要跳转的三方应用的bundleName - moduleName: 'entry', // moduleName非必选 - abilityName: 'EntryAbility', - parameters: { - // 自定义参数传递页面信息 - router: 'index' - } - } - context.startAbility(want).then(() => { - console.log('success') - }).catch((err: BusinessError) => { - console.log('error:' + JSON.stringify(err)) - }); - return false; - }) - } - .layoutWeight(1) - } - - } -} -// DocsCode 8 - -// DocsCode 9 - - - - - - - Document - - -跳转至三方应用 - - -// DocsCode 9 \ No newline at end of file +// [End UseLabelAOpenPages_Three] \ No newline at end of file diff --git a/ArkWebKit/entry/src/main/ets/pages/UseLabelAOpenPages_Two.ets b/ArkWebKit/entry/src/main/ets/pages/UseLabelAOpenPages_Two.ets new file mode 100644 index 00000000..5c2f5a40 --- /dev/null +++ b/ArkWebKit/entry/src/main/ets/pages/UseLabelAOpenPages_Two.ets @@ -0,0 +1,30 @@ +/* +* Copyright (c) 2024 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* +* FAQ:在Web组件的H5页面中,如何使用a标签实现打开各种页面 +*/ + +// [Start UseLabelAOpenPages_Two] +@Entry +@Component +struct Second { + build() { + Column() { + Text('这是本应用的第二个页面') + } + } +} +// [End UseLabelAOpenPages_Two] \ No newline at end of file diff --git a/ArkWebKit/entry/src/main/ets/pages/UseWebDownloadPdf.ets b/ArkWebKit/entry/src/main/ets/pages/UseWebDownloadPdf.ets index 05e12fb0..4e240e35 100644 --- a/ArkWebKit/entry/src/main/ets/pages/UseWebDownloadPdf.ets +++ b/ArkWebKit/entry/src/main/ets/pages/UseWebDownloadPdf.ets @@ -17,13 +17,13 @@ * FAQ:如何使用Web组件下载pdf文件并展示给用户 */ -// DocsCode 1 +// [Start UseWebDownloadPdf] import { webview } from '@kit.ArkWeb'; import { common } from '@kit.AbilityKit'; import { request } from '@kit.BasicServicesKit'; -let context = getContext(this) as common.UIAbilityContext; -let filesDir = context.filesDir; +let context = AppStorage.get("context") as UIContext; +let filesDir = context.getHostContext()!.filesDir; let config: request.agent.Config = { action: request.agent.Action.DOWNLOAD, url: 'https://www-file.huawei.com/minisite/media/annual_report/annual_report_2023_cn.pdf', @@ -47,7 +47,7 @@ let config: request.agent.Config = { }; let createOnCallback = (progress: request.agent.Progress) => { console.info('download task completed.'); - this.getUIContext().getPromptAction().showToast({ + context.getPromptAction().showToast({ message: '下载完成', duration: 2000 }); @@ -83,4 +83,4 @@ struct Index { } } } -// DocsCode 1 \ No newline at end of file +// [End UseWebDownloadPdf] \ No newline at end of file diff --git a/ArkWebKit/entry/src/main/resources/rawfile/UseAlertInWebview_Fragment.html b/ArkWebKit/entry/src/main/resources/rawfile/UseAlertInWebview_Fragment.html new file mode 100644 index 00000000..f57650d2 --- /dev/null +++ b/ArkWebKit/entry/src/main/resources/rawfile/UseAlertInWebview_Fragment.html @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* +* FAQ:如何在webview中使用H5中的alert +*/ + +// [Start UseAlertInWebview_Fragment] + + + + + + +

WebView onAlert Demo

+ + + + +// [End UseAlertInWebview_Fragment] \ No newline at end of file diff --git a/ArkWebKit/entry/src/main/resources/rawfile/UseLabelAOpenPages_Fragment_Five.html b/ArkWebKit/entry/src/main/resources/rawfile/UseLabelAOpenPages_Fragment_Five.html new file mode 100644 index 00000000..2fbe58a9 --- /dev/null +++ b/ArkWebKit/entry/src/main/resources/rawfile/UseLabelAOpenPages_Fragment_Five.html @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* +* FAQ:在Web组件的H5页面中,如何使用a标签实现打开各种页面 +*/ + +// [Start UseLabelAOpenPages_Fragment_Five] + + + + + + + Document + + +跳转至三方应用 + + +// [End UseLabelAOpenPages_Fragment_Five] \ No newline at end of file diff --git a/ArkWebKit/entry/src/main/resources/rawfile/UseLabelAOpenPages_Fragment_Four.html b/ArkWebKit/entry/src/main/resources/rawfile/UseLabelAOpenPages_Fragment_Four.html new file mode 100644 index 00000000..cc7159d0 --- /dev/null +++ b/ArkWebKit/entry/src/main/resources/rawfile/UseLabelAOpenPages_Fragment_Four.html @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* +* FAQ:在Web组件的H5页面中,如何使用a标签实现打开各种页面 +*/ + +// [Start UseLabelAOpenPages_Fragment_Four] + + + + + + + Document + + + +
+ hello world!
+ 跳转至系统应用(以声音与震动为例) +
+ + +// [End UseLabelAOpenPages_Fragment_Four] \ No newline at end of file diff --git a/ArkWebKit/entry/src/main/resources/rawfile/UseLabelAOpenPages_Fragment_One.html b/ArkWebKit/entry/src/main/resources/rawfile/UseLabelAOpenPages_Fragment_One.html new file mode 100644 index 00000000..57fecbed --- /dev/null +++ b/ArkWebKit/entry/src/main/resources/rawfile/UseLabelAOpenPages_Fragment_One.html @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* +* FAQ:在Web组件的H5页面中,如何使用a标签实现打开各种页面 +*/ + +// [Start UseLabelAOpenPages_Fragment_One] + + + + + + + Document + + +
+ hello world!
+ 跳转至本应用第二个arkts页面 +
+ + +// [End UseLabelAOpenPages_Fragment_One] \ No newline at end of file diff --git a/ArkWebKit/entry/src/main/resources/rawfile/UseLabelAOpenPages_Fragment_Three.html b/ArkWebKit/entry/src/main/resources/rawfile/UseLabelAOpenPages_Fragment_Three.html new file mode 100644 index 00000000..3ebb5479 --- /dev/null +++ b/ArkWebKit/entry/src/main/resources/rawfile/UseLabelAOpenPages_Fragment_Three.html @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* +* FAQ:在Web组件的H5页面中,如何使用a标签实现打开各种页面 +*/ + +// [Start UseLabelAOpenPages_Fragment_Three] + + + + + + + Document + + +
+ hello world +
+
+ 我是本应用的第二个H5页面 +
+ + +// [End UseLabelAOpenPages_Fragment_Three] \ No newline at end of file diff --git a/ArkWebKit/entry/src/main/resources/rawfile/UseLabelAOpenPages_Fragment_Two.html b/ArkWebKit/entry/src/main/resources/rawfile/UseLabelAOpenPages_Fragment_Two.html new file mode 100644 index 00000000..eae4b1d2 --- /dev/null +++ b/ArkWebKit/entry/src/main/resources/rawfile/UseLabelAOpenPages_Fragment_Two.html @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* +* FAQ:在Web组件的H5页面中,如何使用a标签实现打开各种页面 +*/ + +// [Start UseLabelAOpenPages_Fragment_Two] + + + + + + + Document + + +
+ hello world!
+ 跳转至本应用第二个H5页面 +
+ + +// [End UseLabelAOpenPages_Fragment_Two] \ No newline at end of file diff --git a/ArkWebKit/entry/src/main/resources/rawfile/WebDownloadPDF.html b/ArkWebKit/entry/src/main/resources/rawfile/WebDownloadPDF.html new file mode 100644 index 00000000..e69de29b diff --git a/ArkWebKit/entry/src/main/resources/rawfile/WebviewAlert.html b/ArkWebKit/entry/src/main/resources/rawfile/WebviewAlert.html new file mode 100644 index 00000000..e69de29b diff --git a/ArkWebKit/entry/src/main/resources/rawfile/hello.html b/ArkWebKit/entry/src/main/resources/rawfile/hello.html new file mode 100644 index 00000000..e69de29b diff --git a/ArkWebKit/entry/src/main/resources/rawfile/test.html b/ArkWebKit/entry/src/main/resources/rawfile/test.html new file mode 100644 index 00000000..e69de29b -- Gitee From 15f8a93db46044f5c895740b8d3a1b01b79e7e5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E9=93=83?= <2540487435@qq.com> Date: Sat, 17 May 2025 06:22:04 +0000 Subject: [PATCH 2/2] =?UTF-8?q?ArkWebKit=E4=BF=AE=E6=94=B9=E6=B3=A8?= =?UTF-8?q?=E9=87=8A=E4=B8=BA=E8=8B=B1=E6=96=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 风铃 <2540487435@qq.com> --- .../src/main/ets/pages/ConfigSaveAsParameter.ets | 4 ++-- .../src/main/ets/pages/FullscreenPlayerSupport.ets | 14 +++++++------- .../src/main/ets/pages/UseLabelAOpenPages_Four.ets | 8 ++++---- .../src/main/ets/pages/UseLabelAOpenPages_Two.ets | 2 +- .../entry/src/main/ets/pages/UseWebDownloadPdf.ets | 4 ++-- .../rawfile/UseLabelAOpenPages_Fragment_Five.html | 2 +- .../rawfile/UseLabelAOpenPages_Fragment_Four.html | 2 +- .../rawfile/UseLabelAOpenPages_Fragment_One.html | 2 +- .../rawfile/UseLabelAOpenPages_Fragment_Three.html | 2 +- .../rawfile/UseLabelAOpenPages_Fragment_Two.html | 2 +- 10 files changed, 21 insertions(+), 21 deletions(-) diff --git a/ArkWebKit/entry/src/main/ets/pages/ConfigSaveAsParameter.ets b/ArkWebKit/entry/src/main/ets/pages/ConfigSaveAsParameter.ets index 6bb0316e..3403faa7 100644 --- a/ArkWebKit/entry/src/main/ets/pages/ConfigSaveAsParameter.ets +++ b/ArkWebKit/entry/src/main/ets/pages/ConfigSaveAsParameter.ets @@ -21,7 +21,7 @@ import { webview } from '@kit.ArkWeb'; import { request } from '@kit.BasicServicesKit'; -// 工具类中:在EntryAbility中获取Context后保存至AppStorage,然后在工具类中使用AppStorage获取 +// In the utility class, retrieve the Context from the Entry Ability and save it to AppStore, then use AppStore to retrieve it in the utility class let context = AppStorage.get("context") as UIContext; let filesDir = context.getHostContext()!.filesDir; let config: request.agent.Config = { @@ -58,7 +58,7 @@ struct Index { build() { Column() { - Button('刷新UI') + Button('Refresh UI') .width('200vp') .onClick(() => { this.controller.loadUrl('file://' + filesDir + '/test.pdf') diff --git a/ArkWebKit/entry/src/main/ets/pages/FullscreenPlayerSupport.ets b/ArkWebKit/entry/src/main/ets/pages/FullscreenPlayerSupport.ets index b49bdf0d..625dcd8e 100644 --- a/ArkWebKit/entry/src/main/ets/pages/FullscreenPlayerSupport.ets +++ b/ArkWebKit/entry/src/main/ets/pages/FullscreenPlayerSupport.ets @@ -29,12 +29,12 @@ struct WebPlayerFullScreen { @State text: string = 'Portrait'; @State portraitFunc: mediaquery.MediaQueryResult | void | null = null; handler: FullScreenExitHandler | null = null; - // 当设备横屏时条件成立 + // The condition is met when the device is in landscape mode listener: mediaquery.MediaQueryListener = this.getUIContext().getMediaQuery().matchMediaSync('(orientation: landscape)'); controller: webview.WebviewController = new webview.WebviewController(); onPortrait(mediaQueryResult: mediaquery.MediaQueryResult) { - // 若设备为横屏状态,更改相应的页面布局 + // If the device is in landscape mode, change the corresponding page layout if (mediaQueryResult.matches as boolean) { this.color = '#FFD700'; this.text = 'Landscape'; @@ -45,18 +45,18 @@ struct WebPlayerFullScreen { } aboutToAppear() { - // 绑定当前应用实例 - // 绑定回调函数 + // Bind the current application instance + // Bind callback function this.listener.on('change', (mediaQueryResult: mediaquery.MediaQueryResult) => { this.onPortrait(mediaQueryResult); }); } - // 改变设备横竖屏状态函数 + // Change the horizontal and vertical screen status function of the device private changeOrientation(isLandscape: boolean) { - // 获取UIAbility实例的上下文信息 + // Retrieve contextual information for UIAbility instances let context: common.UIAbilityContext = this.getUIContext().getHostContext() as common.UIAbilityContext; - // 调用该接口手动改变设备横竖屏状态 + // Call this interface to manually change the device's horizontal and vertical screen status window.getLastWindow(context).then((lastWindow) => { lastWindow.setPreferredOrientation(isLandscape ? window.Orientation.LANDSCAPE : window.Orientation.PORTRAIT); }); diff --git a/ArkWebKit/entry/src/main/ets/pages/UseLabelAOpenPages_Four.ets b/ArkWebKit/entry/src/main/ets/pages/UseLabelAOpenPages_Four.ets index 5a5c08db..ae2973ad 100644 --- a/ArkWebKit/entry/src/main/ets/pages/UseLabelAOpenPages_Four.ets +++ b/ArkWebKit/entry/src/main/ets/pages/UseLabelAOpenPages_Four.ets @@ -34,12 +34,12 @@ struct WebComponent { .onLoadIntercept((event) => { let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext; // UIAbilityContext let want: Want = { - deviceId: '', // deviceId为空表示本设备 - bundleName: '***', // 想要跳转的三方应用的bundleName - moduleName: 'entry', // moduleName非必选 + deviceId: '', // An empty DeviceId indicates that this device + bundleName: '***', // BundleName of the third-party application you want to jump to + moduleName: 'entry', // ModuleName is not mandatory abilityName: 'EntryAbility', parameters: { - // 自定义参数传递页面信息 + // Customize parameters to transmit page information router: 'index' } } diff --git a/ArkWebKit/entry/src/main/ets/pages/UseLabelAOpenPages_Two.ets b/ArkWebKit/entry/src/main/ets/pages/UseLabelAOpenPages_Two.ets index 5c2f5a40..f5b0c719 100644 --- a/ArkWebKit/entry/src/main/ets/pages/UseLabelAOpenPages_Two.ets +++ b/ArkWebKit/entry/src/main/ets/pages/UseLabelAOpenPages_Two.ets @@ -23,7 +23,7 @@ struct Second { build() { Column() { - Text('这是本应用的第二个页面') + Text('This is the second page of this application') } } } diff --git a/ArkWebKit/entry/src/main/ets/pages/UseWebDownloadPdf.ets b/ArkWebKit/entry/src/main/ets/pages/UseWebDownloadPdf.ets index 4e240e35..50773020 100644 --- a/ArkWebKit/entry/src/main/ets/pages/UseWebDownloadPdf.ets +++ b/ArkWebKit/entry/src/main/ets/pages/UseWebDownloadPdf.ets @@ -48,7 +48,7 @@ let config: request.agent.Config = { let createOnCallback = (progress: request.agent.Progress) => { console.info('download task completed.'); context.getPromptAction().showToast({ - message: '下载完成', + message: 'Download completed', duration: 2000 }); }; @@ -62,7 +62,7 @@ struct Index { build() { Column() { - Button('刷新UI') + Button('Refresh UI') .width('200vp') .onClick(() => { this.controller.loadUrl('file://' + filesDir + '/test.pdf'); diff --git a/ArkWebKit/entry/src/main/resources/rawfile/UseLabelAOpenPages_Fragment_Five.html b/ArkWebKit/entry/src/main/resources/rawfile/UseLabelAOpenPages_Fragment_Five.html index 2fbe58a9..823f3be4 100644 --- a/ArkWebKit/entry/src/main/resources/rawfile/UseLabelAOpenPages_Fragment_Five.html +++ b/ArkWebKit/entry/src/main/resources/rawfile/UseLabelAOpenPages_Fragment_Five.html @@ -28,7 +28,7 @@ Document -跳转至三方应用 +Jump to third-party applications // [End UseLabelAOpenPages_Fragment_Five] \ No newline at end of file diff --git a/ArkWebKit/entry/src/main/resources/rawfile/UseLabelAOpenPages_Fragment_Four.html b/ArkWebKit/entry/src/main/resources/rawfile/UseLabelAOpenPages_Fragment_Four.html index cc7159d0..b7422dde 100644 --- a/ArkWebKit/entry/src/main/resources/rawfile/UseLabelAOpenPages_Fragment_Four.html +++ b/ArkWebKit/entry/src/main/resources/rawfile/UseLabelAOpenPages_Fragment_Four.html @@ -30,7 +30,7 @@
hello world!
- 跳转至系统应用(以声音与震动为例) + Jump to system application (taking sound and vibration as examples)
diff --git a/ArkWebKit/entry/src/main/resources/rawfile/UseLabelAOpenPages_Fragment_One.html b/ArkWebKit/entry/src/main/resources/rawfile/UseLabelAOpenPages_Fragment_One.html index 57fecbed..7f13e419 100644 --- a/ArkWebKit/entry/src/main/resources/rawfile/UseLabelAOpenPages_Fragment_One.html +++ b/ArkWebKit/entry/src/main/resources/rawfile/UseLabelAOpenPages_Fragment_One.html @@ -29,7 +29,7 @@
hello world!
- 跳转至本应用第二个arkts页面 + Jump to the second ads page of this application
diff --git a/ArkWebKit/entry/src/main/resources/rawfile/UseLabelAOpenPages_Fragment_Three.html b/ArkWebKit/entry/src/main/resources/rawfile/UseLabelAOpenPages_Fragment_Three.html index 3ebb5479..9c6fa1fa 100644 --- a/ArkWebKit/entry/src/main/resources/rawfile/UseLabelAOpenPages_Fragment_Three.html +++ b/ArkWebKit/entry/src/main/resources/rawfile/UseLabelAOpenPages_Fragment_Three.html @@ -31,7 +31,7 @@ hello world

- 我是本应用的第二个H5页面 + I am the second H5 page of this application diff --git a/ArkWebKit/entry/src/main/resources/rawfile/UseLabelAOpenPages_Fragment_Two.html b/ArkWebKit/entry/src/main/resources/rawfile/UseLabelAOpenPages_Fragment_Two.html index eae4b1d2..4e3ea551 100644 --- a/ArkWebKit/entry/src/main/resources/rawfile/UseLabelAOpenPages_Fragment_Two.html +++ b/ArkWebKit/entry/src/main/resources/rawfile/UseLabelAOpenPages_Fragment_Two.html @@ -29,7 +29,7 @@
hello world!
- 跳转至本应用第二个H5页面 + Jump to the second H5 page of this application
-- Gitee