diff --git a/ArkWebKit/AppScope/app.json5 b/ArkWebKit/AppScope/app.json5
new file mode 100644
index 0000000000000000000000000000000000000000..4cfb8aeba5d4de4a04bae5b59f8d613a7056f471
--- /dev/null
+++ b/ArkWebKit/AppScope/app.json5
@@ -0,0 +1,10 @@
+{
+ "app": {
+ "bundleName": "com.example.arkwebkit",
+ "vendor": "example",
+ "versionCode": 1000000,
+ "versionName": "1.0.0",
+ "icon": "$media:layered_image",
+ "label": "$string:app_name"
+ }
+}
diff --git a/ArkWebKit/AppScope/resources/base/element/string.json b/ArkWebKit/AppScope/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..015917acccfe2c3cef04256900e1be232fcc1b0d
--- /dev/null
+++ b/ArkWebKit/AppScope/resources/base/element/string.json
@@ -0,0 +1,8 @@
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "ArkWebKit"
+ }
+ ]
+}
diff --git a/ArkWebKit/AppScope/resources/base/media/background.png b/ArkWebKit/AppScope/resources/base/media/background.png
new file mode 100644
index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f
Binary files /dev/null and b/ArkWebKit/AppScope/resources/base/media/background.png differ
diff --git a/ArkWebKit/AppScope/resources/base/media/foreground.png b/ArkWebKit/AppScope/resources/base/media/foreground.png
new file mode 100644
index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f
Binary files /dev/null and b/ArkWebKit/AppScope/resources/base/media/foreground.png differ
diff --git a/ArkWebKit/AppScope/resources/base/media/layered_image.json b/ArkWebKit/AppScope/resources/base/media/layered_image.json
new file mode 100644
index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a
--- /dev/null
+++ b/ArkWebKit/AppScope/resources/base/media/layered_image.json
@@ -0,0 +1,7 @@
+{
+ "layered-image":
+ {
+ "background" : "$media:background",
+ "foreground" : "$media:foreground"
+ }
+}
\ No newline at end of file
diff --git a/ArkWebKit/build-profile.json5 b/ArkWebKit/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..03ac3a3ae9dd397844173066e5d5ee21b49455a1
--- /dev/null
+++ b/ArkWebKit/build-profile.json5
@@ -0,0 +1,41 @@
+{
+ "app": {
+ "signingConfigs": [],
+ "products": [
+ {
+ "name": "default",
+ "signingConfig": "default",
+ "compatibleSdkVersion": "5.0.4(16)",
+ "runtimeOS": "HarmonyOS",
+ "buildOption": {
+ "strictMode": {
+ "caseSensitiveCheck": true,
+ "useNormalizedOHMUrl": true
+ }
+ }
+ }
+ ],
+ "buildModeSet": [
+ {
+ "name": "debug",
+ },
+ {
+ "name": "release"
+ }
+ ]
+ },
+ "modules": [
+ {
+ "name": "entry",
+ "srcPath": "./entry",
+ "targets": [
+ {
+ "name": "default",
+ "applyToProducts": [
+ "default"
+ ]
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ArkWebKit/code-linter.json5 b/ArkWebKit/code-linter.json5
new file mode 100644
index 0000000000000000000000000000000000000000..073990fa45394e1f8e85d85418ee60a8953f9b99
--- /dev/null
+++ b/ArkWebKit/code-linter.json5
@@ -0,0 +1,32 @@
+{
+ "files": [
+ "**/*.ets"
+ ],
+ "ignore": [
+ "**/src/ohosTest/**/*",
+ "**/src/test/**/*",
+ "**/src/mock/**/*",
+ "**/node_modules/**/*",
+ "**/oh_modules/**/*",
+ "**/build/**/*",
+ "**/.preview/**/*"
+ ],
+ "ruleSet": [
+ "plugin:@performance/recommended",
+ "plugin:@typescript-eslint/recommended"
+ ],
+ "rules": {
+ "@security/no-unsafe-aes": "error",
+ "@security/no-unsafe-hash": "error",
+ "@security/no-unsafe-mac": "warn",
+ "@security/no-unsafe-dh": "error",
+ "@security/no-unsafe-dsa": "error",
+ "@security/no-unsafe-ecdsa": "error",
+ "@security/no-unsafe-rsa-encrypt": "error",
+ "@security/no-unsafe-rsa-sign": "error",
+ "@security/no-unsafe-rsa-key": "error",
+ "@security/no-unsafe-dsa-key": "error",
+ "@security/no-unsafe-dh-key": "error",
+ "@security/no-unsafe-3des": "error"
+ }
+}
\ No newline at end of file
diff --git a/ArkWebKit/entry/build-profile.json5 b/ArkWebKit/entry/build-profile.json5
new file mode 100644
index 0000000000000000000000000000000000000000..4d611879c7913fb0610c686e2399258ab3a6dad1
--- /dev/null
+++ b/ArkWebKit/entry/build-profile.json5
@@ -0,0 +1,28 @@
+{
+ "apiType": "stageMode",
+ "buildOption": {
+ },
+ "buildOptionSet": [
+ {
+ "name": "release",
+ "arkOptions": {
+ "obfuscation": {
+ "ruleOptions": {
+ "enable": false,
+ "files": [
+ "./obfuscation-rules.txt"
+ ]
+ }
+ }
+ }
+ },
+ ],
+ "targets": [
+ {
+ "name": "default"
+ },
+ {
+ "name": "ohosTest",
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ArkWebKit/entry/hvigorfile.ts b/ArkWebKit/entry/hvigorfile.ts
new file mode 100644
index 0000000000000000000000000000000000000000..c6edcd90486dd5a853cf7d34c8647f08414ca7a3
--- /dev/null
+++ b/ArkWebKit/entry/hvigorfile.ts
@@ -0,0 +1,6 @@
+import { hapTasks } from '@ohos/hvigor-ohos-plugin';
+
+export default {
+ system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
+}
diff --git a/ArkWebKit/entry/obfuscation-rules.txt b/ArkWebKit/entry/obfuscation-rules.txt
new file mode 100644
index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b
--- /dev/null
+++ b/ArkWebKit/entry/obfuscation-rules.txt
@@ -0,0 +1,23 @@
+# Define project specific obfuscation rules here.
+# You can include the obfuscation configuration files in the current module's build-profile.json5.
+#
+# For more details, see
+# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5
+
+# Obfuscation options:
+# -disable-obfuscation: disable all obfuscations
+# -enable-property-obfuscation: obfuscate the property names
+# -enable-toplevel-obfuscation: obfuscate the names in the global scope
+# -compact: remove unnecessary blank spaces and all line feeds
+# -remove-log: remove all console.* statements
+# -print-namecache: print the name cache that contains the mapping from the old names to new names
+# -apply-namecache: reuse the given cache file
+
+# Keep options:
+# -keep-property-name: specifies property names that you want to keep
+# -keep-global-name: specifies names that you want to keep in the global scope
+
+-enable-property-obfuscation
+-enable-toplevel-obfuscation
+-enable-filename-obfuscation
+-enable-export-obfuscation
\ No newline at end of file
diff --git a/ArkWebKit/entry/oh-package.json5 b/ArkWebKit/entry/oh-package.json5
new file mode 100644
index 0000000000000000000000000000000000000000..248c3b7541a589682a250f86a6d3ecf7414d2d6a
--- /dev/null
+++ b/ArkWebKit/entry/oh-package.json5
@@ -0,0 +1,10 @@
+{
+ "name": "entry",
+ "version": "1.0.0",
+ "description": "Please describe the basic information.",
+ "main": "",
+ "author": "",
+ "license": "",
+ "dependencies": {}
+}
+
diff --git a/ArkWebKit/entry/src/main/ets/entryability/EntryAbility.ets b/ArkWebKit/entry/src/main/ets/entryability/EntryAbility.ets
new file mode 100644
index 0000000000000000000000000000000000000000..508880af8c33aa838016d1cd4b2c68be2f447540
--- /dev/null
+++ b/ArkWebKit/entry/src/main/ets/entryability/EntryAbility.ets
@@ -0,0 +1,44 @@
+import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit';
+import { hilog } from '@kit.PerformanceAnalysisKit';
+import { window } from '@kit.ArkUI';
+
+const DOMAIN = 0x0000;
+
+export default class EntryAbility extends UIAbility {
+ onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
+ this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET);
+ hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate');
+ }
+
+ onDestroy(): void {
+ hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy');
+ }
+
+ onWindowStageCreate(windowStage: window.WindowStage): void {
+ // Main window is created, set main page for this ability
+ hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
+
+ windowStage.loadContent('pages/Index', (err) => {
+ if (err.code) {
+ hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err));
+ return;
+ }
+ hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.');
+ });
+ }
+
+ onWindowStageDestroy(): void {
+ // Main window is destroyed, release UI related resources
+ hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
+ }
+
+ onForeground(): void {
+ // Ability has brought to foreground
+ hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onForeground');
+ }
+
+ onBackground(): void {
+ // Ability has back to background
+ hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onBackground');
+ }
+}
\ No newline at end of file
diff --git a/ArkWebKit/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/ArkWebKit/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
new file mode 100644
index 0000000000000000000000000000000000000000..8e4de99282050bad799ac892eb85ac5449364a51
--- /dev/null
+++ b/ArkWebKit/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
@@ -0,0 +1,16 @@
+import { hilog } from '@kit.PerformanceAnalysisKit';
+import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit';
+
+const DOMAIN = 0x0000;
+
+export default class EntryBackupAbility extends BackupExtensionAbility {
+ async onBackup() {
+ hilog.info(DOMAIN, 'testTag', 'onBackup ok');
+ await Promise.resolve();
+ }
+
+ async onRestore(bundleVersion: BundleVersion) {
+ hilog.info(DOMAIN, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion));
+ await Promise.resolve();
+ }
+}
\ No newline at end of file
diff --git a/ArkWebKit/entry/src/main/ets/pages/ConfigSaveAsParameter.ets b/ArkWebKit/entry/src/main/ets/pages/ConfigSaveAsParameter.ets
new file mode 100644
index 0000000000000000000000000000000000000000..09c2a154f2fc367d2ad0964b097933d853fe54f0
--- /dev/null
+++ b/ArkWebKit/entry/src/main/ets/pages/ConfigSaveAsParameter.ets
@@ -0,0 +1,81 @@
+/*
+* 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:如何设置request.agent.Config中saveas参数
+*/
+
+// DocsCode 1
+import { webview } from '@kit.ArkWeb';
+import { request } from '@kit.BasicServicesKit';
+
+// 工具类中:在EntryAbility中获取Context后保存至AppStorage,然后在工具类中使用AppStorage获取
+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',
+ title: 'createTest',
+ description: 'Sample code for create task',
+ mode: request.agent.Mode.FOREGROUND,
+ overwrite: true,
+ method: "get",
+ saveas: filesDir + '/test.pdf',
+ network: request.agent.Network.WIFI,
+ metered: false,
+ roaming: true,
+ retry: true,
+ redirect: true,
+ index: 0,
+ begins: 0,
+ ends: -1,
+ gauge: false,
+ precise: false,
+ token: 'it is a secret'
+};
+let createOnCallback = (progress: request.agent.Progress) => {
+ console.info('upload task progress.');
+};
+
+@Entry
+@Component
+struct Index {
+ controller: webview.WebviewController = new webview.WebviewController();
+ @State uri: string = '';
+ @State isChange: boolean = false;
+
+ build() {
+ Column() {
+ Button('刷新UI')
+ .width('200vp')
+ .onClick(() => {
+ this.controller.loadUrl('file://' + filesDir + '/test.pdf')
+ })
+ .margin({ bottom: '20vp' })
+ Web({ src: $rawfile('test.html'), controller: this.controller })
+ .domStorageAccess(true)
+ .onPageBegin((event)=>{
+ request.agent.create(this.getUIContext().getHostContext(), config).then((task: request.agent.Task) => {
+ task.on('progress', createOnCallback);
+ console.info(`Succeeded in creating a download task. result: ${task.config}`);
+ task.start();
+ }).catch((err: Error) => {
+ console.error(`Failed to create a download task, message: ${err.message}`);
+ });
+ })
+ }
+ }
+}
+// DocsCode 1
\ 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
new file mode 100644
index 0000000000000000000000000000000000000000..33c937b64a3d6da5541b5b9e3b2ad453fc94dd8e
--- /dev/null
+++ b/ArkWebKit/entry/src/main/ets/pages/FullscreenPlayerSupport.ets
@@ -0,0 +1,85 @@
+/*
+* 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:如何适配网页内播放器全屏
+*/
+
+// DocsCode 1
+import { mediaquery, window } from '@kit.ArkUI';
+import { common } from '@kit.AbilityKit';
+import { webview } from '@kit.ArkWeb';
+
+@Entry
+@Component
+struct WebPlayerFullScreen {
+ @State color: string = '#DB7093';
+ @State text: string = 'Portrait';
+ @State portraitFunc: mediaquery.MediaQueryResult | void | null = null;
+ handler: FullScreenExitHandler | null = null;
+ // 当设备横屏时条件成立
+ listener: mediaquery.MediaQueryListener = this.getUIContext().getMediaQuery().matchMediaSync('(orientation: landscape)');
+ controller: webview.WebviewController = new webview.WebviewController();
+
+ onPortrait(mediaQueryResult: mediaquery.MediaQueryResult) {
+ // 若设备为横屏状态,更改相应的页面布局
+ if (mediaQueryResult.matches as boolean) {
+ this.color = '#FFD700';
+ this.text = 'Landscape';
+ } else {
+ this.color = '#DB7093';
+ this.text = 'Portrait';
+ }
+ }
+
+ aboutToAppear() {
+ // 绑定当前应用实例
+ // 绑定回调函数
+ this.listener.on('change', (mediaQueryResult: mediaquery.MediaQueryResult) => {
+ this.onPortrait(mediaQueryResult);
+ });
+ }
+
+ // 改变设备横竖屏状态函数
+ private changeOrientation(isLandscape: boolean) {
+ // 获取UIAbility实例的上下文信息
+ let context: common.UIAbilityContext = this.getUIContext().getHostContext() as common.UIAbilityContext;
+ // 调用该接口手动改变设备横竖屏状态
+ window.getLastWindow(context).then((lastWindow) => {
+ lastWindow.setPreferredOrientation(isLandscape ? window.Orientation.LANDSCAPE : window.Orientation.PORTRAIT);
+ });
+ }
+
+ build() {
+ Column() {
+ Web({ src: 'https://developer.huawei.com/consumer/cn/design/', controller: this.controller })
+ .javaScriptAccess(true)
+ .domStorageAccess(true)
+ .onFullScreenEnter((event) => {
+ this.handler = event.handler;
+ this.changeOrientation(true);
+ })
+ .onFullScreenExit(() => {
+ if (this.handler) {
+ this.handler.exitFullScreen();
+ this.changeOrientation(false);
+ }
+ })
+ }
+ .width('100%')
+ .height('100%')
+ }
+}
+// DocsCode 1
\ No newline at end of file
diff --git a/ArkWebKit/entry/src/main/ets/pages/Index.ets b/ArkWebKit/entry/src/main/ets/pages/Index.ets
new file mode 100644
index 0000000000000000000000000000000000000000..8e2d24ad42693fc877d51bb7820f0a9da68fa135
--- /dev/null
+++ b/ArkWebKit/entry/src/main/ets/pages/Index.ets
@@ -0,0 +1,23 @@
+@Entry
+@Component
+struct Index {
+ @State message: string = 'Hello World';
+
+ build() {
+ RelativeContainer() {
+ Text(this.message)
+ .id('HelloWorld')
+ .fontSize($r('app.float.page_text_font_size'))
+ .fontWeight(FontWeight.Bold)
+ .alignRules({
+ center: { anchor: '__container__', align: VerticalAlign.Center },
+ middle: { anchor: '__container__', align: HorizontalAlign.Center }
+ })
+ .onClick(() => {
+ this.message = 'Welcome';
+ })
+ }
+ .height('100%')
+ .width('100%')
+ }
+}
\ 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
new file mode 100644
index 0000000000000000000000000000000000000000..dd75768b4b1ca3ab63e58bf9fb3942adb9778244
--- /dev/null
+++ b/ArkWebKit/entry/src/main/ets/pages/UseAlertInWebview.ets
@@ -0,0 +1,78 @@
+/*
+* 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
+*/
+
+// DocsCode 1
+import { webview } from '@kit.ArkWeb';
+
+@Entry
+@Component
+struct WebviewAlert {
+ controller: webview.WebviewController = new webview.WebviewController();
+
+ build() {
+ Column() {
+ Web({ src: $rawfile('WebviewAlert.html'), controller: this.controller })
+ .onAlert((event) => {
+ if (event) {
+ console.log('event.url:' + event.url);
+ console.log('event.message:' + event.message);
+ this.getUIContext().showAlertDialog({
+ title: 'onAlert',
+ message: 'text',
+ primaryButton: {
+ value: 'cancel',
+ action: () => {
+ event.result.handleCancel();
+ }
+ },
+ secondaryButton: {
+ value: 'ok',
+ action: () => {
+ event.result.handleConfirm();
+ }
+ },
+ cancel: () => {
+ event.result.handleCancel();
+ }
+ })
+ }
+ return true;
+ })
+ }
+ }
+}
+// DocsCode 1
+
+// DocsCode 2
+
+
+
+
+
+
+
WebView onAlert Demo
+
+
+
+
+// DocsCode 2
\ 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.ets
new file mode 100644
index 0000000000000000000000000000000000000000..9e10b20af999ebd2d64640aa5faa08903586b011
--- /dev/null
+++ b/ArkWebKit/entry/src/main/ets/pages/UseLabelAOpenPages.ets
@@ -0,0 +1,242 @@
+/*
+* 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标签实现打开各种页面
+*/
+
+// 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
+
+
+