diff --git a/AppScope/app.json5 b/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..5470c22e225cb61e721cda383f7074711b2b0911 --- /dev/null +++ b/AppScope/app.json5 @@ -0,0 +1,10 @@ +{ + "app": { + "bundleName": "com.example.myapplication", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/AppScope/resources/base/element/string.json b/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..1080233f01384411ec684b58955cb8808746fdd3 --- /dev/null +++ b/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "MyApplication" + } + ] +} diff --git a/AppScope/resources/base/media/app_icon.png b/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..a39445dc87828b76fed6d2ec470dd455c45319e3 Binary files /dev/null and b/AppScope/resources/base/media/app_icon.png differ diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..338e5b0bc22082e0ffcc7121c2ed3897a3ddccb0 --- /dev/null +++ b/LICENSE @@ -0,0 +1,78 @@ + Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved. + + 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. + +Apache License, Version 2.0 +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. + +"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. + +2. Grant of Copyright License. + +Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. + +Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. + +4. Redistribution. + +You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: +1.You must give any other recipients of the Work or Derivative Works a copy of this License; and +2.You must cause any modified files to carry prominent notices stating that You changed the files; and +3.You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and +4.If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. + +You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. + +5. Submission of Contributions. + +Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. + +6. Trademarks. + +This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. + +Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. + +In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. + +While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS \ No newline at end of file diff --git a/README.md b/README.md index f09a1801206b60926ca7a352a4471bf1d2465285..ff84a80a6afe5ef05ce301d6598a23967459a1b4 100644 --- a/README.md +++ b/README.md @@ -1,39 +1,52 @@ -# RemoteCommunicationPlatform - -#### 介绍 -{**以下是 Gitee 平台说明,您可以替换此简介** -Gitee 是 OSCHINA 推出的基于 Git 的代码托管平台(同时支持 SVN)。专为开发者提供稳定、高效、安全的云端软件开发协作平台 -无论是个人、团队、或是企业,都能够用 Gitee 实现代码托管、项目管理、协作开发。企业项目请看 [https://gitee.com/enterprises](https://gitee.com/enterprises)} - -#### 软件架构 -软件架构说明 - - -#### 安装教程 - -1. xxxx -2. xxxx -3. xxxx - -#### 使用说明 - -1. xxxx -2. xxxx -3. xxxx - -#### 参与贡献 - -1. Fork 本仓库 -2. 新建 Feat_xxx 分支 -3. 提交代码 -4. 新建 Pull Request - - -#### 特技 - -1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md -2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com) -3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目 -4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目 -5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help) -6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) +# **基于RCP的网络请求能力** +## 介绍 +RCP指的是远程通信平台(remote communication platform),RCP提供网络数据请求功能,相较于Network Kit中HTTP请求能力,RCP更具易用性,且拥有更多的功能。例如: +* 支持发送PATCH请求 + +* 支持设置BaseURL + +* 支持取消请求,取消指定或正在进行的会话请求 + +* 支持自定义证书校验,可以根据自身业务需要,对证书进行校验 + +* 支持自定义DNS解析 + +* 支持自定义拦截器实现响应缓存 + +* 支持在会话中的HTTP请求期间捕获详细的跟踪信息 +## 预览效果 +![](screenshots/device/rcp.gif) +## 工程目录 +``` +├──entry/src/main/ets // 代码区 +│ ├──common +│ | ├──CommonConstants.ets // 日志工具类 +│ | └──Logger.ets // 常量 +│ ├──entryability +│ | └──EntryAbility.ets // 程序入口类 +│ ├──entrybackupability +│ | └──EntryBackupAbility.ets +│ ├──pages +│ | ├──BaseRequest.ets // 基础网络请求 +│ | ├──DNSSetting.ets // DNS相关设置 +│ | ├──Index.ets // 首页 +│ | ├──MultipartForm.ets // 多表单提交 +│ | ├──RequestAndResponse.ets // 请求与响应拦截示例 +│ | └──TracingPoint.ets // 捕获有关HTTP请求/响应流的详细信息 +| └──utils.ets +│ ├──Interceptors.ets // 请求与响应拦截 +│ └──NetworkStateSimulator.ets // 模拟慢速网络 +└──entry/src/main/resources // 应用资源目录 +``` +## 相关权限 +应用需要访问互联网,需要使用网络权限。 + +`ohos.permission.INTERNET` +## 约束与限制 +* 本示例仅支持标准系统上运行,支持设备:华为手机。 + +* HarmonyOS系统:HarmonyOS NEXT Developer Beta1及以上。 + +* DevEco Studio版本:DevEco Studio NEXT Developer Beta1及以上。 + +* HarmonyOS SDK版本:HarmonyOS NEXT Developer Beta1 SDK及以上。 \ No newline at end of file diff --git a/build-profile.json5 b/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..c033ce4278fb0641d84107c3c134047ac487368e --- /dev/null +++ b/build-profile.json5 @@ -0,0 +1,35 @@ +{ + "app": { + "signingConfigs": [], + "products": [ + { + "name": "default", + "signingConfig": "default", + "compatibleSdkVersion": "5.0.0(12)", + "runtimeOS": "HarmonyOS", + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/entry/build-profile.json5 b/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..b695582d3680556f4cce2ec518f65720a9413ca3 --- /dev/null +++ b/entry/build-profile.json5 @@ -0,0 +1,28 @@ +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": true, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/entry/hvigorfile.ts b/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..c6edcd90486dd5a853cf7d34c8647f08414ca7a3 --- /dev/null +++ b/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/entry/obfuscation-rules.txt b/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..69c4d6a8a5531548e4886fa766090c5c157a87d9 --- /dev/null +++ b/entry/obfuscation-rules.txt @@ -0,0 +1,18 @@ +# 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 \ No newline at end of file diff --git a/entry/oh-package.json5 b/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..248c3b7541a589682a250f86a6d3ecf7414d2d6a --- /dev/null +++ b/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/entry/src/main/ets/common/CommonConstants.ets b/entry/src/main/ets/common/CommonConstants.ets new file mode 100644 index 0000000000000000000000000000000000000000..1d44ccf3296712493cb24990bce8cc670a8a14f5 --- /dev/null +++ b/entry/src/main/ets/common/CommonConstants.ets @@ -0,0 +1,66 @@ +/* + * 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. + */ + +export class CommonConstants { + /** + * Full percent. + */ + static readonly FULL_PERCENT: string = '100%'; + + /** + * Text area height. + */ + static readonly TEXTAREA_HEIGHT: string = '35%'; + + /** + * Multipart form text area height. + */ + static readonly FORM_TEXTAREA_HEIGHT: string = '45%'; + + /** + * Multipart form column height. + */ + static readonly FORM_COLUMN_HEIGHT: string = '36%'; + + /** + * Text font weight. + */ + static readonly TEXT_FONT_WEIGHT: number = 700; + + /** + * Column space. + */ + static readonly COLUMN_SPACE: number = 12; + + /** + * Simulate slow network text height. + */ + static readonly SIMULATE_TEXT_HEIGHT: number = 56; + + /** + * TextInput maxLength. + */ + static readonly TEXT_INPUT_MAXLENGTH: number = 20; + + /** + * Column height. + */ + static readonly COLUMN_HEIGHT: number = 100; + + /** + * Multipart form text weight. + */ + static readonly FORM_TEXT_FONT_WEIGHT: number = 500; +} \ No newline at end of file diff --git a/entry/src/main/ets/common/Logger.ets b/entry/src/main/ets/common/Logger.ets new file mode 100644 index 0000000000000000000000000000000000000000..16296944268e9787bf390020e6b76030e2e39d64 --- /dev/null +++ b/entry/src/main/ets/common/Logger.ets @@ -0,0 +1,50 @@ +/* + * 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. + */ +import { hilog } from '@kit.PerformanceAnalysisKit'; + +class Logger { + private domain: number; + private prefix: string; + private format: string = '%{public}s'; + + /** + * constructor. + * + * @param Prefix Identifies the log tag. + * @param domain Domain Indicates this service domain, which is a hexadecimal integer ranging from 0x0 to 0xFFFFF. + */ + constructor(prefix: string) { + this.prefix = prefix; + this.domain = 0xFF00; + } + + debug(...args: string[]): void{ + hilog.debug(this.domain, this.prefix, this.format, args) + } + + info(...args: string[]): void{ + hilog.info(this.domain, this.prefix, this.format, args) + } + + warn(...args: string[]): void{ + hilog.warn(this.domain, this.prefix, this.format, args) + } + + error(...args: string[]): void{ + hilog.error(this.domain, this.prefix, this.format, args) + } +} + +export default new Logger('RCP') \ No newline at end of file diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..8335b7692d4cac1f8b5d78ce7bc1c45a453d563e --- /dev/null +++ b/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,41 @@ +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..dc55c03d3eea7ce53d5346c732a39ce9bf5267e1 --- /dev/null +++ b/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -0,0 +1,12 @@ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit'; + +export default class EntryBackupAbility extends BackupExtensionAbility { + async onBackup() { + hilog.info(0x0000, 'testTag', 'onBackup ok'); + } + + async onRestore(bundleVersion: BundleVersion) { + hilog.info(0x0000, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion)); + } +} \ No newline at end of file diff --git a/entry/src/main/ets/pages/BaseRequest.ets b/entry/src/main/ets/pages/BaseRequest.ets new file mode 100644 index 0000000000000000000000000000000000000000..f2705b67dcc5d355f444a24121b9a625199fe634 --- /dev/null +++ b/entry/src/main/ets/pages/BaseRequest.ets @@ -0,0 +1,129 @@ +/* + * 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. + */ + +import { BusinessError } from '@kit.BasicServicesKit'; +import { rcp } from '@kit.RemoteCommunicationKit'; +import { url } from '@kit.ArkTS'; +import Logger from '../common/Logger'; +import { CommonConstants } from '../common/CommonConstants'; + +interface UserInfo { + userName: string; +} + +@Builder +export function BaseRequestBuilder() { + BaseRequest() +} + +@Component +export struct BaseRequest { + @State patchHeaders: string = ''; + @State baseAddress: url.URL | string | undefined = ''; + @StorageLink('PatchHeaders') storageLinkPatchHeaders: string = ''; + @StorageLink('BaseAddress') storageLinkBaseAddress: string = ''; + + patchRequest() { + // DocsCode 1 + // Define the headers + let headers: rcp.RequestHeaders = { + 'accept': 'application/json' + }; + // Define the content to be modified + let modifiedContent: UserInfo = { + 'userName': 'xxxxxx' + }; + // Create the communication session object session + const session = rcp.createSession(); + // Define the request object rep + let req = new rcp.Request('http://example.com/fetch', 'PATCH', headers, modifiedContent); + // Initiate a request + session.fetch(req).then((response) => { + Logger.info(`Request succeeded, message is ${JSON.stringify(response)}`); + }).catch((err: BusinessError) => { + Logger.error(`err: err code is ${err.code}, err message is ${JSON.stringify(err)}`); + }); + // DocsCode 1 + this.patchHeaders = JSON.stringify(req, null, 2); + AppStorage.setOrCreate('PatchHeaders', this.patchHeaders); + } + + setBaseAddress() { + // DocsCode 2 + // Define the sessionConfig object + const sessionConfig: rcp.SessionConfiguration = { + baseAddress: 'http://api.example.com', + headers: { + 'authorization': 'Bearer YOUR_ACCESS_TOKEN', + 'content-type': 'application/json' + } + }; + // Create the communication session object session and input sessionConfig + const session = rcp.createSession(sessionConfig); + // DocsCode 2 + let req = new rcp.Request('http://example.com', 'GET'); + session.fetch(req).then((response) => { + Logger.info(`Request succeeded, message is ${JSON.stringify(response)}`); + }).catch((err: BusinessError) => { + Logger.error(`err: err code is ${err.code}, err message is ${JSON.stringify(err)}`); + }); + this.baseAddress = sessionConfig.baseAddress; + AppStorage.setOrCreate('BaseAddress', this.baseAddress); + } + + build() { + NavDestination() { + Column() { + Text($r('app.string.patch_request_param')) + .margin({ bottom: $r('app.float.text_margin_bottom') }) + .textAlign(TextAlign.Start) + .width(CommonConstants.FULL_PERCENT) + TextArea({ text: this.storageLinkPatchHeaders }) + .margin({ bottom: $r('app.float.textArea_margin_bottom') }) + .width(CommonConstants.FULL_PERCENT) + .height(CommonConstants.TEXTAREA_HEIGHT) + .focusable(false) + Button($r('app.string.patch_request')) + .onClick(() => { + if(!this.storageLinkPatchHeaders){ + this.patchRequest(); + } + }) + .margin({ bottom: $r('app.float.button_margin_bottom') }) + .width(CommonConstants.FULL_PERCENT) + Text($r('app.string.set_baseAddress_success')) + .margin({ bottom: $r('app.float.text_margin_bottom') }) + .textAlign(TextAlign.Start) + .width(CommonConstants.FULL_PERCENT) + TextArea({ text: this.storageLinkBaseAddress }) + .margin({ bottom: $r('app.float.textArea_margin_bottom') }) + .width(CommonConstants.FULL_PERCENT) + .height(CommonConstants.TEXTAREA_HEIGHT) + .focusable(false) + Button($r('app.string.set_baseAddress')) + .onClick(() => { + if(!this.storageLinkBaseAddress){ + this.setBaseAddress(); + } + }) + .width(CommonConstants.FULL_PERCENT) + } + .width(CommonConstants.FULL_PERCENT) + .height(CommonConstants.FULL_PERCENT) + .justifyContent(FlexAlign.End) + .padding($r('app.float.padding')) + } + } +} \ No newline at end of file diff --git a/entry/src/main/ets/pages/DNSSetting.ets b/entry/src/main/ets/pages/DNSSetting.ets new file mode 100644 index 0000000000000000000000000000000000000000..af8f401c7d36a6a95808215b5b49f5938e99f35c --- /dev/null +++ b/entry/src/main/ets/pages/DNSSetting.ets @@ -0,0 +1,172 @@ +/* + * 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. + */ + +import { BusinessError } from '@kit.BasicServicesKit'; +import { rcp } from '@kit.RemoteCommunicationKit'; +import Logger from '../common/Logger'; +import { CommonConstants } from '../common/CommonConstants'; + +@Builder +export function DNSSettingBuilder() { + DNSSetting() +} + +@Component +export struct DNSSetting { + @State customizingDNS: string = ''; + @State staticDNS: string = ''; + @State dnsOverHttp: string = ''; + @State text: string = ''; + @State textArea: string = ''; + @StorageLink('CustomizingDNS') storageLinkCustomizingDNS: string = ''; + @StorageLink('StaticDNS') storageLinkStaticDNS: string = ''; + @StorageLink('DnsOverHttp') storageLinkDnsOverHttp: string = ''; + + setDnsServers() { + // DocsCode 4 + // Configure a User-Defined DNS Server + const customDnsServers: rcp.DnsServers = [ + { ip: '8.8.8.8' }, + { ip: '8.8.4.4', port: 53 } + ]; + // Creating a Communication Session Object + const sessionWithCustomDns = rcp.createSession({ + requestConfiguration: { + dns: { + dnsRules: customDnsServers + } + } + }); + // Initiate a request + sessionWithCustomDns.get('http://www.example.com').then((response) => { + Logger.info(`Request succeeded, message is ${JSON.stringify(response)}`); + }).catch((err: BusinessError) => { + Logger.error(`err: err code is ${err.code}, err message is ${JSON.stringify(err)}`); + }); + // DocsCode 4 + this.customizingDNS = JSON.stringify(customDnsServers, null, 2); + this.textArea = this.customizingDNS; + AppStorage.setOrCreate('CustomizingDNS', this.customizingDNS); + } + + setStaticDnsRules() { + // DocsCode 5 + // When hostname is matched, the specified address is used preferentially + const staticDnsRules: rcp.StaticDnsRules = [ + { + host: 'example.com', + port: 80, + ipAddresses: ['192.168.1.1', '192.168.1.2'] + } + ]; + // Creating a Communication Session Object + const sessionWithCustomDns = rcp.createSession({ + requestConfiguration: { + dns: { + dnsRules: staticDnsRules + } + } + }); + // Initiate a request + sessionWithCustomDns.get('http://www.example.com').then((response) => { + Logger.info(`Request succeeded, message is ${JSON.stringify(response)}`); + }).catch((err: BusinessError) => { + Logger.error(`err: err code is ${err.code}, err message is ${JSON.stringify(err)}`); + }); + // DocsCode 5 + this.staticDNS = JSON.stringify(staticDnsRules, null, 2); + this.textArea = this.staticDNS; + AppStorage.setOrCreate('StaticDNS', this.staticDNS); + } + + setDnsOverHttps() { + // DocsCode 6 + // DNS over HTTPS Configuration + const dohConfig: rcp.DnsOverHttpsConfiguration = { + url: 'https://dns.example.com/dns-query', + skipCertificatesValidation: true + }; + // Creating a Communication Session Object + const sessionWithCustomDns = rcp.createSession({ + requestConfiguration: { + dns: { + dnsOverHttps: dohConfig + } + } + }); + // Initiate a request + sessionWithCustomDns.get('http://www.example.com').then((response) => { + Logger.info(`Request succeeded, message is ${JSON.stringify(response)}`); + }).catch((err: BusinessError) => { + Logger.error(`err: err code is ${err.code}, err message is ${JSON.stringify(err)}`); + }); + // DocsCode 6 + this.dnsOverHttp = JSON.stringify(dohConfig, null, 2); + this.textArea = this.dnsOverHttp; + AppStorage.setOrCreate('DnsOverHttp', this.dnsOverHttp); + } + + build() { + NavDestination() { + Column() { + Column() { + Text($r(this.text)) + .margin({ bottom: $r('app.float.text_margin_bottom') }) + .textAlign(TextAlign.Start) + .width(CommonConstants.FULL_PERCENT) + .height($r('app.float.text_height')) + TextArea({ text: this.textArea }) + .width(CommonConstants.FULL_PERCENT) + .height(CommonConstants.TEXTAREA_HEIGHT) + .focusable(false) + } + + Column({ space: CommonConstants.COLUMN_SPACE }) { + Button($r('app.string.custom_dns')) + .onClick(() => { + this.text = 'app.string.set_custom_dns'; + this.textArea = this.storageLinkCustomizingDNS; + if (!this.storageLinkCustomizingDNS) { + this.setDnsServers(); + } + }) + .width(CommonConstants.FULL_PERCENT) + Button($r('app.string.static_dns')) + .onClick(() => { + this.text = 'app.string.set_static_dns'; + this.textArea = this.storageLinkStaticDNS; + if (!this.storageLinkStaticDNS) { + this.setStaticDnsRules(); + } + }) + .width(CommonConstants.FULL_PERCENT) + Button($r('app.string.dns_over_http')) + .onClick(() => { + this.text = 'app.string.set_dns_over_http'; + this.textArea = this.storageLinkDnsOverHttp; + if (!this.storageLinkDnsOverHttp) { + this.setDnsOverHttps(); + } + }) + .width(CommonConstants.FULL_PERCENT) + } + } + .width(CommonConstants.FULL_PERCENT) + .height(CommonConstants.FULL_PERCENT) + .justifyContent(FlexAlign.SpaceBetween) + .padding($r('app.float.padding')) + } + } +} \ No newline at end of file diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..750b44c52da936f100dca2a66c1be7aa5256f962 --- /dev/null +++ b/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,71 @@ +/* + * 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. + */ + +import { CommonConstants } from '../common/CommonConstants'; + +@Entry +@Component +struct Index { + pathStack: NavPathStack = new NavPathStack(); + + @Builder + NavigationTitle() { + Column() { + Text($r('app.string.title')) + .fontSize($r('app.float.text_fontsize')) + .lineHeight($r('app.float.text_lineHeight')) + .fontWeight(CommonConstants.TEXT_FONT_WEIGHT) + } + .width(CommonConstants.FULL_PERCENT) + } + + build() { + Navigation(this.pathStack) { + Column({ space: CommonConstants.COLUMN_SPACE }) { + Button($r('app.string.base_request'), { stateEffect: true, type: ButtonType.Capsule }) + .onClick(() => { + this.pathStack.pushPathByName('BaseRequest', null, false); + }) + .width(CommonConstants.FULL_PERCENT) + Button($r('app.string.multipart_form'), { stateEffect: true, type: ButtonType.Capsule }) + .onClick(() => { + this.pathStack.pushPathByName('MultipartForm', null, false); + }) + .width(CommonConstants.FULL_PERCENT) + Button($r('app.string.request_response'), { stateEffect: true, type: ButtonType.Capsule }) + .onClick(() => { + this.pathStack.pushPathByName('RequestAndResponse', null, false); + }) + .width(CommonConstants.FULL_PERCENT) + Button($r('app.string.dns_setting'), { stateEffect: true, type: ButtonType.Capsule }) + .onClick(() => { + this.pathStack.pushPathByName('DNSSetting', null, false); + }) + .width(CommonConstants.FULL_PERCENT) + Button($r('app.string.tracing_point'), { stateEffect: true, type: ButtonType.Capsule }) + .onClick(() => { + this.pathStack.pushPathByName('TracingPoint', null, false); + }) + .width(CommonConstants.FULL_PERCENT) + } + .justifyContent(FlexAlign.End) + .width(CommonConstants.FULL_PERCENT) + .height(CommonConstants.FULL_PERCENT) + .padding($r('app.float.padding')) + } + .title(this.NavigationTitle()) + .titleMode(NavigationTitleMode.Full) + } +} \ No newline at end of file diff --git a/entry/src/main/ets/pages/MultipartForm.ets b/entry/src/main/ets/pages/MultipartForm.ets new file mode 100644 index 0000000000000000000000000000000000000000..ad43ca3a154c7527478c236e6e52e836c34ac682 --- /dev/null +++ b/entry/src/main/ets/pages/MultipartForm.ets @@ -0,0 +1,232 @@ +/* + * 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. + */ + +import { BusinessError } from '@kit.BasicServicesKit'; +import { rcp } from '@kit.RemoteCommunicationKit'; +import Logger from '../common/Logger'; +import { CommonConstants } from '../common/CommonConstants'; +import { SegmentButtonOptions } from '@kit.ArkUI'; +import { ItemRestriction, SegmentButton, SegmentButtonTextItem } from '@ohos.arkui.advanced.SegmentButton'; + +@Builder +export function MultipartFormBuilder() { + MultipartForm() +} + +@Component +export struct MultipartForm { + @State name: string = ''; + @State hobbies: Array = []; + @State multipartFormHeaders: string = ''; + @State tabOptions: SegmentButtonOptions = SegmentButtonOptions.tab({ + buttons: [{ text: $r('app.string.form_one') }, + { text: $r('app.string.form_two') }] as ItemRestriction, + backgroundBlurStyle: BlurStyle.BACKGROUND_THICK, + fontSize: $r('app.float.segmentButton_font_size'), + selectedFontSize: $r('app.float.selected_font_size'), + textPadding: $r('app.float.segmentButton_text_padding'), + }) + @State tabSelectedIndexes: number[] = [0]; + @StorageLink('MultipartFormHeaders') storageLinkMultipartFormHeaders: string = ''; + + @Builder + NavigationTitle() { + Column() { + Text($r('app.string.form_title')) + .fontSize($r('app.float.form_font_size')) + .fontColor($r('app.color.font_color')) + .lineHeight($r('app.float.text_lineHeight')) + .fontWeight(CommonConstants.TEXT_FONT_WEIGHT) + .textAlign(TextAlign.Start) + .width(CommonConstants.FULL_PERCENT) + .margin({ left: $r('app.float.form_margin_left') }) + } + } + + multipartFormSubmit() { + // DocsCode 3 + // Defines the request header type + let headers: rcp.RequestHeaders = { + 'accept': 'application/json' + }; + // configure timeout values for HTTP requests + let configuration: rcp.Configuration = { + transfer: { + timeout: { + connectMs: 60000, + transferMs: 60000 + } + } + }; + // Cookies included in the HTTP request + let cookies: rcp.RequestCookies = { + 'name1': 'value1', + 'name2': 'value2', + }; + // Setting the Data Transmission Range + let transferRange: rcp.TransferRange = { + from: 100, + to: 200 + }; + + // Set up multipartFrom data + const multiForm = new rcp.MultipartForm({ + 'Form1': this.name, // string + 'Form2': this.hobbies, // string + 'Form3': { + contentType: 'text/plain', + remoteFileName: 'RemoteFileName', + contentOrPath: '/file/to/Path' + } // object + }); + + // Create a communication session object session + const session = rcp.createSession(); + // Define the request object req + let req = + new rcp.Request('https://www.example.com', 'POST', headers, multiForm, cookies, transferRange, configuration); + req.content = multiForm; + + // Initiate a request + session.fetch(req).then((response) => { + Logger.info(`Request succeeded, message is ${JSON.stringify(response)}`); + }).catch((err: BusinessError) => { + Logger.error(`err: err code is ${err.code}, err message is ${JSON.stringify(err)}`); + }); + // DocsCode 3 + this.multipartFormHeaders = JSON.stringify(multiForm, null, 2); + AppStorage.setOrCreate('MultipartFormHeaders', this.multipartFormHeaders); + } + + build() { + NavDestination() { + Column() { + Column() { + SegmentButton({ options: this.tabOptions, selectedIndexes: $tabSelectedIndexes }) + if (this.tabSelectedIndexes[0] === 0) { + Column() { + Text($r('app.string.input_name')) + .margin({ top: $r('app.float.form_margin_top'), bottom: $r('app.float.form_margin_bottom') }) + .width(CommonConstants.FULL_PERCENT) + .textAlign(TextAlign.Start) + TextInput({ text: this.name }) + .onChange((value: string) => { + this.name = value; + }) + .maxLength(CommonConstants.TEXT_INPUT_MAXLENGTH) + } + .width(CommonConstants.FULL_PERCENT) + .height(CommonConstants.COLUMN_HEIGHT) + .justifyContent(FlexAlign.Start) + } else { + Column() { + Text($r('app.string.choose_hobbies')) + .margin({ top: $r('app.float.form_margin_top'), bottom: $r('app.float.form_margin_bottom') }) + .width(CommonConstants.FULL_PERCENT) + .textAlign(TextAlign.Start) + Column({ space: CommonConstants.COLUMN_SPACE }) { + // Option1 + Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { + Checkbox({ name: 'Basketball', group: 'checkboxGroup' }) + .selectedColor($r('app.color.selected_color')) + .shape(CheckBoxShape.CIRCLE) + + Text($r('app.string.basketball')) + .fontSize($r('app.float.form_text_size')) + .lineHeight($r('app.float.form_text_lineHeight')) + .fontColor($r('app.color.font_color')) + .fontWeight(CommonConstants.FORM_TEXT_FONT_WEIGHT) + } + + // Option2 + Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { + Checkbox({ name: 'Football', group: 'checkboxGroup' }) + .selectedColor($r('app.color.selected_color')) + .shape(CheckBoxShape.CIRCLE) + + Text($r('app.string.football')) + .fontSize($r('app.float.form_text_size')) + .lineHeight($r('app.float.form_text_lineHeight')) + .fontColor($r('app.color.font_color')) + .fontWeight(CommonConstants.FORM_TEXT_FONT_WEIGHT) + } + + // Option3 + Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { + Checkbox({ name: 'Badminton', group: 'checkboxGroup' }) + .selectedColor($r('app.color.selected_color')) + .shape(CheckBoxShape.CIRCLE) + + Text($r('app.string.badminton')) + .fontSize($r('app.float.form_text_size')) + .lineHeight($r('app.float.form_text_lineHeight')) + .fontColor($r('app.color.font_color')) + .fontWeight(CommonConstants.FORM_TEXT_FONT_WEIGHT) + } + + // Select All + Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { + CheckboxGroup({ group: 'checkboxGroup' }) + .checkboxShape(CheckBoxShape.CIRCLE) + .selectedColor($r('app.color.selected_color')) + .onChange((itemName: CheckboxGroupResult) => { + this.hobbies = []; + if (itemName.name.length) { + this.hobbies = itemName.name; + } + }) + + Text($r('app.string.choose_all')) + .fontSize($r('app.float.form_text_size')) + .lineHeight($r('app.float.form_text_lineHeight')) + .fontColor($r('app.color.font_color')) + } + } + .backgroundColor($r('app.color.start_window_background')) + .borderRadius($r('app.float.form_borderRadius')) + .padding($r('app.float.padding')) + } + .width(CommonConstants.FULL_PERCENT) + .height(CommonConstants.FORM_COLUMN_HEIGHT) + .justifyContent(FlexAlign.Start) + } + TextArea({ text: String(this.multipartFormHeaders) }) + .height(CommonConstants.FORM_TEXTAREA_HEIGHT) + .margin({ top: $r('app.float.textArea_margin_top'), bottom: $r('app.float.textArea_margin_bottom') }) + .focusable(false) + } + + Button($r('app.string.submit')) + .onClick(() => { + if (!this.storageLinkMultipartFormHeaders) { + this.multipartFormSubmit(); + } else { + let res: rcp.MultipartForm = JSON.parse(this.storageLinkMultipartFormHeaders); + res.fields.Form1 = this.name || ''; + res.fields.Form2 = this.hobbies || []; + this.multipartFormHeaders = JSON.stringify(res, null, 2); + } + }) + .width(CommonConstants.FULL_PERCENT) + } + .width(CommonConstants.FULL_PERCENT) + .height(CommonConstants.FULL_PERCENT) + .padding($r('app.float.padding')) + .justifyContent(FlexAlign.SpaceBetween) + } + .title(this.NavigationTitle()) + .backgroundColor($r('app.color.gray_background')) + } +} \ No newline at end of file diff --git a/entry/src/main/ets/pages/RequestAndResponse.ets b/entry/src/main/ets/pages/RequestAndResponse.ets new file mode 100644 index 0000000000000000000000000000000000000000..895e9baf91be0db318816aa718c2519333334a61 --- /dev/null +++ b/entry/src/main/ets/pages/RequestAndResponse.ets @@ -0,0 +1,122 @@ +/* + * 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. + */ + +import { rcp } from '@kit.RemoteCommunicationKit'; +import { url } from '@kit.ArkTS'; +import { CommonConstants } from '../common/CommonConstants'; +import { NetworkStateSimulator } from '../utils/NetworkStateSimulator'; +import { RequestUrlChangeInterceptor, ResponseHeaderRemoveInterceptor } from '../utils/Interceptors'; +import { fileIo as fs } from '@kit.CoreFileKit'; + +@Builder +export function RequestAndResponseBuilder() { + RequestAndResponse() +} + +@Component +export struct RequestAndResponse { + @State requestAndResponse: string = ''; + @State isImageDownloaded: boolean = false; + @State requestUrl: url.URL | string = ''; + @State url: string = ''; + @StorageLink('ReplacedInfo') storageLink: string = ''; + private readonly pathToImage: string = getContext().filesDir + '/panda.jpg'; + private simulateSlowNetwork: boolean = false; + + private async getImage() { + this.isImageDownloaded = false; + const networkStateSimulator = new NetworkStateSimulator(); + // DocsCode 8 + const sessionConfig: rcp.SessionConfiguration = { + interceptors: [ + new RequestUrlChangeInterceptor(networkStateSimulator), + new ResponseHeaderRemoveInterceptor() + ] + }; + + const session = rcp.createSession(sessionConfig); + // DocsCode 8 + if (this.simulateSlowNetwork) { + networkStateSimulator.simulateSlowNetwork(); + } else { + networkStateSimulator.simulateFastNetwork(); + } + + const request = new rcp.Request('http://www.example.com/Panda.jpg', 'GET'); + this.requestUrl = request.url; + + request.destination = { + kind: 'file', + file: this.pathToImage + }; + + if (!this.storageLink) { + const response = await session.fetch(request); + const isFileCreated = fs.accessSync(this.pathToImage); + if (response.statusCode === 200 && isFileCreated) { + this.isImageDownloaded = true; + } + } + + if (this.simulateSlowNetwork) { + this.url = this.storageLink; + } else { + this.url = String(this.requestUrl); + } + } + + build() { + NavDestination() { + Column() { + Column() { + Row() { + Text($r('app.string.simulate_slow_network')) + Toggle({ type: ToggleType.Switch, isOn: this.simulateSlowNetwork }) + .onChange((isOn) => { + this.simulateSlowNetwork = isOn; + }) + } + .margin({ bottom: $r('app.float.simulate_margin_bottom') }) + .backgroundColor($r('app.color.start_window_background')) + .borderRadius($r('app.float.simulate_borderRadius')) + .padding({ left: $r('app.float.simulate_padding_left'), right: $r('app.float.simulate_padding_right') }) + .width(CommonConstants.FULL_PERCENT) + .height(CommonConstants.SIMULATE_TEXT_HEIGHT) + .justifyContent(FlexAlign.SpaceBetween) + + Text($r('app.string.image_url')) + .margin({ bottom: $r('app.float.simulate_margin_bottom') }) + .width(CommonConstants.FULL_PERCENT) + TextArea({ text: this.url }) + .width(CommonConstants.FULL_PERCENT) + .height(CommonConstants.TEXTAREA_HEIGHT) + .textAlign(TextAlign.Start) + .focusable(false) + } + + Button($r('app.string.get_image')) + .width(CommonConstants.FULL_PERCENT) + .onClick(() => { + this.getImage(); + }) + } + .width(CommonConstants.FULL_PERCENT) + .height(CommonConstants.FULL_PERCENT) + .justifyContent(FlexAlign.SpaceBetween) + .padding($r('app.float.padding')) + } + .backgroundColor($r('app.color.gray_background')) + } +} \ No newline at end of file diff --git a/entry/src/main/ets/pages/TracingPoint.ets b/entry/src/main/ets/pages/TracingPoint.ets new file mode 100644 index 0000000000000000000000000000000000000000..af99dbc2cedf90536b68819beb799469b3fd2173 --- /dev/null +++ b/entry/src/main/ets/pages/TracingPoint.ets @@ -0,0 +1,105 @@ +/* + * 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. + */ + +import { BusinessError } from '@kit.BasicServicesKit'; +import { rcp } from '@kit.RemoteCommunicationKit'; +import Logger from '../common/Logger'; +import { CommonConstants } from '../common/CommonConstants'; + +@Builder +export function TracingPointBuilder() { + TracingPoint() +} + +@Component +export struct TracingPoint { + @State detailInfo: string = ''; + @StorageLink('TracingPoint') storageLinkTracingPoint: string = ''; + + setTracingPoint(){ + // DocsCode 9 + // Define a custom response handler + const customHttpEventsHandler: rcp.HttpEventsHandler = { + onDataReceive: (incomingData: ArrayBuffer) => { + // Custom logic for handling incoming data + Logger.info('Received data:', JSON.stringify(incomingData)); + return incomingData.byteLength; + }, + onHeaderReceive: (headers: rcp.RequestHeaders) => { + // Custom logic for handling response headers + Logger.info('Received headers:', JSON.stringify(headers)); + }, + onDataEnd: () => { + // Custom logic for handling data transfer completion + Logger.info('Data transfer complete'); + } + }; + + // Configure tracing settings + const tracingConfig: rcp.TracingConfiguration = { + verbose: true, + infoToCollect: { + incomingHeader: true, // Event of collecting the input header information + outgoingHeader: true, // Collect Outgoing Header Information Event + incomingData: true, // Collect Incoming Data Information Event + outgoingData: true // Collect Outgoing Data Information Event + }, + collectTimeInfo: true, + httpEventsHandler: customHttpEventsHandler + }; + + // Use the configuration in the session creation + const session = rcp.createSession({ requestConfiguration: { tracing: tracingConfig } }); + session.get('http://developer.huawei.com').then((response) => { + Logger.info(`Request succeeded, message is ${JSON.stringify(response)}`); + }).catch((err: BusinessError) => { + Logger.error(`err: err code is ${err.code}, err message is ${JSON.stringify(err)}`); + }); + // DocsCode 9 + this.detailInfo = JSON.stringify(tracingConfig, null, 2); + AppStorage.setOrCreate('TracingPoint', this.detailInfo); + } + + build() { + NavDestination() { + Column() { + Column() { + Text($r('app.string.information')) + .margin({ bottom: $r('app.float.text_margin_bottom') }) + .textAlign(TextAlign.Start) + .width(CommonConstants.FULL_PERCENT) + TextArea({ text: this.storageLinkTracingPoint }) + .width(CommonConstants.FULL_PERCENT) + .height(CommonConstants.TEXTAREA_HEIGHT) + .focusable(false) + } + + Column() { + Button($r('app.string.configuration_information')) + .onClick(() => { + if(!this.storageLinkTracingPoint){ + this.setTracingPoint(); + } + }) + .width(CommonConstants.FULL_PERCENT) + } + } + .width(CommonConstants.FULL_PERCENT) + .height(CommonConstants.FULL_PERCENT) + .justifyContent(FlexAlign.SpaceBetween) + .padding($r('app.float.padding')) + } + } +} \ No newline at end of file diff --git a/entry/src/main/ets/utils/Interceptors.ets b/entry/src/main/ets/utils/Interceptors.ets new file mode 100644 index 0000000000000000000000000000000000000000..9da4728e036bb73ab8c8ccca03530446d3c79456 --- /dev/null +++ b/entry/src/main/ets/utils/Interceptors.ets @@ -0,0 +1,69 @@ +/* + * 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. + */ + +// DocsCode 7 +import { rcp } from '@kit.RemoteCommunicationKit'; +import { url } from '@kit.ArkTS'; +import Logger from '../common/Logger'; +import { NetworkQualityProvider } from './NetworkStateSimulator'; + +// Define the RequestUrlChangeInterceptor interceptor +export class RequestUrlChangeInterceptor implements rcp.Interceptor { + private readonly networkQualityProvider: NetworkQualityProvider; + + constructor(networkQualityProvider: NetworkQualityProvider) { + this.networkQualityProvider = networkQualityProvider + } + + // Custom Request processing Logic + async intercept(context: rcp.RequestContext, next: rcp.RequestHandler): Promise { + if (context.request.method === 'GET' && !this.networkQualityProvider.isNetworkFast()) { + Logger.info('[RequestUrlChangeInterceptor]: Slow network is detected'); + const parts = context.request.url.pathname.split('.'); + if (parts.length === 2) { + const changed = url.URL.parseURL(context.request.url.href); + changed.pathname = parts[0] + '_small.' + parts[1]; + Logger.info(`[RequestUrlChangeInterceptor]: Replace URL from "${context.request.url.href}" to "${changed}"`); + AppStorage.setOrCreate('ReplacedInfo',`[RequestUrlChangeInterceptor]: Replace URL from "${context.request.url.href}" to "${changed}"`); + context.request.url = changed; + } + } else { + Logger.info('[RequestUrlChangeInterceptor]: Network is fast'); + } + return next.handle(context); + } +} + +// Define the ResponseHeaderRemoveInterceptor interceptor +export class ResponseHeaderRemoveInterceptor implements rcp.Interceptor { + // Custom Response processing Logic + async intercept(context: rcp.RequestContext, next: rcp.RequestHandler): Promise { + const response = await next.handle(context); + const toReturn: rcp.Response = { + request: response.request, + statusCode: response.statusCode, + httpVersion: response.httpVersion, + headers: { + 'content-range': response.headers['content-range'] + }, + effectiveUrl: response.effectiveUrl, + timeInfo: response.timeInfo, + toJSON: () => null + }; + Logger.info('[ResponseHeaderRemoveInterceptor]: Response was modified'); + return toReturn; + } +} +// DocsCode 7 \ No newline at end of file diff --git a/entry/src/main/ets/utils/NetworkStateSimulator.ets b/entry/src/main/ets/utils/NetworkStateSimulator.ets new file mode 100644 index 0000000000000000000000000000000000000000..3df124682264c36ab93766ed6abeebed54b21e79 --- /dev/null +++ b/entry/src/main/ets/utils/NetworkStateSimulator.ets @@ -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. + */ + +export interface NetworkQualityProvider { + isNetworkFast: () => boolean; +} + +export class NetworkStateSimulator implements NetworkQualityProvider { + private is_NetworkFast: boolean = true; + + isNetworkFast(): boolean { + return this.is_NetworkFast; + } + + simulateFastNetwork(): boolean { + return this.is_NetworkFast = true; + } + + simulateSlowNetwork(): boolean { + return this.is_NetworkFast = false; + } +} \ No newline at end of file diff --git a/entry/src/main/module.json5 b/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..36a1f1fd386b47087750d7102d64cff7959edfe6 --- /dev/null +++ b/entry/src/main/module.json5 @@ -0,0 +1,63 @@ +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "phone" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:layered_image", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "EntryBackupAbility", + "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets", + "type": "backup", + "exported": false, + "metadata": [ + { + "name": "ohos.extension.backup", + "resource": "$profile:backup_config" + } + ], + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.INTERNET", + "reason": "$string:reason", + "usedScene": { + "abilities": [ + "FormAbility" + ], + "when": "always" + } + } + ], + "routerMap": "$profile:route_map" + } +} \ No newline at end of file diff --git a/entry/src/main/resources/base/element/color.json b/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..9e7451f11cf951283cfabff0a33aa1edb6d4c828 --- /dev/null +++ b/entry/src/main/resources/base/element/color.json @@ -0,0 +1,24 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + }, + { + "name": "text_border_color", + "value": "#D3D3D3" + }, + { + "name": "selected_color", + "value": "#007DFF" + }, + { + "name": "font_color", + "value": "#182431" + }, + { + "name": "gray_background", + "value": "#EFEFEF" + } + ] +} \ No newline at end of file diff --git a/entry/src/main/resources/base/element/float.json b/entry/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..95065cc78885744523eea939f140ee24062698d7 --- /dev/null +++ b/entry/src/main/resources/base/element/float.json @@ -0,0 +1,100 @@ +{ + "float": [ + { + "name": "common_height", + "value": "40vp" + }, + { + "name": "text_height", + "value": "20vp" + }, + { + "name": "text_lineHeight", + "value": "40vp" + }, + { + "name": "text_fontsize", + "value": "30vp" + }, + { + "name": "margin_bottom", + "value": "12vp" + }, + { + "name": "text_margin_bottom", + "value": "24vp" + }, + { + "name": "textArea_margin_bottom", + "value": "16vp" + }, + { + "name": "textArea_margin_top", + "value": "16vp" + }, + { + "name": "button_margin_bottom", + "value": "12vp" + }, + { + "name": "padding", + "value": "16vp" + }, + { + "name": "simulate_margin_bottom", + "value": "24vp" + }, + { + "name": "simulate_borderRadius", + "value": "15vp" + }, + { + "name": "simulate_padding_left", + "value": "16vp" + }, + { + "name": "simulate_padding_right", + "value": "16vp" + }, + { + "name": "segmentButton_font_size", + "value": "18vp" + }, + { + "name": "selected_font_size", + "value": "18vp" + }, + { + "name": "segmentButton_text_padding", + "value": "5vp" + }, + { + "name": "form_margin_left", + "value": "12vp" + }, + { + "name": "form_font_size", + "value": "20vp" + }, + { + "name": "form_text_lineHeight", + "value": "20vp" + }, + { + "name": "form_text_size", + "value": "14vp" + }, + { + "name": "form_margin_top", + "value": "20vp" + }, + { + "name": "form_margin_bottom", + "value": "20vp" + }, + { + "name": "form_borderRadius", + "value": "15vp" + } + ] +} \ No newline at end of file diff --git a/entry/src/main/resources/base/element/string.json b/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..40a6eae86041388bc7c632f2684e809b601b54fe --- /dev/null +++ b/entry/src/main/resources/base/element/string.json @@ -0,0 +1,148 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "远程通信平台" + }, + { + "name": "reason", + "value": "使用网络" + }, + { + "name": "title", + "value": "基于RCP的网络请求能力" + }, + { + "name": "base_request", + "value": "基础请求" + }, + { + "name": "multipart_form", + "value": "多表单提交" + }, + { + "name": "request_response", + "value": "请求与响应拦截" + }, + { + "name": "dns_setting", + "value": "DNS设置" + }, + { + "name": "tracing_point", + "value": "捕获有关HTTP请求/响应流的详细信息" + }, + { + "name": "patch_request", + "value": "发起PATCH请求" + }, + { + "name": "patch_request_param", + "value": "PATCH请求相关参数如下:" + }, + { + "name": "set_baseAddress", + "value": "设置会话中URL的基地址" + }, + { + "name": "set_baseAddress_success", + "value": "baseAddress为:" + }, + { + "name": "form_title", + "value": "表单:" + }, + { + "name": "input_name", + "value": "请输入你的姓名:" + }, + { + "name": "form_one", + "value": "表单一" + }, + { + "name": "choose_hobbies", + "value": "请选择兴趣爱好:" + }, + { + "name": "choose_all", + "value": "选择所有" + }, + { + "name": "basketball", + "value": "篮球" + }, + { + "name": "football", + "value": "足球" + }, + { + "name": "badminton", + "value": "羽毛球" + }, + { + "name": "form_two", + "value": "表单二" + }, + { + "name": "submit", + "value": "提交" + }, + { + "name": "submit_data", + "value": "多表单提交数据为:" + }, + { + "name": "custom_dns", + "value": "自定义DNS服务器" + }, + { + "name": "set_custom_dns", + "value": "自定义DNS服务器为:" + }, + { + "name": "static_dns", + "value": "自定义静态DNS" + }, + { + "name": "set_static_dns", + "value": "自定义静态DNS为:" + }, + { + "name": "dns_over_http", + "value": "配置HTTP上的DNS" + }, + { + "name": "set_dns_over_http", + "value": "HTTP上的DNS为:" + }, + { + "name": "get_image", + "value": "获取图片" + }, + { + "name": "image_url", + "value": "图片请求地址:" + }, + { + "name": "simulate_slow_network", + "value": "模拟慢速网络" + }, + { + "name": "configuration_information", + "value": "配置详细信息收集" + }, + { + "name": "information", + "value": "详细信息收集配置如下:" + } + ] +} \ No newline at end of file diff --git a/entry/src/main/resources/base/media/background.png b/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d Binary files /dev/null and b/entry/src/main/resources/base/media/background.png differ diff --git a/entry/src/main/resources/base/media/foreground.png b/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902 Binary files /dev/null and b/entry/src/main/resources/base/media/foreground.png differ diff --git a/entry/src/main/resources/base/media/layered_image.json b/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/entry/src/main/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/entry/src/main/resources/base/media/startIcon.png b/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/entry/src/main/resources/base/media/startIcon.png differ diff --git a/entry/src/main/resources/base/profile/backup_config.json b/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/entry/src/main/resources/base/profile/backup_config.json @@ -0,0 +1,3 @@ +{ + "allowToBackupRestore": true +} \ No newline at end of file diff --git a/entry/src/main/resources/base/profile/main_pages.json b/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce --- /dev/null +++ b/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/entry/src/main/resources/base/profile/route_map.json b/entry/src/main/resources/base/profile/route_map.json new file mode 100644 index 0000000000000000000000000000000000000000..797b3e445fa64402290afca57b0f345938d87387 --- /dev/null +++ b/entry/src/main/resources/base/profile/route_map.json @@ -0,0 +1,44 @@ +{ + "routerMap": [ + { + "name": "BaseRequest", + "pageSourceFile": "src/main/ets/pages/BaseRequest.ets", + "buildFunction": "BaseRequestBuilder", + "data": { + "description": "this is BaseRequest" + } + }, + { + "name": "MultipartForm", + "pageSourceFile": "src/main/ets/pages/MultipartForm.ets", + "buildFunction": "MultipartFormBuilder", + "data": { + "description": "this is MultipartForm" + } + }, + { + "name": "RequestAndResponse", + "pageSourceFile": "src/main/ets/pages/RequestAndResponse.ets", + "buildFunction": "RequestAndResponseBuilder", + "data": { + "description": "this is RequestAndResponse" + } + }, + { + "name": "DNSSetting", + "pageSourceFile": "src/main/ets/pages/DNSSetting.ets", + "buildFunction": "DNSSettingBuilder", + "data": { + "description": "this is DNSSetting" + } + }, + { + "name": "TracingPoint", + "pageSourceFile": "src/main/ets/pages/TracingPoint.ets", + "buildFunction": "TracingPointBuilder", + "data": { + "description": "this is TracingPoint" + } + } + ] +} \ No newline at end of file diff --git a/entry/src/main/resources/en_US/element/string.json b/entry/src/main/resources/en_US/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..d79c1d3fde7c90c645bb5e5090221eff5ea13fa0 --- /dev/null +++ b/entry/src/main/resources/en_US/element/string.json @@ -0,0 +1,148 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "Remote communication platform" + }, + { + "name": "reason", + "value": "Using the internet" + }, + { + "name": "title", + "value": "Network Request Capability Based on RCP" + }, + { + "name": "base_request", + "value": "Basic request" + }, + { + "name": "multipart_form", + "value": "Multiple form submission" + }, + { + "name": "request_response", + "value": "Request and response interception" + }, + { + "name": "dns_setting", + "value": "DNS settings" + }, + { + "name": "tracing_point", + "value": "Capture detailed information about HTTP request/response flows" + }, + { + "name": "patch_request", + "value": "Initiate PATCH request" + }, + { + "name": "patch_request_param", + "value": "The parameters related to PATCH request are as follows:" + }, + { + "name": "set_baseAddress", + "value": "Set the base address of the URL in the session" + }, + { + "name": "set_baseAddress_success", + "value": "BaseAddress is:" + }, + { + "name": "form_title", + "value": "Form:" + }, + { + "name": "input_name", + "value": "Please enter your name:" + }, + { + "name": "form_one", + "value": "Form 1" + }, + { + "name": "choose_hobbies", + "value": "Please choose your interests and hobbies:" + }, + { + "name": "choose_all", + "value": "Select all" + }, + { + "name": "basketball", + "value": "Basketball" + }, + { + "name": "football", + "value": "Football" + }, + { + "name": "badminton", + "value": "Badminton" + }, + { + "name": "form_two", + "value": "Form 2" + }, + { + "name": "submit", + "value": "Submit" + }, + { + "name": "submit_data", + "value": "Submitting data from multiple forms:" + }, + { + "name": "custom_dns", + "value": "Customize DNS Server" + }, + { + "name": "set_custom_dns", + "value": "Customize DNS Server as:" + }, + { + "name": "static_dns", + "value": "Customize static DNS" + }, + { + "name": "set_static_dns", + "value": "Customize static DNS as:" + }, + { + "name": "dns_over_http", + "value": "Configure DNS on HTTP" + }, + { + "name": "set_dns_over_http", + "value": "The DNS on HTTP is" + }, + { + "name": "get_image", + "value": "Get image" + }, + { + "name": "image_url", + "value": "Image request address:" + }, + { + "name": "simulate_slow_network", + "value": "Simulate slow network" + }, + { + "name": "configuration_information", + "value": "Collect detailed configuration information" + }, + { + "name": "information", + "value": "The detailed information collection configuration is as follows:" + } + ] +} \ No newline at end of file diff --git a/entry/src/main/resources/zh_CN/element/string.json b/entry/src/main/resources/zh_CN/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..40a6eae86041388bc7c632f2684e809b601b54fe --- /dev/null +++ b/entry/src/main/resources/zh_CN/element/string.json @@ -0,0 +1,148 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "远程通信平台" + }, + { + "name": "reason", + "value": "使用网络" + }, + { + "name": "title", + "value": "基于RCP的网络请求能力" + }, + { + "name": "base_request", + "value": "基础请求" + }, + { + "name": "multipart_form", + "value": "多表单提交" + }, + { + "name": "request_response", + "value": "请求与响应拦截" + }, + { + "name": "dns_setting", + "value": "DNS设置" + }, + { + "name": "tracing_point", + "value": "捕获有关HTTP请求/响应流的详细信息" + }, + { + "name": "patch_request", + "value": "发起PATCH请求" + }, + { + "name": "patch_request_param", + "value": "PATCH请求相关参数如下:" + }, + { + "name": "set_baseAddress", + "value": "设置会话中URL的基地址" + }, + { + "name": "set_baseAddress_success", + "value": "baseAddress为:" + }, + { + "name": "form_title", + "value": "表单:" + }, + { + "name": "input_name", + "value": "请输入你的姓名:" + }, + { + "name": "form_one", + "value": "表单一" + }, + { + "name": "choose_hobbies", + "value": "请选择兴趣爱好:" + }, + { + "name": "choose_all", + "value": "选择所有" + }, + { + "name": "basketball", + "value": "篮球" + }, + { + "name": "football", + "value": "足球" + }, + { + "name": "badminton", + "value": "羽毛球" + }, + { + "name": "form_two", + "value": "表单二" + }, + { + "name": "submit", + "value": "提交" + }, + { + "name": "submit_data", + "value": "多表单提交数据为:" + }, + { + "name": "custom_dns", + "value": "自定义DNS服务器" + }, + { + "name": "set_custom_dns", + "value": "自定义DNS服务器为:" + }, + { + "name": "static_dns", + "value": "自定义静态DNS" + }, + { + "name": "set_static_dns", + "value": "自定义静态DNS为:" + }, + { + "name": "dns_over_http", + "value": "配置HTTP上的DNS" + }, + { + "name": "set_dns_over_http", + "value": "HTTP上的DNS为:" + }, + { + "name": "get_image", + "value": "获取图片" + }, + { + "name": "image_url", + "value": "图片请求地址:" + }, + { + "name": "simulate_slow_network", + "value": "模拟慢速网络" + }, + { + "name": "configuration_information", + "value": "配置详细信息收集" + }, + { + "name": "information", + "value": "详细信息收集配置如下:" + } + ] +} \ No newline at end of file diff --git a/hvigor/hvigor-config.json5 b/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..06b2783670a348f95533b352c1ceda909a842bbc --- /dev/null +++ b/hvigor/hvigor-config.json5 @@ -0,0 +1,22 @@ +{ + "modelVersion": "5.0.0", + "dependencies": { + }, + "execution": { + // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */ + // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */ + // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */ + // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */ + // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */ + }, + "logging": { + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ + }, + "debugging": { + // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */ + }, + "nodeOptions": { + // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/ + // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/ + } +} diff --git a/hvigorfile.ts b/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..f3cb9f1a87a81687554a76283af8df27d8bda775 --- /dev/null +++ b/hvigorfile.ts @@ -0,0 +1,6 @@ +import { appTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/oh-package.json5 b/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..8bf916d4a165e0466c65bc49f58ab2e3c27e8931 --- /dev/null +++ b/oh-package.json5 @@ -0,0 +1,8 @@ +{ + "modelVersion": "5.0.0", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + } +} diff --git a/screenshots/device/rcp.gif b/screenshots/device/rcp.gif new file mode 100644 index 0000000000000000000000000000000000000000..fa9bbc5b882bb0cb339d4b21c2af1c874c88006d Binary files /dev/null and b/screenshots/device/rcp.gif differ