diff --git a/code/ArkTS1.2/DownloadSample/.gitignore b/code/ArkTS1.2/DownloadSample/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b --- /dev/null +++ b/code/ArkTS1.2/DownloadSample/.gitignore @@ -0,0 +1,12 @@ +/node_modules +/oh_modules +/local.properties +/.idea +**/build +/.hvigor +.cxx +/.clangd +/.clang-format +/.clang-tidy +**/.test +/.appanalyzer \ No newline at end of file diff --git a/code/ArkTS1.2/DownloadSample/AppScope/app.json5 b/code/ArkTS1.2/DownloadSample/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..350c11b1aa892b88f9308c9906e74137237459a8 --- /dev/null +++ b/code/ArkTS1.2/DownloadSample/AppScope/app.json5 @@ -0,0 +1,36 @@ +/** + * + * Copyright (c) 2025 Huawei Device Co., Ltd. + * + * All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice,this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS, + * + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +{ + "app": { + "bundleName": "com.samples.DownloadSample", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/ArkTS1.2/DownloadSample/AppScope/resources/base/element/string.json b/code/ArkTS1.2/DownloadSample/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..a9f86e0b9da71179cb298b2048a23e88aac4c5f5 --- /dev/null +++ b/code/ArkTS1.2/DownloadSample/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "DownloadSample" + } + ] +} diff --git a/code/ArkTS1.2/DownloadSample/AppScope/resources/base/media/app_icon.png b/code/ArkTS1.2/DownloadSample/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..a39445dc87828b76fed6d2ec470dd455c45319e3 Binary files /dev/null and b/code/ArkTS1.2/DownloadSample/AppScope/resources/base/media/app_icon.png differ diff --git a/code/ArkTS1.2/DownloadSample/README.md b/code/ArkTS1.2/DownloadSample/README.md new file mode 100644 index 0000000000000000000000000000000000000000..8ba7d5cc4a08ce2a0586a0d0d36f2dca68fbf855 --- /dev/null +++ b/code/ArkTS1.2/DownloadSample/README.md @@ -0,0 +1,65 @@ +# 文件并行化处理场景 + +### 介绍 + +多文件下载监听案例 + +### 效果预览 + +效果如下所示: + +|多文件下载监听案例| +|--------------------------------| +|![Alt text](entry/src/main/resources/base/media/sample1.png)| + +使用说明 + +在多文件下载监听案例。 + * 点击全部开始进行下载,下载超过3分钟进行并行化下载 + + + +### 工程目录 + +``` +entry/src/main/ets/ +|---pages +| | |---model +| | | |---dataType.ets // 数据类型定义 +| | |---view +| | | |---HistoryItem.ets // 下载历史组件 +| | | |---MultipleFilesDownload.ets // 下载列表组件 +| |---index.ets // 首页 +``` + +### 具体实现 + +* 多文件下载监听案例源码参考: + * 下载历史组件。源码参考[HistoryItem.ets](entry/src/main/ets/pages/view/HistoryItem.ets) + * 下载列表组件。源码参考[MultipleFilesDownload.ets](entry/src/main/ets/pages/view/MultipleFilesDownload.ets) + +### 相关权限 + +网络权限: ohos.permission.INTERNET + +### 依赖 + +无 + +### 约束与限制 + +1. 本示例仅支持标准系统上运行,支持设备:Phone; +2. 本示例为Stage模型,支持API20版本SDK,SDK版本号(API Version 20),镜像版本号(6.0.0.31)。 +3. 本示例需要使用DevEco Studio 版本号(6.0.0.6)版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +``` +git init +git config core.sparsecheckout true +echo code/ArkTS1.2/DownloadSample/ > .git/info/sparse-checkout +git remote add origin https://gitee.com/openharmony/applications_app_samples.git +git pull +``` \ No newline at end of file diff --git a/code/ArkTS1.2/DownloadSample/build-profile.json5 b/code/ArkTS1.2/DownloadSample/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..c83260a8d4a7c41693901753e0c0ea562824569c --- /dev/null +++ b/code/ArkTS1.2/DownloadSample/build-profile.json5 @@ -0,0 +1,68 @@ +/** + * + * Copyright (c) 2025 Huawei Device Co., Ltd. + * + * All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice,this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS, + * + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +{ + "app": { + "signingConfigs": [], + "products": [ + { + "name": "default", + "signingConfig": "default", + "arkTSVersion": "1.2", + "compatibleSdkVersion": "6.0.0(20)", + "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/code/ArkTS1.2/DownloadSample/code-linter.json5 b/code/ArkTS1.2/DownloadSample/code-linter.json5 new file mode 100644 index 0000000000000000000000000000000000000000..87b3919d419c09728067f1b545b7e2d5116adc07 --- /dev/null +++ b/code/ArkTS1.2/DownloadSample/code-linter.json5 @@ -0,0 +1,58 @@ +/** + * + * Copyright (c) 2025 Huawei Device Co., Ltd. + * + * All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice,this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS, + * + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +{ + "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/code/ArkTS1.2/DownloadSample/entry/.gitignore b/code/ArkTS1.2/DownloadSample/entry/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/code/ArkTS1.2/DownloadSample/entry/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/ArkTS1.2/DownloadSample/entry/build-profile.json5 b/code/ArkTS1.2/DownloadSample/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..36f9e65afb2abbbbdda625e86543807eee16240c --- /dev/null +++ b/code/ArkTS1.2/DownloadSample/entry/build-profile.json5 @@ -0,0 +1,54 @@ +/** + * + * Copyright (c) 2025 Huawei Device Co., Ltd. + * + * All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice,this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS, + * + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +{ + "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/code/ArkTS1.2/DownloadSample/entry/hvigorfile.ts b/code/ArkTS1.2/DownloadSample/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..8f830cdfd5bfdd8bde92ebfc27fc0562423dca3d --- /dev/null +++ b/code/ArkTS1.2/DownloadSample/entry/hvigorfile.ts @@ -0,0 +1,32 @@ +/** + * + * Copyright (c) 2025 Huawei Device Co., Ltd. + * + * All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice,this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS, + * + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +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/code/ArkTS1.2/DownloadSample/entry/obfuscation-rules.txt b/code/ArkTS1.2/DownloadSample/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/code/ArkTS1.2/DownloadSample/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/code/ArkTS1.2/DownloadSample/entry/oh-package.json5 b/code/ArkTS1.2/DownloadSample/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..39ab3f901494a87d5ab258dfaa9e6882de1f5166 --- /dev/null +++ b/code/ArkTS1.2/DownloadSample/entry/oh-package.json5 @@ -0,0 +1,36 @@ +/** + * + * Copyright (c) 2025 Huawei Device Co., Ltd. + * + * All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice,this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS, + * + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/code/ArkTS1.2/DownloadSample/entry/src/main/ets/entryability/EntryAbility.ets b/code/ArkTS1.2/DownloadSample/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..d205c00999b495e390eb8582f3dec20cc547d5fc --- /dev/null +++ b/code/ArkTS1.2/DownloadSample/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,54 @@ +/** + * + * Copyright (c) 2025 Huawei Device Co., Ltd. + * + * All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice,this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS, + * + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import UIAbility from '@ohos.app.ability.UIAbility'; +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; +import { BusinessError } from '@ohos.base' +import hilog from '@ohos.hilog' + +class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', 'EntryAbility onCreate'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + hilog.info(0x0000, 'testTag', 'EntryAbility onWindowStageCreate'); + try { + windowStage.loadContent('pages/Index', (err: BusinessError): void => { + hilog.info(0x0000, 'testTag', 'loadContent entering'); + if (err.code) { + hilog.info(0x0000, 'testTag', 'loadContent error'); + return; + } + hilog.info(0x0000, 'testTag', 'loadContent ok'); + }); + } catch (e: Error) { + hilog.info(0x0000, 'testTag', 'loadContent catch error:-----------' + e.message); + } + } +} \ No newline at end of file diff --git a/code/ArkTS1.2/DownloadSample/entry/src/main/ets/pages/Index.ets b/code/ArkTS1.2/DownloadSample/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..180910f994430ecb930810ca23615ac77eeb9220 --- /dev/null +++ b/code/ArkTS1.2/DownloadSample/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,56 @@ +/** + * + * Copyright (c) 2025 Huawei Device Co., Ltd. + * + * All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice,this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS, + * + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +import { memo, __memo_context_type, __memo_id_type } from "@ohos.arkui.stateManagement"; // should be insert by ui-plugins +import { Text, TextAttribute, Column, Component, Button, ButtonAttribute, ClickEvent, UserView, Entry, JSON } from "@ohos.arkui.component"; // TextAttribute should be insert by ui-plugins +import { State, StateDecoratedVariable, MutableState, stateOf, observableProxy } from "@ohos.arkui.stateManagement"; // should be insert by ui-plugins +import hilog from '@ohos.hilog'; +import request from '@ohos.request'; +import {BusinessError} from '@ohos.base'; +import common from '@ohos.app.ability.common'; // 导入依赖资源context模块 +import { UIContext, Router } from "@ohos.arkui.UIContext"; +import { MultipleFilesDownloadComponent } from './view/MultipleFilesDownload'; + +@Entry +@Component +struct MyStateSample { + + build() { + Column(undefined) { + MultipleFilesDownloadComponent(); + } + } +} + +export class ComExampleTrivialApplication extends UserView { + getBuilder() { + hilog.info(0x0000, 'testTag', 'getBuilder'); + let wrapper = @memo () => { + hilog.info(0x0000, 'testTag', 'MyStateSample'); + MyStateSample(undefined); + } + return wrapper; + } +} \ No newline at end of file diff --git a/code/ArkTS1.2/DownloadSample/entry/src/main/ets/pages/model/dataType.ets b/code/ArkTS1.2/DownloadSample/entry/src/main/ets/pages/model/dataType.ets new file mode 100644 index 0000000000000000000000000000000000000000..702faa42fa2fe1c103d38678862c15065911ad09 --- /dev/null +++ b/code/ArkTS1.2/DownloadSample/entry/src/main/ets/pages/model/dataType.ets @@ -0,0 +1,49 @@ +/** + * + * Copyright (c) 2025 Huawei Device Co., Ltd. + * + * All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice,this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS, + * + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +let nextID: number = 1; + +export class downloadFilesData { + // 唯一标识 + id: string; + // 下载地址 + url: string; + // 文件下载状态: 0未下载, 1下载成功, 2下载失败, 3已删除 + fileStatus: number; + // 下载完成的时间戳 + downloadTime: number; + + constructor( + url: string = '', + fileStatus: number = 0, + downloadTime: number = 0, + ) { + this.id = String(nextID++); + this.url = url; + this.fileStatus = fileStatus; + this.downloadTime = downloadTime; + } +} \ No newline at end of file diff --git a/code/ArkTS1.2/DownloadSample/entry/src/main/ets/pages/view/HistoryItem.ets b/code/ArkTS1.2/DownloadSample/entry/src/main/ets/pages/view/HistoryItem.ets new file mode 100644 index 0000000000000000000000000000000000000000..db2357d0e8cdfbd1bba2220798d57468c37abbb0 --- /dev/null +++ b/code/ArkTS1.2/DownloadSample/entry/src/main/ets/pages/view/HistoryItem.ets @@ -0,0 +1,108 @@ +/** + * + * Copyright (c) 2025 Huawei Device Co., Ltd. + * + * All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice,this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS, + * + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +import { memo, __memo_context_type, __memo_id_type } from '@ohos.arkui.stateManagement'; // should be insert by ui-plugins +import { Entry, Text, TextAttribute, Column, Component, Button, ButtonAttribute, + ClickEvent, UserView, Row, TextAlign, Visibility, List, ListItem, ForEach, + TextOverflow, Image, HorizontalAlign, Progress, ProgressType, FlexAlign, SafeAreaType, + RelativeContainer, TextDecorationType, ButtonType, $r, Margin +} from '@ohos.arkui.component'; +import { Entry, Text, TextAttribute, Column, Component, Button, ButtonAttribute, ClickEvent, UserView, Row, TextAlign, + Visibility, List, ListItem, ForEach, TextOverflow, Image, HorizontalAlign, Progress, ProgressType, FlexAlign, + SafeAreaType, RelativeContainer, TextDecorationType, ButtonType, $r, Margin +} from '@ohos.arkui.component'; +import { State, Link, StateDecoratedVariable, MutableState, stateOf, observableProxy, Prop, Watch } from '@ohos.arkui.stateManagement'; // should be insert by ui-plugins +import { downloadFilesData } from '../model/dataType'; +import fs from '@ohos.file.fs'; +import hilog from '@ohos.hilog'; +import { BusinessError } from '@ohos.base'; +import common from '@ohos.app.ability.common'; + +const TAG: string = 'HistoryFiles'; + +@Component +export struct HistoryItem { + // 文件名称 + @State fileName: string = '文件名'; + // 待下载任务数量 + @Link downloadCount: number; + // 下载历史列表 + @Link historyArray: downloadFilesData[] = new Array(); + // 下载列表 + @Link downloadFileArray: downloadFilesData[] = new Array(); + // 文件下载状态 + @State fileStatus: number = -1; + + aboutToAppear(): void { + } + build() { + Row(){ + Row(){ + Image($r('app.media.multiple_files_download_file')) + .height(50) + .width(50) + .borderRadius(8) + .id('fileImage') + }.width('17%') + + Column(){ + Row(){ + Column(){ + Text(this.fileName) + .height(22) + .width('100%') + .fontSize(14) + .fontColor('#000000') + .textAlign(TextAlign.Start) + .maxLines(1) // 限制为单行 + .id('fileName') + + Row(){ + Text($r('app.string.text_download')) + .fontSize(12) + .fontColor('#66182431') + .id('downloadVal') + }.width('100%') + .height(23) + } + .width('75%') + + // 完成按钮 + Button($r('app.string.button_finish')) + .fontSize(12) + .height(30) + .width('25%') + .borderRadius(8) + .backgroundColor($r('app.color.operate_rdb_in_taskpool_button_background_color_green')) + } + } + .width('83%') + .height(50) + .alignItems(HorizontalAlign.Start) + } + .width('100%') + .height(80) + } +} \ No newline at end of file diff --git a/code/ArkTS1.2/DownloadSample/entry/src/main/ets/pages/view/MultipleFilesDownload.ets b/code/ArkTS1.2/DownloadSample/entry/src/main/ets/pages/view/MultipleFilesDownload.ets new file mode 100644 index 0000000000000000000000000000000000000000..e1caa88b8d02ccdaa69c8b43a448df16337f06d0 --- /dev/null +++ b/code/ArkTS1.2/DownloadSample/entry/src/main/ets/pages/view/MultipleFilesDownload.ets @@ -0,0 +1,440 @@ +/** + * + * Copyright (c) 2025 Huawei Device Co., Ltd. + * + * All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice,this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS, + * + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +import { + memo, + __memo_context_type, + __memo_id_type +} from '@ohos.arkui.stateManagement'; // should be insert by ui-plugins +import { + Entry, + Text, + TextAttribute, + Column, + Component, + Button, + ButtonAttribute, + ClickEvent, + UserView, + Row, + TextAlign, + Visibility, + List, + ListItem, + ForEach, + TextOverflow, + Image, + HorizontalAlign, + Progress, + ProgressType, + FlexAlign, + SafeAreaType, + JSON, + $r, + Margin +} from '@ohos.arkui.component'; // TextAttribute should be insert by ui-plugins +import { + State, + Link, + StateDecoratedVariable, + MutableState, + stateOf, + observableProxy, + Prop, + Watch +} from '@ohos.arkui.stateManagement'; // should be insert by ui-plugins\ +import hilog from '@ohos.hilog'; +import zlib from '@ohos.zlib'; +import common from '@ohos.app.ability.common'; +import fs from '@ohos.file.fs'; +import { BusinessError } from '@ohos.base'; +import { HistoryItem } from './HistoryItem'; +import request from '@ohos.request'; // 导入上传下载模块。需要配置ohos.permission.INTERNET权限 +import { downloadFilesData } from '../model/dataType'; +import util from '@ohos.util'; + +const NO_TASK: number = 0; // 0个下载任务 +const INIT_PROGRESS: number = 0; // 进度条初始值 +const BYTE_CONVERSION: number = 1024; // 字节转换 + +/** + * 功能描述: 多文件下载监听在应用开发中是一个非常常见的需求。本示例将介绍如何使用request上传下载模块实现多文件下载监听,如监听每个文件下载任务的进度,任务暂停,下载完成等下载情况。 + * 每个应用最多支持创建10个未完成的任务,相关规格说明请参考request.agent.create。 + * + * 推荐场景: 多文件下载 + * + * 核心组件: + * 1. FileDownloadItem + * + * 实现步骤: + * 1.配置下载参数。一个下载任务需要配置对应一套下载参数request.agent.Config。本例中使用downloadConfig方法简单配置了下载文件的url,实际业务 + * 中请按实际情况按需配置。 + * 2.创建多个文件下载监听实例。单个文件下载监听只需要配置下载参数,创建下载任务,注册下载任务相关监听,启动下载任务即可实现。而要实现多文件下载监听, + * 需要每个下载任务注册独立的下载监听回调。本例通过封装自定义组件FileDownloadItem,在每个FileDownloadItem中创建各自的下载任务和监听回调,从 + * 而实现多文件下载监听。 + * 3.创建下载任务,并注册下载任务相关监听。本例在每个FileDownloadItem中使用request.agent.create创建下载任务。然后在下载任务创建成功后,注 + * 册各自下载任务相关监听。本例中注册了下载任务完成回调,下载任务失败回调,下载进度更新回调,暂停任务回调,重新启动任务回调。 + * 4.启动下载任务。本例在每个FileDownloadItem中使用task.start方法启动各自的下载任务。 + * 5.本例中下载任务用到的其他操作:使用request.agent.show,根据任务id可查询任务的详细信息。使用task.pause可以暂停正在等待WAITING/正在运行 + * RUNNING/正在重试RETRYING的后台下载任务。使用task.resume可以重新启动任务,可恢复暂停的后台任务。 + */ + +@Entry +@Component +export struct MultipleFilesDownloadComponent { + @State message: string = '待下载'; + // 是否全部开始下载 + @State isStartAllDownload: boolean = false; + // 待下载任务数量 + @State downloadCount: number = 0; + // 下载失败任务数量。当所有任务下载失败时,'全部暂停'状态重置为'全部开始'。 + @State downloadFailCount: number = 0; + // 下载列表内容透明度。用于控制是否显示下载列表相应内容 + @State downloadPageOpacity: number = 1; + // 下载列表内容使能控制。避免隐藏后还能点击 + @State isDownloadPageEnabled: boolean = true; + // 历史列表的显隐控制。 + @State historyPageVisibility: Visibility = Visibility.None; + // 历史列表内容使其能控制。避免隐藏后还能点击 + @State isHistoryPageEnabled: boolean = false; + // 点击历史列表tab时,控制下载列表相应的内容的显隐 + @State downloadPageVisibility: Visibility = Visibility.Visible; + // 下载列表数据 + @State downloadFileArray: downloadFilesData[] = new Array(); + // 下载历史列表数据 + @State historyList: downloadFilesData[] = new Array(); + // 下载文件名 + @State fileName: string = '文件名'; + // 下载任务状态 + @State state: string = ''; + // 下载状态图标显隐控制。下载中显示图标,下载完成或者下载失败隐藏图标 + @State isShow: boolean = false; + // 是否正在下载标志位 + @State downloading: boolean = false; + // 下载文件大小。类型字符串 + @State sFileSize: string = '-'; + // 下载文件大小。类型数值 + @State nFileSize: number = 0; + // 当前已下载数据量。类型字符串 + @State sCurrentDownloadSize: string = '-'; + // 当前已下载数据量。类型数值 + @State nCurrentDownloadSize: number = 0; + // 下载任务对象初始化。用于下载失败和下载过程中暂停和重新启动下载。 + private downloadTask: request.agent.Task | undefined; + + // 下载信息初始化 + aboutToAppear(): void { + this.downloadFileArray = [ + { + 'id': '1', + 'url': '这里改为下载文件路径', + 'fileStatus': 0, + 'downloadTime': 1728529510880 + }, + { + 'id': '2', + 'url': '这里改为下载文件路径', + 'fileStatus': 0, + 'downloadTime': 1728529510880 + }, + { + 'id': '3', + 'url': '这里改为下载文件路径', + 'fileStatus': 0, + 'downloadTime': 1728529510880 + }, + { + 'id': '4', + 'url': '这里改为下载文件路径', + 'fileStatus': 0, + 'downloadTime': 1728529510880 + } + ] + // 下载数量,用于显示页面上下载队列数量 + this.downloadCount = this.downloadFileArray.length; + } + + // 监听是否开始下载/暂停下载 + onDownLoadUpdated(): void { + if (this.isStartAllDownload) { + this.startAllDownloads(); + } + } + + startAllDownloads() { + this.downloadFileArray.forEach((item: downloadFilesData) => { + this.startDownload(item.url); + }) + } + + // 启动下载任务 + startDownload(url: string) { + // 首次下载,创建任务 + let context = this.getUIContext().getHostContext() as common.UIAbilityContext; + (request.agent.create(context, { + action: request.agent.Action.DOWNLOAD, // 配置任务选项,这里配置为下载任务 + url: url, // 配置下载任务url + overwrite: true, // 下载过程中路径已存在时的解决方案选择。true表示覆盖已存在的文件 + method: 'GET', // HTTP标准方法。下载时,使用GET或POST。 + saveas: './', // 这里'./'表示下载至应用当前缓存路径下。 + mode: request.agent.Mode.BACKGROUND, // 任务模式设置后台任务。 + gauge: true, // 后台任务的过程进度通知策略,仅应用于后台任务。true表示发出每个进度已完成或失败的通知。 + retry: false, // 默认为true,如果没有网络或者网络不满足时,会自动暂停waiting,等网络满足时进行一次重试。设置为false时,没网直接走失败回调 + } as request.agent.Config) as Promise) + .then((task: request.agent.Task) => { + // 注册下载任务相关回调 + task.on('completed', (progress: request.agent.Progress) => { + hilog.info(0x0000, 'TAGhttp', `下载完成`); + }); // 下载任务完成回调 + task.on('progress', this.progressCallback); // 下载进度更新回调 + task.on('failed', (progress: request.agent.Progress) => { + hilog.info(0x0000, 'TAGhttp', `下载失败`); + }); // 下载任务失败回调 + + task.on('resume', (progress: request.agent.Progress) => { + hilog.info(0x0000, 'TAGhttp', `重新启动`); + }); // 重新启动任务回调 + + task.on('pause', (progress: request.agent.Progress) => { + hilog.info(0x0000, 'TAGhttp', `暂停`); + }); // 暂停任务回调 + + // TODO 知识点:启动下载任务。本例在每个FileDownloadItem中使用task.start方法启动各自的下载任务。 + task.start((err: BusinessError) => { + if (err) { + hilog.info(0x0000, 'TAGhttp', + `Failed to task start with error message: ${err.message}, error code: ${err.code}`); + return; + } + this.downloadTask = task as request.agent.Task; + }) + }) + } + + // 下载进度更新回调 + private progressCallback: (progress: request.agent.Progress) => void = (progress: request.agent.Progress) => { + // 性能知识点: 如果注册了progress下载进度更新监听,不建议在progress下载进度更新回调中加日志打印,减少不必要的性能损耗。 + this.state = '下载中'; + this.downloading = true; + // 显示下载状态图标 + this.isShow = true; + // 第一次开始下载 + if (this.sFileSize === '-') { + // 如果下载url文件的服务器采用chunk分块传输文件数据,是获取不到下载文件总大小的。传过来的值为-1,则在页面上显示'未知大小' + if (progress.sizes[0] === -1) { + this.sFileSize = '未知大小'; + // 文件大小无法获取的情况下,进度条的值设置为0,总进度设置为1 + this.nCurrentDownloadSize = 0; + this.nFileSize = 1; + } else { + // 能获取文件大小时,按实际下载数据量更新进度 + this.nFileSize = progress.sizes[0]; + hilog.info(0x0000, 'TAGhttp', `nFileSize: ` + String(this.nFileSize)); + this.sFileSize = (progress.sizes[0] / BYTE_CONVERSION) + 'kb'; + hilog.info(0x0000, 'TAGhttp', `sFileSize: ` + String(this.sFileSize)); + this.nCurrentDownloadSize = progress.processed; + hilog.info(0x0000, 'TAGhttp', `nCurrentDownloadSize: ` + String(this.nCurrentDownloadSize)); + } + } else if (this.sFileSize === '未知大小') { + // 非首次下载(暂停过下载任务后重新启动下载时),文件大小未知情况时,下载时进度不做更新 + hilog.info(0x0000, 'TAGhttp', `When the file size is unknown, the download progress will not be updated`); + } else { + // 非首次下载(暂停过下载任务后重新启动下载时),文件大小能获取到的情况,更新下载进度 + this.nCurrentDownloadSize = progress.processed; + } + // 用于显示已下载文件数据大小 + this.sCurrentDownloadSize = (progress.processed / BYTE_CONVERSION) + 'kb'; + } + + build() { + Column() { + Text($r('app.string.router_back')) + .fontSize(20) + .width('100%') + .onClick((): void => { + this.getUIContext().getRouter().back(); + }) + + Text($r('app.string.multiple_files_download_transfer_list')) + .fontSize(25) + .textAlign(TextAlign.Center) + Row() { + Text($r('app.string.multiple_files_download_list')) + .fontSize(16) + .fontColor(this.downloadPageOpacity === 1 ? '#FFFFFF' : '#808080') + .textAlign(TextAlign.Center) + .backgroundColor(this.downloadPageOpacity === 1 ? '#007DFF' : '#E8E8E8') + .width('49%') + .height(35) + .borderRadius(50) + .margin(3) + .onClick((e: ClickEvent) => { + this.downloadPageOpacity = 1; + this.isDownloadPageEnabled = true; + this.downloadPageVisibility = Visibility.Visible; + this.historyPageVisibility = Visibility.None; + this.isHistoryPageEnabled = false; + }) + + Text($r('app.string.multiple_files_download_album_backup')) + .fontSize(16) + .fontColor(this.downloadPageOpacity === 1 ? '#808080' : '#FFFFFF') + .textAlign(TextAlign.Center) + .backgroundColor(this.downloadPageOpacity === 1 ? '#E8E8E8' : '#007DFF') + .width('49%') + .height(35) + .borderRadius(50) + .margin(3) + .onClick((e: ClickEvent) => { + this.downloadPageOpacity = 0; + this.isDownloadPageEnabled = false; + this.downloadPageVisibility = Visibility.None; + this.historyPageVisibility = Visibility.Visible; + this.isHistoryPageEnabled = true; + }) + } + .width('100%') + .backgroundColor('#E8E8E8') + .borderRadius(50) + .margin(20) + + Row() { + Row() { + Text($r('app.string.multiple_files_download_queue')).fontSize(20) + Text(this.downloadCount + '').fontSize(20) + }.width('50%') + + Row() { + Text(this.isStartAllDownload && this.downloadCount > NO_TASK ? '全部暂停' : '全部开始') + .fontSize(20) + .fontColor('#418AF3') + .textAlign(TextAlign.End) + .width('100%') + .id('download') + .onClick((): void => { + if (this.downloadCount === NO_TASK) { + return; + } + this.isStartAllDownload = !this.isStartAllDownload; + this.onDownLoadUpdated() + }) + }.width('50%') + } + .opacity(this.downloadPageOpacity) + .visibility(this.downloadPageVisibility) + .enabled(this.isDownloadPageEnabled) + .width('100%') + + List() { + ForEach(this.downloadFileArray, (item: downloadFilesData) => { + ListItem() { + Row() { + Row() { + Image($r('app.media.multiple_files_download_file')) + .height(50) + .width(50) + .borderRadius(8) + .id('fileImage') + }.width('17%') + + Column() { + Row() { + Column() { + Text(this.fileName) + .height(22) + .width('100%') + .fontSize(14) + .fontColor('#000000') + .textAlign(TextAlign.Start) + .maxLines(1)// 限制为单行 + .id('fileName') + + Row() { + Text(this.sCurrentDownloadSize + '/' + this.sFileSize + 'MB ') + .fontSize(12) + .fontColor('#66182431') + .id('downloadVal') + + Text(this.state) + .fontSize(12) + .fontColor('#66182431') + .id(this.fileName + 'state') + }.width('100%') + .height(23) + } + .width('90%') + + Image($r('app.media.multiple_files_download_start')) + .height(25) + .width('10%') + .id('downloadImage') + } + + // 下载进度条,用于显示从下载进度更新回调中获取到的已下载数据大小 + Progress({ value: INIT_PROGRESS, total: this.nFileSize, type: ProgressType.Capsule }) + .value(1) + .height(5) + .id('progress') + + } + .width('83%') + .height(50) + .alignItems(HorizontalAlign.Start) + } + .width('100%') + .height(50) + .margin({ top: 15, bottom: 15 } as Margin) + } + }, (item: downloadFilesData) => item.id) + } + .opacity(this.downloadPageOpacity) + .visibility(this.downloadPageVisibility) + .enabled(this.isDownloadPageEnabled) + .width('100%') + .height('80%') + + // 下载历史列表 + List() { + ForEach(this.downloadFileArray, (item: downloadFilesData) => { + ListItem() { + HistoryItem({ + downloadCount: this.downloadCount, // 待下载任务数量 + historyArray: this.historyList, + downloadFileArray: this.downloadFileArray // 下载文件数据源 + }) + }.onClick((): void => { + hilog.info(0x0000, 'testTag', '点击单个文件'); + }) + }) + }.visibility(this.historyPageVisibility) + .enabled(this.isHistoryPageEnabled) + .width('100%') + .height('80%') + + }.padding(15) + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/code/ArkTS1.2/DownloadSample/entry/src/main/module.json5 b/code/ArkTS1.2/DownloadSample/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..cca7656f5308dac3ecbf78c69f40fb1c89c8ec6a --- /dev/null +++ b/code/ArkTS1.2/DownloadSample/entry/src/main/module.json5 @@ -0,0 +1,69 @@ +/** + * + * Copyright (c) 2025 Huawei Device Co., Ltd. + * + * All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice,this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS, + * + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "requestPermissions": [ + { + "name": "ohos.permission.INTERNET" + }, + ], + "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" + ] + } + ] + } + ] + } +} \ No newline at end of file diff --git a/code/ArkTS1.2/DownloadSample/entry/src/main/resources/base/element/color.json b/code/ArkTS1.2/DownloadSample/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..4d7d6016598d738996ff7ea3be42ad8df7516edf --- /dev/null +++ b/code/ArkTS1.2/DownloadSample/entry/src/main/resources/base/element/color.json @@ -0,0 +1,37 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + }, + { + "name": "multiple_files_download_text_font_color", + "value": "#66182431" + }, + { + "name": "multiple_files_download_column_border_color", + "value": "#6fafee" + }, + { + "name": "multiple_files_download_selected_background_color", + "value": "#FF007DFF" + }, + { + "name": "multiple_files_download_background_color", + "value": "#FFFEFEFE" + }, + { + "name": "multiple_files_download_text_color", + "value": "#418AF3" + }, + { + "name": "multiple_files_download_del_bgc", + "value": "#F55A42" + }, + { + "name": "operate_rdb_in_taskpool_button_background_color_green", + "value": "#FF2F9117" + } + + ] +} \ No newline at end of file diff --git a/code/ArkTS1.2/DownloadSample/entry/src/main/resources/base/element/float.json b/code/ArkTS1.2/DownloadSample/entry/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..33ea22304f9b1485b5f22d811023701b5d4e35b6 --- /dev/null +++ b/code/ArkTS1.2/DownloadSample/entry/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} diff --git a/code/ArkTS1.2/DownloadSample/entry/src/main/resources/base/element/integer.json b/code/ArkTS1.2/DownloadSample/entry/src/main/resources/base/element/integer.json new file mode 100644 index 0000000000000000000000000000000000000000..3b1936d6a96a00d707f9a14b4086f09e4b381961 --- /dev/null +++ b/code/ArkTS1.2/DownloadSample/entry/src/main/resources/base/element/integer.json @@ -0,0 +1,104 @@ +{ + "integer": [ + { + "name": "multiple_files_download_image_size_fifty", + "value": 50 + }, + { + "name": "multiple_files_download_image_size_twenty_five", + "value": 25 + }, + { + "name": "multiple_files_download_text_font_size_fourteen", + "value": 14 + }, + { + "name": "multiple_files_download_text_font_size_twelve", + "value": 12 + }, + { + "name": "multiple_files_download_text_font_size_twenty_five", + "value": 25 + }, + { + "name": "multiple_files_download_text_font_size_twenty", + "value": 20 + }, + { + "name": "multiple_files_download_padding_twenty", + "value": 20 + }, + { + "name": "multiple_files_download_padding_fifteen", + "value": 15 + }, + { + "name": "multiple_files_download_margin_bottom_eighteen", + "value": 18 + }, + { + "name": "multiple_files_download_margin_bottom_twelve", + "value": 12 + }, + { + "name": "multiple_files_download_margin_top_twenty", + "value": 20 + }, + { + "name": "multiple_files_download_margin_top_seven", + "value": 7 + }, + { + "name": "multiple_files_download_margin_top_five", + "value": 5 + }, + { + "name": "multiple_files_download_progress_height", + "value": 5 + }, + { + "name": "multiple_files_download_border_width", + "value": 5 + }, + { + "name": "multiple_files_download_border_radius", + "value": 10 + }, + { + "name": "multiple_files_download_margin_top_thirty", + "value": 30 + }, + { + "name": "multiple_files_download_margin_left_four", + "value": 4 + }, + { + "name": "multiple_files_download_padding_zero", + "value": 0 + }, + { + "name": "multiple_files_download_padding_five", + "value": 5 + }, + { + "name": "multiple_files_download_height_twenty_six", + "value": 26 + }, + { + "name": "multiple_files_download_borderRadius_eight", + "value": 8 + }, + { + "name": "multiple_files_download_borderRadius_twelve", + "value": 12 + }, + { + "name": "multiple_files_download_history_percentage_fifty", + "value": 50 + }, + { + "name": "multiple_files_download_margin_left_sixty", + "value": 60 + } + ] +} \ No newline at end of file diff --git a/code/ArkTS1.2/DownloadSample/entry/src/main/resources/base/element/string.json b/code/ArkTS1.2/DownloadSample/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..1f87b0cf1c3f1b2b503ad882d9936d66b42f7f3d --- /dev/null +++ b/code/ArkTS1.2/DownloadSample/entry/src/main/resources/base/element/string.json @@ -0,0 +1,116 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "router_back", + "value": "←" + }, + { + "name": "EntryAbility_label", + "value": "DownloadSample" + }, + { + "name": "multiple_files_download_text_width", + "value": "40%" + }, + { + "name": "button_finish", + "value": "已完成" + }, + { + "name": "text_download", + "value": "已下载" + }, + { + "name": "multiple_files_download_relative_container_width", + "value": "100%" + }, + { + "name": "multiple_files_download_relative_container_height", + "value": "15%" + }, + { + "name": "multiple_files_download_row_width", + "value": "50%" + }, + { + "name": "multiple_files_download_row_text_width", + "value": "100%" + }, + { + "name": "multiple_files_download_outer_row_width", + "value": "100%" + }, + { + "name": "multiple_files_download_transfer_list", + "value": "传输列表" + }, + { + "name": "multiple_files_download_queue", + "value": "下载队列 " + }, + { + "name": "multiple_files_download_completed", + "value": "下载已完成" + }, + { + "name": "multiple_files_download_function_only_display_purposes", + "value": "功能仅做展示" + }, + { + "name": "multiple_files_download_list", + "value": "下载列表" + }, + { + "name": "multiple_files_download_file_upload", + "value": "文件上传" + }, + { + "name": "multiple_files_download_album_backup", + "value": "下载历史" + }, + { + "name": "multiple_files_download_row_height", + "value": "30%" + }, + { + "name": "multiple_files_download_list_width", + "value": "100%" + }, + { + "name": "multiple_files_download_list_height", + "value": "80%" + }, + { + "name": "multiple_files_download_history_button_del", + "value": "删除" + }, + { + "name": "multiple_files_download_history_toast_text_del", + "value": "文件已删除" + }, + { + "name": "multiple_files_download_history_text_downloaded", + "value": "已下载" + }, + { + "name": "multiple_files_download_history_button_text_cancel", + "value": "取消" + }, + { + "name": "multiple_files_download_history_button_text_confirm", + "value": "确定" + }, + { + "name": "multiple_files_download_history_toast_text_exist", + "value": "文件已存在" + } + ] +} \ No newline at end of file diff --git a/code/ArkTS1.2/DownloadSample/entry/src/main/resources/base/media/background.png b/code/ArkTS1.2/DownloadSample/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/code/ArkTS1.2/DownloadSample/entry/src/main/resources/base/media/background.png differ diff --git a/code/ArkTS1.2/DownloadSample/entry/src/main/resources/base/media/foreground.png b/code/ArkTS1.2/DownloadSample/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/code/ArkTS1.2/DownloadSample/entry/src/main/resources/base/media/foreground.png differ diff --git a/code/ArkTS1.2/DownloadSample/entry/src/main/resources/base/media/layered_image.json b/code/ArkTS1.2/DownloadSample/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/code/ArkTS1.2/DownloadSample/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/code/ArkTS1.2/DownloadSample/entry/src/main/resources/base/media/multiple_files_download_file.png b/code/ArkTS1.2/DownloadSample/entry/src/main/resources/base/media/multiple_files_download_file.png new file mode 100644 index 0000000000000000000000000000000000000000..a323e4d76acc869e00672162e540167576b93c71 Binary files /dev/null and b/code/ArkTS1.2/DownloadSample/entry/src/main/resources/base/media/multiple_files_download_file.png differ diff --git a/code/ArkTS1.2/DownloadSample/entry/src/main/resources/base/media/multiple_files_download_start.png b/code/ArkTS1.2/DownloadSample/entry/src/main/resources/base/media/multiple_files_download_start.png new file mode 100644 index 0000000000000000000000000000000000000000..78100dcba58fcc7cc98d979fe5f025653d823ecb Binary files /dev/null and b/code/ArkTS1.2/DownloadSample/entry/src/main/resources/base/media/multiple_files_download_start.png differ diff --git a/code/ArkTS1.2/DownloadSample/entry/src/main/resources/base/media/multiple_files_download_stop.png b/code/ArkTS1.2/DownloadSample/entry/src/main/resources/base/media/multiple_files_download_stop.png new file mode 100644 index 0000000000000000000000000000000000000000..5ba740178443c784ba961aec5dca4375b30f7f38 Binary files /dev/null and b/code/ArkTS1.2/DownloadSample/entry/src/main/resources/base/media/multiple_files_download_stop.png differ diff --git a/code/ArkTS1.2/DownloadSample/entry/src/main/resources/base/media/sample1.png b/code/ArkTS1.2/DownloadSample/entry/src/main/resources/base/media/sample1.png new file mode 100644 index 0000000000000000000000000000000000000000..9f2cb05e25031b1895e9b142aa8493c74faf9281 Binary files /dev/null and b/code/ArkTS1.2/DownloadSample/entry/src/main/resources/base/media/sample1.png differ diff --git a/code/ArkTS1.2/DownloadSample/entry/src/main/resources/base/media/sample2.png b/code/ArkTS1.2/DownloadSample/entry/src/main/resources/base/media/sample2.png new file mode 100644 index 0000000000000000000000000000000000000000..cf4913e63011961de1f7e8c3d1ecb98c1efc05c7 Binary files /dev/null and b/code/ArkTS1.2/DownloadSample/entry/src/main/resources/base/media/sample2.png differ diff --git a/code/ArkTS1.2/DownloadSample/entry/src/main/resources/base/media/startIcon.png b/code/ArkTS1.2/DownloadSample/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/code/ArkTS1.2/DownloadSample/entry/src/main/resources/base/media/startIcon.png differ diff --git a/code/ArkTS1.2/DownloadSample/entry/src/main/resources/base/profile/backup_config.json b/code/ArkTS1.2/DownloadSample/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/code/ArkTS1.2/DownloadSample/entry/src/main/resources/base/profile/backup_config.json @@ -0,0 +1,3 @@ +{ + "allowToBackupRestore": true +} \ No newline at end of file diff --git a/code/ArkTS1.2/DownloadSample/entry/src/main/resources/base/profile/main_pages.json b/code/ArkTS1.2/DownloadSample/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce --- /dev/null +++ b/code/ArkTS1.2/DownloadSample/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/ArkTS1.2/DownloadSample/entry/src/main/resources/dark/element/color.json b/code/ArkTS1.2/DownloadSample/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..79b11c2747aec33e710fd3a7b2b3c94dd9965499 --- /dev/null +++ b/code/ArkTS1.2/DownloadSample/entry/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/code/ArkTS1.2/DownloadSample/hvigor/hvigor-config.json5 b/code/ArkTS1.2/DownloadSample/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..57c58e3641a0b085f39f7f137b9a938ecb20f2fd --- /dev/null +++ b/code/ArkTS1.2/DownloadSample/hvigor/hvigor-config.json5 @@ -0,0 +1,49 @@ +/** + * + * Copyright (c) 2025 Huawei Device Co., Ltd. + * + * All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice,this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS, + * + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +{ + "modelVersion": "5.0.2", + "dependencies": { + "@ohos/hvigor-ohos-online-sign-plugin": "4.0.2" + }, + "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/code/ArkTS1.2/DownloadSample/hvigorfile.ts b/code/ArkTS1.2/DownloadSample/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..f435606b5766719f7203539113d84a2b281b0353 --- /dev/null +++ b/code/ArkTS1.2/DownloadSample/hvigorfile.ts @@ -0,0 +1,32 @@ +/** + * + * Copyright (c) 2025 Huawei Device Co., Ltd. + * + * All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice,this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS, + * + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +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/code/ArkTS1.2/DownloadSample/oh-package.json5 b/code/ArkTS1.2/DownloadSample/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..b6f7090658c0e69d5582af5d236fde4eab954ed6 --- /dev/null +++ b/code/ArkTS1.2/DownloadSample/oh-package.json5 @@ -0,0 +1,34 @@ +/** + * + * Copyright (c) 2025 Huawei Device Co., Ltd. + * + * All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice,this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS, + * + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +{ + "modelVersion": "5.0.2", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + } +} diff --git a/code/ArkTS1.2/DownloadSample/ohosTest.md b/code/ArkTS1.2/DownloadSample/ohosTest.md new file mode 100644 index 0000000000000000000000000000000000000000..33406552043ea890890f2e4946ea6f24633953ab --- /dev/null +++ b/code/ArkTS1.2/DownloadSample/ohosTest.md @@ -0,0 +1,12 @@ +# 文件并行化处理场景测试用例 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +|-----------------------------------|-------------------------------------|----------------------|------------------------------------|------|------| +|压缩模式选择"自动模式",查看图片压缩效果 | 1. 需在真机测试
2. 构建并安装测试hap
3.进入【图片压缩方案】| 1、压缩模式选择"自动模式",输入图片压缩目标大小,"scale每次缩小倍数",点击"压缩"按钮 | 1、在"压缩后"下方显示压缩后的图片大小,格式,尺寸,图片大小不超过"图片压缩目标大小","scale每次缩小倍数"值设置越低,更接近图片压缩目标大小 | 否 | Pass | +| 压缩模式选择"手动模式",查看压缩效果 | 1. 需在真机测试
2. 构建并安装测试hap
3.进入【图片压缩方案】| 1、压缩模式选择"手动模式",设置"图片质量","图片尺寸",点击压缩按钮 |1、在"压缩后"下方显示压缩后的图片大小,格式,尺寸, “图片质量”值设置越低,图片越不清晰;“图片尺寸”值设置越低,图片尺寸越小 | 否 | Pass | +| 查看设置"压缩偏好"选项后,压缩功能是否正常 | 1. 需在真机测试
2. 构建并安装测试hap
3.进入【图片压缩方案】| 1、选择“优先压缩质量”
2、选择“优先压缩尺寸”
3、点击压缩按钮 | 1、“packing最小二分单位”滑块可以正常滑动,“最低图片质量”滑块不可滑动
2、“packing最小二分单位”滑块不可滑动,“最低图片质量”滑块可以滑动
3、在"压缩后"下方显示压缩后的图片大小,格式,尺寸| 否 | Pass | +| 选择不同的"输出格式",查看压缩后的图片格式 | 1. 需在真机测试
2. 构建并安装测试hap
3.进入【图片压缩方案】| 1、选择“原格式”,点击压缩按钮
2、选择“PNG”,点击压缩按钮
3、选择“JPG”,点击压缩按钮
4、选择“WEBP”,点击压缩按钮 | 1、压缩后的图片和压缩前图片格式一致
2、压缩后的图片格式为PNG格式
3、压缩后的图片格式为JPG格式
4、压缩后的图片格式为WEBP格式 | 否 | Pass | +| 下载文件是否正常 | 1. 需在真机测试
2. 构建并安装测试hap
3.进入【多文件下载监听案例】| 1、点击“全部开始”
2、点击“全部暂停”
3、点击“全部开始”
4、等待下载完成后,查看下载的文件是否保存在应用缓存路径下(手工可用hdc shell cd /data/app/el2/100/base/com.example.helloworld/haps/entry/cache) | 1、下载队列中两个任务能正常下载
2、下载队列中正在下载的任务被暂停了
3、下载任务重新恢复下载
4、下载完成后,在案例应用缓存路径下可以找到下载的文件:favor_list_tea.png favor_list_tree.png | 否 | Pass | +| 在下载历史中把已删除的文件重新下载 | 1. 需在真机测试
2. 构建并安装测试hap
3.进入【多文件下载监听案例】| 1、点击已下载文件
2、点击“删除”
3、点击已删除文件
4、点击“确认”| 1、弹出“文件已存在”toast
2、文件被删除样式发生变化且在案例应用缓存路径下不能找到已删除的文件
3、弹出“xxx文件已被删除,是否重新下载”的弹窗提示
4、文件重新下载 | 否 | Pass | \ No newline at end of file diff --git a/code/ArkTS1.2/NetworkSample/.gitignore b/code/ArkTS1.2/NetworkSample/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b --- /dev/null +++ b/code/ArkTS1.2/NetworkSample/.gitignore @@ -0,0 +1,12 @@ +/node_modules +/oh_modules +/local.properties +/.idea +**/build +/.hvigor +.cxx +/.clangd +/.clang-format +/.clang-tidy +**/.test +/.appanalyzer \ No newline at end of file diff --git a/code/ArkTS1.2/NetworkSample/AppScope/app.json5 b/code/ArkTS1.2/NetworkSample/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..d0c9a256058348416a39fd085af1b495a5be6e8d --- /dev/null +++ b/code/ArkTS1.2/NetworkSample/AppScope/app.json5 @@ -0,0 +1,36 @@ +/** + * + * Copyright (c) 2025 Huawei Device Co., Ltd. + * + * All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice,this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS, + * + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +{ + "app": { + "bundleName": "com.samples.NetworkSample", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/ArkTS1.2/NetworkSample/AppScope/resources/base/element/string.json b/code/ArkTS1.2/NetworkSample/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..80d6266a934f056e196d3fce9dde8c209917c9a7 --- /dev/null +++ b/code/ArkTS1.2/NetworkSample/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "NetworkSample" + } + ] +} diff --git a/code/ArkTS1.2/NetworkSample/AppScope/resources/base/media/app_icon.png b/code/ArkTS1.2/NetworkSample/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..a39445dc87828b76fed6d2ec470dd455c45319e3 Binary files /dev/null and b/code/ArkTS1.2/NetworkSample/AppScope/resources/base/media/app_icon.png differ diff --git a/code/ArkTS1.2/NetworkSample/README.md b/code/ArkTS1.2/NetworkSample/README.md new file mode 100644 index 0000000000000000000000000000000000000000..c906b41047bf523d68a00c78e1d7cd0a8f1f6c57 --- /dev/null +++ b/code/ArkTS1.2/NetworkSample/README.md @@ -0,0 +1,90 @@ +# 网络场景 + +### 介绍 +多任务依赖,要在完成任务A和完成任务B之后,才会唤醒任务C。 + +**使用说明** +1. 用户点击"启动所有任务"按钮 +2. 任务A和B同时开始执行 +3. 任务A完成后: + - 进度条更新至100% +4. 任务B完成后: + - 进度条更新至100% + - 任务锁被释放 +5. 任务C检测到锁已释放,开始执行: + - 进度条开始增长 +6. 任务C完成后: + - 进度条更新至100% + +### 工程结构&模块类型 + ``` + entry/src/main/ets/ +|---pages +| |---taskDependencies.ets // 任务依赖 +| |---index.ets // 首页(UI) + ``` + +### 具体实现 +*初始状态*: +- 任务锁 `lock` 设置为 `true`(锁定状态) +- 任务A和B完成状态均为 `false` + +2. **任务执行过程**: + - 任务A和B并行执行 + - 当任务A完成时,调用 `completeTaskA()` 方法: + - 设置 `taskACompleted = true` + - 更新进度 + - 检查是否可以解锁 + - 任务B同理 + +3. **解锁条件**: + - 只有当任务A和B都完成且锁处于锁定状态时才会解锁 + +4. **任务C触发**: + - 当锁被释放(`lock = false`)时执行任务C + +### 进度管理 + +1. **进度分配**: + - 任务A完成:100% + - 任务B完成:100% + - 任务C完成:100% + +2. **进度更新**: + - 每次任务完成时增加相应进度 + +### UI组件说明 + +1. **进度条组件**: + - 使用ArkTS的`Progress`组件 + - 线性样式直观展示进度变化 + - 实时显示百分比数值 + +2. **控制按钮**: + - "启动所有任务":触发整个任务流程 + +### 相关权限 + +网络权限: ohos.permission.INTERNET + +### 依赖 + +无 + +### 约束与限制 + +1. 本示例仅支持标准系统上运行,支持设备:Phone; +2. 本示例为Stage模型,支持API20版本SDK,SDK版本号(API Version 20),镜像版本号(6.0.0.31)。 +3. 本示例需要使用DevEco Studio 版本号(6.0.0.6)版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +``` +git init +git config core.sparsecheckout true +echo code/ArkTS1.2/NetworkSample/ > .git/info/sparse-checkout +git remote add origin https://gitee.com/openharmony/applications_app_samples.git +git pull +``` \ No newline at end of file diff --git a/code/ArkTS1.2/NetworkSample/build-profile.json5 b/code/ArkTS1.2/NetworkSample/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..c83260a8d4a7c41693901753e0c0ea562824569c --- /dev/null +++ b/code/ArkTS1.2/NetworkSample/build-profile.json5 @@ -0,0 +1,68 @@ +/** + * + * Copyright (c) 2025 Huawei Device Co., Ltd. + * + * All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice,this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS, + * + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +{ + "app": { + "signingConfigs": [], + "products": [ + { + "name": "default", + "signingConfig": "default", + "arkTSVersion": "1.2", + "compatibleSdkVersion": "6.0.0(20)", + "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/code/ArkTS1.2/NetworkSample/code-linter.json5 b/code/ArkTS1.2/NetworkSample/code-linter.json5 new file mode 100644 index 0000000000000000000000000000000000000000..87b3919d419c09728067f1b545b7e2d5116adc07 --- /dev/null +++ b/code/ArkTS1.2/NetworkSample/code-linter.json5 @@ -0,0 +1,58 @@ +/** + * + * Copyright (c) 2025 Huawei Device Co., Ltd. + * + * All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice,this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS, + * + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +{ + "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/code/ArkTS1.2/NetworkSample/entry/.gitignore b/code/ArkTS1.2/NetworkSample/entry/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/code/ArkTS1.2/NetworkSample/entry/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/ArkTS1.2/NetworkSample/entry/build-profile.json5 b/code/ArkTS1.2/NetworkSample/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..36f9e65afb2abbbbdda625e86543807eee16240c --- /dev/null +++ b/code/ArkTS1.2/NetworkSample/entry/build-profile.json5 @@ -0,0 +1,54 @@ +/** + * + * Copyright (c) 2025 Huawei Device Co., Ltd. + * + * All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice,this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS, + * + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +{ + "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/code/ArkTS1.2/NetworkSample/entry/hvigorfile.ts b/code/ArkTS1.2/NetworkSample/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..8f830cdfd5bfdd8bde92ebfc27fc0562423dca3d --- /dev/null +++ b/code/ArkTS1.2/NetworkSample/entry/hvigorfile.ts @@ -0,0 +1,32 @@ +/** + * + * Copyright (c) 2025 Huawei Device Co., Ltd. + * + * All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice,this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS, + * + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +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/code/ArkTS1.2/NetworkSample/entry/obfuscation-rules.txt b/code/ArkTS1.2/NetworkSample/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/code/ArkTS1.2/NetworkSample/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/code/ArkTS1.2/NetworkSample/entry/oh-package.json5 b/code/ArkTS1.2/NetworkSample/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..39ab3f901494a87d5ab258dfaa9e6882de1f5166 --- /dev/null +++ b/code/ArkTS1.2/NetworkSample/entry/oh-package.json5 @@ -0,0 +1,36 @@ +/** + * + * Copyright (c) 2025 Huawei Device Co., Ltd. + * + * All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice,this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS, + * + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/code/ArkTS1.2/NetworkSample/entry/src/main/ets/entryability/EntryAbility.ets b/code/ArkTS1.2/NetworkSample/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..d205c00999b495e390eb8582f3dec20cc547d5fc --- /dev/null +++ b/code/ArkTS1.2/NetworkSample/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,54 @@ +/** + * + * Copyright (c) 2025 Huawei Device Co., Ltd. + * + * All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice,this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS, + * + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import UIAbility from '@ohos.app.ability.UIAbility'; +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import Want from '@ohos.app.ability.Want'; +import window from '@ohos.window'; +import { BusinessError } from '@ohos.base' +import hilog from '@ohos.hilog' + +class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', 'EntryAbility onCreate'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + hilog.info(0x0000, 'testTag', 'EntryAbility onWindowStageCreate'); + try { + windowStage.loadContent('pages/Index', (err: BusinessError): void => { + hilog.info(0x0000, 'testTag', 'loadContent entering'); + if (err.code) { + hilog.info(0x0000, 'testTag', 'loadContent error'); + return; + } + hilog.info(0x0000, 'testTag', 'loadContent ok'); + }); + } catch (e: Error) { + hilog.info(0x0000, 'testTag', 'loadContent catch error:-----------' + e.message); + } + } +} \ No newline at end of file diff --git a/code/ArkTS1.2/NetworkSample/entry/src/main/ets/pages/Index.ets b/code/ArkTS1.2/NetworkSample/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..2c98a1464f010ed699d3a471b7fadf0f4c03feb1 --- /dev/null +++ b/code/ArkTS1.2/NetworkSample/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,95 @@ +/** + * + * Copyright (c) 2025 Huawei Device Co., Ltd. + * + * All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice,this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS, + * + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import { memo, __memo_context_type, __memo_id_type } from '@ohos.arkui.stateManagement' // should be insert by ui-plugins +import { Text, TextAttribute, Column, Component, Button, ButtonAttribute, ClickEvent, UserView, Entry, JSON, List, ListItem, Progress, ProgressOptions } from '@ohos.arkui.component' // TextAttribute should be insert by ui-plugins +import { State, StateDecoratedVariable, MutableState, stateOf, observableProxy } from '@ohos.arkui.stateManagement' // should be insert by ui-plugins +import hilog from '@ohos.hilog' +import request from '@ohos.request'; +import {BusinessError} from '@ohos.base'; +import common from '@ohos.app.ability.common'; // 导入依赖资源context模块 +import { UIContext, Router } from '@ohos.arkui.UIContext' + +@Entry +@Component +struct MyStateSample { + build() { + Column(undefined) { + List() { + ListItem() { + Text('任务A') + Progress({ value: 33, total: 100, type: ProgressType.Capsule }) + .width(300) + .height(50) + .color(Color.Blue) + .style({ + borderWidth: 5, + font: { size: 13, style: FontStyle.Normal }, + enableScanEffect: false, + showDefaultPercentage: true + }) + .privacySensitive(true) + } + + ListItem() { + Text('任务B') + Progress({ value: 33, total: 100, type: ProgressType.Capsule }) + .width(300) + .height(50) + .color(Color.Blue) + .style({ + borderWidth: 5, + font: { size: 13, style: FontStyle.Normal }, + enableScanEffect: false, + showDefaultPercentage: true + }) + .privacySensitive(true) + } + + List() { + ListItem() { + Text('任务C') + Progress({ value: 33, total: 100, type: ProgressType.Capsule }) + .width(300) + .height(50) + .color(Color.Blue) + .style({ + borderWidth: 5, + font: { size: 13, style: FontStyle.Normal }, + enableScanEffect: false, + showDefaultPercentage: true + }) + .privacySensitive(true) + } + } + + ListItem() { + Button('开始任务') + } + } + } + } +} \ No newline at end of file diff --git a/code/ArkTS1.2/NetworkSample/entry/src/main/module.json5 b/code/ArkTS1.2/NetworkSample/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..cca7656f5308dac3ecbf78c69f40fb1c89c8ec6a --- /dev/null +++ b/code/ArkTS1.2/NetworkSample/entry/src/main/module.json5 @@ -0,0 +1,69 @@ +/** + * + * Copyright (c) 2025 Huawei Device Co., Ltd. + * + * All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice,this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS, + * + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "requestPermissions": [ + { + "name": "ohos.permission.INTERNET" + }, + ], + "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" + ] + } + ] + } + ] + } +} \ No newline at end of file diff --git a/code/ArkTS1.2/NetworkSample/entry/src/main/resources/base/element/color.json b/code/ArkTS1.2/NetworkSample/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/code/ArkTS1.2/NetworkSample/entry/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/code/ArkTS1.2/NetworkSample/entry/src/main/resources/base/element/float.json b/code/ArkTS1.2/NetworkSample/entry/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..33ea22304f9b1485b5f22d811023701b5d4e35b6 --- /dev/null +++ b/code/ArkTS1.2/NetworkSample/entry/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} diff --git a/code/ArkTS1.2/NetworkSample/entry/src/main/resources/base/element/integer.json b/code/ArkTS1.2/NetworkSample/entry/src/main/resources/base/element/integer.json new file mode 100644 index 0000000000000000000000000000000000000000..117fe2d1c259c7d7350e26ab047a88337fefddd9 --- /dev/null +++ b/code/ArkTS1.2/NetworkSample/entry/src/main/resources/base/element/integer.json @@ -0,0 +1,8 @@ +{ + "integer": [ + { + "name": "multiple_files_download_image_size_fifty", + "value": 50 + } + ] +} \ No newline at end of file diff --git a/code/ArkTS1.2/NetworkSample/entry/src/main/resources/base/element/string.json b/code/ArkTS1.2/NetworkSample/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..632febf68d49993c789b885b46a4107b5f664f04 --- /dev/null +++ b/code/ArkTS1.2/NetworkSample/entry/src/main/resources/base/element/string.json @@ -0,0 +1,20 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "router_back", + "value": "←" + }, + { + "name": "EntryAbility_label", + "value": "NetworkSample" + } + ] +} \ No newline at end of file diff --git a/code/ArkTS1.2/NetworkSample/entry/src/main/resources/base/media/background.png b/code/ArkTS1.2/NetworkSample/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/code/ArkTS1.2/NetworkSample/entry/src/main/resources/base/media/background.png differ diff --git a/code/ArkTS1.2/NetworkSample/entry/src/main/resources/base/media/foreground.png b/code/ArkTS1.2/NetworkSample/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/code/ArkTS1.2/NetworkSample/entry/src/main/resources/base/media/foreground.png differ diff --git a/code/ArkTS1.2/NetworkSample/entry/src/main/resources/base/media/layered_image.json b/code/ArkTS1.2/NetworkSample/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/code/ArkTS1.2/NetworkSample/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/code/ArkTS1.2/NetworkSample/entry/src/main/resources/base/media/multiple_files_download_file.png b/code/ArkTS1.2/NetworkSample/entry/src/main/resources/base/media/multiple_files_download_file.png new file mode 100644 index 0000000000000000000000000000000000000000..a323e4d76acc869e00672162e540167576b93c71 Binary files /dev/null and b/code/ArkTS1.2/NetworkSample/entry/src/main/resources/base/media/multiple_files_download_file.png differ diff --git a/code/ArkTS1.2/NetworkSample/entry/src/main/resources/base/media/multiple_files_download_start.png b/code/ArkTS1.2/NetworkSample/entry/src/main/resources/base/media/multiple_files_download_start.png new file mode 100644 index 0000000000000000000000000000000000000000..78100dcba58fcc7cc98d979fe5f025653d823ecb Binary files /dev/null and b/code/ArkTS1.2/NetworkSample/entry/src/main/resources/base/media/multiple_files_download_start.png differ diff --git a/code/ArkTS1.2/NetworkSample/entry/src/main/resources/base/media/multiple_files_download_stop.png b/code/ArkTS1.2/NetworkSample/entry/src/main/resources/base/media/multiple_files_download_stop.png new file mode 100644 index 0000000000000000000000000000000000000000..5ba740178443c784ba961aec5dca4375b30f7f38 Binary files /dev/null and b/code/ArkTS1.2/NetworkSample/entry/src/main/resources/base/media/multiple_files_download_stop.png differ diff --git a/code/ArkTS1.2/NetworkSample/entry/src/main/resources/base/media/startIcon.png b/code/ArkTS1.2/NetworkSample/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/code/ArkTS1.2/NetworkSample/entry/src/main/resources/base/media/startIcon.png differ diff --git a/code/ArkTS1.2/NetworkSample/entry/src/main/resources/base/profile/backup_config.json b/code/ArkTS1.2/NetworkSample/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/code/ArkTS1.2/NetworkSample/entry/src/main/resources/base/profile/backup_config.json @@ -0,0 +1,3 @@ +{ + "allowToBackupRestore": true +} \ No newline at end of file diff --git a/code/ArkTS1.2/NetworkSample/entry/src/main/resources/base/profile/main_pages.json b/code/ArkTS1.2/NetworkSample/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce --- /dev/null +++ b/code/ArkTS1.2/NetworkSample/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/ArkTS1.2/NetworkSample/entry/src/main/resources/dark/element/color.json b/code/ArkTS1.2/NetworkSample/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..79b11c2747aec33e710fd3a7b2b3c94dd9965499 --- /dev/null +++ b/code/ArkTS1.2/NetworkSample/entry/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/code/ArkTS1.2/NetworkSample/hvigor/hvigor-config.json5 b/code/ArkTS1.2/NetworkSample/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..57c58e3641a0b085f39f7f137b9a938ecb20f2fd --- /dev/null +++ b/code/ArkTS1.2/NetworkSample/hvigor/hvigor-config.json5 @@ -0,0 +1,49 @@ +/** + * + * Copyright (c) 2025 Huawei Device Co., Ltd. + * + * All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice,this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS, + * + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +{ + "modelVersion": "5.0.2", + "dependencies": { + "@ohos/hvigor-ohos-online-sign-plugin": "4.0.2" + }, + "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/code/ArkTS1.2/NetworkSample/hvigorfile.ts b/code/ArkTS1.2/NetworkSample/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..f435606b5766719f7203539113d84a2b281b0353 --- /dev/null +++ b/code/ArkTS1.2/NetworkSample/hvigorfile.ts @@ -0,0 +1,32 @@ +/** + * + * Copyright (c) 2025 Huawei Device Co., Ltd. + * + * All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice,this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS, + * + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +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/code/ArkTS1.2/NetworkSample/oh-package.json5 b/code/ArkTS1.2/NetworkSample/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..b6f7090658c0e69d5582af5d236fde4eab954ed6 --- /dev/null +++ b/code/ArkTS1.2/NetworkSample/oh-package.json5 @@ -0,0 +1,34 @@ +/** + * + * Copyright (c) 2025 Huawei Device Co., Ltd. + * + * All rights reserved. + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice,this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS, + * + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +{ + "modelVersion": "5.0.2", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + } +} diff --git a/code/ArkTS1.2/NetworkSample/ohosTest.md b/code/ArkTS1.2/NetworkSample/ohosTest.md new file mode 100644 index 0000000000000000000000000000000000000000..4e8ff7aa9bdf3893834f14e69d8a235328c3b142 --- /dev/null +++ b/code/ArkTS1.2/NetworkSample/ohosTest.md @@ -0,0 +1,7 @@ +# 网络场景测试用例 + +## 用例表 + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +|-----------------------------------|-------------------------------------|----------------------|------------------------------------|------|------| +| 多任务依赖执行 | 1. 需在真机测试
2. 构建并安装测试hap | 点击启动所有任务按钮 | 任务A、B开始执行,A、B执行完成后任务C开始执行 | 否 | Pass |