diff --git a/.idea/workspace.xml b/.idea/workspace.xml index b0a56cb87c12792884daaa599ac00da88af8562d..845f7b34179ead8d00db1120e26e25953a0b39a5 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -1,7 +1,324 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/LowPowerOfForegroundTask/.gitignore b/LowPowerOfForegroundTask/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b --- /dev/null +++ b/LowPowerOfForegroundTask/.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/LowPowerOfForegroundTask/AppScope/app.json5 b/LowPowerOfForegroundTask/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..51c019fd61ef30b7859ed3d804362c83d6e9ffa9 --- /dev/null +++ b/LowPowerOfForegroundTask/AppScope/app.json5 @@ -0,0 +1,10 @@ +{ + "app": { + "bundleName": "com.example.lowpowerofforegroundtask", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:layered_image", + "label": "$string:app_name" + } +} diff --git a/LowPowerOfForegroundTask/AppScope/resources/base/element/string.json b/LowPowerOfForegroundTask/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..607b10b7f9dcf124e1f1c86bf79e6a5722f5c70e --- /dev/null +++ b/LowPowerOfForegroundTask/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "LowPowerOfForegroundTask" + } + ] +} diff --git a/LowPowerOfForegroundTask/AppScope/resources/base/media/background.png b/LowPowerOfForegroundTask/AppScope/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/LowPowerOfForegroundTask/AppScope/resources/base/media/background.png differ diff --git a/LowPowerOfForegroundTask/AppScope/resources/base/media/foreground.png b/LowPowerOfForegroundTask/AppScope/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/LowPowerOfForegroundTask/AppScope/resources/base/media/foreground.png differ diff --git a/LowPowerOfForegroundTask/AppScope/resources/base/media/layered_image.json b/LowPowerOfForegroundTask/AppScope/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/LowPowerOfForegroundTask/AppScope/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/LowPowerOfForegroundTask/build-profile.json5 b/LowPowerOfForegroundTask/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..9e87e7e6f19020fe21192844709f192cec80fd44 --- /dev/null +++ b/LowPowerOfForegroundTask/build-profile.json5 @@ -0,0 +1,42 @@ +{ + "app": { + "signingConfigs": [], + "products": [ + { + "name": "default", + "signingConfig": "default", + "targetSdkVersion": "5.0.5(17)", + "compatibleSdkVersion": "5.0.5(17)", + "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/LowPowerOfForegroundTask/code-linter.json5 b/LowPowerOfForegroundTask/code-linter.json5 new file mode 100644 index 0000000000000000000000000000000000000000..073990fa45394e1f8e85d85418ee60a8953f9b99 --- /dev/null +++ b/LowPowerOfForegroundTask/code-linter.json5 @@ -0,0 +1,32 @@ +{ + "files": [ + "**/*.ets" + ], + "ignore": [ + "**/src/ohosTest/**/*", + "**/src/test/**/*", + "**/src/mock/**/*", + "**/node_modules/**/*", + "**/oh_modules/**/*", + "**/build/**/*", + "**/.preview/**/*" + ], + "ruleSet": [ + "plugin:@performance/recommended", + "plugin:@typescript-eslint/recommended" + ], + "rules": { + "@security/no-unsafe-aes": "error", + "@security/no-unsafe-hash": "error", + "@security/no-unsafe-mac": "warn", + "@security/no-unsafe-dh": "error", + "@security/no-unsafe-dsa": "error", + "@security/no-unsafe-ecdsa": "error", + "@security/no-unsafe-rsa-encrypt": "error", + "@security/no-unsafe-rsa-sign": "error", + "@security/no-unsafe-rsa-key": "error", + "@security/no-unsafe-dsa-key": "error", + "@security/no-unsafe-dh-key": "error", + "@security/no-unsafe-3des": "error" + } +} \ No newline at end of file diff --git a/LowPowerOfForegroundTask/entry/.gitignore b/LowPowerOfForegroundTask/entry/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/LowPowerOfForegroundTask/entry/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/LowPowerOfForegroundTask/entry/build-profile.json5 b/LowPowerOfForegroundTask/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..4d611879c7913fb0610c686e2399258ab3a6dad1 --- /dev/null +++ b/LowPowerOfForegroundTask/entry/build-profile.json5 @@ -0,0 +1,28 @@ +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/LowPowerOfForegroundTask/entry/hvigorfile.ts b/LowPowerOfForegroundTask/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..c6edcd90486dd5a853cf7d34c8647f08414ca7a3 --- /dev/null +++ b/LowPowerOfForegroundTask/entry/hvigorfile.ts @@ -0,0 +1,6 @@ +import { hapTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/LowPowerOfForegroundTask/entry/obfuscation-rules.txt b/LowPowerOfForegroundTask/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/LowPowerOfForegroundTask/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/LowPowerOfForegroundTask/entry/oh-package.json5 b/LowPowerOfForegroundTask/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..248c3b7541a589682a250f86a6d3ecf7414d2d6a --- /dev/null +++ b/LowPowerOfForegroundTask/entry/oh-package.json5 @@ -0,0 +1,10 @@ +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/LowPowerOfForegroundTask/entry/src/main/ets/entryability/EntryAbility.ets b/LowPowerOfForegroundTask/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..767528e4294fa9baa4552f9e92dae266c5aac764 --- /dev/null +++ b/LowPowerOfForegroundTask/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,67 @@ +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +const DOMAIN = 0x0000; + +// [Start power_entry_ability] +export default class EntryAbility extends UIAbility { + // [StartExclude power_entry_ability] + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy'); + } + // [EndExclude power_entry_ability] + + onWindowStageCreate(windowStage: window.WindowStage): void { + // [StartExclude power_entry_ability] + // Main window is created, set main page for this ability + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err)); + return; + } + hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.'); + }); + // [EndExclude power_entry_ability] + // Determine whether it is currently in dark mode. + if (this.context?.config?.colorMode == ConfigurationConstant.ColorMode.COLOR_MODE_DARK) { + let windowClass = windowStage.getMainWindowSync(); + try { + // Set the brightness of the current application window + windowClass.setWindowBrightness(0.2, (err) => { + if (err.code) { + console.error('Failed to set the brightness. Cause: ' + JSON.stringify(err)); + return; + } + console.info('Succeeded in setting the brightness.'); + }); + } catch (exception) { + console.error('Failed to set the brightness. Cause: ' + JSON.stringify(exception)); + } + } + } + + // [StartExclude power_entry_ability] + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onBackground'); + } + // [EndExclude power_entry_ability] +} +// [End power_entry_ability] \ No newline at end of file diff --git a/LowPowerOfForegroundTask/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/LowPowerOfForegroundTask/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..8e4de99282050bad799ac892eb85ac5449364a51 --- /dev/null +++ b/LowPowerOfForegroundTask/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -0,0 +1,16 @@ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit'; + +const DOMAIN = 0x0000; + +export default class EntryBackupAbility extends BackupExtensionAbility { + async onBackup() { + hilog.info(DOMAIN, 'testTag', 'onBackup ok'); + await Promise.resolve(); + } + + async onRestore(bundleVersion: BundleVersion) { + hilog.info(DOMAIN, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion)); + await Promise.resolve(); + } +} \ No newline at end of file diff --git a/LowPowerOfForegroundTask/entry/src/main/ets/pages/ArticleCardView.ets b/LowPowerOfForegroundTask/entry/src/main/ets/pages/ArticleCardView.ets new file mode 100644 index 0000000000000000000000000000000000000000..b95fea96b0f7dff5e0a45fd6b8456ea1477aa8ce --- /dev/null +++ b/LowPowerOfForegroundTask/entry/src/main/ets/pages/ArticleCardView.ets @@ -0,0 +1,62 @@ +// [Start article_card_view] +import { router } from '@kit.ArkUI'; +import { common } from '@kit.AbilityKit'; +import { LearningResource, ActionButtonView, CommonConstants, ArticleCardButtonView } from '@ohos/common'; +// Introduction of power module +import { power } from '@kit.BasicServicesKit'; + +@Component +export struct ArticleCardView { + @Prop isLiked: boolean = false; + @Prop isCollected: boolean = false; + @ObjectLink articleItem: LearningResource; + onCollected?: () => void; + onLiked?: () => void; + + build() { + Row({ space: CommonConstants.SPACE_16 }) { + Column() { + // ... + Row() { + ActionButtonView({ + imgResource: $r('app.media.ic_eye_open'), + count: this.articleItem.viewsCount, + textWidth: $r('app.float.view_count_icon_width') + }) + // Use getPowerMode to get the power mode of the current system and determine whether it is currently a power-saving mode. + if (power.getPowerMode() == power.DevicePowerMode.MODE_POWER_SAVE) { + ActionButtonView({ + imgResource: this.isLiked ? $r('app.media.btn_good_on') : $r('app.media.btn_good_normal'), + count: this.articleItem.likesCount, + textWidth: $r('app.float.like_icon_width') + }) + .onClick(() => { + this.onLiked?.(); + }) + // ... + } else { + ArticleCardButtonView({ + clickAnimationPath: 'common/lottie/liked_lottie.json', + cancelAnimationPath: 'common/lottie/cancel_liked_lottie.json', + isClicked: this.isLiked, + count: this.articleItem.likesCount, + articleId: this.articleItem.id, + textWidth: $r('app.float.like_icon_width'), + type: 'like', + onClicked: this.onLiked, + normalImage: $r('app.media.btn_like_normal'), + onImage: $r('app.media.btn_like_on') + }) + // ... + } + } + .width(CommonConstants.FULL_PERCENT) + .justifyContent(FlexAlign.SpaceBetween) + } + .layoutWeight(1) + .height(CommonConstants.FULL_PERCENT) + .justifyContent(FlexAlign.SpaceAround) + } + } +} +// [End article_card_view] \ No newline at end of file diff --git a/LowPowerOfForegroundTask/entry/src/main/ets/pages/ArticleCardViewNew.ets b/LowPowerOfForegroundTask/entry/src/main/ets/pages/ArticleCardViewNew.ets new file mode 100644 index 0000000000000000000000000000000000000000..c5400d76edacac0aaeb5c762193f8be88a3c3c48 --- /dev/null +++ b/LowPowerOfForegroundTask/entry/src/main/ets/pages/ArticleCardViewNew.ets @@ -0,0 +1,86 @@ +// [Start article_card_view_new] +import { router } from '@kit.ArkUI'; +import common from '@ohos.app.ability.common'; +import { LearningResource, ActionButtonView, CommonConstants, ArticleCardButtonView } from '@ohos/common'; +import { power } from '@kit.BasicServicesKit'; + +@Component +export struct ArticleCardView { + @Prop isLiked: boolean = false; + @Prop isCollected: boolean = false; + @ObjectLink articleItem: LearningResource; + onCollected?: () => void; + onLiked?: () => void; + + + build() { + Row({ space: CommonConstants.SPACE_16 }) { + Column() { + // ... + Row() { + ActionButtonView({ + imgResource: $r('app.media.ic_eye_open'), + count: this.articleItem.viewsCount, + textWidth: $r('app.float.view_count_icon_width') + }) + // Determine whether it is a power-saving mode + if (power.getPowerMode() == power.DevicePowerMode.MODE_EXTREME_POWER_SAVE) { + // Set up likes and favorite pictures + ActionButtonView({ + imgResource: this.isLiked ? $r('app.media.btn_good_on') : $r('app.media.btn_good_normal'), + count: this.articleItem.likesCount, + textWidth: $r('app.float.like_icon_width') + }) + .onClick(() => { + this.onLiked?.(); + }) + + ActionButtonView({ + imgResource: this.isCollected ? $r('app.media.btn_favorites_on') : $r('app.media.btn_favorites_normal'), + count: this.articleItem.collectionCount, + textWidth: $r('app.float.star_icon_width') + }) + .onClick(() => { + this.onCollected?.() + }) + } else { + // Set the lottie animation of likes and collections + ArticleCardButtonView({ + clickAnimationPath: 'common/lottie/liked_lottie.json', + cancelAnimationPath: 'common/lottie/cancel_liked_lottie.json', + isClicked: this.isLiked, + count: this.articleItem.likesCount, + articleId: this.articleItem.id, + textWidth: $r('app.float.like_icon_width'), + type: 'like', + onClicked: this.onLiked, + normalImage: $r('app.media.btn_like_normal'), + onImage: $r('app.media.btn_like_on') + }) + + ArticleCardButtonView({ + clickAnimationPath: 'common/lottie/collected_lottie.json', + cancelAnimationPath: 'common/lottie/cancel_collect_lottie.json', + isClicked: this.isCollected, + count: this.articleItem.collectionCount, + articleId: this.articleItem.id, + textWidth: $r('app.float.star_icon_width'), + type: 'collect', + onClicked: this.onCollected, + normalImage: $r('app.media.btn_collect_normal'), + onImage: $r('app.media.btn_collect_on') + }) + } + } + .width(CommonConstants.FULL_PERCENT) + .justifyContent(FlexAlign.SpaceBetween) + } + .layoutWeight(1) + .height(CommonConstants.FULL_PERCENT) + .justifyContent(FlexAlign.SpaceAround) + // ... + } + // ... + } +} +// [End article_card_view_new] \ No newline at end of file diff --git a/LowPowerOfForegroundTask/entry/src/main/ets/pages/Index.ets b/LowPowerOfForegroundTask/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..8e2d24ad42693fc877d51bb7820f0a9da68fa135 --- /dev/null +++ b/LowPowerOfForegroundTask/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,23 @@ +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + RelativeContainer() { + Text(this.message) + .id('HelloWorld') + .fontSize($r('app.float.page_text_font_size')) + .fontWeight(FontWeight.Bold) + .alignRules({ + center: { anchor: '__container__', align: VerticalAlign.Center }, + middle: { anchor: '__container__', align: HorizontalAlign.Center } + }) + .onClick(() => { + this.message = 'Welcome'; + }) + } + .height('100%') + .width('100%') + } +} \ No newline at end of file diff --git a/LowPowerOfForegroundTask/entry/src/main/module.json5 b/LowPowerOfForegroundTask/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..a1cea8b6a4560cee7bda7a2db52f310c035ab6c8 --- /dev/null +++ b/LowPowerOfForegroundTask/entry/src/main/module.json5 @@ -0,0 +1,52 @@ +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:layered_image", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "EntryBackupAbility", + "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets", + "type": "backup", + "exported": false, + "metadata": [ + { + "name": "ohos.extension.backup", + "resource": "$profile:backup_config" + } + ], + } + ] + } +} \ No newline at end of file diff --git a/LowPowerOfForegroundTask/entry/src/main/resources/base/element/color.json b/LowPowerOfForegroundTask/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/LowPowerOfForegroundTask/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/LowPowerOfForegroundTask/entry/src/main/resources/base/element/float.json b/LowPowerOfForegroundTask/entry/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..33ea22304f9b1485b5f22d811023701b5d4e35b6 --- /dev/null +++ b/LowPowerOfForegroundTask/entry/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} diff --git a/LowPowerOfForegroundTask/entry/src/main/resources/base/element/string.json b/LowPowerOfForegroundTask/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..f94595515a99e0c828807e243494f57f09251930 --- /dev/null +++ b/LowPowerOfForegroundTask/entry/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/LowPowerOfForegroundTask/entry/src/main/resources/base/media/background.png b/LowPowerOfForegroundTask/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/LowPowerOfForegroundTask/entry/src/main/resources/base/media/background.png differ diff --git a/LowPowerOfForegroundTask/entry/src/main/resources/base/media/foreground.png b/LowPowerOfForegroundTask/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/LowPowerOfForegroundTask/entry/src/main/resources/base/media/foreground.png differ diff --git a/LowPowerOfForegroundTask/entry/src/main/resources/base/media/layered_image.json b/LowPowerOfForegroundTask/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/LowPowerOfForegroundTask/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/LowPowerOfForegroundTask/entry/src/main/resources/base/media/startIcon.png b/LowPowerOfForegroundTask/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/LowPowerOfForegroundTask/entry/src/main/resources/base/media/startIcon.png differ diff --git a/LowPowerOfForegroundTask/entry/src/main/resources/base/profile/backup_config.json b/LowPowerOfForegroundTask/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/LowPowerOfForegroundTask/entry/src/main/resources/base/profile/backup_config.json @@ -0,0 +1,3 @@ +{ + "allowToBackupRestore": true +} \ No newline at end of file diff --git a/LowPowerOfForegroundTask/entry/src/main/resources/base/profile/main_pages.json b/LowPowerOfForegroundTask/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce --- /dev/null +++ b/LowPowerOfForegroundTask/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/LowPowerOfForegroundTask/entry/src/main/resources/dark/element/color.json b/LowPowerOfForegroundTask/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..79b11c2747aec33e710fd3a7b2b3c94dd9965499 --- /dev/null +++ b/LowPowerOfForegroundTask/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/LowPowerOfForegroundTask/entry/src/mock/mock-config.json5 b/LowPowerOfForegroundTask/entry/src/mock/mock-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..7a73a41bfdf76d6f793007240d80983a52f15f97 --- /dev/null +++ b/LowPowerOfForegroundTask/entry/src/mock/mock-config.json5 @@ -0,0 +1,2 @@ +{ +} \ No newline at end of file diff --git a/LowPowerOfForegroundTask/entry/src/ohosTest/ets/test/Ability.test.ets b/LowPowerOfForegroundTask/entry/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..85c78f67579d6e31b5f5aeea463e216b9b141048 --- /dev/null +++ b/LowPowerOfForegroundTask/entry/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,35 @@ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }) + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }) + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }) + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }) + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + hilog.info(0x0000, 'testTag', '%{public}s', 'it begin'); + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }) + }) +} \ No newline at end of file diff --git a/LowPowerOfForegroundTask/entry/src/ohosTest/ets/test/List.test.ets b/LowPowerOfForegroundTask/entry/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..794c7dc4ed66bd98fa3865e07922906e2fcef545 --- /dev/null +++ b/LowPowerOfForegroundTask/entry/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,5 @@ +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/LowPowerOfForegroundTask/entry/src/ohosTest/module.json5 b/LowPowerOfForegroundTask/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..55725a929993a8a18b3808d41ef037759440488b --- /dev/null +++ b/LowPowerOfForegroundTask/entry/src/ohosTest/module.json5 @@ -0,0 +1,13 @@ +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/LowPowerOfForegroundTask/entry/src/test/List.test.ets b/LowPowerOfForegroundTask/entry/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..bb5b5c3731e283dd507c847560ee59bde477bbc7 --- /dev/null +++ b/LowPowerOfForegroundTask/entry/src/test/List.test.ets @@ -0,0 +1,5 @@ +import localUnitTest from './LocalUnit.test'; + +export default function testsuite() { + localUnitTest(); +} \ No newline at end of file diff --git a/LowPowerOfForegroundTask/entry/src/test/LocalUnit.test.ets b/LowPowerOfForegroundTask/entry/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..165fc1615ee8618b4cb6a622f144a9a707eee99f --- /dev/null +++ b/LowPowerOfForegroundTask/entry/src/test/LocalUnit.test.ets @@ -0,0 +1,33 @@ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function localUnitTest() { + describe('localUnitTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }); + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }); + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }); + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }); + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }); + }); +} \ No newline at end of file diff --git a/LowPowerOfForegroundTask/hvigor/hvigor-config.json5 b/LowPowerOfForegroundTask/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..5bebc9755447385d82ce4138f54d991b1f85f348 --- /dev/null +++ b/LowPowerOfForegroundTask/hvigor/hvigor-config.json5 @@ -0,0 +1,22 @@ +{ + "modelVersion": "5.0.5", + "dependencies": { + }, + "execution": { + // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */ + // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */ + // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */ + // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */ + // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */ + }, + "logging": { + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ + }, + "debugging": { + // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */ + }, + "nodeOptions": { + // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/ + // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/ + } +} diff --git a/LowPowerOfForegroundTask/hvigorfile.ts b/LowPowerOfForegroundTask/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..f3cb9f1a87a81687554a76283af8df27d8bda775 --- /dev/null +++ b/LowPowerOfForegroundTask/hvigorfile.ts @@ -0,0 +1,6 @@ +import { appTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/LowPowerOfForegroundTask/oh-package-lock.json5 b/LowPowerOfForegroundTask/oh-package-lock.json5 new file mode 100644 index 0000000000000000000000000000000000000000..7fcf818273347b97063c0c0a151bb14770ca1c79 --- /dev/null +++ b/LowPowerOfForegroundTask/oh-package-lock.json5 @@ -0,0 +1,27 @@ +{ + "meta": { + "stableOrder": true + }, + "lockfileVersion": 3, + "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", + "specifiers": { + "@ohos/hamock@1.0.0": "@ohos/hamock@1.0.0", + "@ohos/hypium@1.0.21": "@ohos/hypium@1.0.21" + }, + "packages": { + "@ohos/hamock@1.0.0": { + "name": "@ohos/hamock", + "version": "1.0.0", + "integrity": "sha512-K6lDPYc6VkKe6ZBNQa9aoG+ZZMiwqfcR/7yAVFSUGIuOAhPvCJAo9+t1fZnpe0dBRBPxj2bxPPbKh69VuyAtDg==", + "resolved": "https://ohpm.openharmony.cn/ohpm/@ohos/hamock/-/hamock-1.0.0.har", + "registryType": "ohpm" + }, + "@ohos/hypium@1.0.21": { + "name": "@ohos/hypium", + "version": "1.0.21", + "integrity": "sha512-iyKGMXxE+9PpCkqEwu0VykN/7hNpb+QOeIuHwkmZnxOpI+dFZt6yhPB7k89EgV1MiSK/ieV/hMjr5Z2mWwRfMQ==", + "resolved": "https://ohpm.openharmony.cn/ohpm/@ohos/hypium/-/hypium-1.0.21.har", + "registryType": "ohpm" + } + } +} \ No newline at end of file diff --git a/LowPowerOfForegroundTask/oh-package.json5 b/LowPowerOfForegroundTask/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..a8aff0c5aff22d78aa26fd19c3861f4320e951ff --- /dev/null +++ b/LowPowerOfForegroundTask/oh-package.json5 @@ -0,0 +1,10 @@ +{ + "modelVersion": "5.0.5", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.21", + "@ohos/hamock": "1.0.0" + } +} diff --git a/PerformanceOptimization/AppColdStart/.gitignore b/PerformanceOptimization/AppColdStart/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b --- /dev/null +++ b/PerformanceOptimization/AppColdStart/.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/PerformanceOptimization/AppColdStart/AppScope/app.json5 b/PerformanceOptimization/AppColdStart/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..f494d994f6201b2a25bb8f89192d6b628170ff14 --- /dev/null +++ b/PerformanceOptimization/AppColdStart/AppScope/app.json5 @@ -0,0 +1,10 @@ +{ + "app": { + "bundleName": "com.example.appcoldstart", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:layered_image", + "label": "$string:app_name" + } +} diff --git a/PerformanceOptimization/AppColdStart/AppScope/resources/base/element/string.json b/PerformanceOptimization/AppColdStart/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..69538d5bc570ff79d061cd3ea9f22e037f60929c --- /dev/null +++ b/PerformanceOptimization/AppColdStart/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "AppColdStart" + } + ] +} diff --git a/PerformanceOptimization/AppColdStart/AppScope/resources/base/media/background.png b/PerformanceOptimization/AppColdStart/AppScope/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/PerformanceOptimization/AppColdStart/AppScope/resources/base/media/background.png differ diff --git a/PerformanceOptimization/AppColdStart/AppScope/resources/base/media/foreground.png b/PerformanceOptimization/AppColdStart/AppScope/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/PerformanceOptimization/AppColdStart/AppScope/resources/base/media/foreground.png differ diff --git a/PerformanceOptimization/AppColdStart/AppScope/resources/base/media/layered_image.json b/PerformanceOptimization/AppColdStart/AppScope/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/PerformanceOptimization/AppColdStart/AppScope/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/PerformanceOptimization/AppColdStart/HapAndHarDependHar/AppScope/app.json5 b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..86cc9b85e3d6376e23d256dffccbcdd1d59b4e6e --- /dev/null +++ b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/AppScope/app.json5 @@ -0,0 +1,10 @@ +{ + "app": { + "bundleName": "com.example.coldstart", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/PerformanceOptimization/AppColdStart/HapAndHarDependHar/AppScope/resources/base/element/string.json b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..7b173461f58b7687bc9b8423941cb83b96c12069 --- /dev/null +++ b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ColdStart" + } + ] +} diff --git a/PerformanceOptimization/AppColdStart/HapAndHarDependHar/AppScope/resources/base/media/app_icon.png b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..a39445dc87828b76fed6d2ec470dd455c45319e3 Binary files /dev/null and b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/AppScope/resources/base/media/app_icon.png differ diff --git a/PerformanceOptimization/AppColdStart/HapAndHarDependHar/build-profile.json5 b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..2c03ac0f094d139e2ae61c76ed8a58d81a0d8dcd --- /dev/null +++ b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/build-profile.json5 @@ -0,0 +1,43 @@ +{ + "app": { + "signingConfigs": [], + "products": [ + { + "name": "default", + "signingConfig": "default", + "compatibleSdkVersion": "5.0.0(12)", + "runtimeOS": "HarmonyOS", + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "har_library", + "srcPath": "./library" + }, + { + "name": "har_common", + "srcPath": "./har_common", + } + ] +} \ No newline at end of file diff --git a/PerformanceOptimization/AppColdStart/HapAndHarDependHar/entry/build-profile.json5 b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..b695582d3680556f4cce2ec518f65720a9413ca3 --- /dev/null +++ b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/entry/build-profile.json5 @@ -0,0 +1,28 @@ +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": true, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/PerformanceOptimization/AppColdStart/HapAndHarDependHar/entry/hvigorfile.ts b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..c6edcd90486dd5a853cf7d34c8647f08414ca7a3 --- /dev/null +++ b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/entry/hvigorfile.ts @@ -0,0 +1,6 @@ +import { hapTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/PerformanceOptimization/AppColdStart/HapAndHarDependHar/entry/obfuscation-rules.txt b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..985b2aeb7658286b17bd26eab8f217c3fe75ea8b --- /dev/null +++ b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/entry/obfuscation-rules.txt @@ -0,0 +1,18 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://gitee.com/openharmony/arkcompiler_ets_frontend/blob/master/arkguard/README.md + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope \ No newline at end of file diff --git a/PerformanceOptimization/AppColdStart/HapAndHarDependHar/entry/oh-package.json5 b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..0fde17fdf11b4e1e509993c6079ea76c582de11a --- /dev/null +++ b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/entry/oh-package.json5 @@ -0,0 +1,13 @@ +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "har_library": "file:../library", + "har_common": "file:../har_common" + } +} + diff --git a/PerformanceOptimization/AppColdStart/HapAndHarDependHar/entry/src/main/ets/entryability/EntryAbility.ets b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..aa7b8e4d139fe8671c5a382b0f8b80e5335c6c52 --- /dev/null +++ b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,57 @@ +/* +* Copyright (C) 2024 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/PerformanceOptimization/AppColdStart/HapAndHarDependHar/entry/src/main/ets/pages/Index.ets b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..6413cae7d4867bc242c0a89f91d560ffd08780a2 --- /dev/null +++ b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,35 @@ +/* +* Copyright (C) 2024 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// DocsCode 1 +// entry/src/main/ets/pages/Index.ets +import { MainPage } from 'har_library'; +import { funcResult } from 'har_common'; +// DocsCode 1 + +@Entry +@Component +struct Index { + @State message: string = 'Hello World' + funcResult; + + build() { + Row() { + // 引用HAR的ArkUI组件 + MainPage() + } + .height('100%') + .width('100%') + } +} diff --git a/PerformanceOptimization/AppColdStart/HapAndHarDependHar/entry/src/main/module.json5 b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..3b355d125c7bb7b28090d101652243c5facbd9ba --- /dev/null +++ b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/entry/src/main/module.json5 @@ -0,0 +1,36 @@ +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "phone" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:layered_image", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ] + } +} diff --git a/PerformanceOptimization/AppColdStart/HapAndHarDependHar/entry/src/main/resources/base/element/color.json b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/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/PerformanceOptimization/AppColdStart/HapAndHarDependHar/entry/src/main/resources/base/element/string.json b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..f94595515a99e0c828807e243494f57f09251930 --- /dev/null +++ b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/entry/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/PerformanceOptimization/AppColdStart/HapAndHarDependHar/entry/src/main/resources/base/media/background.png b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d Binary files /dev/null and b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/entry/src/main/resources/base/media/background.png differ diff --git a/PerformanceOptimization/AppColdStart/HapAndHarDependHar/entry/src/main/resources/base/media/foreground.png b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902 Binary files /dev/null and b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/entry/src/main/resources/base/media/foreground.png differ diff --git a/PerformanceOptimization/AppColdStart/HapAndHarDependHar/entry/src/main/resources/base/media/layered_image.json b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/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/PerformanceOptimization/AppColdStart/HapAndHarDependHar/entry/src/main/resources/base/media/startIcon.png b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/entry/src/main/resources/base/media/startIcon.png differ diff --git a/PerformanceOptimization/AppColdStart/HapAndHarDependHar/entry/src/main/resources/base/profile/main_pages.json b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce --- /dev/null +++ b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/PerformanceOptimization/AppColdStart/HapAndHarDependHar/har_common/Index.ets b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/har_common/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..557674ecc19a7d3bf7692082e2713e2e6883fcf0 --- /dev/null +++ b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/har_common/Index.ets @@ -0,0 +1,16 @@ +/* +* Copyright (C) 2024 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +export { funcResult } from './src/main/ets/utils/Utils'; \ No newline at end of file diff --git a/PerformanceOptimization/AppColdStart/HapAndHarDependHar/har_common/build-profile.json5 b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/har_common/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..697dff23e224373edb713dc2b8a08ed7341d5b4c --- /dev/null +++ b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/har_common/build-profile.json5 @@ -0,0 +1,31 @@ +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": true, + "files": [ + "./obfuscation-rules.txt" + ] + }, + "consumerFiles": [ + "./consumer-rules.txt" + ] + } + }, + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest" + } + ] +} diff --git a/PerformanceOptimization/AppColdStart/HapAndHarDependHar/har_common/consumer-rules.txt b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/har_common/consumer-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/PerformanceOptimization/AppColdStart/HapAndHarDependHar/har_common/hvigorfile.ts b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/har_common/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..42187071482d292588ad40babeda74f7b8d97a23 --- /dev/null +++ b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/har_common/hvigorfile.ts @@ -0,0 +1,6 @@ +import { harTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: harTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/PerformanceOptimization/AppColdStart/HapAndHarDependHar/har_common/obfuscation-rules.txt b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/har_common/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..985b2aeb7658286b17bd26eab8f217c3fe75ea8b --- /dev/null +++ b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/har_common/obfuscation-rules.txt @@ -0,0 +1,18 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://gitee.com/openharmony/arkcompiler_ets_frontend/blob/master/arkguard/README.md + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope \ No newline at end of file diff --git a/PerformanceOptimization/AppColdStart/HapAndHarDependHar/har_common/oh-package.json5 b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/har_common/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..c9288aefd5fa8348c6967366470b24384f1b52a0 --- /dev/null +++ b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/har_common/oh-package.json5 @@ -0,0 +1,10 @@ +{ + "name": "har_common", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "Index.ets", + "author": "", + "license": "Apache-2.0", + "dependencies": { + } +} diff --git a/PerformanceOptimization/AppColdStart/HapAndHarDependHar/har_common/src/main/ets/components/mainpage/MainPage.ets b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/har_common/src/main/ets/components/mainpage/MainPage.ets new file mode 100644 index 0000000000000000000000000000000000000000..8fe31bb9fbcd035b0eddfd578f9b01099a294585 --- /dev/null +++ b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/har_common/src/main/ets/components/mainpage/MainPage.ets @@ -0,0 +1,31 @@ +/* +* Copyright (C) 2024 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +@Component +export struct MainPage { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} diff --git a/PerformanceOptimization/AppColdStart/HapAndHarDependHar/har_common/src/main/ets/utils/Utils.ets b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/har_common/src/main/ets/utils/Utils.ets new file mode 100644 index 0000000000000000000000000000000000000000..e22b4f60a4e92b96f9ecc8d1bb897af3994e8e8b --- /dev/null +++ b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/har_common/src/main/ets/utils/Utils.ets @@ -0,0 +1,26 @@ +/* +* Copyright (C) 2024 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +const LARGE_NUMBER = 100000000; + +function func(): number { + let count = 0; + while (count < LARGE_NUMBER) { + count++; + } + return count; +} + +export let funcResult = func(); \ No newline at end of file diff --git a/PerformanceOptimization/AppColdStart/HapAndHarDependHar/har_common/src/main/module.json5 b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/har_common/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..b26580cd6a0aa8c7df3ca1fc657f963a1b1b4ef4 --- /dev/null +++ b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/har_common/src/main/module.json5 @@ -0,0 +1,11 @@ +{ + "module": { + "name": "har_common", + "type": "har", + "deviceTypes": [ + "default", + "tablet", + "2in1" + ] + } +} diff --git a/PerformanceOptimization/AppColdStart/HapAndHarDependHar/har_common/src/main/resources/base/element/string.json b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/har_common/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..f51a9c8461a55f6312ef950344e3145b7f82d607 --- /dev/null +++ b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/har_common/src/main/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "page_show", + "value": "page from package" + } + ] +} diff --git a/PerformanceOptimization/AppColdStart/HapAndHarDependHar/hvigor/hvigor-config.json5 b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..06b2783670a348f95533b352c1ceda909a842bbc --- /dev/null +++ b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/hvigor/hvigor-config.json5 @@ -0,0 +1,22 @@ +{ + "modelVersion": "5.0.0", + "dependencies": { + }, + "execution": { + // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */ + // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */ + // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */ + // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */ + // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */ + }, + "logging": { + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ + }, + "debugging": { + // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */ + }, + "nodeOptions": { + // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/ + // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/ + } +} diff --git a/PerformanceOptimization/AppColdStart/HapAndHarDependHar/hvigorfile.ts b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..f3cb9f1a87a81687554a76283af8df27d8bda775 --- /dev/null +++ b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/hvigorfile.ts @@ -0,0 +1,6 @@ +import { appTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/PerformanceOptimization/AppColdStart/HapAndHarDependHar/library/Index.ets b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/library/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..6f8afc6e836c6ca8e21cba85918b0495bbc721bb --- /dev/null +++ b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/library/Index.ets @@ -0,0 +1,19 @@ +/* +* Copyright (C) 2024 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// [Start not_recommend_demo] +export { MainPage } from './src/main/ets/components/mainpage/MainPage'; // 冷启动强相关文件 +export { SubPage } from './src/main/ets/components/mainpage/SubPage'; // 非冷启动强相关文件 +// [End not_recommend_demo] diff --git a/PerformanceOptimization/AppColdStart/HapAndHarDependHar/library/IndexAppStart.ets b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/library/IndexAppStart.ets new file mode 100644 index 0000000000000000000000000000000000000000..a55bfcfabc6016ed7fd6eeaa58330490fa1f3d80 --- /dev/null +++ b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/library/IndexAppStart.ets @@ -0,0 +1,4 @@ +// [Start export_main_page] +// library/IndexAppStart.ets +export { MainPage } from './src/main/ets/components/mainpage/MainPage'; +// [End export_main_page] \ No newline at end of file diff --git a/PerformanceOptimization/AppColdStart/HapAndHarDependHar/library/IndexOthers.ets b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/library/IndexOthers.ets new file mode 100644 index 0000000000000000000000000000000000000000..23247b428a49453900fe6d89cafec3841914c5bd --- /dev/null +++ b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/library/IndexOthers.ets @@ -0,0 +1,4 @@ +// [Start export_sub_page] +// library/IndexOthers.ets +export { SubPage } from './src/main/ets/components/mainpage/SubPage'; +// [End export_sub_page] \ No newline at end of file diff --git a/PerformanceOptimization/AppColdStart/HapAndHarDependHar/library/build-profile.json5 b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/library/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..697dff23e224373edb713dc2b8a08ed7341d5b4c --- /dev/null +++ b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/library/build-profile.json5 @@ -0,0 +1,31 @@ +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": true, + "files": [ + "./obfuscation-rules.txt" + ] + }, + "consumerFiles": [ + "./consumer-rules.txt" + ] + } + }, + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest" + } + ] +} diff --git a/PerformanceOptimization/AppColdStart/HapAndHarDependHar/library/consumer-rules.txt b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/library/consumer-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/PerformanceOptimization/AppColdStart/HapAndHarDependHar/library/hvigorfile.ts b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/library/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..42187071482d292588ad40babeda74f7b8d97a23 --- /dev/null +++ b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/library/hvigorfile.ts @@ -0,0 +1,6 @@ +import { harTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: harTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/PerformanceOptimization/AppColdStart/HapAndHarDependHar/library/obfuscation-rules.txt b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/library/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..985b2aeb7658286b17bd26eab8f217c3fe75ea8b --- /dev/null +++ b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/library/obfuscation-rules.txt @@ -0,0 +1,18 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://gitee.com/openharmony/arkcompiler_ets_frontend/blob/master/arkguard/README.md + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope \ No newline at end of file diff --git a/PerformanceOptimization/AppColdStart/HapAndHarDependHar/library/oh-package.json5 b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/library/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..3824a8247b7ff16278737ec539e98f7b88a8de55 --- /dev/null +++ b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/library/oh-package.json5 @@ -0,0 +1,11 @@ +{ + "name": "har_library", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "Index.ets", + "author": "", + "license": "Apache-2.0", + "dependencies": { + "har_common": "file:../har_common" + } +} diff --git a/PerformanceOptimization/AppColdStart/HapAndHarDependHar/library/src/main/ets/components/mainpage/MainPage.ets b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/library/src/main/ets/components/mainpage/MainPage.ets new file mode 100644 index 0000000000000000000000000000000000000000..f08845bef3153cdb35ecbc1834d3d1df29507132 --- /dev/null +++ b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/library/src/main/ets/components/mainpage/MainPage.ets @@ -0,0 +1,33 @@ +/* +* Copyright (C) 2024 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// [Start not_recommend_demo] +// library/src/main/ets/components/mainpage/MainPage.ets +@Component +export struct MainPage { + @Consume pathStack: NavPathStack; + @State message: string = 'HAR MainPage'; + + build() { + Row() { + Text(this.message) + .fontSize(32) + .fontWeight(FontWeight.Bold) + }.onClick(() => { + this.pathStack.pushPath({ name: 'SecondPage' }); + }) + } +} + // [End not_recommend_demo] \ No newline at end of file diff --git a/PerformanceOptimization/AppColdStart/HapAndHarDependHar/library/src/main/ets/components/mainpage/SubPage.ets b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/library/src/main/ets/components/mainpage/SubPage.ets new file mode 100644 index 0000000000000000000000000000000000000000..5d9893548432c492579940234cc5ab33ad7b0a64 --- /dev/null +++ b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/library/src/main/ets/components/mainpage/SubPage.ets @@ -0,0 +1,14 @@ +// [Start not_recommend_demo] +// library/src/main/ets/components/mainpage/SubPage.ets +// SubPage中的全局耗时函数 +const LARGE_NUMBER = 10000000; +function computeTask(): number { + let count = 0; + while (count < LARGE_NUMBER) { + count++; + } + return count; +} +let count = computeTask(); +// ... +// [End not_recommend_demo] \ No newline at end of file diff --git a/PerformanceOptimization/AppColdStart/HapAndHarDependHar/library/src/main/module.json5 b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/library/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..2892dab4fe007cb1eda74bd7189f3a55159038ff --- /dev/null +++ b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/library/src/main/module.json5 @@ -0,0 +1,11 @@ +{ + "module": { + "name": "har_library", + "type": "har", + "deviceTypes": [ + "default", + "tablet", + "2in1" + ] + } +} diff --git a/PerformanceOptimization/AppColdStart/HapAndHarDependHar/library/src/main/resources/base/element/string.json b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/library/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..f51a9c8461a55f6312ef950344e3145b7f82d607 --- /dev/null +++ b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/library/src/main/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "page_show", + "value": "page from package" + } + ] +} diff --git a/PerformanceOptimization/AppColdStart/HapAndHarDependHar/library/src/main/resources/en_US/element/string.json b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/library/src/main/resources/en_US/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..f51a9c8461a55f6312ef950344e3145b7f82d607 --- /dev/null +++ b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/library/src/main/resources/en_US/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "page_show", + "value": "page from package" + } + ] +} diff --git a/PerformanceOptimization/AppColdStart/HapAndHarDependHar/library/src/main/resources/zh_CN/element/string.json b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/library/src/main/resources/zh_CN/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..f51a9c8461a55f6312ef950344e3145b7f82d607 --- /dev/null +++ b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/library/src/main/resources/zh_CN/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "page_show", + "value": "page from package" + } + ] +} diff --git a/PerformanceOptimization/AppColdStart/HapAndHarDependHar/oh-package.json5 b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..8bf916d4a165e0466c65bc49f58ab2e3c27e8931 --- /dev/null +++ b/PerformanceOptimization/AppColdStart/HapAndHarDependHar/oh-package.json5 @@ -0,0 +1,8 @@ +{ + "modelVersion": "5.0.0", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + } +} diff --git a/PerformanceOptimization/AppColdStart/build-profile.json5 b/PerformanceOptimization/AppColdStart/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..9e87e7e6f19020fe21192844709f192cec80fd44 --- /dev/null +++ b/PerformanceOptimization/AppColdStart/build-profile.json5 @@ -0,0 +1,42 @@ +{ + "app": { + "signingConfigs": [], + "products": [ + { + "name": "default", + "signingConfig": "default", + "targetSdkVersion": "5.0.5(17)", + "compatibleSdkVersion": "5.0.5(17)", + "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/PerformanceOptimization/AppColdStart/code-linter.json5 b/PerformanceOptimization/AppColdStart/code-linter.json5 new file mode 100644 index 0000000000000000000000000000000000000000..073990fa45394e1f8e85d85418ee60a8953f9b99 --- /dev/null +++ b/PerformanceOptimization/AppColdStart/code-linter.json5 @@ -0,0 +1,32 @@ +{ + "files": [ + "**/*.ets" + ], + "ignore": [ + "**/src/ohosTest/**/*", + "**/src/test/**/*", + "**/src/mock/**/*", + "**/node_modules/**/*", + "**/oh_modules/**/*", + "**/build/**/*", + "**/.preview/**/*" + ], + "ruleSet": [ + "plugin:@performance/recommended", + "plugin:@typescript-eslint/recommended" + ], + "rules": { + "@security/no-unsafe-aes": "error", + "@security/no-unsafe-hash": "error", + "@security/no-unsafe-mac": "warn", + "@security/no-unsafe-dh": "error", + "@security/no-unsafe-dsa": "error", + "@security/no-unsafe-ecdsa": "error", + "@security/no-unsafe-rsa-encrypt": "error", + "@security/no-unsafe-rsa-sign": "error", + "@security/no-unsafe-rsa-key": "error", + "@security/no-unsafe-dsa-key": "error", + "@security/no-unsafe-dh-key": "error", + "@security/no-unsafe-3des": "error" + } +} \ No newline at end of file diff --git a/PerformanceOptimization/AppColdStart/entry/.gitignore b/PerformanceOptimization/AppColdStart/entry/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/PerformanceOptimization/AppColdStart/entry/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/PerformanceOptimization/AppColdStart/entry/build-profile.json5 b/PerformanceOptimization/AppColdStart/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..4d611879c7913fb0610c686e2399258ab3a6dad1 --- /dev/null +++ b/PerformanceOptimization/AppColdStart/entry/build-profile.json5 @@ -0,0 +1,28 @@ +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/PerformanceOptimization/AppColdStart/entry/hvigorfile.ts b/PerformanceOptimization/AppColdStart/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..c6edcd90486dd5a853cf7d34c8647f08414ca7a3 --- /dev/null +++ b/PerformanceOptimization/AppColdStart/entry/hvigorfile.ts @@ -0,0 +1,6 @@ +import { hapTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/PerformanceOptimization/AppColdStart/entry/obfuscation-rules.txt b/PerformanceOptimization/AppColdStart/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/PerformanceOptimization/AppColdStart/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/PerformanceOptimization/AppColdStart/entry/oh-package.json5 b/PerformanceOptimization/AppColdStart/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..248c3b7541a589682a250f86a6d3ecf7414d2d6a --- /dev/null +++ b/PerformanceOptimization/AppColdStart/entry/oh-package.json5 @@ -0,0 +1,10 @@ +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/PerformanceOptimization/AppColdStart/entry/src/main/ets/entryability/EntryAbility.ets b/PerformanceOptimization/AppColdStart/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..3122ebd39d8ca0655442c1743ca7829584fe551d --- /dev/null +++ b/PerformanceOptimization/AppColdStart/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,16 @@ +// [Start my_ability_stage] +// MyAbilityStage.ets +import { AbilityStage, Want } from '@kit.AbilityKit'; +import { httpRequest } from '../utils/NetRequest'; +export default class MyAbilityStage extends AbilityStage { + onCreate(): void { + // 发送网络请求 + httpRequest(); + } + + onAcceptWant(want: Want): string { + // 仅specified模式下触发 + return 'MyAbilityStage'; + } +} +// [End my_ability_stage] \ No newline at end of file diff --git a/PerformanceOptimization/AppColdStart/entry/src/main/ets/entryability/EntryAbilityDemo.ets b/PerformanceOptimization/AppColdStart/entry/src/main/ets/entryability/EntryAbilityDemo.ets new file mode 100644 index 0000000000000000000000000000000000000000..f0dc3f343819e7ed2e9784f219f2c2f397ee7c4f --- /dev/null +++ b/PerformanceOptimization/AppColdStart/entry/src/main/ets/entryability/EntryAbilityDemo.ets @@ -0,0 +1,49 @@ +// [Start entry_ability_demo] +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { window } from '@kit.ArkUI' + +const LARGE_NUMBER = 100000000; +const DELAYED_TIME = 1000; + + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + // Time-consuming operation + // this.computeTask(); + this.computeTaskAsync(); // Asynchronous tasks + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + windowStage.loadContent('pages/Index', (err, data) => { + if (err.code) { + console.error('Failed to load the content. Cause: ' + JSON.stringify(err) ?? ''); + return; + } + console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data) ?? ''); + }); + + // Time-consuming operation + // this.computeTask(); + // this.computeTaskAsync(); // Asynchronous mission + } + + onForeground(): void { + // Time-consuming operation + // this.computeTask(); + // this.computeTaskAsync(); // Asynchronous mission + } + + private computeTask(): void { + let count = 0; + while (count < LARGE_NUMBER) { + count++; + } + } + + private computeTaskAsync(): void { + setTimeout(() => { // SetTimeout is used here to achieve asynchronous delayed operation. + this.computeTask(); + }, DELAYED_TIME); + } +} +// [End entry_ability_demo] \ No newline at end of file diff --git a/PerformanceOptimization/AppColdStart/entry/src/main/ets/entryability/MyAbilityStage.ets b/PerformanceOptimization/AppColdStart/entry/src/main/ets/entryability/MyAbilityStage.ets new file mode 100644 index 0000000000000000000000000000000000000000..da3225812a26ffd802864288847604a10355df15 --- /dev/null +++ b/PerformanceOptimization/AppColdStart/entry/src/main/ets/entryability/MyAbilityStage.ets @@ -0,0 +1,32 @@ +// [Start reduce_ability_stage_time] +import { AbilityStage, Want } from '@kit.AbilityKit'; + +const LARGE_NUMBER = 100000000; +const DELAYED_TIME = 1000; + +export default class MyAbilityStage extends AbilityStage { + onCreate(): void { + // Time-consuming operation + // this.computeTask(); + this.computeTaskAsync(); // Asynchronous mission + } + + onAcceptWant(want: Want): string { + // Trigger in specified mode only + return 'MyAbilityStage'; + } + + private computeTask(): void { + let count = 0; + while (count < LARGE_NUMBER) { + count++; + } + } + + private computeTaskAsync(): void { + setTimeout(() => { // SetTimeout is used here to achieve asynchronous delayed operation. + this.computeTask(); + }, DELAYED_TIME); + } +} +// [End reduce_ability_stage_time] \ No newline at end of file diff --git a/PerformanceOptimization/AppColdStart/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/PerformanceOptimization/AppColdStart/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..8e4de99282050bad799ac892eb85ac5449364a51 --- /dev/null +++ b/PerformanceOptimization/AppColdStart/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -0,0 +1,16 @@ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit'; + +const DOMAIN = 0x0000; + +export default class EntryBackupAbility extends BackupExtensionAbility { + async onBackup() { + hilog.info(DOMAIN, 'testTag', 'onBackup ok'); + await Promise.resolve(); + } + + async onRestore(bundleVersion: BundleVersion) { + hilog.info(DOMAIN, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion)); + await Promise.resolve(); + } +} \ No newline at end of file diff --git a/PerformanceOptimization/AppColdStart/entry/src/main/ets/pages/ColdStartSlow.ets b/PerformanceOptimization/AppColdStart/entry/src/main/ets/pages/ColdStartSlow.ets new file mode 100644 index 0000000000000000000000000000000000000000..fd03ac97033a5cce90ea14d9c6daf2532259a6be --- /dev/null +++ b/PerformanceOptimization/AppColdStart/entry/src/main/ets/pages/ColdStartSlow.ets @@ -0,0 +1,34 @@ +// [Start cold_start_slow] +const LARGE_NUMBER = 200000000; +const DELAYED_TIME = 1000; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + aboutToAppear(): void { + console.log('aboutToAppear'); + this.computeTask(); + } + + computeTask(): void { + let count = 0; + while (count < LARGE_NUMBER) { + count++; + } + } + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} +// [End cold_start_slow] \ No newline at end of file diff --git a/PerformanceOptimization/AppColdStart/entry/src/main/ets/pages/ColdStartSpeedOptimization.ets b/PerformanceOptimization/AppColdStart/entry/src/main/ets/pages/ColdStartSpeedOptimization.ets new file mode 100644 index 0000000000000000000000000000000000000000..94550b28811d4d937e07fb9bcf7e845fc78dbe76 --- /dev/null +++ b/PerformanceOptimization/AppColdStart/entry/src/main/ets/pages/ColdStartSpeedOptimization.ets @@ -0,0 +1,43 @@ +// [Start cold_start_speed_optimization] +const LARGE_NUMBER = 100000000; +const DELAYED_TIME = 1000; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + aboutToAppear(): void { + console.log('aboutToAppear'); + this.computeTaskAsync(); + } + + // [StartExclude cold_start_speed_optimization] + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } + // [EndExclude cold_start_speed_optimization] + + computeTask(): void { + let count = 0; + while (count < LARGE_NUMBER) { + count++; + } + } + + // 运算任务异步处理 + private computeTaskAsync(): void { + setTimeout(() => { // 这里使用setTimeout来实现异步延迟运行 + this.computeTask(); + }, DELAYED_TIME); + } +} +// [End cold_start_speed_optimization] \ No newline at end of file diff --git a/PerformanceOptimization/AppColdStart/entry/src/main/ets/pages/ComputeTaskAsync.ets b/PerformanceOptimization/AppColdStart/entry/src/main/ets/pages/ComputeTaskAsync.ets new file mode 100644 index 0000000000000000000000000000000000000000..53d1a1a4f24078e2406316888d23104d0edaaafe --- /dev/null +++ b/PerformanceOptimization/AppColdStart/entry/src/main/ets/pages/ComputeTaskAsync.ets @@ -0,0 +1,42 @@ +// [Start compute_task_async] +const LARGE_NUMBER = 100000000; +const DELAYED_TIME = 1000; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + aboutToAppear(): void { + // Time-consuming operation + // this.computeTask(); + this.computeTaskAsync(); // Asynchronous tasks + } + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } + + private computeTask(): void { + let count = 0; + while (count < LARGE_NUMBER) { + count++; + } + } + + // Asynchronous processing of computing tasks + private computeTaskAsync(): void { + setTimeout(() => { // SetTimeout is used here to achieve asynchronous delayed operation. + this.computeTask(); + }, DELAYED_TIME); + } +} +// [End compute_task_async] \ No newline at end of file diff --git a/PerformanceOptimization/AppColdStart/entry/src/main/ets/pages/ImportMainPage.ets b/PerformanceOptimization/AppColdStart/entry/src/main/ets/pages/ImportMainPage.ets new file mode 100644 index 0000000000000000000000000000000000000000..581fc19ec1e16d748f5a674c9164b669664856f2 --- /dev/null +++ b/PerformanceOptimization/AppColdStart/entry/src/main/ets/pages/ImportMainPage.ets @@ -0,0 +1,21 @@ +// [Start import_main_page] +// Index.ets +import { MainPage } from 'library/IndexAppStart'; + +@Entry +@Component +struct Index { + @Provide pathStack: NavPathStack = new NavPathStack(); + + build() { + Navigation(this.pathStack) { + Row() { + // Refer to the custom components of HAR + MainPage() + } + } + .height('100%') + .width('100%') + } +} +// [End import_main_page] \ No newline at end of file diff --git a/PerformanceOptimization/AppColdStart/entry/src/main/ets/pages/ImportMainPageDemo.ets b/PerformanceOptimization/AppColdStart/entry/src/main/ets/pages/ImportMainPageDemo.ets new file mode 100644 index 0000000000000000000000000000000000000000..b348b090bde12e91d74342d1f8430bcff0465ebf --- /dev/null +++ b/PerformanceOptimization/AppColdStart/entry/src/main/ets/pages/ImportMainPageDemo.ets @@ -0,0 +1,21 @@ +// [Start import_main_page_demo] +// Index.ets +import { MainPage } from 'library/src/main/ets/components/mainpage/MainPage'; + +@Entry +@Component +struct Index { + @Provide pathStack: NavPathStack = new NavPathStack(); + + build() { + Navigation(this.pathStack) { + Row() { + // Refer to the custom components of HAR + MainPage() + } + } + .height('100%') + .width('100%') + } +} +// [End import_main_page_demo] \ No newline at end of file diff --git a/PerformanceOptimization/AppColdStart/entry/src/main/ets/pages/ImportOthers.ets b/PerformanceOptimization/AppColdStart/entry/src/main/ets/pages/ImportOthers.ets new file mode 100644 index 0000000000000000000000000000000000000000..c867ddd5d95672a010cbb35a16080c761cb13457 --- /dev/null +++ b/PerformanceOptimization/AppColdStart/entry/src/main/ets/pages/ImportOthers.ets @@ -0,0 +1,22 @@ +// [Start import_others] +import { add } from 'hsp1'; +import { add2 } from 'hsp2'; +import { add3 } from 'hsp3'; +import { add4 } from 'hsp4'; +import { add5 } from 'hsp5'; +import { add6 } from 'hsp6'; +import { add7 } from 'hsp7'; +import { add8 } from 'hsp8'; +import { add9 } from 'hsp9'; +import { add10 } from 'hsp10'; +import { add11 } from 'hsp11'; +import { add12 } from 'hsp12'; +import { add13 } from 'hsp13'; +import { add14 } from 'hsp14'; +import { add15 } from 'hsp15'; +import { add16 } from 'hsp16'; +import { add17 } from 'hsp17'; +import { add18 } from 'hsp18'; +import { add19 } from 'hsp19'; +import { add20 } from 'hsp20' +// [End import_others] \ No newline at end of file diff --git a/PerformanceOptimization/AppColdStart/entry/src/main/ets/pages/ImportSubPage.ets b/PerformanceOptimization/AppColdStart/entry/src/main/ets/pages/ImportSubPage.ets new file mode 100644 index 0000000000000000000000000000000000000000..61c1be1d1ecb55d7dc957d1bc6254cbbd4ae3996 --- /dev/null +++ b/PerformanceOptimization/AppColdStart/entry/src/main/ets/pages/ImportSubPage.ets @@ -0,0 +1,28 @@ +// [Start import_sub_page] +// SecondPage.ets +import { SubPage } from 'library/IndexOthers'; + +@Builder +export function SecondPageBuilder() { + SecondPage() +} + +@Entry +@Component +struct SecondPage { + pathStack: NavPathStack = new NavPathStack(); + + build() { + NavDestination() { + Row() { + // Refer to the custom components of HAR + SubPage() + } + .height('100%') + } + .onReady((context: NavDestinationContext) => { + this.pathStack = context.pathStack; + }) + } +} +// [End import_sub_page] \ No newline at end of file diff --git a/PerformanceOptimization/AppColdStart/entry/src/main/ets/pages/Index.ets b/PerformanceOptimization/AppColdStart/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..13b64258e8c48209fdb0ced0bc1f6bf10f9acf7d --- /dev/null +++ b/PerformanceOptimization/AppColdStart/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,28 @@ +// [Start request_in_home] +// entry/src/main/ets/pages/Index.ets +import { httpRequest } from '../utils/NetRequest'; + +import { number } from '../utils/Calculator'; + +AppStorage.link('netData'); +PersistentStorage.persistProp('netData', undefined); + +@Entry +@Component +struct Index { + @State message: string = 'Hello World' + number; // In order to reflect the performance benefits, refer to the execution result number of the time-consuming function. + @StorageLink('netData') netData: PixelMap | undefined = undefined; + build(){ + Row(){ + Image(this.netData) + .objectFit(ImageFit.Contain) + .width('50%') + .height('50%') + } + .onAppear(() => { + // Send a network request + httpRequest(); + }) + } +} +// [End request_in_home] diff --git a/PerformanceOptimization/AppColdStart/entry/src/main/ets/pages/NewIndex.ets b/PerformanceOptimization/AppColdStart/entry/src/main/ets/pages/NewIndex.ets new file mode 100644 index 0000000000000000000000000000000000000000..cd0605ce633c12bf9e38c17ac51ab5f146c7adb6 --- /dev/null +++ b/PerformanceOptimization/AppColdStart/entry/src/main/ets/pages/NewIndex.ets @@ -0,0 +1,27 @@ +// [Start new_index] +// Index.ets +import { number } from '../utils/Calculator'; + +AppStorage.link('netData'); +PersistentStorage.persistProp('netData', undefined); + +@Entry +@Component +struct Index { + @State message: string = 'Hello World' + number; // In order to reflect the performance benefits, refer to the execution result number of the time-consuming function. + @StorageLink('netData') netData: PixelMap | undefined = undefined; + build() { + Row() { + Image(this.netData) + .objectFit(ImageFit.Contain) + .width('50%') + .height('50%') + } + .onDisAppear(() => { + AppStorage.set('netData', undefined); + }) + .height('100%') + .width('100%') + } +} +// [End new_index] \ No newline at end of file diff --git a/PerformanceOptimization/AppColdStart/entry/src/main/ets/pages/NotRecommendDemo.ets b/PerformanceOptimization/AppColdStart/entry/src/main/ets/pages/NotRecommendDemo.ets new file mode 100644 index 0000000000000000000000000000000000000000..87ea199a85fc04ffa253b8543e63c0dad76dbdf2 --- /dev/null +++ b/PerformanceOptimization/AppColdStart/entry/src/main/ets/pages/NotRecommendDemo.ets @@ -0,0 +1,16 @@ +// [Start not_recommend_demo] +// entry/src/main/ets/pages/Index.ets +import { MainPage } from 'library/Index'; // Unrecommended usage: Direct import of subPage.ets files related to cold start non-strong +@Component +export struct Index{ + @Provide pathStack: NavPathStack = new NavPathStack(); + build() { + Navigation(this.pathStack) { + Row() { + // Refer to the custom components of HAR + MainPage() + } + } + } +} +// [End not_recommend_demo] \ No newline at end of file diff --git a/PerformanceOptimization/AppColdStart/entry/src/main/ets/pages/ReduceImport.ets b/PerformanceOptimization/AppColdStart/entry/src/main/ets/pages/ReduceImport.ets new file mode 100644 index 0000000000000000000000000000000000000000..6d499cce99f72ca10ddc81a67811effc26a39f6f --- /dev/null +++ b/PerformanceOptimization/AppColdStart/entry/src/main/ets/pages/ReduceImport.ets @@ -0,0 +1,19 @@ +// [Start reduce_import] +// 优化减少import的模块 +/*import { ConfigurationConstant, contextConstant, wantConstant } from '@kit.AbilityKit'; +import { GesturePath, GesturePoint } from '@kit.AccessibilityKit'; +import { distributedAccount, osAccount } from '@kit.BasicServicesKit'; +import { Configuration } from '@kit.ArkUI'; +import { atomicService } from '@kit.ScenarioFusionKit'; +import { sim } from '@kit.TelephonyKit';*/ + + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + + +export default class EntryAbility extends UIAbility { + // ... +} +// [End reduce_import] \ No newline at end of file diff --git a/PerformanceOptimization/AppColdStart/entry/src/main/ets/pages/ScenariosExample.ets b/PerformanceOptimization/AppColdStart/entry/src/main/ets/pages/ScenariosExample.ets new file mode 100644 index 0000000000000000000000000000000000000000..29dfe398389119b45eac6c2fc01272d646eaec0e --- /dev/null +++ b/PerformanceOptimization/AppColdStart/entry/src/main/ets/pages/ScenariosExample.ets @@ -0,0 +1,122 @@ +// [Start scenarios_example] +// Index.ets +import { http } from '@kit.NetworkKit'; +import { image } from '@kit.ImageKit'; +import { BusinessError } from '@kit.BasicServicesKit'; +import { abilityAccessCtrl, common, Permissions } from '@kit.AbilityKit'; +import { fileIo as fs } from '@kit.CoreFileKit'; + +const PERMISSIONS: Array = [ + 'ohos.permission.READ_MEDIA', + 'ohos.permission.WRITE_MEDIA' +]; +AppStorage.link('net_picture'); +PersistentStorage.persistProp('net_picture', ''); + +@Entry +@Component +struct Index { + @State image: PixelMap | undefined = undefined; + @State imageBuffer: ArrayBuffer | undefined = undefined; // Picture ArrayBuffer + + /** + * Download picture resources from the Internet through the http request method + */ + async getPicture() { + http.createHttp() + .request('https://www.example1.com/POST?e=f&g=h', + (error: BusinessError, data: http.HttpResponse) => { + if (error) { + return; + } + // Determine whether the resources obtained by the network are of the ArrayBuffer type. + if (data.result instanceof ArrayBuffer) { + this.imageBuffer = data.result as ArrayBuffer; + } + this.transcodePixelMap(data); + } + ) + } + + /** + * Use createPixelMap to replace pictures of ArrayBuffer type with PixelMap type + * @param data:Resources obtained from the network + */ + transcodePixelMap(data: http.HttpResponse) { + if (http.ResponseCode.OK === data.responseCode) { + const imageData: ArrayBuffer = data.result as ArrayBuffer; + // Create a picture source instance through ArrayBuffer + const imageSource: image.ImageSource = image.createImageSource(imageData); + const options: image.InitializationOptions = { + 'alphaType': 0, // Transparency + 'editable': false, // Is it editable? + 'pixelFormat': 3, // Pixel format + 'scaleMode': 1, // Abbreviation + 'size': { height: 100, width: 100 } + }; // Create the size of the picture + + // Create PixelMap through attributes + imageSource.createPixelMap(options).then((pixelMap: PixelMap) => { + this.image = pixelMap; + setTimeout(() => { + if (this.imageBuffer !== undefined) { + this.saveImage(this.imageBuffer); + } + }, 0) + }); + } + } + + + /** + * 保存ArrayBuffer到沙箱路径 + * @param buffer:图片ArrayBuffer + * @returns + */ + async saveImage(buffer: ArrayBuffer | string): Promise { + const context = this.getUIContext().getHostContext() as common.UIAbilityContext; + const filePath: string = context.cacheDir + '/test.jpg'; + AppStorage.set('net_picture', filePath); + const file = await fs.open(filePath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE); + await fs.write(file.fd, buffer); + await fs.close(file.fd); + } + + + async useCachePic(): Promise { + if (AppStorage.get('net_picture') !== '') { + // 获取图片的ArrayBuffer + const imageSource: image.ImageSource = image.createImageSource(AppStorage.get('net_picture')); + const options: image.InitializationOptions = { + 'alphaType': 0, // 透明度 + 'editable': false, // 是否可编辑 + 'pixelFormat': 3, // 像素格式 + 'scaleMode': 1, // 缩略值 + 'size': { height: 100, width: 100 } + }; + imageSource.createPixelMap(options).then((pixelMap: PixelMap) => { + this.image = pixelMap; + }); + } + } + + + async aboutToAppear(): Promise { + const context = this.getUIContext().getHostContext() as common.UIAbilityContext; + const atManager = abilityAccessCtrl.createAtManager(); + await atManager.requestPermissionsFromUser(context, PERMISSIONS); + this.useCachePic(); // 从本地存储获取数据 + this.getPicture(); // 从网络端获取数据 + } + + + build() { + Column() { + Image(this.image) + .objectFit(ImageFit.Contain) + .width('50%') + .height('50%') + } + } +} +// [End scenarios_example] \ No newline at end of file diff --git a/PerformanceOptimization/AppColdStart/entry/src/main/ets/pages/SecondPage.ets b/PerformanceOptimization/AppColdStart/entry/src/main/ets/pages/SecondPage.ets new file mode 100644 index 0000000000000000000000000000000000000000..34891c80268b250c5cc7396ddce787b4859c427d --- /dev/null +++ b/PerformanceOptimization/AppColdStart/entry/src/main/ets/pages/SecondPage.ets @@ -0,0 +1,25 @@ +// [Start not_recommend_demo] +// entry/src/main/ets/pages/SecondPage.ets +import { SubPage } from 'library/Index'; +@Builder +export function SecondPageBuilder() { + SecondPage() +} +@Entry +@Component +struct SecondPage { + pathStack: NavPathStack = new NavPathStack(); + build() { + NavDestination() { + Row() { + // Refer to the custom components of HAR + SubPage() + } + .height('100%') + } + .onReady((context: NavDestinationContext) => { + this.pathStack = context.pathStack; + }) + } +} +// [End not_recommend_demo] \ No newline at end of file diff --git a/PerformanceOptimization/AppColdStart/entry/src/main/ets/utils/Calculator.ets b/PerformanceOptimization/AppColdStart/entry/src/main/ets/utils/Calculator.ets new file mode 100644 index 0000000000000000000000000000000000000000..d41b4edcf2722dbfbc5647edfbc2da8d54447c74 --- /dev/null +++ b/PerformanceOptimization/AppColdStart/entry/src/main/ets/utils/Calculator.ets @@ -0,0 +1,13 @@ +// [Start request_in_home] +// Calculator.ets +const LARGE_NUMBER = 100000000; +function computeTask(): number { + let count = 0; + while (count < LARGE_NUMBER) { + count++; + } + return count; +} + +export let number = computeTask(); +// [End request_in_home] diff --git a/PerformanceOptimization/AppColdStart/entry/src/main/ets/utils/NetRequest.ets b/PerformanceOptimization/AppColdStart/entry/src/main/ets/utils/NetRequest.ets new file mode 100644 index 0000000000000000000000000000000000000000..296eed70650e67c83b9bfe173103e6c724c67301 --- /dev/null +++ b/PerformanceOptimization/AppColdStart/entry/src/main/ets/utils/NetRequest.ets @@ -0,0 +1,46 @@ +// [Start request_in_home] +// [Start net_request] +// NetRequest.ets +import { hiTraceMeter } from '@kit.PerformanceAnalysisKit'; +import { http } from '@kit.NetworkKit'; +import { BusinessError } from '@kit.BasicServicesKit'; +import { image } from '@kit.ImageKit'; +// Download picture resources from the Internet through the http request method +export function httpRequest() { + hiTraceMeter.startTrace('Http Request', 1); + http.createHttp() + // The actual development needs to "https://www.example1.com/POST? E=f&g=h"replaced with the real website address to visit + .request('https://www.example1.com/POST?e=f&g=h', + (error: BusinessError, data: http.HttpResponse) => { + if (error) { + // The follow-up logic is not executed when the download fails. + return; + } + // Processing the data returned by network requests + transcodePixelMap(data); + } + ) +} + +// Use createPixelMap to replace pictures of ArrayBuffer types with PixelMap types. +function transcodePixelMap(data: http.HttpResponse) { + if (http.ResponseCode.OK === data.responseCode) { + const imageData: ArrayBuffer = data.result as ArrayBuffer; + // Create a picture source instance through ArrayBuffer + const imageSource: image.ImageSource = image.createImageSource(imageData); + const options: image.InitializationOptions = { + 'alphaType': 0, // Transparency + 'editable': false, // Is it editable? + 'pixelFormat': 3, // Pixel format + 'scaleMode': 1, // Abbreviation + 'size': { height: 100, width: 100 } + }; // Create the size of the picture + // Create PixelMap through properties + imageSource.createPixelMap(options).then((pixelMap: PixelMap) => { + AppStorage.set('netData', pixelMap); + hiTraceMeter.finishTrace('Http Request', 1); + }); + } +} +// [End net_request] +// [End request_in_home] diff --git a/PerformanceOptimization/AppColdStart/entry/src/main/module.json5 b/PerformanceOptimization/AppColdStart/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..ad219d733f6afa5ea07f85f580208b08cc3b9041 --- /dev/null +++ b/PerformanceOptimization/AppColdStart/entry/src/main/module.json5 @@ -0,0 +1,50 @@ +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "phone" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:layered_image", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "EntryBackupAbility", + "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets", + "type": "backup", + "exported": false, + "metadata": [ + { + "name": "ohos.extension.backup", + "resource": "$profile:backup_config" + } + ], + } + ] + } +} \ No newline at end of file diff --git a/PerformanceOptimization/AppColdStart/entry/src/main/resources/base/element/color.json b/PerformanceOptimization/AppColdStart/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/PerformanceOptimization/AppColdStart/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/PerformanceOptimization/AppColdStart/entry/src/main/resources/base/element/float.json b/PerformanceOptimization/AppColdStart/entry/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..33ea22304f9b1485b5f22d811023701b5d4e35b6 --- /dev/null +++ b/PerformanceOptimization/AppColdStart/entry/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} diff --git a/PerformanceOptimization/AppColdStart/entry/src/main/resources/base/element/string.json b/PerformanceOptimization/AppColdStart/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..f94595515a99e0c828807e243494f57f09251930 --- /dev/null +++ b/PerformanceOptimization/AppColdStart/entry/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/PerformanceOptimization/AppColdStart/entry/src/main/resources/base/media/background.png b/PerformanceOptimization/AppColdStart/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/PerformanceOptimization/AppColdStart/entry/src/main/resources/base/media/background.png differ diff --git a/PerformanceOptimization/AppColdStart/entry/src/main/resources/base/media/foreground.png b/PerformanceOptimization/AppColdStart/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/PerformanceOptimization/AppColdStart/entry/src/main/resources/base/media/foreground.png differ diff --git a/PerformanceOptimization/AppColdStart/entry/src/main/resources/base/media/layered_image.json b/PerformanceOptimization/AppColdStart/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/PerformanceOptimization/AppColdStart/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/PerformanceOptimization/AppColdStart/entry/src/main/resources/base/media/startIcon.png b/PerformanceOptimization/AppColdStart/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/PerformanceOptimization/AppColdStart/entry/src/main/resources/base/media/startIcon.png differ diff --git a/PerformanceOptimization/AppColdStart/entry/src/main/resources/base/profile/backup_config.json b/PerformanceOptimization/AppColdStart/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/PerformanceOptimization/AppColdStart/entry/src/main/resources/base/profile/backup_config.json @@ -0,0 +1,3 @@ +{ + "allowToBackupRestore": true +} \ No newline at end of file diff --git a/PerformanceOptimization/AppColdStart/entry/src/main/resources/base/profile/main_pages.json b/PerformanceOptimization/AppColdStart/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce --- /dev/null +++ b/PerformanceOptimization/AppColdStart/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/PerformanceOptimization/AppColdStart/entry/src/main/resources/dark/element/color.json b/PerformanceOptimization/AppColdStart/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..79b11c2747aec33e710fd3a7b2b3c94dd9965499 --- /dev/null +++ b/PerformanceOptimization/AppColdStart/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/PerformanceOptimization/AppColdStart/entry/src/mock/mock-config.json5 b/PerformanceOptimization/AppColdStart/entry/src/mock/mock-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..7a73a41bfdf76d6f793007240d80983a52f15f97 --- /dev/null +++ b/PerformanceOptimization/AppColdStart/entry/src/mock/mock-config.json5 @@ -0,0 +1,2 @@ +{ +} \ No newline at end of file diff --git a/PerformanceOptimization/AppColdStart/entry/src/ohosTest/ets/test/Ability.test.ets b/PerformanceOptimization/AppColdStart/entry/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..85c78f67579d6e31b5f5aeea463e216b9b141048 --- /dev/null +++ b/PerformanceOptimization/AppColdStart/entry/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,35 @@ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }) + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }) + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }) + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }) + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + hilog.info(0x0000, 'testTag', '%{public}s', 'it begin'); + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }) + }) +} \ No newline at end of file diff --git a/PerformanceOptimization/AppColdStart/entry/src/ohosTest/ets/test/List.test.ets b/PerformanceOptimization/AppColdStart/entry/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..794c7dc4ed66bd98fa3865e07922906e2fcef545 --- /dev/null +++ b/PerformanceOptimization/AppColdStart/entry/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,5 @@ +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/PerformanceOptimization/AppColdStart/entry/src/ohosTest/module.json5 b/PerformanceOptimization/AppColdStart/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..509a3a28a3e6be8d7f98cc563fa8195657d77d1d --- /dev/null +++ b/PerformanceOptimization/AppColdStart/entry/src/ohosTest/module.json5 @@ -0,0 +1,11 @@ +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "phone" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/PerformanceOptimization/AppColdStart/entry/src/test/List.test.ets b/PerformanceOptimization/AppColdStart/entry/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..bb5b5c3731e283dd507c847560ee59bde477bbc7 --- /dev/null +++ b/PerformanceOptimization/AppColdStart/entry/src/test/List.test.ets @@ -0,0 +1,5 @@ +import localUnitTest from './LocalUnit.test'; + +export default function testsuite() { + localUnitTest(); +} \ No newline at end of file diff --git a/PerformanceOptimization/AppColdStart/entry/src/test/LocalUnit.test.ets b/PerformanceOptimization/AppColdStart/entry/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..165fc1615ee8618b4cb6a622f144a9a707eee99f --- /dev/null +++ b/PerformanceOptimization/AppColdStart/entry/src/test/LocalUnit.test.ets @@ -0,0 +1,33 @@ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function localUnitTest() { + describe('localUnitTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }); + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }); + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }); + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }); + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }); + }); +} \ No newline at end of file diff --git a/PerformanceOptimization/AppColdStart/hvigor/hvigor-config.json5 b/PerformanceOptimization/AppColdStart/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..5bebc9755447385d82ce4138f54d991b1f85f348 --- /dev/null +++ b/PerformanceOptimization/AppColdStart/hvigor/hvigor-config.json5 @@ -0,0 +1,22 @@ +{ + "modelVersion": "5.0.5", + "dependencies": { + }, + "execution": { + // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */ + // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */ + // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */ + // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */ + // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */ + }, + "logging": { + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ + }, + "debugging": { + // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */ + }, + "nodeOptions": { + // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/ + // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/ + } +} diff --git a/PerformanceOptimization/AppColdStart/hvigorfile.ts b/PerformanceOptimization/AppColdStart/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..f3cb9f1a87a81687554a76283af8df27d8bda775 --- /dev/null +++ b/PerformanceOptimization/AppColdStart/hvigorfile.ts @@ -0,0 +1,6 @@ +import { appTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/PerformanceOptimization/AppColdStart/oh-package-lock.json5 b/PerformanceOptimization/AppColdStart/oh-package-lock.json5 new file mode 100644 index 0000000000000000000000000000000000000000..7fcf818273347b97063c0c0a151bb14770ca1c79 --- /dev/null +++ b/PerformanceOptimization/AppColdStart/oh-package-lock.json5 @@ -0,0 +1,27 @@ +{ + "meta": { + "stableOrder": true + }, + "lockfileVersion": 3, + "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", + "specifiers": { + "@ohos/hamock@1.0.0": "@ohos/hamock@1.0.0", + "@ohos/hypium@1.0.21": "@ohos/hypium@1.0.21" + }, + "packages": { + "@ohos/hamock@1.0.0": { + "name": "@ohos/hamock", + "version": "1.0.0", + "integrity": "sha512-K6lDPYc6VkKe6ZBNQa9aoG+ZZMiwqfcR/7yAVFSUGIuOAhPvCJAo9+t1fZnpe0dBRBPxj2bxPPbKh69VuyAtDg==", + "resolved": "https://ohpm.openharmony.cn/ohpm/@ohos/hamock/-/hamock-1.0.0.har", + "registryType": "ohpm" + }, + "@ohos/hypium@1.0.21": { + "name": "@ohos/hypium", + "version": "1.0.21", + "integrity": "sha512-iyKGMXxE+9PpCkqEwu0VykN/7hNpb+QOeIuHwkmZnxOpI+dFZt6yhPB7k89EgV1MiSK/ieV/hMjr5Z2mWwRfMQ==", + "resolved": "https://ohpm.openharmony.cn/ohpm/@ohos/hypium/-/hypium-1.0.21.har", + "registryType": "ohpm" + } + } +} \ No newline at end of file diff --git a/PerformanceOptimization/AppColdStart/oh-package.json5 b/PerformanceOptimization/AppColdStart/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..a8aff0c5aff22d78aa26fd19c3861f4320e951ff --- /dev/null +++ b/PerformanceOptimization/AppColdStart/oh-package.json5 @@ -0,0 +1,10 @@ +{ + "modelVersion": "5.0.5", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.21", + "@ohos/hamock": "1.0.0" + } +} diff --git a/PerformanceOptimization/FileUploadAndDownloadSlow/.gitignore b/PerformanceOptimization/FileUploadAndDownloadSlow/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b --- /dev/null +++ b/PerformanceOptimization/FileUploadAndDownloadSlow/.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/PerformanceOptimization/FileUploadAndDownloadSlow/AppScope/app.json5 b/PerformanceOptimization/FileUploadAndDownloadSlow/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..f6c5348cc974a2fdf90ad963812200a12864f5ab --- /dev/null +++ b/PerformanceOptimization/FileUploadAndDownloadSlow/AppScope/app.json5 @@ -0,0 +1,10 @@ +{ + "app": { + "bundleName": "com.example.fileuploadanddownloadslow", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:layered_image", + "label": "$string:app_name" + } +} diff --git a/PerformanceOptimization/FileUploadAndDownloadSlow/AppScope/resources/base/element/string.json b/PerformanceOptimization/FileUploadAndDownloadSlow/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..c44da732731613952428cad348bb6c81aff524fa --- /dev/null +++ b/PerformanceOptimization/FileUploadAndDownloadSlow/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "FileUploadAndDownloadSlow" + } + ] +} diff --git a/PerformanceOptimization/FileUploadAndDownloadSlow/AppScope/resources/base/media/background.png b/PerformanceOptimization/FileUploadAndDownloadSlow/AppScope/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/PerformanceOptimization/FileUploadAndDownloadSlow/AppScope/resources/base/media/background.png differ diff --git a/PerformanceOptimization/FileUploadAndDownloadSlow/AppScope/resources/base/media/foreground.png b/PerformanceOptimization/FileUploadAndDownloadSlow/AppScope/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/PerformanceOptimization/FileUploadAndDownloadSlow/AppScope/resources/base/media/foreground.png differ diff --git a/PerformanceOptimization/FileUploadAndDownloadSlow/AppScope/resources/base/media/layered_image.json b/PerformanceOptimization/FileUploadAndDownloadSlow/AppScope/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/PerformanceOptimization/FileUploadAndDownloadSlow/AppScope/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/PerformanceOptimization/FileUploadAndDownloadSlow/build-profile.json5 b/PerformanceOptimization/FileUploadAndDownloadSlow/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..9e87e7e6f19020fe21192844709f192cec80fd44 --- /dev/null +++ b/PerformanceOptimization/FileUploadAndDownloadSlow/build-profile.json5 @@ -0,0 +1,42 @@ +{ + "app": { + "signingConfigs": [], + "products": [ + { + "name": "default", + "signingConfig": "default", + "targetSdkVersion": "5.0.5(17)", + "compatibleSdkVersion": "5.0.5(17)", + "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/PerformanceOptimization/FileUploadAndDownloadSlow/code-linter.json5 b/PerformanceOptimization/FileUploadAndDownloadSlow/code-linter.json5 new file mode 100644 index 0000000000000000000000000000000000000000..073990fa45394e1f8e85d85418ee60a8953f9b99 --- /dev/null +++ b/PerformanceOptimization/FileUploadAndDownloadSlow/code-linter.json5 @@ -0,0 +1,32 @@ +{ + "files": [ + "**/*.ets" + ], + "ignore": [ + "**/src/ohosTest/**/*", + "**/src/test/**/*", + "**/src/mock/**/*", + "**/node_modules/**/*", + "**/oh_modules/**/*", + "**/build/**/*", + "**/.preview/**/*" + ], + "ruleSet": [ + "plugin:@performance/recommended", + "plugin:@typescript-eslint/recommended" + ], + "rules": { + "@security/no-unsafe-aes": "error", + "@security/no-unsafe-hash": "error", + "@security/no-unsafe-mac": "warn", + "@security/no-unsafe-dh": "error", + "@security/no-unsafe-dsa": "error", + "@security/no-unsafe-ecdsa": "error", + "@security/no-unsafe-rsa-encrypt": "error", + "@security/no-unsafe-rsa-sign": "error", + "@security/no-unsafe-rsa-key": "error", + "@security/no-unsafe-dsa-key": "error", + "@security/no-unsafe-dh-key": "error", + "@security/no-unsafe-3des": "error" + } +} \ No newline at end of file diff --git a/PerformanceOptimization/FileUploadAndDownloadSlow/entry/.gitignore b/PerformanceOptimization/FileUploadAndDownloadSlow/entry/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/PerformanceOptimization/FileUploadAndDownloadSlow/entry/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/PerformanceOptimization/FileUploadAndDownloadSlow/entry/build-profile.json5 b/PerformanceOptimization/FileUploadAndDownloadSlow/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..4d611879c7913fb0610c686e2399258ab3a6dad1 --- /dev/null +++ b/PerformanceOptimization/FileUploadAndDownloadSlow/entry/build-profile.json5 @@ -0,0 +1,28 @@ +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/PerformanceOptimization/FileUploadAndDownloadSlow/entry/hvigorfile.ts b/PerformanceOptimization/FileUploadAndDownloadSlow/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..c6edcd90486dd5a853cf7d34c8647f08414ca7a3 --- /dev/null +++ b/PerformanceOptimization/FileUploadAndDownloadSlow/entry/hvigorfile.ts @@ -0,0 +1,6 @@ +import { hapTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/PerformanceOptimization/FileUploadAndDownloadSlow/entry/obfuscation-rules.txt b/PerformanceOptimization/FileUploadAndDownloadSlow/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/PerformanceOptimization/FileUploadAndDownloadSlow/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/PerformanceOptimization/FileUploadAndDownloadSlow/entry/oh-package.json5 b/PerformanceOptimization/FileUploadAndDownloadSlow/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..248c3b7541a589682a250f86a6d3ecf7414d2d6a --- /dev/null +++ b/PerformanceOptimization/FileUploadAndDownloadSlow/entry/oh-package.json5 @@ -0,0 +1,10 @@ +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/PerformanceOptimization/FileUploadAndDownloadSlow/entry/src/main/ets/entryability/EntryAbility.ets b/PerformanceOptimization/FileUploadAndDownloadSlow/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..508880af8c33aa838016d1cd4b2c68be2f447540 --- /dev/null +++ b/PerformanceOptimization/FileUploadAndDownloadSlow/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,44 @@ +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +const DOMAIN = 0x0000; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err)); + return; + } + hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onBackground'); + } +} \ No newline at end of file diff --git a/PerformanceOptimization/FileUploadAndDownloadSlow/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/PerformanceOptimization/FileUploadAndDownloadSlow/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..8e4de99282050bad799ac892eb85ac5449364a51 --- /dev/null +++ b/PerformanceOptimization/FileUploadAndDownloadSlow/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -0,0 +1,16 @@ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit'; + +const DOMAIN = 0x0000; + +export default class EntryBackupAbility extends BackupExtensionAbility { + async onBackup() { + hilog.info(DOMAIN, 'testTag', 'onBackup ok'); + await Promise.resolve(); + } + + async onRestore(bundleVersion: BundleVersion) { + hilog.info(DOMAIN, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion)); + await Promise.resolve(); + } +} \ No newline at end of file diff --git a/PerformanceOptimization/FileUploadAndDownloadSlow/entry/src/main/ets/pages/FileUploadPage.ets b/PerformanceOptimization/FileUploadAndDownloadSlow/entry/src/main/ets/pages/FileUploadPage.ets new file mode 100644 index 0000000000000000000000000000000000000000..386896914f1b51c4cacde2e76555a5696fe4b4c2 --- /dev/null +++ b/PerformanceOptimization/FileUploadAndDownloadSlow/entry/src/main/ets/pages/FileUploadPage.ets @@ -0,0 +1,83 @@ +// [Start import_request] +import { common } from '@kit.AbilityKit'; +import { request } from '@kit.BasicServicesKit'; +// [End import_request] + +// [Start class_upload] +class Upload { + // Background tasks + private backgroundTask: request.agent.Task | undefined = undefined; + // The uri stored before creating the task + private waitList: Array = []; + // ... +} +// [End class_upload] + +@Component +struct FileUploadPage { + // [Start file_upload_page] + private config: request.agent.Config = { + action: request.agent.Action.UPLOAD, + headers: HEADER, + url: '', + mode: request.agent.Mode.BACKGROUND, + method: 'POST', + title: 'upload', + network: request.agent.Network.ANY, + data: [], + token: 'UPLOAD_TOKEN' + } + // ... + // Convert uri + private async getFilesAndData(cacheDir: string, fileUris: Array): Promise> { + // ... + } + // Create a file upload background task + async createBackgroundTask(fileUris: Array) { + if (this.context === undefined) { + return; + } + // Get the upload URL + this.config.url = await urlUtils.getUrl(this.context); + this.config.data = await this.getFilesAndData(this.context.cacheDir, fileUris); + this.config.mode = request.agent.Mode.BACKGROUND; + try { + this.backgroundTask = await request.agent.create(this.context, this.config); + // [Start background_task_start] + await this.backgroundTask.start(); + // [End background_task_start] + let state = AppStorage.get('backTaskState'); + if (state === BackgroundTaskState.PAUSE) { + await this.backgroundTask.pause(); + } + logger.info(TAG, `createBackgroundTask success`); + } catch (err) { + logger.error(TAG, `task err, err = ${JSON.stringify(err)}`); + } + } + // [End file_upload_page] + + // [Start background_task_pause] + async pause() { + // ... + if (this.backgroundTask === undefined) { + return; + } + await this.backgroundTask.pause(); + } + // [End background_task_pause] + + // [Start background_task_resume] + async resume() { + // ... + if (this.backgroundTask === undefined) { + return; + } + await this.backgroundTask.resume(); + } + // [End background_task_resume] + + build() { + + } +} \ No newline at end of file diff --git a/PerformanceOptimization/FileUploadAndDownloadSlow/entry/src/main/ets/pages/Index.ets b/PerformanceOptimization/FileUploadAndDownloadSlow/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..8e2d24ad42693fc877d51bb7820f0a9da68fa135 --- /dev/null +++ b/PerformanceOptimization/FileUploadAndDownloadSlow/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,23 @@ +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + RelativeContainer() { + Text(this.message) + .id('HelloWorld') + .fontSize($r('app.float.page_text_font_size')) + .fontWeight(FontWeight.Bold) + .alignRules({ + center: { anchor: '__container__', align: VerticalAlign.Center }, + middle: { anchor: '__container__', align: HorizontalAlign.Center } + }) + .onClick(() => { + this.message = 'Welcome'; + }) + } + .height('100%') + .width('100%') + } +} \ No newline at end of file diff --git a/PerformanceOptimization/FileUploadAndDownloadSlow/entry/src/main/ets/pages/RequestDownloadPage.ets b/PerformanceOptimization/FileUploadAndDownloadSlow/entry/src/main/ets/pages/RequestDownloadPage.ets new file mode 100644 index 0000000000000000000000000000000000000000..d087bce7f20bd21736e5927fac88783d8a673699 --- /dev/null +++ b/PerformanceOptimization/FileUploadAndDownloadSlow/entry/src/main/ets/pages/RequestDownloadPage.ets @@ -0,0 +1,58 @@ +// [Start import_request_download] +import { common } from '@kit.AbilityKit'; +import { request } from '@kit.BasicServicesKit'; +// [End import_request_download] + +// [Start request_download] +class RequestDownload { + // Uri before the task is stored + private waitList: Array = []; + // Uri before the task is stored + private downloadTask: request.agent.Task | undefined = undefined; + // ... +} +// [End request_download] + +@Component +struct RequestDownloadPage { + // [Start request_download_page] + async createBackgroundTask(downloadList: Array) { + if (this.context === undefined) { + return; + } + for (let i = 0; i < downloadList.length; i++) { + try { + let splitUrl = downloadList[i][1].split('//')[1].split('/'); + let downloadConfig: request.agent.Config = { + action: request.agent.Action.DOWNLOAD, + url: downloadList[i][1], + method: 'POST', + title: 'download', + mode: request.agent.Mode.BACKGROUND, // It must be a background task to continue. + network: request.agent.Network.ANY, + saveas: `./${downloadList[i][0]}/${splitUrl[splitUrl.length-1]}`, + overwrite: true, + gauge: true + } + let downTask = await request.agent.create(this.context, downloadConfig); + if (this.backgroundDownloadTaskList.findIndex(task => task.config.url === downTask.config.url) === -1) { + this.backgroundDownloadTaskList.push(downTask); + } + // [Start down_task_start] + // [StartExclude down_task_start] + // [EndExclude down_task_start] + await downTask.start(); + // [StartExclude down_task_start] + // [EndExclude down_task_start] + // [End down_task_start] + } catch (err) { + logger.error(TAG, `task err, err = ${JSON.stringify(err)}`); + this.waitList.push(downloadList[i]); + } + } + } + // [End request_download_page] + build() { + + } +} \ No newline at end of file diff --git a/PerformanceOptimization/FileUploadAndDownloadSlow/entry/src/main/ets/pages/UploadAndDownloadPage.ets b/PerformanceOptimization/FileUploadAndDownloadSlow/entry/src/main/ets/pages/UploadAndDownloadPage.ets new file mode 100644 index 0000000000000000000000000000000000000000..0dfec90f9122c91679fcec7cde869252c6a8a1de --- /dev/null +++ b/PerformanceOptimization/FileUploadAndDownloadSlow/entry/src/main/ets/pages/UploadAndDownloadPage.ets @@ -0,0 +1,93 @@ +// [Start create_config] +let config: request.agent.Config = { + action: request.agent.Action.DOWNLOAD, // Configure task options, which are configured as download tasks. + url: downloadUrl, // Configure the download task url + overwrite: true, // Solution selection when the path already exists during the download process. True means overwriting existing files. + method: 'GET', // HTTP standard method. When downloading, use GET or POST + saveas: './', // Here'. /' indicates that the download is downloaded to the current cache path of the application. + mode: request.agent.Mode.BACKGROUND, // Task mode setting background tasks + gauge: true // The process progress notification strategy of background tasks is only applicable to background tasks. True means to send a notification that each progress has been completed or failed. +}; +// [End create_config] + +@Component +struct UploadAndDownloadPage { + + create() { + // [Start request_agent_create] + request.agent.create(context, this.downloadConfig).then((task: request.agent.Task) => { + // Callbacks related to the registration download task + task.on('completed', this.completedCallback); // Complete the callback + task.on('failed', this.failedCallback); // Failed callback + task.on('pause', this.pauseCallback); // Pause the callback + task.on('resume', this.resumeCallback); // Restart the callback + task.on('progress', this.progressCallback); // Progress update callback + task.on('response', this.progressCallback); // Response header data callback + }).catch((err: BusinessError) => { + logger.error(TAG, `Failed to task create with error message: ${err.message}, error code: ${err.code}`); + }); + // [End request_agent_create] + } + + start() { + // [Start task_start] + task.start().then(() => { + this.downloadTask = task; + }).catch((err: Error) => { + logger.error(TAG, 'task start error:', err); + }) + // [End task_start] + } + + // [Start file_download_item] + FileDownloadItem() { + // Determine whether the current download task status meets the pause conditions + if (this.downloadTask && (taskInfo.progress.state === request.agent.State.WAITING || taskInfo.progress.state + === request.agent.State.RUNNING || taskInfo.progress.state === request.agent.State.RETRYING)) { + this.downloadTask.pause().then(() => { + }).catch((err: Error) => { + logger.error(TAG, 'task pause error:', err); + }); + } + + // Determine if the task is suspended, restart the download task. + if (this.downloadTask && taskInfo.progress.state === request.agent.State.PAUSED) { + this.downloadTask.resume().then(() => { + }).catch((err: Error) => { + logger.error(TAG, 'task resume error:', err); + }); + } + } + // [End file_download_item] + + + // [Start request_agent_create] + private completedCallback = (progress: request.agent.Progress) => { + // The download status is set to download completion. + this.state = "下载完成"; + if (this.sFileSize === '未知大小') { + this.nCurrentDownloadSize = 1; + } + // The file download is completed, and the number of tasks to be downloaded will be reduced by 1 + this.downloadCount--; + this.isShow = false; + } + // [End request_agent_create] + + build() { + Column() { + // [Start download_config_array] + ForEach(this.downloadConfigArray, (item: request.agent.Config) => { + ListItem() { + // Create a file download monitoring instance + FileDownloadItem({ + downloadConfig: item, // File download configuration + isStartAllDownload: this.isStartAllDownload, // Do you start downloading all? + downloadCount: this.downloadCount // Number of tasks to be downloaded + }) + } + }, (item: request.agent.Config) => JSON.stringify(item)) + // [End download_config_array] + } + } +} \ No newline at end of file diff --git a/PerformanceOptimization/FileUploadAndDownloadSlow/entry/src/main/ets/pages/ZipUploadPage.ets b/PerformanceOptimization/FileUploadAndDownloadSlow/entry/src/main/ets/pages/ZipUploadPage.ets new file mode 100644 index 0000000000000000000000000000000000000000..24e3d55d41b69f123ee3e93dfeb47d1c50943aeb --- /dev/null +++ b/PerformanceOptimization/FileUploadAndDownloadSlow/entry/src/main/ets/pages/ZipUploadPage.ets @@ -0,0 +1,48 @@ +// [Start import_zlib] +import { common } from '@kit.AbilityKit'; +import { fileIo } from '@kit.CoreFileKit'; +import { zlib } from '@kit.BasicServicesKit'; +// [End import_zlib] + +// [Start zip_upload] +class ZipUpload { + // Uri stored before creating the task + private waitList: Array = []; + // Files that need to be uploaded uri + private fileUris: Array = []; + // ... +} +// [End zip_upload] + +@Component +struct ZipUploadPage { + // [Start zip_upload_page] + // Data compression processing + async zipUploadFiles(fileUris: Array): Promise { + this.context = this.getUIContext().getHostContext() as common.UIAbilityContext; + let cacheDir = this.context.cacheDir; + let tempDir = fileIo.mkdtempSync(`${cacheDir}/XXXXXX`); + // Put the uri obtained from the library picture into fileUris and copy it to the temporary folder. + for (let i = 0; i < fileUris.length; i++) { + let fileName = fileUris[i].split('/').pop(); + let resourceFile: fileIo.File = fileIo.openSync(fileUris[i], fileIo.OpenMode.READ_ONLY); + fileIo.copyFileSync(resourceFile.fd, `${tempDir}/${fileName}`, 0); + fileIo.closeSync(resourceFile); + } + // File compression, package the previously generated temporary folder into test.zip + let options: zlib.Options = { + level: zlib.CompressLevel.COMPRESS_LEVEL_DEFAULT_COMPRESSION, + memLevel: zlib.MemLevel.MEM_LEVEL_DEFAULT, + strategy: zlib.CompressStrategy.COMPRESS_STRATEGY_DEFAULT_STRATEGY + }; + let data = await zlib.compressFile(tempDir, `${cacheDir}/test.zip`, options); + // Delete temporary folders + fileIo.rmdirSync(tempDir); + // Put the generated zip package into the transmission queue. + this.waitList.push(`${cacheDir}/test.zip`); + } + // [End zip_upload_page] + build() { + + } +} \ No newline at end of file diff --git a/PerformanceOptimization/FileUploadAndDownloadSlow/entry/src/main/module.json5 b/PerformanceOptimization/FileUploadAndDownloadSlow/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..a1cea8b6a4560cee7bda7a2db52f310c035ab6c8 --- /dev/null +++ b/PerformanceOptimization/FileUploadAndDownloadSlow/entry/src/main/module.json5 @@ -0,0 +1,52 @@ +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:layered_image", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "EntryBackupAbility", + "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets", + "type": "backup", + "exported": false, + "metadata": [ + { + "name": "ohos.extension.backup", + "resource": "$profile:backup_config" + } + ], + } + ] + } +} \ No newline at end of file diff --git a/PerformanceOptimization/FileUploadAndDownloadSlow/entry/src/main/resources/base/element/color.json b/PerformanceOptimization/FileUploadAndDownloadSlow/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/PerformanceOptimization/FileUploadAndDownloadSlow/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/PerformanceOptimization/FileUploadAndDownloadSlow/entry/src/main/resources/base/element/float.json b/PerformanceOptimization/FileUploadAndDownloadSlow/entry/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..33ea22304f9b1485b5f22d811023701b5d4e35b6 --- /dev/null +++ b/PerformanceOptimization/FileUploadAndDownloadSlow/entry/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} diff --git a/PerformanceOptimization/FileUploadAndDownloadSlow/entry/src/main/resources/base/element/string.json b/PerformanceOptimization/FileUploadAndDownloadSlow/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..f94595515a99e0c828807e243494f57f09251930 --- /dev/null +++ b/PerformanceOptimization/FileUploadAndDownloadSlow/entry/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/PerformanceOptimization/FileUploadAndDownloadSlow/entry/src/main/resources/base/media/background.png b/PerformanceOptimization/FileUploadAndDownloadSlow/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/PerformanceOptimization/FileUploadAndDownloadSlow/entry/src/main/resources/base/media/background.png differ diff --git a/PerformanceOptimization/FileUploadAndDownloadSlow/entry/src/main/resources/base/media/foreground.png b/PerformanceOptimization/FileUploadAndDownloadSlow/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/PerformanceOptimization/FileUploadAndDownloadSlow/entry/src/main/resources/base/media/foreground.png differ diff --git a/PerformanceOptimization/FileUploadAndDownloadSlow/entry/src/main/resources/base/media/layered_image.json b/PerformanceOptimization/FileUploadAndDownloadSlow/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/PerformanceOptimization/FileUploadAndDownloadSlow/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/PerformanceOptimization/FileUploadAndDownloadSlow/entry/src/main/resources/base/media/startIcon.png b/PerformanceOptimization/FileUploadAndDownloadSlow/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/PerformanceOptimization/FileUploadAndDownloadSlow/entry/src/main/resources/base/media/startIcon.png differ diff --git a/PerformanceOptimization/FileUploadAndDownloadSlow/entry/src/main/resources/base/profile/backup_config.json b/PerformanceOptimization/FileUploadAndDownloadSlow/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/PerformanceOptimization/FileUploadAndDownloadSlow/entry/src/main/resources/base/profile/backup_config.json @@ -0,0 +1,3 @@ +{ + "allowToBackupRestore": true +} \ No newline at end of file diff --git a/PerformanceOptimization/FileUploadAndDownloadSlow/entry/src/main/resources/base/profile/main_pages.json b/PerformanceOptimization/FileUploadAndDownloadSlow/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce --- /dev/null +++ b/PerformanceOptimization/FileUploadAndDownloadSlow/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/PerformanceOptimization/FileUploadAndDownloadSlow/entry/src/main/resources/dark/element/color.json b/PerformanceOptimization/FileUploadAndDownloadSlow/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..79b11c2747aec33e710fd3a7b2b3c94dd9965499 --- /dev/null +++ b/PerformanceOptimization/FileUploadAndDownloadSlow/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/PerformanceOptimization/FileUploadAndDownloadSlow/entry/src/mock/mock-config.json5 b/PerformanceOptimization/FileUploadAndDownloadSlow/entry/src/mock/mock-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..7a73a41bfdf76d6f793007240d80983a52f15f97 --- /dev/null +++ b/PerformanceOptimization/FileUploadAndDownloadSlow/entry/src/mock/mock-config.json5 @@ -0,0 +1,2 @@ +{ +} \ No newline at end of file diff --git a/PerformanceOptimization/FileUploadAndDownloadSlow/entry/src/ohosTest/ets/test/Ability.test.ets b/PerformanceOptimization/FileUploadAndDownloadSlow/entry/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..85c78f67579d6e31b5f5aeea463e216b9b141048 --- /dev/null +++ b/PerformanceOptimization/FileUploadAndDownloadSlow/entry/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,35 @@ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }) + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }) + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }) + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }) + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + hilog.info(0x0000, 'testTag', '%{public}s', 'it begin'); + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }) + }) +} \ No newline at end of file diff --git a/PerformanceOptimization/FileUploadAndDownloadSlow/entry/src/ohosTest/ets/test/List.test.ets b/PerformanceOptimization/FileUploadAndDownloadSlow/entry/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..794c7dc4ed66bd98fa3865e07922906e2fcef545 --- /dev/null +++ b/PerformanceOptimization/FileUploadAndDownloadSlow/entry/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,5 @@ +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/PerformanceOptimization/FileUploadAndDownloadSlow/entry/src/ohosTest/module.json5 b/PerformanceOptimization/FileUploadAndDownloadSlow/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..55725a929993a8a18b3808d41ef037759440488b --- /dev/null +++ b/PerformanceOptimization/FileUploadAndDownloadSlow/entry/src/ohosTest/module.json5 @@ -0,0 +1,13 @@ +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/PerformanceOptimization/FileUploadAndDownloadSlow/entry/src/test/List.test.ets b/PerformanceOptimization/FileUploadAndDownloadSlow/entry/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..bb5b5c3731e283dd507c847560ee59bde477bbc7 --- /dev/null +++ b/PerformanceOptimization/FileUploadAndDownloadSlow/entry/src/test/List.test.ets @@ -0,0 +1,5 @@ +import localUnitTest from './LocalUnit.test'; + +export default function testsuite() { + localUnitTest(); +} \ No newline at end of file diff --git a/PerformanceOptimization/FileUploadAndDownloadSlow/entry/src/test/LocalUnit.test.ets b/PerformanceOptimization/FileUploadAndDownloadSlow/entry/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..165fc1615ee8618b4cb6a622f144a9a707eee99f --- /dev/null +++ b/PerformanceOptimization/FileUploadAndDownloadSlow/entry/src/test/LocalUnit.test.ets @@ -0,0 +1,33 @@ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function localUnitTest() { + describe('localUnitTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }); + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }); + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }); + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }); + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }); + }); +} \ No newline at end of file diff --git a/PerformanceOptimization/FileUploadAndDownloadSlow/hvigor/hvigor-config.json5 b/PerformanceOptimization/FileUploadAndDownloadSlow/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..5bebc9755447385d82ce4138f54d991b1f85f348 --- /dev/null +++ b/PerformanceOptimization/FileUploadAndDownloadSlow/hvigor/hvigor-config.json5 @@ -0,0 +1,22 @@ +{ + "modelVersion": "5.0.5", + "dependencies": { + }, + "execution": { + // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */ + // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */ + // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */ + // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */ + // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */ + }, + "logging": { + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ + }, + "debugging": { + // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */ + }, + "nodeOptions": { + // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/ + // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/ + } +} diff --git a/PerformanceOptimization/FileUploadAndDownloadSlow/hvigorfile.ts b/PerformanceOptimization/FileUploadAndDownloadSlow/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..f3cb9f1a87a81687554a76283af8df27d8bda775 --- /dev/null +++ b/PerformanceOptimization/FileUploadAndDownloadSlow/hvigorfile.ts @@ -0,0 +1,6 @@ +import { appTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/PerformanceOptimization/FileUploadAndDownloadSlow/oh-package-lock.json5 b/PerformanceOptimization/FileUploadAndDownloadSlow/oh-package-lock.json5 new file mode 100644 index 0000000000000000000000000000000000000000..7fcf818273347b97063c0c0a151bb14770ca1c79 --- /dev/null +++ b/PerformanceOptimization/FileUploadAndDownloadSlow/oh-package-lock.json5 @@ -0,0 +1,27 @@ +{ + "meta": { + "stableOrder": true + }, + "lockfileVersion": 3, + "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", + "specifiers": { + "@ohos/hamock@1.0.0": "@ohos/hamock@1.0.0", + "@ohos/hypium@1.0.21": "@ohos/hypium@1.0.21" + }, + "packages": { + "@ohos/hamock@1.0.0": { + "name": "@ohos/hamock", + "version": "1.0.0", + "integrity": "sha512-K6lDPYc6VkKe6ZBNQa9aoG+ZZMiwqfcR/7yAVFSUGIuOAhPvCJAo9+t1fZnpe0dBRBPxj2bxPPbKh69VuyAtDg==", + "resolved": "https://ohpm.openharmony.cn/ohpm/@ohos/hamock/-/hamock-1.0.0.har", + "registryType": "ohpm" + }, + "@ohos/hypium@1.0.21": { + "name": "@ohos/hypium", + "version": "1.0.21", + "integrity": "sha512-iyKGMXxE+9PpCkqEwu0VykN/7hNpb+QOeIuHwkmZnxOpI+dFZt6yhPB7k89EgV1MiSK/ieV/hMjr5Z2mWwRfMQ==", + "resolved": "https://ohpm.openharmony.cn/ohpm/@ohos/hypium/-/hypium-1.0.21.har", + "registryType": "ohpm" + } + } +} \ No newline at end of file diff --git a/PerformanceOptimization/FileUploadAndDownloadSlow/oh-package.json5 b/PerformanceOptimization/FileUploadAndDownloadSlow/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..a8aff0c5aff22d78aa26fd19c3861f4320e951ff --- /dev/null +++ b/PerformanceOptimization/FileUploadAndDownloadSlow/oh-package.json5 @@ -0,0 +1,10 @@ +{ + "modelVersion": "5.0.5", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.21", + "@ohos/hamock": "1.0.0" + } +} diff --git a/PerformanceOptimization/GridComponentLoadSlow/.gitignore b/PerformanceOptimization/GridComponentLoadSlow/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b --- /dev/null +++ b/PerformanceOptimization/GridComponentLoadSlow/.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/PerformanceOptimization/GridComponentLoadSlow/AppScope/app.json5 b/PerformanceOptimization/GridComponentLoadSlow/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..2cbd63a6e7f9bfa5990de76d8337d96c22ee498d --- /dev/null +++ b/PerformanceOptimization/GridComponentLoadSlow/AppScope/app.json5 @@ -0,0 +1,10 @@ +{ + "app": { + "bundleName": "com.example.gridcomponentloadslow", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:layered_image", + "label": "$string:app_name" + } +} diff --git a/PerformanceOptimization/GridComponentLoadSlow/AppScope/resources/base/element/string.json b/PerformanceOptimization/GridComponentLoadSlow/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..871b44c775b25620d1c62abb3016e37cfa33ca52 --- /dev/null +++ b/PerformanceOptimization/GridComponentLoadSlow/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "GridComponentLoadSlow" + } + ] +} diff --git a/PerformanceOptimization/GridComponentLoadSlow/AppScope/resources/base/media/background.png b/PerformanceOptimization/GridComponentLoadSlow/AppScope/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/PerformanceOptimization/GridComponentLoadSlow/AppScope/resources/base/media/background.png differ diff --git a/PerformanceOptimization/GridComponentLoadSlow/AppScope/resources/base/media/foreground.png b/PerformanceOptimization/GridComponentLoadSlow/AppScope/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/PerformanceOptimization/GridComponentLoadSlow/AppScope/resources/base/media/foreground.png differ diff --git a/PerformanceOptimization/GridComponentLoadSlow/AppScope/resources/base/media/layered_image.json b/PerformanceOptimization/GridComponentLoadSlow/AppScope/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/PerformanceOptimization/GridComponentLoadSlow/AppScope/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/PerformanceOptimization/GridComponentLoadSlow/build-profile.json5 b/PerformanceOptimization/GridComponentLoadSlow/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..9e87e7e6f19020fe21192844709f192cec80fd44 --- /dev/null +++ b/PerformanceOptimization/GridComponentLoadSlow/build-profile.json5 @@ -0,0 +1,42 @@ +{ + "app": { + "signingConfigs": [], + "products": [ + { + "name": "default", + "signingConfig": "default", + "targetSdkVersion": "5.0.5(17)", + "compatibleSdkVersion": "5.0.5(17)", + "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/PerformanceOptimization/GridComponentLoadSlow/code-linter.json5 b/PerformanceOptimization/GridComponentLoadSlow/code-linter.json5 new file mode 100644 index 0000000000000000000000000000000000000000..073990fa45394e1f8e85d85418ee60a8953f9b99 --- /dev/null +++ b/PerformanceOptimization/GridComponentLoadSlow/code-linter.json5 @@ -0,0 +1,32 @@ +{ + "files": [ + "**/*.ets" + ], + "ignore": [ + "**/src/ohosTest/**/*", + "**/src/test/**/*", + "**/src/mock/**/*", + "**/node_modules/**/*", + "**/oh_modules/**/*", + "**/build/**/*", + "**/.preview/**/*" + ], + "ruleSet": [ + "plugin:@performance/recommended", + "plugin:@typescript-eslint/recommended" + ], + "rules": { + "@security/no-unsafe-aes": "error", + "@security/no-unsafe-hash": "error", + "@security/no-unsafe-mac": "warn", + "@security/no-unsafe-dh": "error", + "@security/no-unsafe-dsa": "error", + "@security/no-unsafe-ecdsa": "error", + "@security/no-unsafe-rsa-encrypt": "error", + "@security/no-unsafe-rsa-sign": "error", + "@security/no-unsafe-rsa-key": "error", + "@security/no-unsafe-dsa-key": "error", + "@security/no-unsafe-dh-key": "error", + "@security/no-unsafe-3des": "error" + } +} \ No newline at end of file diff --git a/PerformanceOptimization/GridComponentLoadSlow/entry/.gitignore b/PerformanceOptimization/GridComponentLoadSlow/entry/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/PerformanceOptimization/GridComponentLoadSlow/entry/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/PerformanceOptimization/GridComponentLoadSlow/entry/build-profile.json5 b/PerformanceOptimization/GridComponentLoadSlow/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..4d611879c7913fb0610c686e2399258ab3a6dad1 --- /dev/null +++ b/PerformanceOptimization/GridComponentLoadSlow/entry/build-profile.json5 @@ -0,0 +1,28 @@ +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/PerformanceOptimization/GridComponentLoadSlow/entry/hvigorfile.ts b/PerformanceOptimization/GridComponentLoadSlow/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..c6edcd90486dd5a853cf7d34c8647f08414ca7a3 --- /dev/null +++ b/PerformanceOptimization/GridComponentLoadSlow/entry/hvigorfile.ts @@ -0,0 +1,6 @@ +import { hapTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/PerformanceOptimization/GridComponentLoadSlow/entry/obfuscation-rules.txt b/PerformanceOptimization/GridComponentLoadSlow/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/PerformanceOptimization/GridComponentLoadSlow/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/PerformanceOptimization/GridComponentLoadSlow/entry/oh-package.json5 b/PerformanceOptimization/GridComponentLoadSlow/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..248c3b7541a589682a250f86a6d3ecf7414d2d6a --- /dev/null +++ b/PerformanceOptimization/GridComponentLoadSlow/entry/oh-package.json5 @@ -0,0 +1,10 @@ +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/PerformanceOptimization/GridComponentLoadSlow/entry/src/main/ets/entryability/EntryAbility.ets b/PerformanceOptimization/GridComponentLoadSlow/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..508880af8c33aa838016d1cd4b2c68be2f447540 --- /dev/null +++ b/PerformanceOptimization/GridComponentLoadSlow/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,44 @@ +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +const DOMAIN = 0x0000; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err)); + return; + } + hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onBackground'); + } +} \ No newline at end of file diff --git a/PerformanceOptimization/GridComponentLoadSlow/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/PerformanceOptimization/GridComponentLoadSlow/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..8e4de99282050bad799ac892eb85ac5449364a51 --- /dev/null +++ b/PerformanceOptimization/GridComponentLoadSlow/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -0,0 +1,16 @@ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit'; + +const DOMAIN = 0x0000; + +export default class EntryBackupAbility extends BackupExtensionAbility { + async onBackup() { + hilog.info(DOMAIN, 'testTag', 'onBackup ok'); + await Promise.resolve(); + } + + async onRestore(bundleVersion: BundleVersion) { + hilog.info(DOMAIN, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion)); + await Promise.resolve(); + } +} \ No newline at end of file diff --git a/PerformanceOptimization/GridComponentLoadSlow/entry/src/main/ets/pages/Index.ets b/PerformanceOptimization/GridComponentLoadSlow/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..0863b716370f3b8cea4c9d8109abb1d33594ee6f --- /dev/null +++ b/PerformanceOptimization/GridComponentLoadSlow/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,90 @@ +// [Start grid_component_load_slow] +// Import performance dot modules +import hiTraceMeter from '@ohos.hiTraceMeter'; + +@Component +struct TextItem { + @State item: string = ""; + + build() { + Text(this.item) + .fontSize(16) + .backgroundColor(0xF9CF93) + .width('100%') + .height(80) + .textAlign(TextAlign.Center) + } + + aboutToAppear() { + // Finish the task + hiTraceMeter.finishTrace("useColumnStartColumnEnd", 1); + } +} + +class MyDataSource implements IDataSource { + private dataArray: string[] = []; + + public pushData(data: string): void { + this.dataArray.push(data); + } + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + registerDataChangeListener(listener: DataChangeListener): void { + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + } +} + +@Entry +@Component +struct GridExample { + private datasource: MyDataSource = new MyDataSource(); + scroller: Scroller = new Scroller(); + + aboutToAppear() { + for (let i = 1; i <= 2000; i++) { + this.datasource.pushData(i + ''); + } + } + + build() { + Column({ space: 5 }) { + Text('使用columnStart,columnEnd设置GridItem大小').fontColor(0xCCCCCC).fontSize(9).width('90%') + Grid(this.scroller) { + LazyForEach(this.datasource, (item: string, index: number) => { + if ((index % 4) === 0) { + GridItem() { + TextItem({ item: item }) + } + .columnStart(0).columnEnd(2) + } else { + GridItem() { + TextItem({ item: item }) + } + } + }, (item: string) => item) + } + .columnsTemplate('1fr 1fr 1fr') + .columnsGap(10) + .rowsGap(10) + .width('90%') + .height('40%') + + Button("scrollToIndex:1900").onClick(() => { + // Start some tasks. + hiTraceMeter.startTrace("useColumnStartColumnEnd", 1); + this.scroller.scrollToIndex(1900); + }) + }.width('100%') + .margin({ top: 5 }) + } +} +// [End grid_component_load_slow] \ No newline at end of file diff --git a/PerformanceOptimization/GridComponentLoadSlow/entry/src/main/ets/pages/RightIndex.ets b/PerformanceOptimization/GridComponentLoadSlow/entry/src/main/ets/pages/RightIndex.ets new file mode 100644 index 0000000000000000000000000000000000000000..c9b965ea9d4051b91224bb1bdb367ac1e5137cd4 --- /dev/null +++ b/PerformanceOptimization/GridComponentLoadSlow/entry/src/main/ets/pages/RightIndex.ets @@ -0,0 +1,90 @@ +// [Start right_index] +// Import performance dot modules +import hiTraceMeter from '@ohos.hiTraceMeter'; + +@Component +struct TextItem { + @State item: string = ""; + + build() { + Text(this.item) + .fontSize(16) + .backgroundColor(0xF9CF93) + .width('100%') + .height(80) + .textAlign(TextAlign.Center) + } + + aboutToAppear() { + // Finish the task + hiTraceMeter.finishTrace("useGridLayoutOptions", 1); + } +} + +class MyDataSource implements IDataSource { + private dataArray: string[] = []; + + public pushData(data: string): void { + this.dataArray.push(data); + } + + public totalCount(): number { + return this.dataArray.length; + } + + public getData(index: number): string { + return this.dataArray[index]; + } + + registerDataChangeListener(listener: DataChangeListener): void { + } + + unregisterDataChangeListener(listener: DataChangeListener): void { + } +} + +@Component +export struct GridExample2 { + private datasource: MyDataSource = new MyDataSource(); + scroller: Scroller = new Scroller(); + private irregularData: number[] = []; + layoutOptions: GridLayoutOptions = { + regularSize: [1, 1], + irregularIndexes: this.irregularData, + }; + + aboutToAppear() { + for (let i = 1; i <= 2000; i++) { + this.datasource.pushData(i + ''); + if ((i - 1) % 4 === 0) { + this.irregularData.push(i - 1); + } + } + } + + build() { + Column({ space: 5 }) { + Text('使用GridLayoutOptions设置GridItem大小').fontColor(0xCCCCCC).fontSize(9).width('90%') + Grid(this.scroller, this.layoutOptions) { + LazyForEach(this.datasource, (item: string, index: number) => { + GridItem() { + TextItem({ item: item }) + } + }, (item: string) => item) + } + .columnsTemplate('1fr 1fr 1fr') + .columnsGap(10) + .rowsGap(10) + .width('90%') + .height('40%') + + Button("scrollToIndex:1900").onClick(() => { + // Start some tasks. + hiTraceMeter.startTrace("useGridLayoutOptions", 1); + this.scroller.scrollToIndex(1900); + }) + }.width('100%') + .margin({ top: 5 }) + } +} +// [End right_index] \ No newline at end of file diff --git a/PerformanceOptimization/GridComponentLoadSlow/entry/src/main/module.json5 b/PerformanceOptimization/GridComponentLoadSlow/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..ad219d733f6afa5ea07f85f580208b08cc3b9041 --- /dev/null +++ b/PerformanceOptimization/GridComponentLoadSlow/entry/src/main/module.json5 @@ -0,0 +1,50 @@ +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "phone" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:layered_image", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "EntryBackupAbility", + "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets", + "type": "backup", + "exported": false, + "metadata": [ + { + "name": "ohos.extension.backup", + "resource": "$profile:backup_config" + } + ], + } + ] + } +} \ No newline at end of file diff --git a/PerformanceOptimization/GridComponentLoadSlow/entry/src/main/resources/base/element/color.json b/PerformanceOptimization/GridComponentLoadSlow/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/PerformanceOptimization/GridComponentLoadSlow/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/PerformanceOptimization/GridComponentLoadSlow/entry/src/main/resources/base/element/float.json b/PerformanceOptimization/GridComponentLoadSlow/entry/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..33ea22304f9b1485b5f22d811023701b5d4e35b6 --- /dev/null +++ b/PerformanceOptimization/GridComponentLoadSlow/entry/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} diff --git a/PerformanceOptimization/GridComponentLoadSlow/entry/src/main/resources/base/element/string.json b/PerformanceOptimization/GridComponentLoadSlow/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..f94595515a99e0c828807e243494f57f09251930 --- /dev/null +++ b/PerformanceOptimization/GridComponentLoadSlow/entry/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/PerformanceOptimization/GridComponentLoadSlow/entry/src/main/resources/base/media/background.png b/PerformanceOptimization/GridComponentLoadSlow/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/PerformanceOptimization/GridComponentLoadSlow/entry/src/main/resources/base/media/background.png differ diff --git a/PerformanceOptimization/GridComponentLoadSlow/entry/src/main/resources/base/media/foreground.png b/PerformanceOptimization/GridComponentLoadSlow/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/PerformanceOptimization/GridComponentLoadSlow/entry/src/main/resources/base/media/foreground.png differ diff --git a/PerformanceOptimization/GridComponentLoadSlow/entry/src/main/resources/base/media/layered_image.json b/PerformanceOptimization/GridComponentLoadSlow/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/PerformanceOptimization/GridComponentLoadSlow/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/PerformanceOptimization/GridComponentLoadSlow/entry/src/main/resources/base/media/startIcon.png b/PerformanceOptimization/GridComponentLoadSlow/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/PerformanceOptimization/GridComponentLoadSlow/entry/src/main/resources/base/media/startIcon.png differ diff --git a/PerformanceOptimization/GridComponentLoadSlow/entry/src/main/resources/base/profile/backup_config.json b/PerformanceOptimization/GridComponentLoadSlow/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/PerformanceOptimization/GridComponentLoadSlow/entry/src/main/resources/base/profile/backup_config.json @@ -0,0 +1,3 @@ +{ + "allowToBackupRestore": true +} \ No newline at end of file diff --git a/PerformanceOptimization/GridComponentLoadSlow/entry/src/main/resources/base/profile/main_pages.json b/PerformanceOptimization/GridComponentLoadSlow/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce --- /dev/null +++ b/PerformanceOptimization/GridComponentLoadSlow/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/PerformanceOptimization/GridComponentLoadSlow/entry/src/main/resources/dark/element/color.json b/PerformanceOptimization/GridComponentLoadSlow/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..79b11c2747aec33e710fd3a7b2b3c94dd9965499 --- /dev/null +++ b/PerformanceOptimization/GridComponentLoadSlow/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/PerformanceOptimization/GridComponentLoadSlow/entry/src/mock/mock-config.json5 b/PerformanceOptimization/GridComponentLoadSlow/entry/src/mock/mock-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..7a73a41bfdf76d6f793007240d80983a52f15f97 --- /dev/null +++ b/PerformanceOptimization/GridComponentLoadSlow/entry/src/mock/mock-config.json5 @@ -0,0 +1,2 @@ +{ +} \ No newline at end of file diff --git a/PerformanceOptimization/GridComponentLoadSlow/entry/src/ohosTest/ets/test/Ability.test.ets b/PerformanceOptimization/GridComponentLoadSlow/entry/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..85c78f67579d6e31b5f5aeea463e216b9b141048 --- /dev/null +++ b/PerformanceOptimization/GridComponentLoadSlow/entry/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,35 @@ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }) + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }) + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }) + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }) + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + hilog.info(0x0000, 'testTag', '%{public}s', 'it begin'); + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }) + }) +} \ No newline at end of file diff --git a/PerformanceOptimization/GridComponentLoadSlow/entry/src/ohosTest/ets/test/List.test.ets b/PerformanceOptimization/GridComponentLoadSlow/entry/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..794c7dc4ed66bd98fa3865e07922906e2fcef545 --- /dev/null +++ b/PerformanceOptimization/GridComponentLoadSlow/entry/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,5 @@ +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/PerformanceOptimization/GridComponentLoadSlow/entry/src/ohosTest/module.json5 b/PerformanceOptimization/GridComponentLoadSlow/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..509a3a28a3e6be8d7f98cc563fa8195657d77d1d --- /dev/null +++ b/PerformanceOptimization/GridComponentLoadSlow/entry/src/ohosTest/module.json5 @@ -0,0 +1,11 @@ +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "phone" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/PerformanceOptimization/GridComponentLoadSlow/entry/src/test/List.test.ets b/PerformanceOptimization/GridComponentLoadSlow/entry/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..bb5b5c3731e283dd507c847560ee59bde477bbc7 --- /dev/null +++ b/PerformanceOptimization/GridComponentLoadSlow/entry/src/test/List.test.ets @@ -0,0 +1,5 @@ +import localUnitTest from './LocalUnit.test'; + +export default function testsuite() { + localUnitTest(); +} \ No newline at end of file diff --git a/PerformanceOptimization/GridComponentLoadSlow/entry/src/test/LocalUnit.test.ets b/PerformanceOptimization/GridComponentLoadSlow/entry/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..165fc1615ee8618b4cb6a622f144a9a707eee99f --- /dev/null +++ b/PerformanceOptimization/GridComponentLoadSlow/entry/src/test/LocalUnit.test.ets @@ -0,0 +1,33 @@ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function localUnitTest() { + describe('localUnitTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }); + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }); + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }); + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }); + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }); + }); +} \ No newline at end of file diff --git a/PerformanceOptimization/GridComponentLoadSlow/hvigor/hvigor-config.json5 b/PerformanceOptimization/GridComponentLoadSlow/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..5bebc9755447385d82ce4138f54d991b1f85f348 --- /dev/null +++ b/PerformanceOptimization/GridComponentLoadSlow/hvigor/hvigor-config.json5 @@ -0,0 +1,22 @@ +{ + "modelVersion": "5.0.5", + "dependencies": { + }, + "execution": { + // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */ + // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */ + // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */ + // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */ + // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */ + }, + "logging": { + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ + }, + "debugging": { + // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */ + }, + "nodeOptions": { + // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/ + // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/ + } +} diff --git a/PerformanceOptimization/GridComponentLoadSlow/hvigorfile.ts b/PerformanceOptimization/GridComponentLoadSlow/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..f3cb9f1a87a81687554a76283af8df27d8bda775 --- /dev/null +++ b/PerformanceOptimization/GridComponentLoadSlow/hvigorfile.ts @@ -0,0 +1,6 @@ +import { appTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/PerformanceOptimization/GridComponentLoadSlow/oh-package-lock.json5 b/PerformanceOptimization/GridComponentLoadSlow/oh-package-lock.json5 new file mode 100644 index 0000000000000000000000000000000000000000..7fcf818273347b97063c0c0a151bb14770ca1c79 --- /dev/null +++ b/PerformanceOptimization/GridComponentLoadSlow/oh-package-lock.json5 @@ -0,0 +1,27 @@ +{ + "meta": { + "stableOrder": true + }, + "lockfileVersion": 3, + "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", + "specifiers": { + "@ohos/hamock@1.0.0": "@ohos/hamock@1.0.0", + "@ohos/hypium@1.0.21": "@ohos/hypium@1.0.21" + }, + "packages": { + "@ohos/hamock@1.0.0": { + "name": "@ohos/hamock", + "version": "1.0.0", + "integrity": "sha512-K6lDPYc6VkKe6ZBNQa9aoG+ZZMiwqfcR/7yAVFSUGIuOAhPvCJAo9+t1fZnpe0dBRBPxj2bxPPbKh69VuyAtDg==", + "resolved": "https://ohpm.openharmony.cn/ohpm/@ohos/hamock/-/hamock-1.0.0.har", + "registryType": "ohpm" + }, + "@ohos/hypium@1.0.21": { + "name": "@ohos/hypium", + "version": "1.0.21", + "integrity": "sha512-iyKGMXxE+9PpCkqEwu0VykN/7hNpb+QOeIuHwkmZnxOpI+dFZt6yhPB7k89EgV1MiSK/ieV/hMjr5Z2mWwRfMQ==", + "resolved": "https://ohpm.openharmony.cn/ohpm/@ohos/hypium/-/hypium-1.0.21.har", + "registryType": "ohpm" + } + } +} \ No newline at end of file diff --git a/PerformanceOptimization/GridComponentLoadSlow/oh-package.json5 b/PerformanceOptimization/GridComponentLoadSlow/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..a8aff0c5aff22d78aa26fd19c3861f4320e951ff --- /dev/null +++ b/PerformanceOptimization/GridComponentLoadSlow/oh-package.json5 @@ -0,0 +1,10 @@ +{ + "modelVersion": "5.0.5", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.21", + "@ohos/hamock": "1.0.0" + } +} diff --git a/PerformanceOptimization/LoadPerformanceInWeb/.gitignore b/PerformanceOptimization/LoadPerformanceInWeb/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b --- /dev/null +++ b/PerformanceOptimization/LoadPerformanceInWeb/.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/PerformanceOptimization/LoadPerformanceInWeb/AppScope/app.json5 b/PerformanceOptimization/LoadPerformanceInWeb/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..90c8a4be23d37f75317e621c713bac79bf9ed023 --- /dev/null +++ b/PerformanceOptimization/LoadPerformanceInWeb/AppScope/app.json5 @@ -0,0 +1,10 @@ +{ + "app": { + "bundleName": "com.example.loadperformanceinweb", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:layered_image", + "label": "$string:app_name" + } +} diff --git a/PerformanceOptimization/LoadPerformanceInWeb/AppScope/resources/base/element/string.json b/PerformanceOptimization/LoadPerformanceInWeb/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..1ef88f629c31c52521700d69d2268570a78bfd40 --- /dev/null +++ b/PerformanceOptimization/LoadPerformanceInWeb/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "LoadPerformanceInWeb" + } + ] +} diff --git a/PerformanceOptimization/LoadPerformanceInWeb/AppScope/resources/base/media/background.png b/PerformanceOptimization/LoadPerformanceInWeb/AppScope/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/PerformanceOptimization/LoadPerformanceInWeb/AppScope/resources/base/media/background.png differ diff --git a/PerformanceOptimization/LoadPerformanceInWeb/AppScope/resources/base/media/foreground.png b/PerformanceOptimization/LoadPerformanceInWeb/AppScope/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/PerformanceOptimization/LoadPerformanceInWeb/AppScope/resources/base/media/foreground.png differ diff --git a/PerformanceOptimization/LoadPerformanceInWeb/AppScope/resources/base/media/layered_image.json b/PerformanceOptimization/LoadPerformanceInWeb/AppScope/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/PerformanceOptimization/LoadPerformanceInWeb/AppScope/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/PerformanceOptimization/LoadPerformanceInWeb/build-profile.json5 b/PerformanceOptimization/LoadPerformanceInWeb/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..9e87e7e6f19020fe21192844709f192cec80fd44 --- /dev/null +++ b/PerformanceOptimization/LoadPerformanceInWeb/build-profile.json5 @@ -0,0 +1,42 @@ +{ + "app": { + "signingConfigs": [], + "products": [ + { + "name": "default", + "signingConfig": "default", + "targetSdkVersion": "5.0.5(17)", + "compatibleSdkVersion": "5.0.5(17)", + "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/PerformanceOptimization/LoadPerformanceInWeb/code-linter.json5 b/PerformanceOptimization/LoadPerformanceInWeb/code-linter.json5 new file mode 100644 index 0000000000000000000000000000000000000000..073990fa45394e1f8e85d85418ee60a8953f9b99 --- /dev/null +++ b/PerformanceOptimization/LoadPerformanceInWeb/code-linter.json5 @@ -0,0 +1,32 @@ +{ + "files": [ + "**/*.ets" + ], + "ignore": [ + "**/src/ohosTest/**/*", + "**/src/test/**/*", + "**/src/mock/**/*", + "**/node_modules/**/*", + "**/oh_modules/**/*", + "**/build/**/*", + "**/.preview/**/*" + ], + "ruleSet": [ + "plugin:@performance/recommended", + "plugin:@typescript-eslint/recommended" + ], + "rules": { + "@security/no-unsafe-aes": "error", + "@security/no-unsafe-hash": "error", + "@security/no-unsafe-mac": "warn", + "@security/no-unsafe-dh": "error", + "@security/no-unsafe-dsa": "error", + "@security/no-unsafe-ecdsa": "error", + "@security/no-unsafe-rsa-encrypt": "error", + "@security/no-unsafe-rsa-sign": "error", + "@security/no-unsafe-rsa-key": "error", + "@security/no-unsafe-dsa-key": "error", + "@security/no-unsafe-dh-key": "error", + "@security/no-unsafe-3des": "error" + } +} \ No newline at end of file diff --git a/PerformanceOptimization/LoadPerformanceInWeb/entry/.gitignore b/PerformanceOptimization/LoadPerformanceInWeb/entry/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/PerformanceOptimization/LoadPerformanceInWeb/entry/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/PerformanceOptimization/LoadPerformanceInWeb/entry/build-profile.json5 b/PerformanceOptimization/LoadPerformanceInWeb/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..4d611879c7913fb0610c686e2399258ab3a6dad1 --- /dev/null +++ b/PerformanceOptimization/LoadPerformanceInWeb/entry/build-profile.json5 @@ -0,0 +1,28 @@ +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/PerformanceOptimization/LoadPerformanceInWeb/entry/hvigorfile.ts b/PerformanceOptimization/LoadPerformanceInWeb/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..c6edcd90486dd5a853cf7d34c8647f08414ca7a3 --- /dev/null +++ b/PerformanceOptimization/LoadPerformanceInWeb/entry/hvigorfile.ts @@ -0,0 +1,6 @@ +import { hapTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/PerformanceOptimization/LoadPerformanceInWeb/entry/obfuscation-rules.txt b/PerformanceOptimization/LoadPerformanceInWeb/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/PerformanceOptimization/LoadPerformanceInWeb/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/PerformanceOptimization/LoadPerformanceInWeb/entry/oh-package.json5 b/PerformanceOptimization/LoadPerformanceInWeb/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..248c3b7541a589682a250f86a6d3ecf7414d2d6a --- /dev/null +++ b/PerformanceOptimization/LoadPerformanceInWeb/entry/oh-package.json5 @@ -0,0 +1,10 @@ +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/cpps/DefineJSBridge.cpp b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/cpps/DefineJSBridge.cpp new file mode 100644 index 0000000000000000000000000000000000000000..727e06acbdc3dd9690ef20217d08cb8b8ca8d359 --- /dev/null +++ b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/cpps/DefineJSBridge.cpp @@ -0,0 +1,56 @@ +// [Start define_js_bridge] +// Define the JSBridge function +static void ProxyMethod1(const char* webTag, void* userData) { + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", "Method1 webTag :%{public}s",webTag); +} + +static void ProxyMethod2(const char* webTag, void* userData) { + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", "Method2 webTag :%{public}s",webTag); +} + +static void ProxyMethod3(const char* webTag, void* userData) { + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", "Method3 webTag :%{public}s",webTag); +} + +void RegisterCallback(const char *webTag) { + int myUserData = 100; + //Create function method structure + ArkWeb_ProxyMethod m1 = { + .methodName = "method1", + .callback = ProxyMethod1, + .userData = (void *)&myUserData + }; + ArkWeb_ProxyMethod m2 = { + .methodName = "method2", + .callback = ProxyMethod2, + .userData = (void *)&myUserData + }; + ArkWeb_ProxyMethod m3 = { + .methodName = "method3", + .callback = ProxyMethod3, + .userData = (void *)&myUserData + }; + ArkWeb_ProxyMethod methodList[2] = {m1,m2}; + + //Create a JSBridge object structure + ArkWeb_ProxyObject obj = { + .objName = "ndkProxy", + .methodList = methodList, + .size = 2 + }; + // Get the ArkWeb_Controller API structure + ArkWeb_AnyNativeAPI* apis = OH_ArkWeb_GetNativeAPI(ArkWeb_NativeAPIVariantKind::ARKWEB_NATIVE_CONTROLLER); + ArkWeb_ControllerAPI* ctrlApi = reinterpret_cast(apis); + + // Call the registration interface, registration function + ctrlApi->registerJavaScriptProxy(webTag, &obj); + + ArkWeb_ProxyMethod asyncMethodList[1] = {m3}; + ArkWeb_ProxyObject obj2 = { + .objName = "ndkProxy", + .methodList = asyncMethodList, + .size = 1 + }; + ctrlApi->registerAsyncJavaScriptProxy(webTag, &obj2); +} +// [End define_js_bridge] \ No newline at end of file diff --git a/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/cpps/hello.cpp b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/cpps/hello.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d395a7f95c5680ee4c482ca2bf2ac0217a29e4c8 --- /dev/null +++ b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/cpps/hello.cpp @@ -0,0 +1,57 @@ +// [Start hello_cpp] +// Registration objects and methods, sending scripts to callbacks after H5 execution, parsing instances passed from the side of the storage application and other code logics are not displayed here, and developers realize them by themselves according to their own business scenarios. +// Send the JS script to the H5 side for execution +static napi_value RunJavaScript(napi_env env, napi_callback_info info) { + size_t argc = 2; + napi_value args[2] = {nullptr}; + napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + + // Get the first parameter webTag + size_t webTagSize = 0; + napi_get_value_string_utf8(env, args[0], nullptr, 0, &webTagSize); + char *webTagValue = new (std::nothrow) char[webTagSize + 1]; + size_t webTagLength = 0; + napi_get_value_string_utf8(env, args[0], webTagValue, webTagSize + 1, &webTagLength); + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", "ndk OH_NativeArkWeb_RunJavaScript webTag:%{public}s", + webTagValue); + + // Get the second parameter jsCode + size_t bufferSize = 0; + napi_get_value_string_utf8(env, args[1], nullptr, 0, &bufferSize); + char *jsCode = new (std::nothrow) char[bufferSize + 1]; + size_t byteLength = 0; + napi_get_value_string_utf8(env, args[1], jsCode, bufferSize + 1, &byteLength); + + OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "ArkWeb", + "ndk OH_NativeArkWeb_RunJavaScript jsCode len:%{public}zu", strlen(jsCode)); + + // Construct the structure of runJS execution + ArkWeb_JavaScriptObject object = {(uint8_t *)jsCode, bufferSize, &JSBridgeObject::StaticRunJavaScriptCallback, + static_cast(jsbridge_object_ptr->GetWeakPtr())}; + controller->runJavaScript(webTagValue, &object); + return nullptr; +} + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) { + napi_property_descriptor desc[] = { + {"nativeWebInit", nullptr, NativeWebInit, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"runJavaScript", nullptr, RunJavaScript, nullptr, nullptr, nullptr, napi_default, nullptr} + }; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void *)0), + .reserved = {0} +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) { napi_module_register(&demoModule); } +// [End hello_cpp] \ No newline at end of file diff --git a/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/cpps/nnapi_init.cpp b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/cpps/nnapi_init.cpp new file mode 100644 index 0000000000000000000000000000000000000000..74d717907e512b4d745f59da435ebf2a9e2c1003 --- /dev/null +++ b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/cpps/nnapi_init.cpp @@ -0,0 +1,51 @@ +// [Start register_custom_schemes] +// 注册三方协议的配置,需要在Web内核初始化之前调用,否则会注册失败。 +static napi_value RegisterCustomSchemes(napi_env env, napi_callback_info info) { + OH_LOG_INFO(LOG_APP, "register custom schemes"); + OH_ArkWeb_RegisterCustomSchemes("custom", ARKWEB_SCHEME_OPTION_STANDARD | ARKWEB_SCHEME_OPTION_CORS_ENABLED | ARKWEB_SCHEME_OPTION_CODE_CACHE_ENABLED); + return nullptr; +} +// [End register_custom_schemes] + +// [Start rawfile_request] +// 在worker线程中读取rawfile,并通过ResourceHandler返回给Web内核。 +void RawfileRequest::ReadRawfileDataOnWorkerThread() { + OH_LOG_INFO(LOG_APP, "read rawfile in worker thread."); + const struct UrlInfo { + std::string resource; + std::string mimeType; + } urlInfos[] = {{"local.html", "text/html"}, + {"local_script.js", "text/javascript"}, + {"test-cc.js", "text/javascript"} + }; + + + if (!resourceManager()) { + OH_LOG_ERROR(LOG_APP, "read rawfile error, resource manager is nullptr."); + return; + } + + + RawFile *rawfile = OH_ResourceManager_OpenRawFile(resourceManager(), rawfilePath().c_str()); + if (!rawfile) { + OH_ArkWebResponse_SetStatus(response(), 404); + } else { + OH_ArkWebResponse_SetStatus(response(), 200); + } + + + for (auto &urlInfo : urlInfos) { + if (urlInfo.resource == rawfilePath()) { + OH_ArkWebResponse_SetMimeType(response(), urlInfo.mimeType.c_str()); + break; + } + } + + + if ("test-cc.js" == rawfilePath()) { + OH_LOG_ERROR(LOG_APP, "OH_ArkWebResponse_SetHeaderByName ResponseDataID"); + OH_ArkWebResponse_SetHeaderByName(response(), "ResponseDataID", "0000000000001", true); + } + OH_ArkWebResponse_SetCharset(response(), "UTF-8"); +} +// [End rawfile_request] \ No newline at end of file diff --git a/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/entryability/CaseFour.ets b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/entryability/CaseFour.ets new file mode 100644 index 0000000000000000000000000000000000000000..5b20d1f8d8606874b9553599a8231c40339f71c3 --- /dev/null +++ b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/entryability/CaseFour.ets @@ -0,0 +1,18 @@ +// [Start case_four] +import { webview } from '@kit.ArkWeb'; + +@Entry +@Component +struct WebComponent { + webviewController: webview.WebviewController = new webview.WebviewController(); + build() { + Column() { + Web({ src: 'https://www.example.com/', controller: this.webviewController}) + .onPageEnd(() => { + // Pre-connected https://www.iana.org/help/example-domains + this.webviewController.prefetchPage('https://www.iana.org/help/example-domains'); + }) + } + } +} +// [End case_four] \ No newline at end of file diff --git a/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/entryability/CreateCarrier.ets b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/entryability/CreateCarrier.ets new file mode 100644 index 0000000000000000000000000000000000000000..9429d5c252c11bef5a10eebc9c20232e8652d2ea --- /dev/null +++ b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/entryability/CreateCarrier.ets @@ -0,0 +1,18 @@ +// [Start carrier_ability] +import { UIAbility } from '@kit.AbilityKit'; +import { window } from '@kit.ArkUI'; +// Carrier Ability +// EntryAbility.ets +import {createNWeb} from '../pages/common'; +export default class EntryAbility extends UIAbility { + onWindowStageCreate(windowStage: window.WindowStage): void { + windowStage.loadContent('pages/Index', (err, data) => { + // Create ArkWeb dynamic components (need to pass in UIContext), which can be created at any time after loadContent. + createNWeb('https://www.example.com', windowStage.getMainWindowSync().getUIContext()); + if (err.code) { + return; + } + }); + } +} +// [End carrier_ability] \ No newline at end of file diff --git a/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/entryability/EntryAbility.ets b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..924b521c190df1ca53f54f4fede8a67c5d5cb4e0 --- /dev/null +++ b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,15 @@ +// [Start entry_ability] +// Carrier Ability +import { UIAbility } from '@kit.AbilityKit'; +import { window } from '@kit.ArkUI'; +import { createNWeb } from '../pages/common'; + +export default class EntryAbility extends UIAbility { + onWindowStageCreate(windowStage: window.WindowStage): void { + windowStage.loadContent('pages/Index', (err) => { + // Create an empty ArkWeb dynamic component in advance (need to pass in UIContext) and start the rendering process. + createNWeb('about://blank', windowStage.getMainWindowSync().getUIContext()); + }); + } +} +// [End entry_ability] \ No newline at end of file diff --git a/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/entryability/PrefetchResource.ets b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/entryability/PrefetchResource.ets new file mode 100644 index 0000000000000000000000000000000000000000..2cac2ea40b0ed98a7c048259f66841ca0bb48cb4 --- /dev/null +++ b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/entryability/PrefetchResource.ets @@ -0,0 +1,30 @@ +// [Start prefetch_resource] +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; +import { webview } from '@kit.ArkWeb'; + +export default class EntryAbility extends UIAbility { + // EntryAbility.ets + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + console.log('EntryAbility onCreate.'); + webview.WebviewController.initializeWebEngine(); + // When pre-acquiring, 'https://www.example1.com/POST? E=f&g=h' is replaced by the actual website address to be visited. + webview.WebviewController.prefetchResource( + { + url: 'https://www.example.com/POST?e=f&g=h', + method: 'POST', + formData: 'a=x&b=y' + }, + [{ + headerKey: 'c', + headerValue: 'z' + }], + 'KeyX', 500 + ); + AppStorage.setOrCreate('abilityWant', want); + console.log('EntryAbility onCreate done.'); + } + // ... +} +// [End prefetch_resource] \ No newline at end of file diff --git a/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/entryability/SetSchemeHandler.ets b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/entryability/SetSchemeHandler.ets new file mode 100644 index 0000000000000000000000000000000000000000..7af1f021d4188f5badde7fd8d54993bfa238caa4 --- /dev/null +++ b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/entryability/SetSchemeHandler.ets @@ -0,0 +1,43 @@ +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; +import testNapi from 'libentry.so'; +import webview from '@ohos.web.webview'; + +export default class EntryAbility extends UIAbility { + // [Start set_scheme_handler] + // EntryAbility.ets + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + // 注册三方协议的配置。 + testNapi.registerCustomSchemes(); + // 初始化Web组件内核,该操作会初始化Browser进程以及创建BrowserContext。 + webview.WebviewController.initializeWebEngine(); + // 设置SchemeHandler。 + testNapi.setSchemeHandler(); + } + // [End set_scheme_handler] + + onDestroy(): void { + + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + windowStage.loadContent('pages/Index', (err, data) => { + if (err.code) { + return; + } + }); + } + + onWindowStageDestroy(): void { + + } + + onForeground(): void { + + } + + onBackground(): void { + + } +}; \ No newline at end of file diff --git a/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..8e4de99282050bad799ac892eb85ac5449364a51 --- /dev/null +++ b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -0,0 +1,16 @@ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit'; + +const DOMAIN = 0x0000; + +export default class EntryBackupAbility extends BackupExtensionAbility { + async onBackup() { + hilog.info(DOMAIN, 'testTag', 'onBackup ok'); + await Promise.resolve(); + } + + async onRestore(bundleVersion: BundleVersion) { + hilog.info(DOMAIN, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion)); + await Promise.resolve(); + } +} \ No newline at end of file diff --git a/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/pages/ByteCodeCache.ets b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/pages/ByteCodeCache.ets new file mode 100644 index 0000000000000000000000000000000000000000..4c74948367ead622ab9ed8d1d44946cafbb90dcb --- /dev/null +++ b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/pages/ByteCodeCache.ets @@ -0,0 +1,79 @@ +import { webview } from '@kit.ArkWeb'; +import business_error from '@kit.BasicServicesKit' + +@Component +struct ByteCodeCache { + // [Start scheme_one] + scheme1: webview.WebCustomScheme = { schemeName: "scheme1", isSupportCORS: true, isSupportFetch: true, isCodeCacheSupported: true } + // [End scheme_one] + webController: webview.WebviewController = new webview.WebviewController(); + @State jsData: string = 'JavaScript Data'; + @State jsData2: string = 'JavaScript Data'; + + // [Start about_to_appear] + aboutToAppear(): void { + try { + webview.WebviewController.customizeSchemes([this.scheme1]) + } catch (error) { + let e: business_error.BusinessError = error as business_error.BusinessError; + console.error(`ErrorCode: ${e.code}, Message: ${e.message}`); + } + } + // [End about_to_appear] + + build() { + Column() { + // [Start byte_code_cache_web] + Web({ + src: $rawfile('index.html'), + controller: this.webController + }) + .fileAccess(true) + .javaScriptAccess(true) + .width('100%') + .height('100%') + .onConsole((event) => { + console.log('ets onConsole:' + event?.message.getMessage()); + return false + }) + .onInterceptRequest((event) => { + let responseResource = new WebResourceResponse() + // Intercept page requests + if (event?.request.getRequestUrl() == 'https://www.intercept.com/test-cc.js') { + // Construct response data + responseResource.setResponseHeader([ + { + headerKey: 'ResponseDataID', + headerValue: '0000000000002' + // Format: No more than 13 digits. Js ID, this field must be updated when Js is updated. + }]); + responseResource.setResponseData(this.jsData); + responseResource.setResponseEncoding('utf-8'); + responseResource.setResponseMimeType('application/javascript'); + responseResource.setResponseCode(200); + responseResource.setReasonMessage('OK'); + return responseResource; + + + } + if (event?.request.getRequestUrl() == 'scheme1://www.intercept.com/test-cc2.js') { + // Construct response data + responseResource.setResponseHeader([ + { + headerKey: 'ResponseDataID', + headerValue: '0000000000001' + // Format: No more than 13 digits. Js ID, this field must be updated when Js is updated. + }]); + responseResource.setResponseData(this.jsData2); + responseResource.setResponseEncoding('utf-8'); + responseResource.setResponseMimeType('application/javascript'); + responseResource.setResponseCode(200); + responseResource.setReasonMessage('OK'); + return responseResource; + } + return null; + }) + // // [End byte_code_cache_web] + } + } +} \ No newline at end of file diff --git a/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/pages/CaseOne.ets b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/pages/CaseOne.ets new file mode 100644 index 0000000000000000000000000000000000000000..ef0cd636615496fe700ddbaf23886eb02f3d6f32 --- /dev/null +++ b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/pages/CaseOne.ets @@ -0,0 +1,18 @@ +// [Start case_one] +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; +import { webview } from '@kit.ArkWeb'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) { + console.log('EntryAbility onCreate'); + webview.WebviewController.initializeWebEngine(); + // When pre-connecting, you need to replace' https://www.example.com' with the actual website address to visit + // Specify that the second parameter is true, which means to pre-connect. If it is false, the interface will only pre-resolve the URL. + webview.WebviewController.prepareForPageLoad('https://www.example.com/', true, 2); + AppStorage.setOrCreate('abilityWant', want); + console.log('EntryAbility onCreate done'); + } +} +// [End case_one] \ No newline at end of file diff --git a/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/pages/CaseThree.ets b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/pages/CaseThree.ets new file mode 100644 index 0000000000000000000000000000000000000000..460f3bb7c3af4a0773d20f88d253a2e541ac24cf --- /dev/null +++ b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/pages/CaseThree.ets @@ -0,0 +1,18 @@ +// [Start case_three] +import { webview } from '@kit.ArkWeb'; + +@Entry +@Component +struct WebComponent { + webviewController: webview.WebviewController = new webview.WebviewController(); + build() { + Column() { + Web({ src: 'https://www.example.com/', controller: this.webviewController}) + .onPageEnd(() => { + // Pre-connected https://www.example1.com/ + webview.WebviewController.prepareForPageLoad('https://www.example.com/', true, 120); + }) + } + } +} +// [End case_three] \ No newline at end of file diff --git a/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/pages/CaseTwo.ets b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/pages/CaseTwo.ets new file mode 100644 index 0000000000000000000000000000000000000000..cd253be2e72a47fab34e511734953f460cdf43c9 --- /dev/null +++ b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/pages/CaseTwo.ets @@ -0,0 +1,25 @@ +// [Start case_two] +import { webview } from '@kit.ArkWeb'; + +@Entry +@Component +struct WebComponent { + webviewController: webview.WebviewController = new webview.WebviewController(); + build() { + Column() { + Button('loadData') + .onClick(() => { + if (this.webviewController.accessBackward()) { + this.webviewController.backward(); + } + }) + Web({ src: 'https://www.example.com/cn/', controller: this.webviewController}) + .onAppear(() => { + // Specify that the second parameter is true, which means to pre-connect. If it is false, the interface will only pre-resolve the URL. + // The third parameter is the number of socket to be pre-connected. A maximum of six are allowed. + webview.WebviewController.prepareForPageLoad('https://www.example.com/cn/', true, 2); + }) + } + } +} +// [End case_two] \ No newline at end of file diff --git a/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/pages/ClearResourceCache.ets b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/pages/ClearResourceCache.ets new file mode 100644 index 0000000000000000000000000000000000000000..ee18035b1f71e96c2c8342b2db52ca2aa08c4526 --- /dev/null +++ b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/pages/ClearResourceCache.ets @@ -0,0 +1,19 @@ +// [Start clear_resource_cache] +import { webview } from '@kit.ArkWeb'; + +@Entry +@Component +struct WebComponent { + webviewController: webview.WebviewController = new webview.WebviewController(); + + build() { + Column() { + Web({ src: 'https://www.example.com/', controller: this.webviewController }) + .onPageEnd(() => { + // Clear the cache of pre-acquired resources that are no longer used in the future. + webview.WebviewController.clearPrefetchedResource(['KeyX']); + }) + } + } +} +// [End clear_resource_cache] \ No newline at end of file diff --git a/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/pages/CreateNodeController.ets b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/pages/CreateNodeController.ets new file mode 100644 index 0000000000000000000000000000000000000000..254814eed60390b24125f5166f2c7ac6ae472e74 --- /dev/null +++ b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/pages/CreateNodeController.ets @@ -0,0 +1,106 @@ +// [Start create_node_controller] +// Create NodeController +// common.ets +import { UIContext } from '@kit.ArkUI'; +import { webview } from '@kit.ArkWeb'; +import { NodeController, BuilderNode, Size, FrameNode } from '@kit.ArkUI'; + +// Specific component contents of dynamic components in @Builder@Builder中为动态组件的具体组件内容 +// Data is a parameter encapsulation class. +class Data{ + url: string = 'https://www.example.com'; + controller: WebviewController = new webview.WebviewController(); +} + +@Builder +function WebBuilder(data:Data) { + Column() { + Web({ src: data.url, controller: data.controller }) + .domStorageAccess(true) + .zoomAccess(true) + .fileAccess(true) + .mixedMode(MixedMode.All) + .width('100%') + .height('100%') + .onPageBegin(() => { + data.controller.onActive(); + }) + } +} + +let wrap = wrapBuilder(WebBuilder); + +// Used to control and feedback the behavior of nodes on the corresponding NodeContainer, which needs to be used together with NodeContainer +export class myNodeController extends NodeController { + private rootNode: BuilderNode | null = null; + private root: FrameNode | null = null; + + // The method that must be overridden is used to build the number of nodes and return the nodes to be mounted in the corresponding NodeContainer. + // //Called when the corresponding NodeContainer is created, or refreshed by calling the rebuild method. + makeNode(uiContext: UIContext): FrameNode | null { + console.log(' uicontext is undefined : '+ (uiContext === undefined)); + if (this.rootNode != null) { + const parent = this.rootNode.getFrameNode()?.getParent(); + if (parent) { + console.info(JSON.stringify(parent.getInspectorInfo())); + parent.removeChild(this.rootNode.getFrameNode()); + this.root = null; + } + this.root = new FrameNode(uiContext); + this.root.appendChild(this.rootNode.getFrameNode()); + // Returns the FrameNode node + return this.root; + } + // Returns a null node that controls the dynamic component to be unbound. + return null; + } + // Callback when layout size changes. + aboutToResize(size: Size) { + console.log('aboutToResize width : ' + size.width + ' height : ' + size.height ) + } + + // Call back when the NodeContainer corresponding to the controller is in Appear. + aboutToAppear() { + console.log('aboutToAppear') + } + + // Call back when the NodeContainer corresponding to the controller is Disappear. + aboutToDisappear() { + console.log('aboutToDisappear') + } + + // This function is a user-defined function and can be used as an initialization function. + // Initialize builderNode through UIContext, and then initialize the contents in @Builder through the Build interface in BuilderNode. + initWeb(url:string, uiContext:UIContext, control:WebviewController) { + if(this.rootNode != null) + { + return; + } + // Creating a node requires uiContext. + this.rootNode = new BuilderNode(uiContext) + // Create dynamic Web components + this.rootNode.build(wrap, { url:url, controller:control }) + } +} + +// Create the NodeController needed for Map saving. +let NodeMap:Map = new Map(); +// Create WebViewController needed for Map saving. +let controllerMap:Map = new Map(); + +// Initialization requires UIContext to be obtained in Ability. +export const createNWeb = (url: string, uiContext: UIContext) => { + // Create NodeController + let baseNode = new myNodeController(); + let controller = new webview.WebviewController() ; + // Initialize a custom web component + baseNode.initWeb(url, uiContext, controller); + controllerMap.set(url, controller) + NodeMap.set(url, baseNode); +} + +// Customize to get the NodeController interface. +export const getNWeb = (url : string) : myNodeController | undefined => { + return NodeMap.get(url); +} +// [End create_node_controller] \ No newline at end of file diff --git a/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/pages/Index.ets b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..5208dd0e18805519ec2d62705a207b299edb2e96 --- /dev/null +++ b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,27 @@ +/** + * 优化Web场景下的加载性能问题 + */ + +// [Start page_index] +// Index.ets +@Entry +@Component +struct Index { + pageInfos: NavPathStack = new NavPathStack() + + build() { + Navigation(this.pageInfos) { + Column() { + Button('加载测试页面', { stateEffect: true, type: ButtonType.Capsule }) + .width('80%') + .height(40) + .margin(20) + .onClick(() => { + // Put the NavDestination page information specified by name on the stack. + this.pageInfos.pushPath({ name: 'pageOne' }) + }) + } + }.title('NavIndex') + } +} +// [End page_index] diff --git a/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/pages/JsBridgeOfArkTS.ets b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/pages/JsBridgeOfArkTS.ets new file mode 100644 index 0000000000000000000000000000000000000000..1c4c47fde571c3db25ea5188b61aa858b39e8a30 --- /dev/null +++ b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/pages/JsBridgeOfArkTS.ets @@ -0,0 +1,31 @@ +// [Start js_bridge_of_arkTs] +import { webview } from '@kit.ArkWeb'; + +@Entry +@Component +struct WebComponent { + webviewController: webview.WebviewController = new webview.WebviewController(); + + aboutToAppear() { + // Configure the Web to open the debugging mode + webview.WebviewController.setWebDebuggingAccess(true); + } + + build() { + Column() { + Button('runJavaScript') + .onClick(() => { + console.info('现在时间是:' + new Date().getTime()); + // When the front-end page function has no parameters, delete the param. + this.webviewController.runJavaScript('htmlTest(param)'); + }) + Button('runJavaScriptCodePassed') + .onClick(() => { + // Pass runJavaScript side code method + this.webviewController.runJavaScript(`function changeColor(){document.getElementById('text').style.color = 'red'}`); + }) + Web({ src: $rawfile('index.html'), controller: this.webviewController }) + } + } +} +// [End js_bridge_of_arkTs] \ No newline at end of file diff --git a/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/pages/JsBridgeOfNdk.ets b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/pages/JsBridgeOfNdk.ets new file mode 100644 index 0000000000000000000000000000000000000000..3c1e086905e6f89aa604eac62b921eef37ba0632 --- /dev/null +++ b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/pages/JsBridgeOfNdk.ets @@ -0,0 +1,54 @@ +// [Start js_bridge_of_ndk] +import testNapi from 'libentry.so'; +import { webview } from '@kit.ArkWeb'; + +class testObj { + constructor() { + } + + test(): string { + console.log('ArkUI Web Component'); + return "ArkUI Web Component"; + } + + toString(): void { + console.log('Web Component toString'); + } +} + +@Entry +@Component +struct Index { + webTag: string = 'ArkWeb1'; + controller: webview.WebviewController = new webview.WebviewController(this.webTag); + @State testObjtest: testObj = new testObj(); + + aboutToAppear() { + console.info("aboutToAppear"); + // init web ndk + testNapi.nativeWebInit(this.webTag); + } + + build() { + Column() { + Row() { + Button('runJS hello') + .fontSize(12) + .onClick(() => { + console.log('start:---->'+new Date().getTime()); + testNapi.runJavaScript(this.webTag, "runJSRetStr(\"" + "hello" + "\")"); + }) + }.height('20%') + + Row() { + Web({ src: $rawfile('runJS.html'), controller: this.controller }) + .javaScriptAccess(true) + .fileAccess(true) + .onControllerAttached(() => { + console.error("ndk onControllerAttached webId: " + this.controller.getWebId()); + }) + }.height('80%') + } + } +} +// [End js_bridge_of_ndk] \ No newline at end of file diff --git a/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/pages/LoadWebComponentError.ets b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/pages/LoadWebComponentError.ets new file mode 100644 index 0000000000000000000000000000000000000000..f85eb69ad86b5e88c0f02b4a846ee57953e2802f --- /dev/null +++ b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/pages/LoadWebComponentError.ets @@ -0,0 +1,21 @@ +// [Start load_web_component_error] +import { webview } from '@kit.ArkWeb'; + +@Entry +@Component +struct WebComponent { + webviewController: webview.WebviewController = new webview.WebviewController(); + + build() { + Column() { + // Load the business Web component at an appropriate time. This example takes the Button click trigger as an example. + Button('加载页面') + .onClick(() => { + // Please replace url with real address. + this.webviewController.loadUrl('https://www.example1.com/'); + }) + Web({ src: 'https://www.example.com/', controller: this.webviewController }) + } + } +} +// [End load_web_component_error] \ No newline at end of file diff --git a/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/pages/LoadWebComponentRight.ets b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/pages/LoadWebComponentRight.ets new file mode 100644 index 0000000000000000000000000000000000000000..7f8de490e184a84495e4c6f5fa10adb14513b7a0 --- /dev/null +++ b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/pages/LoadWebComponentRight.ets @@ -0,0 +1,40 @@ +// [Start load_web_component_right] +import { hiTraceMeter } from '@kit.PerformanceAnalysisKit'; +import { webview } from '@kit.ArkWeb'; + +@Entry +@Component +struct WebComponent { + controller: webview.WebviewController = new webview.WebviewController(); + webviewController: webview.WebviewController = new webview.WebviewController(); + + build() { + Column() { + // Load the business Web component at an appropriate time. This example takes the Button click trigger as an example. + Button('加载页面') + .onClick(() => { + // Performance dot + hiTraceMeter.startTrace('getMessageData', 1); + // Please replace url with real address. + this.controller.loadUrl('https://www.example1.com/'); + }) + Web({ src: 'https://www.example.com/', controller: this.webviewController }) + .onPageEnd(() => { + // When pre-acquiring, 'https://www.example1.com/POST? E=f&g=h' is replaced by the actual website address to be visited. + webview.WebviewController.prefetchResource( + { + url: 'https://www.example1.com/POST?e=f&g=h', + method: 'POST', + formData: 'a=x&b=y' + }, + [{ + headerKey: 'c', + headerValue: 'z' + }], + 'KeyX', 500 + ); + }) + } + } +} +// [End load_web_component_right] \ No newline at end of file diff --git a/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/pages/LoadWebPage.ets b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/pages/LoadWebPage.ets new file mode 100644 index 0000000000000000000000000000000000000000..c818fd53a3d980fdc22c26e9392154455990a6af --- /dev/null +++ b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/pages/LoadWebPage.ets @@ -0,0 +1,29 @@ +// [Start load_web_page] +import { webview } from '@kit.ArkWeb'; +import { hiTraceMeter } from '@kit.PerformanceAnalysisKit'; + +@Entry +@Component +struct Index { + controller: webview.WebviewController = new webview.WebviewController(); + + + build() { + Column() { + // Load business web components at the right time. This example is the example of Button click trigger. + Button('加载页面') + .onClick(() => { + // Performance hit point + hiTraceMeter.startTrace('getMessageData', 1); + this.controller.loadUrl('https://www.example.com/b.html'); + }) + Web({ src: 'https://www.example.com/a.html', controller: this.controller }) + .fileAccess(true) + .onPageEnd(() => { + // Performance hit point + hiTraceMeter.finishTrace('getMessageData', 1); + }) + } + } +} +// [End load_web_page] \ No newline at end of file diff --git a/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/pages/PageRequestInterception.ets b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/pages/PageRequestInterception.ets new file mode 100644 index 0000000000000000000000000000000000000000..78e0cd6d590207a8a376380f0c0e0144863611fd --- /dev/null +++ b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/pages/PageRequestInterception.ets @@ -0,0 +1,39 @@ +// [Start page_request_interception] +import { webview } from '@kit.ArkWeb'; +import { hiTraceMeter } from '@kit.PerformanceAnalysisKit'; + +@Entry +@Component +struct Index { + webViewController: webview.WebviewController = new webview.WebviewController(); + responseResource: WebResourceResponse = new WebResourceResponse(); + // The developer defines the response data, and the length of the response data must be greater than or equal to 1024 to generate CodeCache. + @State jsData: string = 'JavaScript Data'; + + build() { + Column() { + Web({ src: $rawfile('index.html'), controller: this.webViewController }) + .onInterceptRequest(event => { + // Intercept page requests + if (event?.request.getRequestUrl() === 'https://www.example.com/test.js') { + // Construct response data + this.responseResource.setResponseData(this.jsData); + this.responseResource.setResponseEncoding('utf-8'); + this.responseResource.setResponseMimeType('application/javascript'); + this.responseResource.setResponseCode(200); + this.responseResource.setReasonMessage('OK'); + return this.responseResource; + } + return null; + }) + .onPageBegin(() => { + hiTraceMeter.startTrace('getMessageData', 0); + }) + .onPageEnd(() => { + hiTraceMeter.finishTrace('getMessageData', 0); + }) + } + .width('100%') + } +} +// [End page_request_interception] \ No newline at end of file diff --git a/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/pages/PracticalCaseOne.ets b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/pages/PracticalCaseOne.ets new file mode 100644 index 0000000000000000000000000000000000000000..c4b679836c96d2e641c7a4a440940660f87ea644 --- /dev/null +++ b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/pages/PracticalCaseOne.ets @@ -0,0 +1,33 @@ +// [Start practical_case_one] +import { webview } from '@kit.ArkWeb'; +import { hiTraceMeter } from '@kit.PerformanceAnalysisKit'; + +@Entry +@Component +struct Index { + controller: webview.WebviewController = new webview.WebviewController(); + + build() { + Column() { + // Load the business Web component at an appropriate time. This example takes the Button click trigger as an example.在适当的时机加载业务用Web组件,本例以Button点击触发为例 + Button('加载页面') + .onClick(() => { + // Performance dot + hiTraceMeter.startTrace('unPrecompileJavaScript', 1); + // Please replace url with real address. + this.controller.loadUrl('https://www.example.com/b.html'); + }) + Web({ src: 'https://www.example.com/a.html', controller: this.controller }) + .fileAccess(true) + .onPageBegin((event) => { + console.log(`load page begin: ${event?.url}`); + }) + .onPageEnd((event) => { + // Performance dot + hiTraceMeter.finishTrace('unPrecompileJavaScript', 1); + console.log(`load page end: ${event?.url}`); + }) + } + } +} +// [End practical_case_one] \ No newline at end of file diff --git a/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/pages/PracticalCaseTwo.ets b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/pages/PracticalCaseTwo.ets new file mode 100644 index 0000000000000000000000000000000000000000..dcd58d26acb08447c737c3d0cc0d1080e909c4a0 --- /dev/null +++ b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/pages/PracticalCaseTwo.ets @@ -0,0 +1,56 @@ +// [Start practical_case_two] +import { webview } from '@kit.ArkWeb'; +import { hiTraceMeter } from '@kit.PerformanceAnalysisKit'; + +interface Config { + url: string, + localPath: string, // 本地资源路径 + options: webview.CacheOptions +} + +@Entry +@Component +struct Index { + controller: webview.WebviewController = new webview.WebviewController(); + // Configure precompiled JavaScript file information + configs: Array = [ + { + url: 'https://www.example.com/example.js', + localPath: 'example.js', + options: { + responseHeaders: [ + { headerKey: 'E-Tag', headerValue: 'xxx' }, + { headerKey: 'Last-Modified', headerValue: 'Web, 21 Mar 2024 10:38:41 GMT' } + ] + } + } + ] + + // [StartExclude practical_case_two] + build() { + Column() { + // [Start web_attach_controller] + Web({ src: 'https://www.example.com/a.html', controller: this.controller }) + .onControllerAttached(async () => { + // Read the configuration and precompile. + for (const config of this.configs) { + let content = await this.getUIContext().getHostContext().resourceManager.getRawFileContentSync(config.localPath); + + try { + this.controller.precompileJavaScript(config.url, content, config.options) + .then((errCode: number) => { + console.log('precompile successfully!' ); + }).catch((errCode: number) => { + console.error('precompile failed.' + errCode); + }) + } catch (err) { + console.error('precompile failed!.' + err.code + err.message); + } + } + }) + // [End web_attach_controller] + } + } + // [EndExclude practical_case_two] +} +// [End practical_case_two] diff --git a/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/pages/RegisterJavaScriptProxy.ets b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/pages/RegisterJavaScriptProxy.ets new file mode 100644 index 0000000000000000000000000000000000000000..94e1c2cba781ac06c697651c31d31a77c0938081 --- /dev/null +++ b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/pages/RegisterJavaScriptProxy.ets @@ -0,0 +1,125 @@ +import { webview } from '@kit.ArkWeb'; +import { BusinessError } from '@kit.BasicServicesKit'; +// Define ETS side objects and functions +class TestObj { + constructor() {} + test(testStr:string): string { + let start = Date.now(); + // Simulate time-consuming operations + for(let i = 0; i < 500000; i++) {} + let end = Date.now(); + console.log('objName.test start: ' + start); + return 'objName.test Sync function took ' + (end - start) + 'ms'; + } + asyncTestBool(testBol:boolean): Promise { + return new Promise((resolve, reject) => { + let start = Date.now(); + // Simulate time-consuming operation (asynchronous) + setTimeout(() => { + for(let i = 0; i < 500000; i++) {} + let end = Date.now(); + console.log('objAsyncName.asyncTestBool start: ' + start); + resolve('objName.asyncTestBool Async function took ' + (end - start) + 'ms'); + }, 0); // Use 0 ms delay to simulate an asynchronous operation that starts immediately + }); + } +} + +class WebObj { + constructor() {} + webTest(): string { + let start = Date.now(); + // Simulate time-consuming operations + for(let i = 0; i < 500000; i++) {} + let end = Date.now(); + console.log('objTestName.webTest start: ' + start); + return 'objTestName.webTest Sync function took ' + (end - start) + 'ms'; + } + webString(): string { + let start = Date.now(); + // Simulate time-consuming operations + for(let i = 0; i < 500000; i++) {} + let end = Date.now(); + console.log('objTestName.webString start: ' + start); + return 'objTestName.webString Sync function took ' + (end - start) + 'ms'; + } +} + +class AsyncObj { + constructor() { + } + + asyncTest(): Promise { + return new Promise((resolve, reject) => { + let start = Date.now(); + // Simulate time-consuming operation (asynchronous) + setTimeout(() => { + for (let i = 0; i < 500000; i++) { + } + let end = Date.now(); + console.log('objAsyncName.asyncTest start: ' + start); + resolve('objAsyncName.asyncTest Async function took ' + (end - start) + 'ms'); + }, 0); // Use 0 ms delay to simulate an asynchronous operation that starts immediately + }); + } + + asyncString(testStr:string): Promise { + return new Promise((resolve, reject) => { + let start = Date.now(); + // Simulate time-consuming operation (asynchronous) + setTimeout(() => { + for (let i = 0; i < 500000; i++) { + } + let end = Date.now(); + console.log('objAsyncName.asyncString start: ' + start); + resolve('objAsyncName.asyncString Async function took ' + (end - start) + 'ms'); + }, 0); // Use 0 millisecond delay to simulate immediate asynchronous operation + }); + } +} + +@Entry +@Component +struct Index { + controller: webview.WebviewController = new webview.WebviewController(); + @State testObjtest: TestObj = new TestObj(); + @State webTestObj: WebObj = new WebObj(); + @State asyncTestObj: AsyncObj = new AsyncObj(); + build() { + Column() { + // [Start register_javaScript_proxy] + Button('refresh') + .onClick(()=>{ + try{ + this.controller.refresh(); + } catch (error) { + console.error(`ErrorCode:${(error as BusinessError).code},Message:${(error as BusinessError).message}`); + } + }) + Button('Register JavaScript To Window') + .onClick(()=>{ + try { + // Only register synchronization functions + this.controller.registerJavaScriptProxy(this.webTestObj,"objTestName",["webTest","webString"]); + } catch (error) { + console.error(`ErrorCode:${(error as BusinessError).code},Message:${(error as BusinessError).message}`); + } + }) + Web({src: $rawfile('index.html'),controller: this.controller}).javaScriptAccess(true) + + // Registration by javaScriptProxy + // javaScriptProxy only supports the registration of one object. If you need to register multiple objects, please use registerJavaScriptProxy. + Web({src: $rawfile('index.html'),controller: this.controller}) + .javaScriptAccess(true) + .javaScriptProxy({ + object: this.testObjtest, + name:"objName", + methodList: ["test","toString"], + // Specify the list of asynchronous functions + asyncMethodList: ["test","toString"], + controller: this.controller + }) + // [End register_javaScript_proxy] + } + } +} \ No newline at end of file diff --git a/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/pages/RegisterSyncFunction.ets b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/pages/RegisterSyncFunction.ets new file mode 100644 index 0000000000000000000000000000000000000000..fbebce72f61c69b557cb94dafac5e921397ca82a --- /dev/null +++ b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/pages/RegisterSyncFunction.ets @@ -0,0 +1,112 @@ +// [Start register_sync_function] +import { webview } from '@kit.ArkWeb'; +import { BusinessError } from '@kit.BasicServicesKit'; +// Define ETS side objects and functions +class TestObj { + constructor() {} + test(testStr:string): string { + let start = Date.now(); + // Simulate time-consuming operations + for(let i = 0; i < 500000; i++) {} + let end = Date.now(); + console.log('objName.test start: ' + start); + return 'objName.test Sync function took ' + (end - start) + 'ms'; + } + asyncTestBool(testBol:boolean): Promise { + return new Promise((resolve, reject) => { + let start = Date.now(); + // Simulate time-consuming operation (asynchronous) + setTimeout(() => { + for(let i = 0; i < 500000; i++) {} + let end = Date.now(); + console.log('objAsyncName.asyncTestBool start: ' + start); + resolve('objName.asyncTestBool Async function took ' + (end - start) + 'ms'); + }, 0); // Use 0 ms delay to simulate an asynchronous operation that starts immediately + }); + } +} + +class WebObj { + constructor() {} + webTest(): string { + let start = Date.now(); + // Simulate time-consuming operations + for(let i = 0; i < 500000; i++) {} + let end = Date.now(); + console.log('objTestName.webTest start: ' + start); + return 'objTestName.webTest Sync function took ' + (end - start) + 'ms'; + } + webString(): string { + let start = Date.now(); + // Simulate time-consuming operations + for(let i = 0; i < 500000; i++) {} + let end = Date.now(); + console.log('objTestName.webString start: ' + start); + return 'objTestName.webString Sync function took ' + (end - start) + 'ms'; + } +} + +class AsyncObj { + constructor() { + } + + asyncTest(): Promise { + return new Promise((resolve, reject) => { + let start = Date.now(); + // Simulate time-consuming operation (asynchronous) + setTimeout(() => { + for (let i = 0; i < 500000; i++) { + } + let end = Date.now(); + console.log('objAsyncName.asyncTest start: ' + start); + resolve('objAsyncName.asyncTest Async function took ' + (end - start) + 'ms'); + }, 0); // Use 0 ms delay to simulate an asynchronous operation that starts immediately + }); + } + + asyncString(testStr:string): Promise { + return new Promise((resolve, reject) => { + let start = Date.now(); + // Simulate time-consuming operation (asynchronous) + setTimeout(() => { + for (let i = 0; i < 500000; i++) { + } + let end = Date.now(); + console.log('objAsyncName.asyncString start: ' + start); + resolve('objAsyncName.asyncString Async function took ' + (end - start) + 'ms'); + }, 0); // Use 0 millisecond delay to simulate immediate asynchronous operation + }); + } +} + +@Entry +@Component +struct Index { + controller: webview.WebviewController = new webview.WebviewController(); + @State testObjtest: TestObj = new TestObj(); + @State webTestObj: WebObj = new WebObj(); + @State asyncTestObj: AsyncObj = new AsyncObj(); + build() { + Column() { + Button('refresh') + .onClick(()=>{ + try{ + this.controller.refresh(); + } catch (error) { + console.error(`ErrorCode:${(error as BusinessError).code},Message:${(error as BusinessError).message}`); + } + }) + Button('Register JavaScript To Window') + .onClick(()=>{ + try { + // Only register synchronization functions + this.controller.registerJavaScriptProxy(this.webTestObj,"objTestName",["webTest","webString"]); + } catch (error) { + console.error(`ErrorCode:${(error as BusinessError).code},Message:${(error as BusinessError).message}`); + } + }) + Web({src: $rawfile('index.html'),controller: this.controller}).javaScriptAccess(true) + } + } +} +// [End register_sync_function] \ No newline at end of file diff --git a/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/pages/Second.ets b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/pages/Second.ets new file mode 100644 index 0000000000000000000000000000000000000000..f6086e22976bffb95b14a3bb468bfcc726cf1fe9 --- /dev/null +++ b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/pages/Second.ets @@ -0,0 +1,33 @@ +// [Start page_second] +// Second.ets +import { webview } from '@kit.ArkWeb'; +import { getNWeb } from './common'; + +@Builder +export function PageOneBuilder() { + Second() +} + +@Component +export struct Second { + webviewController: webview.WebviewController = new webview.WebviewController(); + aboutToAppear(): void { + // Output Web page start loading time + console.info(`load page start time: ${Date.now()}`); + } + build() { + NavDestination() { + Row() { + Column() { + // Please replace url with real address. + NodeContainer(getNWeb('https://www.example.com')) + .height('100%') + .width('100%') + } + .width('100%') + } + .height('100%') + } + } +} +// [End page_second] \ No newline at end of file diff --git a/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/pages/SetResposeData.ets b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/pages/SetResposeData.ets new file mode 100644 index 0000000000000000000000000000000000000000..0a4a2608c6fcb58c9df673a989ffaa256e74c1a8 --- /dev/null +++ b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/pages/SetResposeData.ets @@ -0,0 +1,44 @@ +// [Start set_respose_data] +import { webview } from '@kit.ArkWeb'; +import { hiTraceMeter } from '@kit.PerformanceAnalysisKit'; + +@Entry +@Component +struct Index { + controller: webview.WebviewController = new webview.WebviewController(); + responseResource: WebResourceResponse = new WebResourceResponse(); + // Construct response data + @State jsData: string = 'JavaScript Data'; + + build() { + Column() { + Web({ src: $rawfile('index.html'), controller: this.controller }) + .onInterceptRequest((event) => { + // Intercept page requests + if (event?.request.getRequestUrl() === 'https://www.example.com/test.js') { + // Construct response data + this.responseResource.setResponseHeader([ + { + // Format: No more than 13 digits. Js ID, this field must be updated when Js is updated. + headerKey: 'ResponseDataID', + headerValue: '0000000000001' + }]); + this.responseResource.setResponseData(this.jsData); + this.responseResource.setResponseEncoding('utf-8'); + this.responseResource.setResponseMimeType('application/javascript'); + this.responseResource.setResponseCode(200); + this.responseResource.setReasonMessage('OK'); + return this.responseResource; + } + return null; + }) + .onPageBegin(() => { + hiTraceMeter.startTrace('getMessageData', 0); + }) + .onPageEnd(() => { + hiTraceMeter.finishTrace('getMessageData', 0); + }) + } + } +} +// [End set_respose_data] \ No newline at end of file diff --git a/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/pages/UseArrayBufferInterceptReplace.ets b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/pages/UseArrayBufferInterceptReplace.ets new file mode 100644 index 0000000000000000000000000000000000000000..bafdc93b9ce5a41a07757692e44a56a524b02567 --- /dev/null +++ b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/pages/UseArrayBufferInterceptReplace.ets @@ -0,0 +1,119 @@ +// [Start use_array_buffer_intercept_replace] +import { webview } from '@kit.ArkWeb'; + +@Entry +@Component +struct WebComponent { + controller: webview.WebviewController = new webview.WebviewController() + scheme1: webview.WebCustomScheme = { schemeName: "imeituan", isSupportCORS: true, isSupportFetch: true } + responseResource: WebResourceResponse = new WebResourceResponse() + // Developer Custom Response Data + data: string = ""; + buffer: ArrayBuffer = new ArrayBuffer(this.data.length); + usingLen: number = 1; + + aboutToAppear(): void { + // Configure the Web to open the debugging mode + webview.WebviewController.setWebDebuggingAccess(true); + + try { + webview.WebviewController.customizeSchemes([this.scheme1]) + console.info(`customizeSchemes`) + } catch (error) { + console.error(error); + } + + this.initArrayBufferData(1); + } + + onPageShow(): void { + + } + + initStringData(size: Number): void { + switch (size){ + case 1: + this.usingLen = 10; //10k + break; + case 2: + this.usingLen = 1024; //1M + break; + case 3: + this.usingLen = 1024 * 10; //10M + break; + default: + this.usingLen = 1; + } + + let str: string = ""; + let str_1k: string = ""; + for (let i = 0 ; i < 1024; i++) { + str_1k = str_1k.concat("x"); + } + for (let j = 0; j < this.usingLen; j++) { + str = str.concat(str_1k); + } + + this.data = JSON.stringify({ + status: 200, + result: str, + }); + console.info("init data length: " + this.data.length); + } + + initArrayBufferData(size:Number): void { + this.initStringData(size); + console.error("target string: " + this.data); + this.buffer = new ArrayBuffer(this.data.length); + const uint8Array: Uint8Array = new Uint8Array(this.buffer); + for (let i = 0; i < this.data.length; i++) { + uint8Array[i] = this.data.charCodeAt(i); + } + } + + build() { + Column() { + Button('set to 10K') + .onClick(() => { + this.initArrayBufferData(1); + console.log("datalen set to length "+ this.buffer.byteLength); + }) + Button('set to 1M') + .onClick(() => { + this.initArrayBufferData(2); + console.log("datalen set to length "+ this.buffer.byteLength); + }) + Button('set to 10M') + .onClick(() => { + this.initArrayBufferData(3); + console.log("datalen set to length "+ this.buffer.byteLength); + }) + Web({ src: $rawfile("intercept.html"), controller: this.controller }) + .onConsole((event) => { + console.error(`ygz ${event?.message?.getMessage()}`); + return true; + }) + .onInterceptRequest((event) => { + if (event) { + console.error('url:' + event.request.getRequestUrl()); + // Block Page Request + if (!event.request.getRequestUrl().startsWith('http://bridge')) { + return null; + } + } + // Construct response data + // const str: string = buffer.from(this.buffer).toString(); + console.error("response data length: " + this.data.length); + this.responseResource.setResponseData(this.buffer); + this.responseResource.setResponseEncoding('utf-8'); + this.responseResource.setResponseMimeType('text/json'); + this.responseResource.setResponseCode(200); + this.responseResource.setReasonMessage('OK'); + this.responseResource.setResponseHeader([{ headerKey: 'Access-Control-Allow-Origin', headerValue: '*' }]); + console.info(`ygz return reponse`); + return this.responseResource; + }) + } + } +} +// [End use_array_buffer_intercept_replace] \ No newline at end of file diff --git a/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/pages/UseNodeController.ets b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/pages/UseNodeController.ets new file mode 100644 index 0000000000000000000000000000000000000000..fff0679327990bef1f973ee20abf7a9c637febe1 --- /dev/null +++ b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/pages/UseNodeController.ets @@ -0,0 +1,23 @@ +// [Start use_node_controller] +// Use the Page page of NodeController. +// Index.ets +import {createNWeb, getNWeb} from './common'; + +@Entry +@Component +struct Index { + build() { + Row() { + Column() { + // NodeContainer is used to bind with NodeController node, and rebuild will trigger makeNode. + // Page page is bound to NodeController through NodeContainer interface to realize dynamic component page display. + NodeContainer(getNWeb('https://www.example.com')) + .height('90%') + .width('100%') + } + .width('100%') + } + .height('100%') + } +} +// [End use_node_controller] \ No newline at end of file diff --git a/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/pages/UseStringInterceptReplace.ets b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/pages/UseStringInterceptReplace.ets new file mode 100644 index 0000000000000000000000000000000000000000..31731ab2310ae57e6e257f40d087e8a6078f7a42 --- /dev/null +++ b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/pages/UseStringInterceptReplace.ets @@ -0,0 +1,33 @@ +// [Start use_string_intercept_replace] +import { webview } from '@kit.ArkWeb'; + +@Entry +@Component +struct Index { + controller: webview.WebviewController = new webview.WebviewController(); + responseResource: WebResourceResponse = new WebResourceResponse(); + // Here is the string format data. + resourceStr: string = 'xxxxxxxxxxxxxxx'; + + build() { + Column() { + Web({ src: 'https:www.example.com/test.html', controller: this.controller }) + .onInterceptRequest(event => { + if (event) { + if (!event.request.getRequestUrl().startsWith('https://www.example.com/')) { + return null; + } + } + // Use string format data for interception and replacement + this.responseResource.setResponseData(this.resourceStr); + this.responseResource.setResponseEncoding('utf-8'); + this.responseResource.setResponseMimeType('text/json'); + this.responseResource.setResponseCode(200); + this.responseResource.setReasonMessage('OK'); + this.responseResource.setResponseHeader([{ headerKey: 'Access-Control-Allow-Origin', headerValue: '*' }]); + return this.responseResource; + }) + } + } +} +// [End use_string_intercept_replace] \ No newline at end of file diff --git a/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/pages/WebComponent.ets b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/pages/WebComponent.ets new file mode 100644 index 0000000000000000000000000000000000000000..68e8d1d4fc9535f993abfbe1c5b06c792ba21ec2 --- /dev/null +++ b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/pages/WebComponent.ets @@ -0,0 +1,15 @@ +// [Start web_component] +import { webview } from '@kit.ArkWeb'; + +@Entry +@Component +struct WebComponent { + webviewController: webview.WebviewController = new webview.WebviewController(); + + build() { + Column() { + Web({ src: 'https://www.example.com/', controller: this.webviewController }) + } + } +} +// [End web_component] \ No newline at end of file diff --git a/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/pages/common.ets b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/pages/common.ets new file mode 100644 index 0000000000000000000000000000000000000000..b293cfb9b83571437b3303b4b6141fdc2ceacc86 --- /dev/null +++ b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/pages/common.ets @@ -0,0 +1,126 @@ +// [Start page_common] +// Create NodeController +// common.ets +import { UIContext } from '@kit.ArkUI'; +import { webview } from '@kit.ArkWeb'; +import { NodeController, BuilderNode, Size, FrameNode } from '@kit.ArkUI'; + +// Specific component contents of dynamic components in @Builder@Builder中为动态组件的具体组件内容 +// Data is a parameter encapsulation class. +class Data { + url: string = 'https://www.example.com'; + controller: WebviewController = new webview.WebviewController(); +} + +@Builder +function webBuilder(data: Data) { + Column() { + Web({ src: data.url, controller: data.controller }) + .domStorageAccess(true) + .zoomAccess(true) + .fileAccess(true) + .mixedMode(MixedMode.All) + .width('100%') + .height('100%') + .onPageEnd((event) => { + // Output Web page loading completion time + console.info(`load page end time: ${Date.now()}`); + }) + } +} + +let wrap = wrapBuilder(webBuilder); + +// Used to control and feedback the behavior of nodes on the corresponding NodeContainer, which needs to be used together with NodeContainer +export class MyNodeController extends NodeController { + private rootNode: BuilderNode | null = null; + private root: FrameNode | null = null; + private rootWebviewController: webview.WebviewController | null = null; + + // The method that must be overridden is used to build the number of nodes and return the nodes to be mounted in the corresponding NodeContainer. + // //Called when the corresponding NodeContainer is created, or refreshed by calling the rebuild method. + makeNode(uiContext: UIContext): FrameNode | null { + console.info(' uicontext is undefined : ' + (uiContext === undefined)); + if (this.rootNode != null) { + const parent = this.rootNode.getFrameNode()?.getParent(); + if (parent) { + console.info(JSON.stringify(parent.getInspectorInfo())); + parent.removeChild(this.rootNode.getFrameNode()); + this.root = null; + } + this.root = new FrameNode(uiContext); + this.root.appendChild(this.rootNode.getFrameNode()); + // Returns the FrameNode node + return this.root; + } + // Returns a null node that controls the dynamic component to be unbound. + return null; + } + + // Callback when layout size changes. + aboutToResize(size: Size) { + console.info('aboutToResize width : ' + size.width + ' height : ' + size.height); + } + + // Call back when the NodeContainer corresponding to the controller is in Appear. + aboutToAppear() { + console.info('aboutToAppear'); + } + + // Call back when the NodeContainer corresponding to the controller is Disappear. + aboutToDisappear() { + console.info('aboutToDisappear'); + } + + // This function is a user-defined function and can be used as an initialization function. + // Initialize builderNode through UIContext, and then initialize the contents in @Builder through the Build interface in BuilderNode. + initWeb(url: string, uiContext: UIContext, control: WebviewController) { + if (this.rootNode != null) { + return; + } + // Bind the pre-created WebviewController + this.rootWebviewController = control; + // Creating a node requires uiContext. + this.rootNode = new BuilderNode(uiContext); + // Create dynamic Web components + this.rootNode.build(wrap, { url: url, controller: control }); + } + + // This function is a user-defined function and can be used as an initialization function. + loadUrl(url: string) { + if (this.rootWebviewController !== null) { + // Reuse the pre-created components and reload the url. + this.rootWebviewController.loadUrl(url); + } + } +} + +// Create the NodeController needed for Map saving. +let NodeMap: Map = new Map(); +// Create WebViewController needed for Map saving. +let controllerMap: Map = new Map(); + +// Initialization requires UIContext to be obtained in Ability. +export const createNWeb = (url: string, uiContext: UIContext) => { + // Create NodeController + let baseNode = new MyNodeController(); + let controller = new webview.WebviewController(); + // Initialize a custom web component + baseNode.initWeb(url, uiContext, controller); + controllerMap.set(url, controller); + NodeMap.set(url, baseNode); +}; + +// Customize to get the NodeController interface. +export const getNWeb = (url: string): MyNodeController | undefined => { + // When loading a new Url, it is recommended to reuse pre-created Web components. + if (!NodeMap.get(url) && NodeMap.get('about://blank')) { + // Get pre-created Web components + let webNode = NodeMap.get('about://blank') as MyNodeController; + // Reload url + webNode.loadUrl(url); + return webNode; + } + return NodeMap.get(url); +}; +// [End page_common] \ No newline at end of file diff --git a/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/utils/CreateResourceConfig.ets b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/utils/CreateResourceConfig.ets new file mode 100644 index 0000000000000000000000000000000000000000..fca61c2bd6a6cc2da7bd295b3099618fc94a179f --- /dev/null +++ b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/utils/CreateResourceConfig.ets @@ -0,0 +1,99 @@ +// [Start create_resource_config] +import { webview } from '@kit.ArkWeb'; + +export interface ResourceConfig { + urlList: Array, + type: webview.OfflineResourceType, + responseHeaders: Array
, + localPath: string, +} + + +export interface ExceptionResource { + console: string, + urlList: Array | undefined | null; + type: webview.OfflineResourceType | undefined | null, + responseHeaders: Array
| undefined | null, + resource?: Uint8Array | undefined | null + localPath?: string, +} + + +export const baseURL = 'http://localhost:8083/resource/'; +export const baseURL1 = 'http://localhost:8083/resource/'; + + +export const basicResources: Array = [ + { + localPath: "in_cache_middle.png", + urlList: [ + baseURL, + baseURL + "request.png", + baseURL1 + "request.png", + ], + type: webview.OfflineResourceType.IMAGE, + responseHeaders: [] + }, + { + localPath: "in_cache.js", + urlList: [ + baseURL, + baseURL + "request.js", + baseURL1 + "request.js" + ], + type: webview.OfflineResourceType.CLASSIC_JS, + responseHeaders: [ + {headerKey: "Content-Type", headerValue: "text/javascript" }, + {headerKey: "Cache-Control", headerValue: "max-age=100000" }, + ] + }, + { + localPath: "in_cache_module1.js", + urlList: [ + baseURL + "request_module1.js", + ], + type: webview.OfflineResourceType.MODULE_JS, + responseHeaders: [ + {headerKey: "Content-Type", headerValue: "application/javascript" }, + {headerKey: "Access-Control-Allow-Origin" , headerValue: "*"}, + {headerKey: "Cache-Control", headerValue: "max-age=100000" }, + ] + }, + { + localPath: "in_cache_module2.js", + urlList: [ + baseURL + "request_module2.js", + ], + type: webview.OfflineResourceType.MODULE_JS, + responseHeaders: [ + {headerKey: "Content-Type", headerValue: "application/javascript" }, + {headerKey: "Access-Control-Allow-Origin" , headerValue: "*"}, + {headerKey: "Cache-Control", headerValue: "max-age=100000" }, + ] + }, + { + localPath: "in_cache.css", + urlList: [ + baseURL, + baseURL + "request.css", + baseURL1 + "request.css", + ], + type: webview.OfflineResourceType.CSS, + responseHeaders: [ + {headerKey: "resource-Type", headerValue: "text/css" }, + {headerKey: "Cache-Control", headerValue: "max-age=100000" }, + ] + }, +]; +// [End create_resource_config] + +// [Start inject_offline_resource] +// Call the offline resource injection cache interface +export async function injectOfflineResource(controller: WebviewController, resourceMapArr: Array) { + try { + controller.injectOfflineResources(resourceMapArr); + } catch (err) { + console.error("qqq injectOfflineResource error: " + err.code + " " + err.message); + } +} +// [End inject_offline_resource] \ No newline at end of file diff --git a/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/utils/HttpRequestPost.js b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/utils/HttpRequestPost.js new file mode 100644 index 0000000000000000000000000000000000000000..b0dfa1518f2cdfc8be9cd3148aae12af8f55c61e --- /dev/null +++ b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/utils/HttpRequestPost.js @@ -0,0 +1,17 @@ +// [Start http_request_post] +const xhr = new XMLHttpRequest(); +xhr.open('POST', 'https://www.example.com/POST?e=f&g=h', true); +xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); +xhr.setRequestHeader('ArkWebPostCacheKey', 'KeyX'); +xhr.onload = function () { + if (xhr.status >= 200 && xhr.status < 300) { + console.log('成功', xhr.responseText); + } else { + console.error('请求失败'); + } +} +const formData = new FormData(); +formData.append('a', 'x'); +formData.append('b', 'y'); +xhr.send(formData); +// [End http_request_post] \ No newline at end of file diff --git a/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/view/Second.ets b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/view/Second.ets new file mode 100644 index 0000000000000000000000000000000000000000..7b6517c65fe8fbcc207d56aa101caab8839199af --- /dev/null +++ b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/ets/view/Second.ets @@ -0,0 +1,38 @@ +// [Start page_index] +// Second.ets +import { webview } from '@kit.ArkWeb' + +@Builder +export function PageOneBuilder() { + Second() +} + +@Component +export struct Second { + webviewController: webview.WebviewController = new webview.WebviewController(); + + aboutToAppear(): void { + // Output Web page start loading time + console.info(`load page start time: ${Date.now()}`); + } + + build() { + NavDestination() { + Row() { + Column() { + // Please replace url with real address. + Web({ src: 'https://www.example.com', controller: this.webviewController }) + .height('100%') + .width('100%') + .onPageEnd((event) => { + // Output Web page loading completion time + console.info(`load page end time: ${Date.now()}`); + }) + } + .width('100%') + } + .height('100%') + } + } +} +// [End page_index] \ No newline at end of file diff --git a/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/module.json5 b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..ad219d733f6afa5ea07f85f580208b08cc3b9041 --- /dev/null +++ b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/module.json5 @@ -0,0 +1,50 @@ +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "phone" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:layered_image", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "EntryBackupAbility", + "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets", + "type": "backup", + "exported": false, + "metadata": [ + { + "name": "ohos.extension.backup", + "resource": "$profile:backup_config" + } + ], + } + ] + } +} \ No newline at end of file diff --git a/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/resources/base/element/color.json b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/PerformanceOptimization/LoadPerformanceInWeb/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/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/resources/base/element/float.json b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..33ea22304f9b1485b5f22d811023701b5d4e35b6 --- /dev/null +++ b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} diff --git a/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/resources/base/element/string.json b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..f94595515a99e0c828807e243494f57f09251930 --- /dev/null +++ b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/resources/base/media/background.png b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/resources/base/media/background.png differ diff --git a/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/resources/base/media/foreground.png b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/resources/base/media/foreground.png differ diff --git a/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/resources/base/media/layered_image.json b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/PerformanceOptimization/LoadPerformanceInWeb/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/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/resources/base/media/startIcon.png b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/resources/base/media/startIcon.png differ diff --git a/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/resources/base/profile/backup_config.json b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/resources/base/profile/backup_config.json @@ -0,0 +1,3 @@ +{ + "allowToBackupRestore": true +} \ No newline at end of file diff --git a/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/resources/base/profile/main_pages.json b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce --- /dev/null +++ b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/resources/dark/element/color.json b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..79b11c2747aec33e710fd3a7b2b3c94dd9965499 --- /dev/null +++ b/PerformanceOptimization/LoadPerformanceInWeb/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/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/resources/rawfile/demo.html b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/resources/rawfile/demo.html new file mode 100644 index 0000000000000000000000000000000000000000..b3b4a01c110f89b6313d1c5e102c4f43eab95b0c --- /dev/null +++ b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/resources/rawfile/demo.html @@ -0,0 +1,43 @@ +// [Start demo_html] + + + + + + Document + + + +

+

+

+ + + +// [End demo_html] \ No newline at end of file diff --git a/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/resources/rawfile/index.html b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/resources/rawfile/index.html new file mode 100644 index 0000000000000000000000000000000000000000..7200c8edbd3e23e4cf34a075c55d8ba7137bd163 --- /dev/null +++ b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/resources/rawfile/index.html @@ -0,0 +1,26 @@ +// [Start page_html] + + + + + + + Document + + +
this is a test div
+
this is a test div
+
this is a test div
+
this is a test div
+
this is a test div
+
this is a test div
+
this is a test div
+
this is a test div
+
this is a test div
+
this is a test div
+
this is a test div
+ + + +// [End page_html] \ No newline at end of file diff --git a/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/resources/rawfile/intercept.html b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/resources/rawfile/intercept.html new file mode 100644 index 0000000000000000000000000000000000000000..d9d489571faaa7b136e36fbcbcc3ac85a34fbfd8 --- /dev/null +++ b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/resources/rawfile/intercept.html @@ -0,0 +1,63 @@ + + + + + +

Hello world!

+ + + + + + + \ No newline at end of file diff --git a/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/resources/rawfile/runJS.html b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/resources/rawfile/runJS.html new file mode 100644 index 0000000000000000000000000000000000000000..380b8591b0ec4628a3112855f879f02239a536dd --- /dev/null +++ b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/resources/rawfile/runJS.html @@ -0,0 +1,70 @@ +// [Start run_js_html] + + + + + run javascript demo + + +

run JavaScript Ext demo

+

+
+ +
+
+ +
+ + + +// [End run_js_html] \ No newline at end of file diff --git a/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/resources/rawfile/test.html b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/resources/rawfile/test.html new file mode 100644 index 0000000000000000000000000000000000000000..cd3371b2426fadf27df4b102802de4ae872eb529 --- /dev/null +++ b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/main/resources/rawfile/test.html @@ -0,0 +1,27 @@ +// [Start test_html] + + + + +

这是一个测试信息,默认字体为黑色,调用runJavaScript方法后字体为绿色,调用runJavaScriptCodePassed方法后字体为红色

+ + + +// [End test_html] \ No newline at end of file diff --git a/PerformanceOptimization/LoadPerformanceInWeb/entry/src/mock/mock-config.json5 b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/mock/mock-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..7a73a41bfdf76d6f793007240d80983a52f15f97 --- /dev/null +++ b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/mock/mock-config.json5 @@ -0,0 +1,2 @@ +{ +} \ No newline at end of file diff --git a/PerformanceOptimization/LoadPerformanceInWeb/entry/src/ohosTest/ets/test/Ability.test.ets b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..85c78f67579d6e31b5f5aeea463e216b9b141048 --- /dev/null +++ b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,35 @@ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }) + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }) + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }) + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }) + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + hilog.info(0x0000, 'testTag', '%{public}s', 'it begin'); + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }) + }) +} \ No newline at end of file diff --git a/PerformanceOptimization/LoadPerformanceInWeb/entry/src/ohosTest/ets/test/List.test.ets b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..794c7dc4ed66bd98fa3865e07922906e2fcef545 --- /dev/null +++ b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,5 @@ +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/PerformanceOptimization/LoadPerformanceInWeb/entry/src/ohosTest/module.json5 b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..509a3a28a3e6be8d7f98cc563fa8195657d77d1d --- /dev/null +++ b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/ohosTest/module.json5 @@ -0,0 +1,11 @@ +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "phone" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/PerformanceOptimization/LoadPerformanceInWeb/entry/src/test/List.test.ets b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..bb5b5c3731e283dd507c847560ee59bde477bbc7 --- /dev/null +++ b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/test/List.test.ets @@ -0,0 +1,5 @@ +import localUnitTest from './LocalUnit.test'; + +export default function testsuite() { + localUnitTest(); +} \ No newline at end of file diff --git a/PerformanceOptimization/LoadPerformanceInWeb/entry/src/test/LocalUnit.test.ets b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..165fc1615ee8618b4cb6a622f144a9a707eee99f --- /dev/null +++ b/PerformanceOptimization/LoadPerformanceInWeb/entry/src/test/LocalUnit.test.ets @@ -0,0 +1,33 @@ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function localUnitTest() { + describe('localUnitTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }); + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }); + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }); + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }); + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }); + }); +} \ No newline at end of file diff --git a/PerformanceOptimization/LoadPerformanceInWeb/hvigor/hvigor-config.json5 b/PerformanceOptimization/LoadPerformanceInWeb/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..5bebc9755447385d82ce4138f54d991b1f85f348 --- /dev/null +++ b/PerformanceOptimization/LoadPerformanceInWeb/hvigor/hvigor-config.json5 @@ -0,0 +1,22 @@ +{ + "modelVersion": "5.0.5", + "dependencies": { + }, + "execution": { + // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */ + // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */ + // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */ + // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */ + // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */ + }, + "logging": { + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ + }, + "debugging": { + // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */ + }, + "nodeOptions": { + // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/ + // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/ + } +} diff --git a/PerformanceOptimization/LoadPerformanceInWeb/hvigorfile.ts b/PerformanceOptimization/LoadPerformanceInWeb/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..f3cb9f1a87a81687554a76283af8df27d8bda775 --- /dev/null +++ b/PerformanceOptimization/LoadPerformanceInWeb/hvigorfile.ts @@ -0,0 +1,6 @@ +import { appTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/PerformanceOptimization/LoadPerformanceInWeb/oh-package-lock.json5 b/PerformanceOptimization/LoadPerformanceInWeb/oh-package-lock.json5 new file mode 100644 index 0000000000000000000000000000000000000000..7fcf818273347b97063c0c0a151bb14770ca1c79 --- /dev/null +++ b/PerformanceOptimization/LoadPerformanceInWeb/oh-package-lock.json5 @@ -0,0 +1,27 @@ +{ + "meta": { + "stableOrder": true + }, + "lockfileVersion": 3, + "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", + "specifiers": { + "@ohos/hamock@1.0.0": "@ohos/hamock@1.0.0", + "@ohos/hypium@1.0.21": "@ohos/hypium@1.0.21" + }, + "packages": { + "@ohos/hamock@1.0.0": { + "name": "@ohos/hamock", + "version": "1.0.0", + "integrity": "sha512-K6lDPYc6VkKe6ZBNQa9aoG+ZZMiwqfcR/7yAVFSUGIuOAhPvCJAo9+t1fZnpe0dBRBPxj2bxPPbKh69VuyAtDg==", + "resolved": "https://ohpm.openharmony.cn/ohpm/@ohos/hamock/-/hamock-1.0.0.har", + "registryType": "ohpm" + }, + "@ohos/hypium@1.0.21": { + "name": "@ohos/hypium", + "version": "1.0.21", + "integrity": "sha512-iyKGMXxE+9PpCkqEwu0VykN/7hNpb+QOeIuHwkmZnxOpI+dFZt6yhPB7k89EgV1MiSK/ieV/hMjr5Z2mWwRfMQ==", + "resolved": "https://ohpm.openharmony.cn/ohpm/@ohos/hypium/-/hypium-1.0.21.har", + "registryType": "ohpm" + } + } +} \ No newline at end of file diff --git a/PerformanceOptimization/LoadPerformanceInWeb/oh-package.json5 b/PerformanceOptimization/LoadPerformanceInWeb/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..a8aff0c5aff22d78aa26fd19c3861f4320e951ff --- /dev/null +++ b/PerformanceOptimization/LoadPerformanceInWeb/oh-package.json5 @@ -0,0 +1,10 @@ +{ + "modelVersion": "5.0.5", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.21", + "@ohos/hamock": "1.0.0" + } +} diff --git a/PerformanceOptimization/OptimizationAppDelay/.gitignore b/PerformanceOptimization/OptimizationAppDelay/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b --- /dev/null +++ b/PerformanceOptimization/OptimizationAppDelay/.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/PerformanceOptimization/OptimizationAppDelay/AppScope/app.json5 b/PerformanceOptimization/OptimizationAppDelay/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..ca61fc08359f40cde6be8031ba9f64483de49467 --- /dev/null +++ b/PerformanceOptimization/OptimizationAppDelay/AppScope/app.json5 @@ -0,0 +1,10 @@ +{ + "app": { + "bundleName": "com.example.optimizationappdelay", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:layered_image", + "label": "$string:app_name" + } +} diff --git a/PerformanceOptimization/OptimizationAppDelay/AppScope/resources/base/element/string.json b/PerformanceOptimization/OptimizationAppDelay/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..4e20da909c104e4c6bab27ca0841d8459c50cd79 --- /dev/null +++ b/PerformanceOptimization/OptimizationAppDelay/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "OptimizationAppDelay" + } + ] +} diff --git a/PerformanceOptimization/OptimizationAppDelay/AppScope/resources/base/media/background.png b/PerformanceOptimization/OptimizationAppDelay/AppScope/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/PerformanceOptimization/OptimizationAppDelay/AppScope/resources/base/media/background.png differ diff --git a/PerformanceOptimization/OptimizationAppDelay/AppScope/resources/base/media/foreground.png b/PerformanceOptimization/OptimizationAppDelay/AppScope/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/PerformanceOptimization/OptimizationAppDelay/AppScope/resources/base/media/foreground.png differ diff --git a/PerformanceOptimization/OptimizationAppDelay/AppScope/resources/base/media/layered_image.json b/PerformanceOptimization/OptimizationAppDelay/AppScope/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/PerformanceOptimization/OptimizationAppDelay/AppScope/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/PerformanceOptimization/OptimizationAppDelay/build-profile.json5 b/PerformanceOptimization/OptimizationAppDelay/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..9e87e7e6f19020fe21192844709f192cec80fd44 --- /dev/null +++ b/PerformanceOptimization/OptimizationAppDelay/build-profile.json5 @@ -0,0 +1,42 @@ +{ + "app": { + "signingConfigs": [], + "products": [ + { + "name": "default", + "signingConfig": "default", + "targetSdkVersion": "5.0.5(17)", + "compatibleSdkVersion": "5.0.5(17)", + "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/PerformanceOptimization/OptimizationAppDelay/code-linter.json5 b/PerformanceOptimization/OptimizationAppDelay/code-linter.json5 new file mode 100644 index 0000000000000000000000000000000000000000..073990fa45394e1f8e85d85418ee60a8953f9b99 --- /dev/null +++ b/PerformanceOptimization/OptimizationAppDelay/code-linter.json5 @@ -0,0 +1,32 @@ +{ + "files": [ + "**/*.ets" + ], + "ignore": [ + "**/src/ohosTest/**/*", + "**/src/test/**/*", + "**/src/mock/**/*", + "**/node_modules/**/*", + "**/oh_modules/**/*", + "**/build/**/*", + "**/.preview/**/*" + ], + "ruleSet": [ + "plugin:@performance/recommended", + "plugin:@typescript-eslint/recommended" + ], + "rules": { + "@security/no-unsafe-aes": "error", + "@security/no-unsafe-hash": "error", + "@security/no-unsafe-mac": "warn", + "@security/no-unsafe-dh": "error", + "@security/no-unsafe-dsa": "error", + "@security/no-unsafe-ecdsa": "error", + "@security/no-unsafe-rsa-encrypt": "error", + "@security/no-unsafe-rsa-sign": "error", + "@security/no-unsafe-rsa-key": "error", + "@security/no-unsafe-dsa-key": "error", + "@security/no-unsafe-dh-key": "error", + "@security/no-unsafe-3des": "error" + } +} \ No newline at end of file diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/.gitignore b/PerformanceOptimization/OptimizationAppDelay/entry/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/PerformanceOptimization/OptimizationAppDelay/entry/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/build-profile.json5 b/PerformanceOptimization/OptimizationAppDelay/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..b695582d3680556f4cce2ec518f65720a9413ca3 --- /dev/null +++ b/PerformanceOptimization/OptimizationAppDelay/entry/build-profile.json5 @@ -0,0 +1,28 @@ +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": true, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/hvigorfile.ts b/PerformanceOptimization/OptimizationAppDelay/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..60e47e178e9702631eaf537cd83a6c400fbbb2da --- /dev/null +++ b/PerformanceOptimization/OptimizationAppDelay/entry/hvigorfile.ts @@ -0,0 +1,6 @@ +import { hapTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins: [] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/obfuscation-rules.txt b/PerformanceOptimization/OptimizationAppDelay/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..985b2aeb7658286b17bd26eab8f217c3fe75ea8b --- /dev/null +++ b/PerformanceOptimization/OptimizationAppDelay/entry/obfuscation-rules.txt @@ -0,0 +1,18 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://gitee.com/openharmony/arkcompiler_ets_frontend/blob/master/arkguard/README.md + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope \ No newline at end of file diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/oh-package.json5 b/PerformanceOptimization/OptimizationAppDelay/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..248c3b7541a589682a250f86a6d3ecf7414d2d6a --- /dev/null +++ b/PerformanceOptimization/OptimizationAppDelay/entry/oh-package.json5 @@ -0,0 +1,10 @@ +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/common/constants/AppConstant.ets b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/common/constants/AppConstant.ets new file mode 100644 index 0000000000000000000000000000000000000000..37c58076c72cf24b593dfd5ba1deff8e58a5a0fc --- /dev/null +++ b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/common/constants/AppConstant.ets @@ -0,0 +1,929 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * 最佳实践:点击响应优化 + */ +export class AppConstant { + static readonly CITYS: Array = [ + "阿城市", "阿尔山市", "阿克苏市", "阿勒泰市", "阿图什市", "安达市", "安国市", "安康市", "安陆市", "安宁市", + "安庆市", "安丘市", "安顺市", "安阳市", "鞍山市", "澳门", + '贵阳市', '清镇市', '开阳县', '修文县', '息烽县', '水城县', '盘 县', '遵义市', '赤水市', + '仁怀市', '遵义县', '绥阳县', '桐梓县', '习水县', '凤冈县', '正安县', '余庆县', '湄潭县', + '安顺市', '普定县', '德江县', '江口县', '思南县', '石阡县', '毕节市', '黔西县', '大方县', + '织金县', '金沙县', '赫章县', '纳雍县', '兴义市', '望谟县', '兴仁县', '普安县', '册亨县', + '晴隆县', '贞丰县', '安龙县', '凯里市', '施秉县', '从江县', '锦屏县', '镇远县', '麻江县', + '台江县', '天柱县', '黄平县', '榕江县', '剑河县', '三穗县', '雷山县', '黎平县', '岑巩县', + '丹寨县', '都匀市', '福泉市', '贵定县', '惠水县', '罗甸县', '瓮安县', '荔波县', '龙里县', + '成都市', '彭州市', '邛崃市', '崇州市', '金堂县', '郫 县', '新津县', '双流县', '蒲江县', + '大邑县', '自贡市', '荣县', '富顺县', '米易县', '盐边县', '泸州市', '泸 县', '合江县', + '叙永县', '古蔺县', '德阳市', '广汉市', '什邡市', '绵竹市', '罗江县', '中江县', '绵阳市', + '江油市', '盐亭县', '三台县', '平武县', '安县', '梓潼县', '广元市', '青川县', '旺苍县', + '剑阁县', '苍溪县', '遂宁市', '射洪县', '蓬溪县', '大英县', '内江市', '资中县', '隆昌县', + '威远县', '乐山市', '夹江县', '井研县', '犍为县', '沐川县', '南充市', '阆中市', '营山县', + '蓬安县', '仪陇县', '南部县', '西充县', '眉山市', '仁寿县', '彭山县', '洪雅县', '丹棱县', + '青神县', '宜宾市', '宜宾县', '兴文县', '南溪县', '珙 县', '长宁县', ' 高 县', '江安县', + '筠连县', '屏山县', '广安市', '华蓥市', '岳池县', '邻水县', '武胜县', '达州市', '万源市', + '达县渠', '汉县', '江县', '竹县', '雅安市', '芦山县', '石棉县', '名山县', + '天全县', '荥经县', '宝兴县', '汉源县', '巴中市', '南江县', '平昌县', '通江县', '资阳市', + '简阳市', '安岳县', '乐至县', '红原县', '汶川县', '阿坝县', '理 县', '小金县', '黑水县', + '金川县', '松潘县', '壤塘县', '茂 县', '康定县', '丹巴县', '炉霍县', '九龙县', '甘孜县', + '雅江县', '新龙县', '道孚县', '白玉县', '理塘县', '德格县', '乡城县', '石渠县', '稻城县', + '色达县', '巴塘县', '泸定县', '得荣县', '西昌市', '美姑县', '昭觉县', '金阳县', '甘洛县', + '布拖县', '雷波县', '普格县', '宁南县', '喜德县', '会东县', '越西县', '会理县', '盐源县', + '叙永县', '古蔺县', '德阳市', '广汉市', '什邡市', '绵竹市', '罗江县', '中江县', '绵阳市', + '江油市', '盐亭县', '三台县', '平武县', '安县', '梓潼县', '广元市', '青川县', '旺苍县', + '剑阁县', '苍溪县', '遂宁市', '射洪县', '蓬溪县', '大英县', '内江市', '资中县', '隆昌县', + '威远县', '乐山市', '夹江县', '井研县', '犍为县', '沐川县', '南充市', '阆中市', '营山县', + '蓬安县', '仪陇县', '南部县', '西充县', '眉山市', '仁寿县', '彭山县', '洪雅县', '丹棱县', + '青神县', '宜宾市', '宜宾县', '兴文县', '南溪县', '珙 县', '长宁县', ' 高 县', '江安县', + '筠连县', '屏山县', '广安市', '华蓥市', '岳池县', '邻水县', '武胜县', '达州市', '万源市', + '达县渠', '汉县', '江县', '竹县', '雅安市', '芦山县', '石棉县', '名山县', + '天全县', '荥经县', '宝兴县', '汉源县', '巴中市', '南江县', '平昌县', '通江县', '资阳市', + '简阳市', '安岳县', '乐至县', '红原县', '汶川县', '阿坝县', '理 县', '小金县', '黑水县', + '金川县', '松潘县', '壤塘县', '茂 县', '康定县', '丹巴县', '炉霍县', '九龙县', '甘孜县', + '雅江县', '新龙县', '道孚县', '白玉县', '理塘县', '德格县', '乡城县', '石渠县', '稻城县', + '色达县', '巴塘县', '泸定县', '得荣县', '西昌市', '美姑县', '昭觉县', '金阳县', '甘洛县', + '布拖县', '雷波县', '普格县', '宁南县', '喜德县', '会东县', '越西县', '会理县', '盐源县', + '叙永县', '古蔺县', '德阳市', '广汉市', '什邡市', '绵竹市', '罗江县', '中江县', '绵阳市', + '江油市', '盐亭县', '三台县', '平武县', '安县', '梓潼县', '广元市', '青川县', '旺苍县', + '剑阁县', '苍溪县', '遂宁市', '射洪县', '蓬溪县', '大英县', '内江市', '资中县', '隆昌县', + '威远县', '乐山市', '夹江县', '井研县', '犍为县', '沐川县', '南充市', '阆中市', '营山县', + '蓬安县', '仪陇县', '南部县', '西充县', '眉山市', '仁寿县', '彭山县', '洪雅县', '丹棱县', + '青神县', '宜宾市', '宜宾县', '兴文县', '南溪县', '珙 县', '长宁县', ' 高 县', '江安县', + '筠连县', '屏山县', '广安市', '华蓥市', '岳池县', '邻水县', '武胜县', '达州市', '万源市', + '达县渠', '汉县', '江县', '竹县', '雅安市', '芦山县', '石棉县', '名山县', + '天全县', '荥经县', '宝兴县', '汉源县', '巴中市', '南江县', '平昌县', '通江县', '资阳市', + '简阳市', '安岳县', '乐至县', '红原县', '汶川县', '阿坝县', '理 县', '小金县', '黑水县', + '金川县', '松潘县', '壤塘县', '茂 县', '康定县', '丹巴县', '炉霍县', '九龙县', '甘孜县', + '雅江县', '新龙县', '道孚县', '白玉县', '理塘县', '德格县', '乡城县', '石渠县', '稻城县', + '色达县', '巴塘县', '泸定县', '得荣县', '西昌市', '美姑县', '昭觉县', '金阳县', '甘洛县', + '布拖县', '雷波县', '普格县', '宁南县', '喜德县', '会东县', '越西县', '会理县', '盐源县', + '叙永县', '古蔺县', '德阳市', '广汉市', '什邡市', '绵竹市', '罗江县', '中江县', '绵阳市', + '江油市', '盐亭县', '三台县', '平武县', '安县', '梓潼县', '广元市', '青川县', '旺苍县', + '剑阁县', '苍溪县', '遂宁市', '射洪县', '蓬溪县', '大英县', '内江市', '资中县', '隆昌县', + '威远县', '乐山市', '夹江县', '井研县', '犍为县', '沐川县', '南充市', '阆中市', '营山县', + '蓬安县', '仪陇县', '南部县', '西充县', '眉山市', '仁寿县', '彭山县', '洪雅县', '丹棱县', + '青神县', '宜宾市', '宜宾县', '兴文县', '南溪县', '珙 县', '长宁县', ' 高 县', '江安县', + '筠连县', '屏山县', '广安市', '华蓥市', '岳池县', '邻水县', '武胜县', '达州市', '万源市', + '达县渠', '汉县', '江县', '竹县', '雅安市', '芦山县', '石棉县', '名山县', + '天全县', '荥经县', '宝兴县', '汉源县', '巴中市', '南江县', '平昌县', '通江县', '资阳市', + '简阳市', '安岳县', '乐至县', '红原县', '汶川县', '阿坝县', '理 县', '小金县', '黑水县', + '金川县', '松潘县', '壤塘县', '茂 县', '康定县', '丹巴县', '炉霍县', '九龙县', '甘孜县', + '雅江县', '新龙县', '道孚县', '白玉县', '理塘县', '德格县', '乡城县', '石渠县', '稻城县', + '色达县', '巴塘县', '泸定县', '得荣县', '西昌市', '美姑县', '昭觉县', '金阳县', '甘洛县', + '布拖县', '雷波县', '普格县', '宁南县', '喜德县', '会东县', '越西县', '会理县', '盐源县', '叙永县', '古蔺县', + '德阳市', '广汉市', '什邡市', '绵竹市', '罗江县', '中江县', '绵阳市', + '江油市', '盐亭县', '三台县', '平武县', '安县', '梓潼县', '广元市', '青川县', '旺苍县', + '剑阁县', '苍溪县', '遂宁市', '射洪县', '蓬溪县', '大英县', '内江市', '资中县', '隆昌县', + '威远县', '乐山市', '夹江县', '井研县', '犍为县', '沐川县', '南充市', '阆中市', '营山县', + '蓬安县', '仪陇县', '南部县', '西充县', '眉山市', '仁寿县', '彭山县', '洪雅县', '丹棱县', + '青神县', '宜宾市', '宜宾县', '兴文县', '南溪县', '珙 县', '长宁县', ' 高 县', '江安县', + '筠连县', '屏山县', '广安市', '华蓥市', '岳池县', '邻水县', '武胜县', '达州市', '万源市', + '达县渠', '汉县', '江县', '竹县', '雅安市', '芦山县', '石棉县', '名山县', + '天全县', '荥经县', '宝兴县', '汉源县', '巴中市', '南江县', '平昌县', '通江县', '资阳市', + '简阳市', '安岳县', '乐至县', '红原县', '汶川县', '阿坝县', '理 县', '小金县', '黑水县', + '金川县', '松潘县', '壤塘县', '茂 县', '康定县', '丹巴县', '炉霍县', '九龙县', '甘孜县', + '雅江县', '新龙县', '道孚县', '白玉县', '理塘县', '德格县', '乡城县', '石渠县', '稻城县', + '色达县', '巴塘县', '泸定县', '得荣县', '西昌市', '美姑县', '昭觉县', '金阳县', '甘洛县', + '布拖县', '雷波县', '普格县', '宁南县', '喜德县', '会东县', '越西县', '会理县', '盐源县', + '叙永县', '古蔺县', '德阳市', '广汉市', '什邡市', '绵竹市', '罗江县', '中江县', '绵阳市', + '江油市', '盐亭县', '三台县', '平武县', '安县', '梓潼县', '广元市', '青川县', '旺苍县', + '剑阁县', '苍溪县', '遂宁市', '射洪县', '蓬溪县', '大英县', '内江市', '资中县', '隆昌县', + '威远县', '乐山市', '夹江县', '井研县', '犍为县', '沐川县', '南充市', '阆中市', '营山县', + '蓬安县', '仪陇县', '南部县', '西充县', '眉山市', '仁寿县', '彭山县', '洪雅县', '丹棱县', + '青神县', '宜宾市', '宜宾县', '兴文县', '南溪县', '珙 县', '长宁县', ' 高 县', '江安县', + '筠连县', '屏山县', '广安市', '华蓥市', '岳池县', '邻水县', '武胜县', '达州市', '万源市', + '达县渠', '汉县', '江县', '竹县', '雅安市', '芦山县', '石棉县', '名山县', + '天全县', '荥经县', '宝兴县', '汉源县', '巴中市', '南江县', '平昌县', '通江县', '资阳市', + '简阳市', '安岳县', '乐至县', '红原县', '汶川县', '阿坝县', '理 县', '小金县', '黑水县', + '金川县', '松潘县', '壤塘县', '茂 县', '康定县', '丹巴县', '炉霍县', '九龙县', '甘孜县', + '雅江县', '新龙县', '道孚县', '白玉县', '理塘县', '德格县', '乡城县', '石渠县', '稻城县', + '色达县', '巴塘县', '泸定县', '得荣县', '西昌市', '美姑县', '昭觉县', '金阳县', '甘洛县', + '布拖县', '雷波县', '普格县', '宁南县', '喜德县', '会东县', '越西县', '会理县', '盐源县', + '叙永县', '古蔺县', '德阳市', '广汉市', '什邡市', '绵竹市', '罗江县', '中江县', '绵阳市', + '江油市', '盐亭县', '三台县', '平武县', '安县', '梓潼县', '广元市', '青川县', '旺苍县', + '剑阁县', '苍溪县', '遂宁市', '射洪县', '蓬溪县', '大英县', '内江市', '资中县', '隆昌县', + '威远县', '乐山市', '夹江县', '井研县', '犍为县', '沐川县', '南充市', '阆中市', '营山县', + '蓬安县', '仪陇县', '南部县', '西充县', '眉山市', '仁寿县', '彭山县', '洪雅县', '丹棱县', + '青神县', '宜宾市', '宜宾县', '兴文县', '南溪县', '珙 县', '长宁县', ' 高 县', '江安县', + '筠连县', '屏山县', '广安市', '华蓥市', '岳池县', '邻水县', '武胜县', '达州市', '万源市', + '达县渠', '汉县', '江县', '竹县', '雅安市', '芦山县', '石棉县', '名山县', + '天全县', '荥经县', '宝兴县', '汉源县', '巴中市', '南江县', '平昌县', '通江县', '资阳市', + '简阳市', '安岳县', '乐至县', '红原县', '汶川县', '阿坝县', '理 县', '小金县', '黑水县', + '金川县', '松潘县', '壤塘县', '茂 县', '康定县', '丹巴县', '炉霍县', '九龙县', '甘孜县', + '雅江县', '新龙县', '道孚县', '白玉县', '理塘县', '德格县', '乡城县', '石渠县', '稻城县', + '色达县', '巴塘县', '泸定县', '得荣县', '西昌市', '美姑县', '昭觉县', '金阳县', '甘洛县', + '布拖县', '雷波县', '普格县', '宁南县', '喜德县', '会东县', '越西县', '会理县', '盐源县', + '叙永县', '古蔺县', '德阳市', '广汉市', '什邡市', '绵竹市', '罗江县', '中江县', '绵阳市', + '江油市', '盐亭县', '三台县', '平武县', '安县', '梓潼县', '广元市', '青川县', '旺苍县', + '剑阁县', '苍溪县', '遂宁市', '射洪县', '蓬溪县', '大英县', '内江市', '资中县', '隆昌县', + '威远县', '乐山市', '夹江县', '井研县', '犍为县', '沐川县', '南充市', '阆中市', '营山县', + '蓬安县', '仪陇县', '南部县', '西充县', '眉山市', '仁寿县', '彭山县', '洪雅县', '丹棱县', + '青神县', '宜宾市', '宜宾县', '兴文县', '南溪县', '珙 县', '长宁县', ' 高 县', '江安县', + '筠连县', '屏山县', '广安市', '华蓥市', '岳池县', '邻水县', '武胜县', '达州市', '万源市', + '达县渠', '汉县', '江县', '竹县', '雅安市', '芦山县', '石棉县', '名山县', + '天全县', '荥经县', '宝兴县', '汉源县', '巴中市', '南江县', '平昌县', '通江县', '资阳市', + '简阳市', '安岳县', '乐至县', '红原县', '汶川县', '阿坝县', '理 县', '小金县', '黑水县', + '金川县', '松潘县', '壤塘县', '茂 县', '康定县', '丹巴县', '炉霍县', '九龙县', '甘孜县', + '雅江县', '新龙县', '道孚县', '白玉县', '理塘县', '德格县', '乡城县', '石渠县', '稻城县', + '色达县', '巴塘县', '泸定县', '得荣县', '西昌市', '美姑县', '昭觉县', '金阳县', '甘洛县', + '布拖县', '雷波县', '普格县', '宁南县', '喜德县', '会东县', '越西县', '会理县', '盐源县', + '叙永县', '古蔺县', '德阳市', '广汉市', '什邡市', '绵竹市', '罗江县', '中江县', '绵阳市', + '江油市', '盐亭县', '三台县', '平武县', '安县', '梓潼县', '广元市', '青川县', '旺苍县', + '剑阁县', '苍溪县', '遂宁市', '射洪县', '蓬溪县', '大英县', '内江市', '资中县', '隆昌县', + '威远县', '乐山市', '夹江县', '井研县', '犍为县', '沐川县', '南充市', '阆中市', '营山县', + '蓬安县', '仪陇县', '南部县', '西充县', '眉山市', '仁寿县', '彭山县', '洪雅县', '丹棱县', + '青神县', '宜宾市', '宜宾县', '兴文县', '南溪县', '珙 县', '长宁县', ' 高 县', '江安县', + '筠连县', '屏山县', '广安市', '华蓥市', '岳池县', '邻水县', '武胜县', '达州市', '万源市', + '达县渠', '汉县', '江县', '竹县', '雅安市', '芦山县', '石棉县', '名山县', + '天全县', '荥经县', '宝兴县', '汉源县', '巴中市', '南江县', '平昌县', '通江县', '资阳市', + '简阳市', '安岳县', '乐至县', '红原县', '汶川县', '阿坝县', '理 县', '小金县', '黑水县', + '金川县', '松潘县', '壤塘县', '茂 县', '康定县', '丹巴县', '炉霍县', '九龙县', '甘孜县', + '雅江县', '新龙县', '道孚县', '白玉县', '理塘县', '德格县', '乡城县', '石渠县', '稻城县', + '色达县', '巴塘县', '泸定县', '得荣县', '西昌市', '美姑县', '昭觉县', '金阳县', '甘洛县', + '布拖县', '雷波县', '普格县', '宁南县', '喜德县', '会东县', '越西县', '会理县', '盐源县', + '叙永县', '古蔺县', '德阳市', '广汉市', '什邡市', '绵竹市', '罗江县', '中江县', '绵阳市', + '江油市', '盐亭县', '三台县', '平武县', '安县', '梓潼县', '广元市', '青川县', '旺苍县', + '剑阁县', '苍溪县', '遂宁市', '射洪县', '蓬溪县', '大英县', '内江市', '资中县', '隆昌县', + '威远县', '乐山市', '夹江县', '井研县', '犍为县', '沐川县', '南充市', '阆中市', '营山县', + '蓬安县', '仪陇县', '南部县', '西充县', '眉山市', '仁寿县', '彭山县', '洪雅县', '丹棱县', + '青神县', '宜宾市', '宜宾县', '兴文县', '南溪县', '珙 县', '长宁县', ' 高 县', '江安县', + '筠连县', '屏山县', '广安市', '华蓥市', '岳池县', '邻水县', '武胜县', '达州市', '万源市', + '达县渠', '汉县', '江县', '竹县', '雅安市', '芦山县', '石棉县', '名山县', + '天全县', '荥经县', '宝兴县', '汉源县', '巴中市', '南江县', '平昌县', '通江县', '资阳市', + '简阳市', '安岳县', '乐至县', '红原县', '汶川县', '阿坝县', '理 县', '小金县', '黑水县', + '金川县', '松潘县', '壤塘县', '茂 县', '康定县', '丹巴县', '炉霍县', '九龙县', '甘孜县', + '雅江县', '新龙县', '道孚县', '白玉县', '理塘县', '德格县', '乡城县', '石渠县', '稻城县', + '色达县', '巴塘县', '泸定县', '得荣县', '西昌市', '美姑县', '昭觉县', '金阳县', '甘洛县', + '布拖县', '雷波县', '普格县', '宁南县', '喜德县', '会东县', '越西县', '会理县', '盐源县', + '叙永县', '古蔺县', '德阳市', '广汉市', '什邡市', '绵竹市', '罗江县', '中江县', '绵阳市', + '江油市', '盐亭县', '三台县', '平武县', '安县', '梓潼县', '广元市', '青川县', '旺苍县', + '剑阁县', '苍溪县', '遂宁市', '射洪县', '蓬溪县', '大英县', '内江市', '资中县', '隆昌县', + '威远县', '乐山市', '夹江县', '井研县', '犍为县', '沐川县', '南充市', '阆中市', '营山县', + '蓬安县', '仪陇县', '南部县', '西充县', '眉山市', '仁寿县', '彭山县', '洪雅县', '丹棱县', + '青神县', '宜宾市', '宜宾县', '兴文县', '南溪县', '珙 县', '长宁县', ' 高 县', '江安县', + '筠连县', '屏山县', '广安市', '华蓥市', '岳池县', '邻水县', '武胜县', '达州市', '万源市', + '达县渠', '汉县', '江县', '竹县', '雅安市', '芦山县', '石棉县', '名山县', + '天全县', '荥经县', '宝兴县', '汉源县', '巴中市', '南江县', '平昌县', '通江县', '资阳市', + '简阳市', '安岳县', '乐至县', '红原县', '汶川县', '阿坝县', '理 县', '小金县', '黑水县', + '金川县', '松潘县', '壤塘县', '茂 县', '康定县', '丹巴县', '炉霍县', '九龙县', '甘孜县', + '雅江县', '新龙县', '道孚县', '白玉县', '理塘县', '德格县', '乡城县', '石渠县', '稻城县', + '色达县', '巴塘县', '泸定县', '得荣县', '西昌市', '美姑县', '昭觉县', '金阳县', '甘洛县', + '布拖县', '雷波县', '普格县', '宁南县', '喜德县', '会东县', '越西县', '会理县', '盐源县', + '叙永县', '古蔺县', '德阳市', '广汉市', '什邡市', '绵竹市', '罗江县', '中江县', '绵阳市', + '江油市', '盐亭县', '三台县', '平武县', '安县', '梓潼县', '广元市', '青川县', '旺苍县', + '剑阁县', '苍溪县', '遂宁市', '射洪县', '蓬溪县', '大英县', '内江市', '资中县', '隆昌县', + '威远县', '乐山市', '夹江县', '井研县', '犍为县', '沐川县', '南充市', '阆中市', '营山县', + '蓬安县', '仪陇县', '南部县', '西充县', '眉山市', '仁寿县', '彭山县', '洪雅县', '丹棱县', + '青神县', '宜宾市', '宜宾县', '兴文县', '南溪县', '珙 县', '长宁县', ' 高 县', '江安县', + '筠连县', '屏山县', '广安市', '华蓥市', '岳池县', '邻水县', '武胜县', '达州市', '万源市', + '达县渠', '汉县', '江县', '竹县', '雅安市', '芦山县', '石棉县', '名山县', + '天全县', '荥经县', '宝兴县', '汉源县', '巴中市', '南江县', '平昌县', '通江县', '资阳市', + '简阳市', '安岳县', '乐至县', '红原县', '汶川县', '阿坝县', '理 县', '小金县', '黑水县', + '金川县', '松潘县', '壤塘县', '茂 县', '康定县', '丹巴县', '炉霍县', '九龙县', '甘孜县', + '雅江县', '新龙县', '道孚县', '白玉县', '理塘县', '德格县', '乡城县', '石渠县', '稻城县', + '色达县', '巴塘县', '泸定县', '得荣县', '西昌市', '美姑县', '昭觉县', '金阳县', '甘洛县', + '布拖县', '雷波县', '普格县', '宁南县', '喜德县', '会东县', '越西县', '会理县', '盐源县', + '叙永县', '古蔺县', '德阳市', '广汉市', '什邡市', '绵竹市', '罗江县', '中江县', '绵阳市', + '江油市', '盐亭县', '三台县', '平武县', '安县', '梓潼县', '广元市', '青川县', '旺苍县', + '剑阁县', '苍溪县', '遂宁市', '射洪县', '蓬溪县', '大英县', '内江市', '资中县', '隆昌县', + '威远县', '乐山市', '夹江县', '井研县', '犍为县', '沐川县', '南充市', '阆中市', '营山县', + '蓬安县', '仪陇县', '南部县', '西充县', '眉山市', '仁寿县', '彭山县', '洪雅县', '丹棱县', + '青神县', '宜宾市', '宜宾县', '兴文县', '南溪县', '珙 县', '长宁县', ' 高 县', '江安县', + '筠连县', '屏山县', '广安市', '华蓥市', '岳池县', '邻水县', '武胜县', '达州市', '万源市', + '达县渠', '汉县', '江县', '竹县', '雅安市', '芦山县', '石棉县', '名山县', + '天全县', '荥经县', '宝兴县', '汉源县', '巴中市', '南江县', '平昌县', '通江县', '资阳市', + '简阳市', '安岳县', '乐至县', '红原县', '汶川县', '阿坝县', '理 县', '小金县', '黑水县', + '金川县', '松潘县', '壤塘县', '茂 县', '康定县', '丹巴县', '炉霍县', '九龙县', '甘孜县', + '雅江县', '新龙县', '道孚县', '白玉县', '理塘县', '德格县', '乡城县', '石渠县', '稻城县', + '色达县', '巴塘县', '泸定县', '得荣县', '西昌市', '美姑县', '昭觉县', '金阳县', '甘洛县', + '布拖县', '雷波县', '普格县', '宁南县', '喜德县', '会东县', '越西县', '会理县', '盐源县', + '叙永县', '古蔺县', '德阳市', '广汉市', '什邡市', '绵竹市', '罗江县', '中江县', '绵阳市', + '江油市', '盐亭县', '三台县', '平武县', '安县', '梓潼县', '广元市', '青川县', '旺苍县', + '剑阁县', '苍溪县', '遂宁市', '射洪县', '蓬溪县', '大英县', '内江市', '资中县', '隆昌县', + '威远县', '乐山市', '夹江县', '井研县', '犍为县', '沐川县', '南充市', '阆中市', '营山县', + '蓬安县', '仪陇县', '南部县', '西充县', '眉山市', '仁寿县', '彭山县', '洪雅县', '丹棱县', + '青神县', '宜宾市', '宜宾县', '兴文县', '南溪县', '珙 县', '长宁县', ' 高 县', '江安县', + '筠连县', '屏山县', '广安市', '华蓥市', '岳池县', '邻水县', '武胜县', '达州市', '万源市', + '达县渠', '汉县', '江县', '竹县', '雅安市', '芦山县', '石棉县', '名山县', + '天全县', '荥经县', '宝兴县', '汉源县', '巴中市', '南江县', '平昌县', '通江县', '资阳市', + '简阳市', '安岳县', '乐至县', '红原县', '汶川县', '阿坝县', '理 县', '小金县', '黑水县', + '金川县', '松潘县', '壤塘县', '茂 县', '康定县', '丹巴县', '炉霍县', '九龙县', '甘孜县', + '雅江县', '新龙县', '道孚县', '白玉县', '理塘县', '德格县', '乡城县', '石渠县', '稻城县', + '色达县', '巴塘县', '泸定县', '得荣县', '西昌市', '美姑县', '昭觉县', '金阳县', '甘洛县', + '布拖县', '雷波县', '普格县', '宁南县', '喜德县', '会东县', '越西县', '会理县', '盐源县', + '叙永县', '古蔺县', '德阳市', '广汉市', '什邡市', '绵竹市', '罗江县', '中江县', '绵阳市', + '江油市', '盐亭县', '三台县', '平武县', '安县', '梓潼县', '广元市', '青川县', '旺苍县', + '剑阁县', '苍溪县', '遂宁市', '射洪县', '蓬溪县', '大英县', '内江市', '资中县', '隆昌县', + '威远县', '乐山市', '夹江县', '井研县', '犍为县', '沐川县', '南充市', '阆中市', '营山县', + '蓬安县', '仪陇县', '南部县', '西充县', '眉山市', '仁寿县', '彭山县', '洪雅县', '丹棱县', + '青神县', '宜宾市', '宜宾县', '兴文县', '南溪县', '珙 县', '长宁县', ' 高 县', '江安县', + '筠连县', '屏山县', '广安市', '华蓥市', '岳池县', '邻水县', '武胜县', '达州市', '万源市', + '达县渠', '汉县', '江县', '竹县', '雅安市', '芦山县', '石棉县', '名山县', + '天全县', '荥经县', '宝兴县', '汉源县', '巴中市', '南江县', '平昌县', '通江县', '资阳市', + '简阳市', '安岳县', '乐至县', '红原县', '汶川县', '阿坝县', '理 县', '小金县', '黑水县', + '金川县', '松潘县', '壤塘县', '茂 县', '康定县', '丹巴县', '炉霍县', '九龙县', '甘孜县', + '雅江县', '新龙县', '道孚县', '白玉县', '理塘县', '德格县', '乡城县', '石渠县', '稻城县', + '色达县', '巴塘县', '泸定县', '得荣县', '西昌市', '美姑县', '昭觉县', '金阳县', '甘洛县', + '布拖县', '雷波县', '普格县', '宁南县', '喜德县', '会东县', '越西县', '会理县', '盐源县', + '叙永县', '古蔺县', '德阳市', '广汉市', '什邡市', '绵竹市', '罗江县', '中江县', '绵阳市', + '江油市', '盐亭县', '三台县', '平武县', '安县', '梓潼县', '广元市', '青川县', '旺苍县', + '剑阁县', '苍溪县', '遂宁市', '射洪县', '蓬溪县', '大英县', '内江市', '资中县', '隆昌县', + '威远县', '乐山市', '夹江县', '井研县', '犍为县', '沐川县', '南充市', '阆中市', '营山县', + '蓬安县', '仪陇县', '南部县', '西充县', '眉山市', '仁寿县', '彭山县', '洪雅县', '丹棱县', + '青神县', '宜宾市', '宜宾县', '兴文县', '南溪县', '珙 县', '长宁县', ' 高 县', '江安县', + '筠连县', '屏山县', '广安市', '华蓥市', '岳池县', '邻水县', '武胜县', '达州市', '万源市', + '达县渠', '汉县', '江县', '竹县', '雅安市', '芦山县', '石棉县', '名山县', + '天全县', '荥经县', '宝兴县', '汉源县', '巴中市', '南江县', '平昌县', '通江县', '资阳市', + '简阳市', '安岳县', '乐至县', '红原县', '汶川县', '阿坝县', '理 县', '小金县', '黑水县', + '金川县', '松潘县', '壤塘县', '茂 县', '康定县', '丹巴县', '炉霍县', '九龙县', '甘孜县', + '雅江县', '新龙县', '道孚县', '白玉县', '理塘县', '德格县', '乡城县', '石渠县', '稻城县', + '色达县', '巴塘县', '泸定县', '得荣县', '西昌市', '美姑县', '昭觉县', '金阳县', '甘洛县', + '布拖县', '雷波县', '普格县', '宁南县', '喜德县', '会东县', '越西县', '会理县', '盐源县', + '叙永县', '古蔺县', '德阳市', '广汉市', '什邡市', '绵竹市', '罗江县', '中江县', '绵阳市', + '江油市', '盐亭县', '三台县', '平武县', '安县', '梓潼县', '广元市', '青川县', '旺苍县', + '剑阁县', '苍溪县', '遂宁市', '射洪县', '蓬溪县', '大英县', '内江市', '资中县', '隆昌县', + '威远县', '乐山市', '夹江县', '井研县', '犍为县', '沐川县', '南充市', '阆中市', '营山县', + '蓬安县', '仪陇县', '南部县', '西充县', '眉山市', '仁寿县', '彭山县', '洪雅县', '丹棱县', + '青神县', '宜宾市', '宜宾县', '兴文县', '南溪县', '珙 县', '长宁县', ' 高 县', '江安县', + '筠连县', '屏山县', '广安市', '华蓥市', '岳池县', '邻水县', '武胜县', '达州市', '万源市', + '达县渠', '汉县', '江县', '竹县', '雅安市', '芦山县', '石棉县', '名山县', + '天全县', '荥经县', '宝兴县', '汉源县', '巴中市', '南江县', '平昌县', '通江县', '资阳市', + '简阳市', '安岳县', '乐至县', '红原县', '汶川县', '阿坝县', '理 县', '小金县', '黑水县', + '金川县', '松潘县', '壤塘县', '茂 县', '康定县', '丹巴县', '炉霍县', '九龙县', '甘孜县', + '雅江县', '新龙县', '道孚县', '白玉县', '理塘县', '德格县', '乡城县', '石渠县', '稻城县', + '色达县', '巴塘县', '泸定县', '得荣县', '西昌市', '美姑县', '昭觉县', '金阳县', '甘洛县', + '布拖县', '雷波县', '普格县', '宁南县', '喜德县', '会东县', '越西县', '会理县', '盐源县', + '叙永县', '古蔺县', '德阳市', '广汉市', '什邡市', '绵竹市', '罗江县', '中江县', '绵阳市', + '江油市', '盐亭县', '三台县', '平武县', '安县', '梓潼县', '广元市', '青川县', '旺苍县', + '剑阁县', '苍溪县', '遂宁市', '射洪县', '蓬溪县', '大英县', '内江市', '资中县', '隆昌县', + '威远县', '乐山市', '夹江县', '井研县', '犍为县', '沐川县', '南充市', '阆中市', '营山县', + '蓬安县', '仪陇县', '南部县', '西充县', '眉山市', '仁寿县', '彭山县', '洪雅县', '丹棱县', + '青神县', '宜宾市', '宜宾县', '兴文县', '南溪县', '珙 县', '长宁县', ' 高 县', '江安县', + '筠连县', '屏山县', '广安市', '华蓥市', '岳池县', '邻水县', '武胜县', '达州市', '万源市', + '达县渠', '汉县', '江县', '竹县', '雅安市', '芦山县', '石棉县', '名山县', + '天全县', '荥经县', '宝兴县', '汉源县', '巴中市', '南江县', '平昌县', '通江县', '资阳市', + '简阳市', '安岳县', '乐至县', '红原县', '汶川县', '阿坝县', '理 县', '小金县', '黑水县', + '金川县', '松潘县', '壤塘县', '茂 县', '康定县', '丹巴县', '炉霍县', '九龙县', '甘孜县', + '雅江县', '新龙县', '道孚县', '白玉县', '理塘县', '德格县', '乡城县', '石渠县', '稻城县', + '色达县', '巴塘县', '泸定县', '得荣县', '西昌市', '美姑县', '昭觉县', '金阳县', '甘洛县', + '布拖县', '雷波县', '普格县', '宁南县', '喜德县', '会东县', '越西县', '会理县', '盐源县', + '简阳市', '安岳县', '乐至县', '红原县', '汶川县', '阿坝县', '理 县', '小金县', '黑水县', + '金川县', '松潘县', '壤塘县', '茂 县', '康定县', '丹巴县', '炉霍县', '九龙县', '甘孜县', + '雅江县', '新龙县', '道孚县', '白玉县', '理塘县', '德格县', '乡城县', '石渠县', '稻城县', + '色达县', '巴塘县', '泸定县', '得荣县', '西昌市', '美姑县', '昭觉县', '金阳县', '甘洛县', + '布拖县', '雷波县', '普格县', '宁南县', '喜德县', '会东县', '越西县', '会理县', '盐源县', + '叙永县', '古蔺县', '德阳市', '广汉市', '什邡市', '绵竹市', '罗江县', '中江县', '绵阳市', + '江油市', '盐亭县', '三台县', '平武县', '安县', '梓潼县', '广元市', '青川县', '旺苍县', + '剑阁县', '苍溪县', '遂宁市', '射洪县', '蓬溪县', '大英县', '内江市', '资中县', '隆昌县', + '威远县', '乐山市', '夹江县', '井研县', '犍为县', '沐川县', '南充市', '阆中市', '营山县', + '蓬安县', '仪陇县', '南部县', '西充县', '眉山市', '仁寿县', '彭山县', '洪雅县', '丹棱县', + '青神县', '宜宾市', '宜宾县', '兴文县', '南溪县', '珙 县', '长宁县', ' 高 县', '江安县', + '筠连县', '屏山县', '广安市', '华蓥市', '岳池县', '邻水县', '武胜县', '达州市', '万源市', + '达县渠', '汉县', '江县', '竹县', '雅安市', '芦山县', '石棉县', '名山县', + '天全县', '荥经县', '宝兴县', '汉源县', '巴中市', '南江县', '平昌县', '通江县', '资阳市', + '简阳市', '安岳县', '乐至县', '红原县', '汶川县', '阿坝县', '理 县', '小金县', '黑水县', + '金川县', '松潘县', '壤塘县', '茂 县', '康定县', '丹巴县', '炉霍县', '九龙县', '甘孜县', + '雅江县', '新龙县', '道孚县', '白玉县', '理塘县', '德格县', '乡城县', '石渠县', '稻城县', + '色达县', '巴塘县', '泸定县', '得荣县', '西昌市', '美姑县', '昭觉县', '金阳县', '甘洛县', + '布拖县', '雷波县', '普格县', '宁南县', '喜德县', '会东县', '越西县', '会理县', '盐源县', '叙永县', '古蔺县', + '德阳市', '广汉市', '什邡市', '绵竹市', '罗江县', '中江县', '绵阳市', + '江油市', '盐亭县', '三台县', '平武县', '安县', '梓潼县', '广元市', '青川县', '旺苍县', + '剑阁县', '苍溪县', '遂宁市', '射洪县', '蓬溪县', '大英县', '内江市', '资中县', '隆昌县', + '威远县', '乐山市', '夹江县', '井研县', '犍为县', '沐川县', '南充市', '阆中市', '营山县', + '蓬安县', '仪陇县', '南部县', '西充县', '眉山市', '仁寿县', '彭山县', '洪雅县', '丹棱县', + '青神县', '宜宾市', '宜宾县', '兴文县', '南溪县', '珙 县', '长宁县', ' 高 县', '江安县', + '筠连县', '屏山县', '广安市', '华蓥市', '岳池县', '邻水县', '武胜县', '达州市', '万源市', + '达县渠', '汉县', '江县', '竹县', '雅安市', '芦山县', '石棉县', '名山县', + '天全县', '荥经县', '宝兴县', '汉源县', '巴中市', '南江县', '平昌县', '通江县', '资阳市', + '简阳市', '安岳县', '乐至县', '红原县', '汶川县', '阿坝县', '理 县', '小金县', '黑水县', + '金川县', '松潘县', '壤塘县', '茂 县', '康定县', '丹巴县', '炉霍县', '九龙县', '甘孜县', + '雅江县', '新龙县', '道孚县', '白玉县', '理塘县', '德格县', '乡城县', '石渠县', '稻城县', + '色达县', '巴塘县', '泸定县', '得荣县', '西昌市', '美姑县', '昭觉县', '金阳县', '甘洛县', + '布拖县', '雷波县', '普格县', '宁南县', '喜德县', '会东县', '越西县', '会理县', '盐源县', + '叙永县', '古蔺县', '德阳市', '广汉市', '什邡市', '绵竹市', '罗江县', '中江县', '绵阳市', + '江油市', '盐亭县', '三台县', '平武县', '安县', '梓潼县', '广元市', '青川县', '旺苍县', + '剑阁县', '苍溪县', '遂宁市', '射洪县', '蓬溪县', '大英县', '内江市', '资中县', '隆昌县', + '威远县', '乐山市', '夹江县', '井研县', '犍为县', '沐川县', '南充市', '阆中市', '营山县', + '蓬安县', '仪陇县', '南部县', '西充县', '眉山市', '仁寿县', '彭山县', '洪雅县', '丹棱县', + '青神县', '宜宾市', '宜宾县', '兴文县', '南溪县', '珙 县', '长宁县', ' 高 县', '江安县', + '筠连县', '屏山县', '广安市', '华蓥市', '岳池县', '邻水县', '武胜县', '达州市', '万源市', + '达县渠', '汉县', '江县', '竹县', '雅安市', '芦山县', '石棉县', '名山县', + '天全县', '荥经县', '宝兴县', '汉源县', '巴中市', '南江县', '平昌县', '通江县', '资阳市', + '简阳市', '安岳县', '乐至县', '红原县', '汶川县', '阿坝县', '理 县', '小金县', '黑水县', + '金川县', '松潘县', '壤塘县', '茂 县', '康定县', '丹巴县', '炉霍县', '九龙县', '甘孜县', + '雅江县', '新龙县', '道孚县', '白玉县', '理塘县', '德格县', '乡城县', '石渠县', '稻城县', + '色达县', '巴塘县', '泸定县', '得荣县', '西昌市', '美姑县', '昭觉县', '金阳县', '甘洛县', + '布拖县', '雷波县', '普格县', '宁南县', '喜德县', '会东县', '越西县', '会理县', '盐源县', + '叙永县', '古蔺县', '德阳市', '广汉市', '什邡市', '绵竹市', '罗江县', '中江县', '绵阳市', + '江油市', '盐亭县', '三台县', '平武县', '安县', '梓潼县', '广元市', '青川县', '旺苍县', + '剑阁县', '苍溪县', '遂宁市', '射洪县', '蓬溪县', '大英县', '内江市', '资中县', '隆昌县', + '威远县', '乐山市', '夹江县', '井研县', '犍为县', '沐川县', '南充市', '阆中市', '营山县', + '蓬安县', '仪陇县', '南部县', '西充县', '眉山市', '仁寿县', '彭山县', '洪雅县', '丹棱县', + '青神县', '宜宾市', '宜宾县', '兴文县', '南溪县', '珙 县', '长宁县', ' 高 县', '江安县', + '筠连县', '屏山县', '广安市', '华蓥市', '岳池县', '邻水县', '武胜县', '达州市', '万源市', + '达县渠', '汉县', '江县', '竹县', '雅安市', '芦山县', '石棉县', '名山县', + '天全县', '荥经县', '宝兴县', '汉源县', '巴中市', '南江县', '平昌县', '通江县', '资阳市', + '简阳市', '安岳县', '乐至县', '红原县', '汶川县', '阿坝县', '理 县', '小金县', '黑水县', + '金川县', '松潘县', '壤塘县', '茂 县', '康定县', '丹巴县', '炉霍县', '九龙县', '甘孜县', + '雅江县', '新龙县', '道孚县', '白玉县', '理塘县', '德格县', '乡城县', '石渠县', '稻城县', + '色达县', '巴塘县', '泸定县', '得荣县', '西昌市', '美姑县', '昭觉县', '金阳县', '甘洛县', + '布拖县', '雷波县', '普格县', '宁南县', '喜德县', '会东县', '越西县', '会理县', '盐源县', + '叙永县', '古蔺县', '德阳市', '广汉市', '什邡市', '绵竹市', '罗江县', '中江县', '绵阳市', + '江油市', '盐亭县', '三台县', '平武县', '安县', '梓潼县', '广元市', '青川县', '旺苍县', + '剑阁县', '苍溪县', '遂宁市', '射洪县', '蓬溪县', '大英县', '内江市', '资中县', '隆昌县', + '威远县', '乐山市', '夹江县', '井研县', '犍为县', '沐川县', '南充市', '阆中市', '营山县', + '蓬安县', '仪陇县', '南部县', '西充县', '眉山市', '仁寿县', '彭山县', '洪雅县', '丹棱县', + '青神县', '宜宾市', '宜宾县', '兴文县', '南溪县', '珙 县', '长宁县', ' 高 县', '江安县', + '筠连县', '屏山县', '广安市', '华蓥市', '岳池县', '邻水县', '武胜县', '达州市', '万源市', + '达县渠', '汉县', '江县', '竹县', '雅安市', '芦山县', '石棉县', '名山县', + '天全县', '荥经县', '宝兴县', '汉源县', '巴中市', '南江县', '平昌县', '通江县', '资阳市', + '简阳市', '安岳县', '乐至县', '红原县', '汶川县', '阿坝县', '理 县', '小金县', '黑水县', + '金川县', '松潘县', '壤塘县', '茂 县', '康定县', '丹巴县', '炉霍县', '九龙县', '甘孜县', + '雅江县', '新龙县', '道孚县', '白玉县', '理塘县', '德格县', '乡城县', '石渠县', '稻城县', + '色达县', '巴塘县', '泸定县', '得荣县', '西昌市', '美姑县', '昭觉县', '金阳县', '甘洛县', + '布拖县', '雷波县', '普格县', '宁南县', '喜德县', '会东县', '越西县', '会理县', '盐源县', + '叙永县', '古蔺县', '德阳市', '广汉市', '什邡市', '绵竹市', '罗江县', '中江县', '绵阳市', + '江油市', '盐亭县', '三台县', '平武县', '安县', '梓潼县', '广元市', '青川县', '旺苍县', + '剑阁县', '苍溪县', '遂宁市', '射洪县', '蓬溪县', '大英县', '内江市', '资中县', '隆昌县', + '威远县', '乐山市', '夹江县', '井研县', '犍为县', '沐川县', '南充市', '阆中市', '营山县', + '蓬安县', '仪陇县', '南部县', '西充县', '眉山市', '仁寿县', '彭山县', '洪雅县', '丹棱县', + '青神县', '宜宾市', '宜宾县', '兴文县', '南溪县', '珙 县', '长宁县', ' 高 县', '江安县', + '筠连县', '屏山县', '广安市', '华蓥市', '岳池县', '邻水县', '武胜县', '达州市', '万源市', + '达县渠', '汉县', '江县', '竹县', '雅安市', '芦山县', '石棉县', '名山县', + '天全县', '荥经县', '宝兴县', '汉源县', '巴中市', '南江县', '平昌县', '通江县', '资阳市', + '简阳市', '安岳县', '乐至县', '红原县', '汶川县', '阿坝县', '理 县', '小金县', '黑水县', + '金川县', '松潘县', '壤塘县', '茂 县', '康定县', '丹巴县', '炉霍县', '九龙县', '甘孜县', + '雅江县', '新龙县', '道孚县', '白玉县', '理塘县', '德格县', '乡城县', '石渠县', '稻城县', + '色达县', '巴塘县', '泸定县', '得荣县', '西昌市', '美姑县', '昭觉县', '金阳县', '甘洛县', + '布拖县', '雷波县', '普格县', '宁南县', '喜德县', '会东县', '越西县', '会理县', '盐源县', + '叙永县', '古蔺县', '德阳市', '广汉市', '什邡市', '绵竹市', '罗江县', '中江县', '绵阳市', + '江油市', '盐亭县', '三台县', '平武县', '安县', '梓潼县', '广元市', '青川县', '旺苍县', + '剑阁县', '苍溪县', '遂宁市', '射洪县', '蓬溪县', '大英县', '内江市', '资中县', '隆昌县', + '威远县', '乐山市', '夹江县', '井研县', '犍为县', '沐川县', '南充市', '阆中市', '营山县', + '蓬安县', '仪陇县', '南部县', '西充县', '眉山市', '仁寿县', '彭山县', '洪雅县', '丹棱县', + '青神县', '宜宾市', '宜宾县', '兴文县', '南溪县', '珙 县', '长宁县', ' 高 县', '江安县', + '筠连县', '屏山县', '广安市', '华蓥市', '岳池县', '邻水县', '武胜县', '达州市', '万源市', + '达县渠', '汉县', '江县', '竹县', '雅安市', '芦山县', '石棉县', '名山县', + '天全县', '荥经县', '宝兴县', '汉源县', '巴中市', '南江县', '平昌县', '通江县', '资阳市', + '简阳市', '安岳县', '乐至县', '红原县', '汶川县', '阿坝县', '理 县', '小金县', '黑水县', + '金川县', '松潘县', '壤塘县', '茂 县', '康定县', '丹巴县', '炉霍县', '九龙县', '甘孜县', + '雅江县', '新龙县', '道孚县', '白玉县', '理塘县', '德格县', '乡城县', '石渠县', '稻城县', + '色达县', '巴塘县', '泸定县', '得荣县', '西昌市', '美姑县', '昭觉县', '金阳县', '甘洛县', + '布拖县', '雷波县', '普格县', '宁南县', '喜德县', '会东县', '越西县', '会理县', '盐源县', + '叙永县', '古蔺县', '德阳市', '广汉市', '什邡市', '绵竹市', '罗江县', '中江县', '绵阳市', + '江油市', '盐亭县', '三台县', '平武县', '安县', '梓潼县', '广元市', '青川县', '旺苍县', + '剑阁县', '苍溪县', '遂宁市', '射洪县', '蓬溪县', '大英县', '内江市', '资中县', '隆昌县', + '威远县', '乐山市', '夹江县', '井研县', '犍为县', '沐川县', '南充市', '阆中市', '营山县', + '蓬安县', '仪陇县', '南部县', '西充县', '眉山市', '仁寿县', '彭山县', '洪雅县', '丹棱县', + '青神县', '宜宾市', '宜宾县', '兴文县', '南溪县', '珙 县', '长宁县', ' 高 县', '江安县', + '筠连县', '屏山县', '广安市', '华蓥市', '岳池县', '邻水县', '武胜县', '达州市', '万源市', + '达县渠', '汉县', '江县', '竹县', '雅安市', '芦山县', '石棉县', '名山县', + '天全县', '荥经县', '宝兴县', '汉源县', '巴中市', '南江县', '平昌县', '通江县', '资阳市', + '简阳市', '安岳县', '乐至县', '红原县', '汶川县', '阿坝县', '理 县', '小金县', '黑水县', + '金川县', '松潘县', '壤塘县', '茂 县', '康定县', '丹巴县', '炉霍县', '九龙县', '甘孜县', + '雅江县', '新龙县', '道孚县', '白玉县', '理塘县', '德格县', '乡城县', '石渠县', '稻城县', + '色达县', '巴塘县', '泸定县', '得荣县', '西昌市', '美姑县', '昭觉县', '金阳县', '甘洛县', + '布拖县', '雷波县', '普格县', '宁南县', '喜德县', '会东县', '越西县', '会理县', '盐源县', + '叙永县', '古蔺县', '德阳市', '广汉市', '什邡市', '绵竹市', '罗江县', '中江县', '绵阳市', + '江油市', '盐亭县', '三台县', '平武县', '安县', '梓潼县', '广元市', '青川县', '旺苍县', + '剑阁县', '苍溪县', '遂宁市', '射洪县', '蓬溪县', '大英县', '内江市', '资中县', '隆昌县', + '威远县', '乐山市', '夹江县', '井研县', '犍为县', '沐川县', '南充市', '阆中市', '营山县', + '蓬安县', '仪陇县', '南部县', '西充县', '眉山市', '仁寿县', '彭山县', '洪雅县', '丹棱县', + '青神县', '宜宾市', '宜宾县', '兴文县', '南溪县', '珙 县', '长宁县', ' 高 县', '江安县', + '筠连县', '屏山县', '广安市', '华蓥市', '岳池县', '邻水县', '武胜县', '达州市', '万源市', + '达县渠', '汉县', '江县', '竹县', '雅安市', '芦山县', '石棉县', '名山县', + '天全县', '荥经县', '宝兴县', '汉源县', '巴中市', '南江县', '平昌县', '通江县', '资阳市', + '简阳市', '安岳县', '乐至县', '红原县', '汶川县', '阿坝县', '理 县', '小金县', '黑水县', + '金川县', '松潘县', '壤塘县', '茂 县', '康定县', '丹巴县', '炉霍县', '九龙县', '甘孜县', + '雅江县', '新龙县', '道孚县', '白玉县', '理塘县', '德格县', '乡城县', '石渠县', '稻城县', + '色达县', '巴塘县', '泸定县', '得荣县', '西昌市', '美姑县', '昭觉县', '金阳县', '甘洛县', + '布拖县', '雷波县', '普格县', '宁南县', '喜德县', '会东县', '越西县', '会理县', '盐源县', + '叙永县', '古蔺县', '德阳市', '广汉市', '什邡市', '绵竹市', '罗江县', '中江县', '绵阳市', + '江油市', '盐亭县', '三台县', '平武县', '安县', '梓潼县', '广元市', '青川县', '旺苍县', + '剑阁县', '苍溪县', '遂宁市', '射洪县', '蓬溪县', '大英县', '内江市', '资中县', '隆昌县', + '威远县', '乐山市', '夹江县', '井研县', '犍为县', '沐川县', '南充市', '阆中市', '营山县', + '蓬安县', '仪陇县', '南部县', '西充县', '眉山市', '仁寿县', '彭山县', '洪雅县', '丹棱县', + '青神县', '宜宾市', '宜宾县', '兴文县', '南溪县', '珙 县', '长宁县', ' 高 县', '江安县', + '筠连县', '屏山县', '广安市', '华蓥市', '岳池县', '邻水县', '武胜县', '达州市', '万源市', + '达县渠', '汉县', '江县', '竹县', '雅安市', '芦山县', '石棉县', '名山县', + '天全县', '荥经县', '宝兴县', '汉源县', '巴中市', '南江县', '平昌县', '通江县', '资阳市', + '简阳市', '安岳县', '乐至县', '红原县', '汶川县', '阿坝县', '理 县', '小金县', '黑水县', + '金川县', '松潘县', '壤塘县', '茂 县', '康定县', '丹巴县', '炉霍县', '九龙县', '甘孜县', + '雅江县', '新龙县', '道孚县', '白玉县', '理塘县', '德格县', '乡城县', '石渠县', '稻城县', + '色达县', '巴塘县', '泸定县', '得荣县', '西昌市', '美姑县', '昭觉县', '金阳县', '甘洛县', + '布拖县', '雷波县', '普格县', '宁南县', '喜德县', '会东县', '越西县', '会理县', '盐源县', + '叙永县', '古蔺县', '德阳市', '广汉市', '什邡市', '绵竹市', '罗江县', '中江县', '绵阳市', + '江油市', '盐亭县', '三台县', '平武县', '安县', '梓潼县', '广元市', '青川县', '旺苍县', + '剑阁县', '苍溪县', '遂宁市', '射洪县', '蓬溪县', '大英县', '内江市', '资中县', '隆昌县', + '威远县', '乐山市', '夹江县', '井研县', '犍为县', '沐川县', '南充市', '阆中市', '营山县', + '蓬安县', '仪陇县', '南部县', '西充县', '眉山市', '仁寿县', '彭山县', '洪雅县', '丹棱县', + '青神县', '宜宾市', '宜宾县', '兴文县', '南溪县', '珙 县', '长宁县', ' 高 县', '江安县', + '筠连县', '屏山县', '广安市', '华蓥市', '岳池县', '邻水县', '武胜县', '达州市', '万源市', + '达县渠', '汉县', '江县', '竹县', '雅安市', '芦山县', '石棉县', '名山县', + '天全县', '荥经县', '宝兴县', '汉源县', '巴中市', '南江县', '平昌县', '通江县', '资阳市', + '简阳市', '安岳县', '乐至县', '红原县', '汶川县', '阿坝县', '理 县', '小金县', '黑水县', + '金川县', '松潘县', '壤塘县', '茂 县', '康定县', '丹巴县', '炉霍县', '九龙县', '甘孜县', + '雅江县', '新龙县', '道孚县', '白玉县', '理塘县', '德格县', '乡城县', '石渠县', '稻城县', + '色达县', '巴塘县', '泸定县', '得荣县', '西昌市', '美姑县', '昭觉县', '金阳县', '甘洛县', + '布拖县', '雷波县', '普格县', '宁南县', '喜德县', '会东县', '越西县', '会理县', '盐源县', + '叙永县', '古蔺县', '德阳市', '广汉市', '什邡市', '绵竹市', '罗江县', '中江县', '绵阳市', + '江油市', '盐亭县', '三台县', '平武县', '安县', '梓潼县', '广元市', '青川县', '旺苍县', + '剑阁县', '苍溪县', '遂宁市', '射洪县', '蓬溪县', '大英县', '内江市', '资中县', '隆昌县', + '威远县', '乐山市', '夹江县', '井研县', '犍为县', '沐川县', '南充市', '阆中市', '营山县', + '蓬安县', '仪陇县', '南部县', '西充县', '眉山市', '仁寿县', '彭山县', '洪雅县', '丹棱县', + '青神县', '宜宾市', '宜宾县', '兴文县', '南溪县', '珙 县', '长宁县', ' 高 县', '江安县', + '筠连县', '屏山县', '广安市', '华蓥市', '岳池县', '邻水县', '武胜县', '达州市', '万源市', + '达县渠', '汉县', '江县', '竹县', '雅安市', '芦山县', '石棉县', '名山县', + '天全县', '荥经县', '宝兴县', '汉源县', '巴中市', '南江县', '平昌县', '通江县', '资阳市', + '简阳市', '安岳县', '乐至县', '红原县', '汶川县', '阿坝县', '理 县', '小金县', '黑水县', + '金川县', '松潘县', '壤塘县', '茂 县', '康定县', '丹巴县', '炉霍县', '九龙县', '甘孜县', + '雅江县', '新龙县', '道孚县', '白玉县', '理塘县', '德格县', '乡城县', '石渠县', '稻城县', + '色达县', '巴塘县', '泸定县', '得荣县', '西昌市', '美姑县', '昭觉县', '金阳县', '甘洛县', + '布拖县', '雷波县', '普格县', '宁南县', '喜德县', '会东县', '越西县', '会理县', '盐源县', + '叙永县', '古蔺县', '德阳市', '广汉市', '什邡市', '绵竹市', '罗江县', '中江县', '绵阳市', + '江油市', '盐亭县', '三台县', '平武县', '安县', '梓潼县', '广元市', '青川县', '旺苍县', + '剑阁县', '苍溪县', '遂宁市', '射洪县', '蓬溪县', '大英县', '内江市', '资中县', '隆昌县', + '威远县', '乐山市', '夹江县', '井研县', '犍为县', '沐川县', '南充市', '阆中市', '营山县', + '蓬安县', '仪陇县', '南部县', '西充县', '眉山市', '仁寿县', '彭山县', '洪雅县', '丹棱县', + '青神县', '宜宾市', '宜宾县', '兴文县', '南溪县', '珙 县', '长宁县', ' 高 县', '江安县', + '筠连县', '屏山县', '广安市', '华蓥市', '岳池县', '邻水县', '武胜县', '达州市', '万源市', + '达县渠', '汉县', '江县', '竹县', '雅安市', '芦山县', '石棉县', '名山县', + '天全县', '荥经县', '宝兴县', '汉源县', '巴中市', '南江县', '平昌县', '通江县', '资阳市', + '简阳市', '安岳县', '乐至县', '红原县', '汶川县', '阿坝县', '理 县', '小金县', '黑水县', + '金川县', '松潘县', '壤塘县', '茂 县', '康定县', '丹巴县', '炉霍县', '九龙县', '甘孜县', + '雅江县', '新龙县', '道孚县', '白玉县', '理塘县', '德格县', '乡城县', '石渠县', '稻城县', + '色达县', '巴塘县', '泸定县', '得荣县', '西昌市', '美姑县', '昭觉县', '金阳县', '甘洛县', + '布拖县', '雷波县', '普格县', '宁南县', '喜德县', '会东县', '越西县', '会理县', '盐源县', + '叙永县', '古蔺县', '德阳市', '广汉市', '什邡市', '绵竹市', '罗江县', '中江县', '绵阳市', + '江油市', '盐亭县', '三台县', '平武县', '安县', '梓潼县', '广元市', '青川县', '旺苍县', + '剑阁县', '苍溪县', '遂宁市', '射洪县', '蓬溪县', '大英县', '内江市', '资中县', '隆昌县', + '威远县', '乐山市', '夹江县', '井研县', '犍为县', '沐川县', '南充市', '阆中市', '营山县', + '蓬安县', '仪陇县', '南部县', '西充县', '眉山市', '仁寿县', '彭山县', '洪雅县', '丹棱县', + '青神县', '宜宾市', '宜宾县', '兴文县', '南溪县', '珙 县', '长宁县', ' 高 县', '江安县', + '筠连县', '屏山县', '广安市', '华蓥市', '岳池县', '邻水县', '武胜县', '达州市', '万源市', + '达县渠', '汉县', '江县', '竹县', '雅安市', '芦山县', '石棉县', '名山县', + '天全县', '荥经县', '宝兴县', '汉源县', '巴中市', '南江县', '平昌县', '通江县', '资阳市', + '简阳市', '安岳县', '乐至县', '红原县', '汶川县', '阿坝县', '理 县', '小金县', '黑水县', + '金川县', '松潘县', '壤塘县', '茂 县', '康定县', '丹巴县', '炉霍县', '九龙县', '甘孜县', + '雅江县', '新龙县', '道孚县', '白玉县', '理塘县', '德格县', '乡城县', '石渠县', '稻城县', + '色达县', '巴塘县', '泸定县', '得荣县', '西昌市', '美姑县', '昭觉县', '金阳县', '甘洛县', + '布拖县', '雷波县', '普格县', '宁南县', '喜德县', '会东县', '越西县', '会理县', '盐源县', + '叙永县', '古蔺县', '德阳市', '广汉市', '什邡市', '绵竹市', '罗江县', '中江县', '绵阳市', + '江油市', '盐亭县', '三台县', '平武县', '安县', '梓潼县', '广元市', '青川县', '旺苍县', + '剑阁县', '苍溪县', '遂宁市', '射洪县', '蓬溪县', '大英县', '内江市', '资中县', '隆昌县', + '威远县', '乐山市', '夹江县', '井研县', '犍为县', '沐川县', '南充市', '阆中市', '营山县', + '蓬安县', '仪陇县', '南部县', '西充县', '眉山市', '仁寿县', '彭山县', '洪雅县', '丹棱县', + '青神县', '宜宾市', '宜宾县', '兴文县', '南溪县', '珙 县', '长宁县', ' 高 县', '江安县', + '筠连县', '屏山县', '广安市', '华蓥市', '岳池县', '邻水县', '武胜县', '达州市', '万源市', + '达县渠', '汉县', '江县', '竹县', '雅安市', '芦山县', '石棉县', '名山县', + '天全县', '荥经县', '宝兴县', '汉源县', '巴中市', '南江县', '平昌县', '通江县', '资阳市', + '简阳市', '安岳县', '乐至县', '红原县', '汶川县', '阿坝县', '理 县', '小金县', '黑水县', + '金川县', '松潘县', '壤塘县', '茂 县', '康定县', '丹巴县', '炉霍县', '九龙县', '甘孜县', + '雅江县', '新龙县', '道孚县', '白玉县', '理塘县', '德格县', '乡城县', '石渠县', '稻城县', + '色达县', '巴塘县', '泸定县', '得荣县', '西昌市', '美姑县', '昭觉县', '金阳县', '甘洛县', + '布拖县', '雷波县', '普格县', '宁南县', '喜德县', '会东县', '越西县', '会理县', '盐源县', + // '简阳市','安岳县','乐至县','红原县', '汶川县', '阿坝县', '理 县', '小金县', '黑水县', + // '金川县','松潘县','壤塘县','茂 县', '康定县', '丹巴县', '炉霍县', '九龙县', '甘孜县', + // '雅江县','新龙县','道孚县','白玉县', '理塘县', '德格县', '乡城县', '石渠县', '稻城县', + // '色达县','巴塘县','泸定县','得荣县', '西昌市', '美姑县', '昭觉县', '金阳县', '甘洛县', + // '布拖县','雷波县','普格县','宁南县', '喜德县', '会东县', '越西县', '会理县', '盐源县', + // '叙永县','古蔺县','德阳市','广汉市', '什邡市', '绵竹市', '罗江县', '中江县', '绵阳市', + // '江油市','盐亭县','三台县','平武县', '安县', '梓潼县', '广元市', '青川县', '旺苍县', + // '剑阁县','苍溪县','遂宁市','射洪县', '蓬溪县', '大英县', '内江市', '资中县', '隆昌县', + // '威远县','乐山市','夹江县','井研县', '犍为县', '沐川县', '南充市', '阆中市', '营山县', + // '蓬安县','仪陇县','南部县','西充县', '眉山市', '仁寿县', '彭山县', '洪雅县', '丹棱县', + // '青神县','宜宾市','宜宾县','兴文县', '南溪县', '珙 县', '长宁县',' 高 县', '江安县', + // '筠连县','屏山县','广安市','华蓥市', '岳池县', '邻水县', '武胜县', '达州市', '万源市', + // '达县渠','汉县' ,'江县' ,'竹县' ,'雅安市' ,'芦山县' ,'石棉县' ,'名山县', + // '天全县','荥经县','宝兴县','汉源县', '巴中市', '南江县', '平昌县', '通江县', '资阳市', + // '简阳市','安岳县','乐至县','红原县', '汶川县', '阿坝县', '理 县', '小金县', '黑水县', + // '金川县','松潘县','壤塘县','茂 县', '康定县', '丹巴县', '炉霍县', '九龙县', '甘孜县', + // '雅江县','新龙县','道孚县','白玉县', '理塘县', '德格县', '乡城县', '石渠县', '稻城县', + // '色达县','巴塘县','泸定县','得荣县', '西昌市', '美姑县', '昭觉县', '金阳县', '甘洛县', + // '布拖县','雷波县','普格县','宁南县', '喜德县', '会东县', '越西县', '会理县', '盐源县','叙永县','古蔺县','德阳市','广汉市', '什邡市', '绵竹市', '罗江县', '中江县', '绵阳市', + // '江油市','盐亭县','三台县','平武县', '安县', '梓潼县', '广元市', '青川县', '旺苍县', + // '剑阁县','苍溪县','遂宁市','射洪县', '蓬溪县', '大英县', '内江市', '资中县', '隆昌县', + // '威远县','乐山市','夹江县','井研县', '犍为县', '沐川县', '南充市', '阆中市', '营山县', + // '蓬安县','仪陇县','南部县','西充县', '眉山市', '仁寿县', '彭山县', '洪雅县', '丹棱县', + // '青神县','宜宾市','宜宾县','兴文县', '南溪县', '珙 县', '长宁县',' 高 县', '江安县', + // '筠连县','屏山县','广安市','华蓥市', '岳池县', '邻水县', '武胜县', '达州市', '万源市', + // '达县渠','汉县' ,'江县' ,'竹县' ,'雅安市' ,'芦山县' ,'石棉县' ,'名山县', + // '天全县','荥经县','宝兴县','汉源县', '巴中市', '南江县', '平昌县', '通江县', '资阳市', + // '简阳市','安岳县','乐至县','红原县', '汶川县', '阿坝县', '理 县', '小金县', '黑水县', + // '金川县','松潘县','壤塘县','茂 县', '康定县', '丹巴县', '炉霍县', '九龙县', '甘孜县', + // '雅江县','新龙县','道孚县','白玉县', '理塘县', '德格县', '乡城县', '石渠县', '稻城县', + // '色达县','巴塘县','泸定县','得荣县', '西昌市', '美姑县', '昭觉县', '金阳县', '甘洛县', + // '布拖县','雷波县','普格县','宁南县', '喜德县', '会东县', '越西县', '会理县', '盐源县', + // '叙永县','古蔺县','德阳市','广汉市', '什邡市', '绵竹市', '罗江县', '中江县', '绵阳市', + // '江油市','盐亭县','三台县','平武县', '安县', '梓潼县', '广元市', '青川县', '旺苍县', + // '剑阁县','苍溪县','遂宁市','射洪县', '蓬溪县', '大英县', '内江市', '资中县', '隆昌县', + // '威远县','乐山市','夹江县','井研县', '犍为县', '沐川县', '南充市', '阆中市', '营山县', + // '蓬安县','仪陇县','南部县','西充县', '眉山市', '仁寿县', '彭山县', '洪雅县', '丹棱县', + // '青神县','宜宾市','宜宾县','兴文县', '南溪县', '珙 县', '长宁县',' 高 县', '江安县', + // '筠连县','屏山县','广安市','华蓥市', '岳池县', '邻水县', '武胜县', '达州市', '万源市', + // '达县渠','汉县' ,'江县' ,'竹县' ,'雅安市' ,'芦山县' ,'石棉县' ,'名山县', + // '天全县','荥经县','宝兴县','汉源县', '巴中市', '南江县', '平昌县', '通江县', '资阳市', + // '简阳市','安岳县','乐至县','红原县', '汶川县', '阿坝县', '理 县', '小金县', '黑水县', + // '金川县','松潘县','壤塘县','茂 县', '康定县', '丹巴县', '炉霍县', '九龙县', '甘孜县', + // '雅江县','新龙县','道孚县','白玉县', '理塘县', '德格县', '乡城县', '石渠县', '稻城县', + // '色达县','巴塘县','泸定县','得荣县', '西昌市', '美姑县', '昭觉县', '金阳县', '甘洛县', + // '布拖县','雷波县','普格县','宁南县', '喜德县', '会东县', '越西县', '会理县', '盐源县', + // '叙永县','古蔺县','德阳市','广汉市', '什邡市', '绵竹市', '罗江县', '中江县', '绵阳市', + // '江油市','盐亭县','三台县','平武县', '安县', '梓潼县', '广元市', '青川县', '旺苍县', + // '剑阁县','苍溪县','遂宁市','射洪县', '蓬溪县', '大英县', '内江市', '资中县', '隆昌县', + // '威远县','乐山市','夹江县','井研县', '犍为县', '沐川县', '南充市', '阆中市', '营山县', + // '蓬安县','仪陇县','南部县','西充县', '眉山市', '仁寿县', '彭山县', '洪雅县', '丹棱县', + // '青神县','宜宾市','宜宾县','兴文县', '南溪县', '珙 县', '长宁县',' 高 县', '江安县', + // '筠连县','屏山县','广安市','华蓥市', '岳池县', '邻水县', '武胜县', '达州市', '万源市', + // '达县渠','汉县' ,'江县' ,'竹县' ,'雅安市' ,'芦山县' ,'石棉县' ,'名山县', + // '天全县','荥经县','宝兴县','汉源县', '巴中市', '南江县', '平昌县', '通江县', '资阳市', + // '简阳市','安岳县','乐至县','红原县', '汶川县', '阿坝县', '理 县', '小金县', '黑水县', + // '金川县','松潘县','壤塘县','茂 县', '康定县', '丹巴县', '炉霍县', '九龙县', '甘孜县', + // '雅江县','新龙县','道孚县','白玉县', '理塘县', '德格县', '乡城县', '石渠县', '稻城县', + // '色达县','巴塘县','泸定县','得荣县', '西昌市', '美姑县', '昭觉县', '金阳县', '甘洛县', + // '布拖县','雷波县','普格县','宁南县', '喜德县', '会东县', '越西县', '会理县', '盐源县', + // '叙永县','古蔺县','德阳市','广汉市', '什邡市', '绵竹市', '罗江县', '中江县', '绵阳市', + // '江油市','盐亭县','三台县','平武县', '安县', '梓潼县', '广元市', '青川县', '旺苍县', + // '剑阁县','苍溪县','遂宁市','射洪县', '蓬溪县', '大英县', '内江市', '资中县', '隆昌县', + // '威远县','乐山市','夹江县','井研县', '犍为县', '沐川县', '南充市', '阆中市', '营山县', + // '蓬安县','仪陇县','南部县','西充县', '眉山市', '仁寿县', '彭山县', '洪雅县', '丹棱县', + // '青神县','宜宾市','宜宾县','兴文县', '南溪县', '珙 县', '长宁县',' 高 县', '江安县', + // '筠连县','屏山县','广安市','华蓥市', '岳池县', '邻水县', '武胜县', '达州市', '万源市', + // '达县渠','汉县' ,'江县' ,'竹县' ,'雅安市' ,'芦山县' ,'石棉县' ,'名山县', + // '天全县','荥经县','宝兴县','汉源县', '巴中市', '南江县', '平昌县', '通江县', '资阳市', + // '简阳市','安岳县','乐至县','红原县', '汶川县', '阿坝县', '理 县', '小金县', '黑水县', + // '金川县','松潘县','壤塘县','茂 县', '康定县', '丹巴县', '炉霍县', '九龙县', '甘孜县', + // '雅江县','新龙县','道孚县','白玉县', '理塘县', '德格县', '乡城县', '石渠县', '稻城县', + // '色达县','巴塘县','泸定县','得荣县', '西昌市', '美姑县', '昭觉县', '金阳县', '甘洛县', + // '布拖县','雷波县','普格县','宁南县', '喜德县', '会东县', '越西县', '会理县', '盐源县', + // '叙永县','古蔺县','德阳市','广汉市', '什邡市', '绵竹市', '罗江县', '中江县', '绵阳市', + // '江油市','盐亭县','三台县','平武县', '安县', '梓潼县', '广元市', '青川县', '旺苍县', + // '剑阁县','苍溪县','遂宁市','射洪县', '蓬溪县', '大英县', '内江市', '资中县', '隆昌县', + // '威远县','乐山市','夹江县','井研县', '犍为县', '沐川县', '南充市', '阆中市', '营山县', + // '蓬安县','仪陇县','南部县','西充县', '眉山市', '仁寿县', '彭山县', '洪雅县', '丹棱县', + // '青神县','宜宾市','宜宾县','兴文县', '南溪县', '珙 县', '长宁县',' 高 县', '江安县', + // '筠连县','屏山县','广安市','华蓥市', '岳池县', '邻水县', '武胜县', '达州市', '万源市', + // '达县渠','汉县' ,'江县' ,'竹县' ,'雅安市' ,'芦山县' ,'石棉县' ,'名山县', + // '天全县','荥经县','宝兴县','汉源县', '巴中市', '南江县', '平昌县', '通江县', '资阳市', + // '简阳市','安岳县','乐至县','红原县', '汶川县', '阿坝县', '理 县', '小金县', '黑水县', + // '金川县','松潘县','壤塘县','茂 县', '康定县', '丹巴县', '炉霍县', '九龙县', '甘孜县', + // '雅江县','新龙县','道孚县','白玉县', '理塘县', '德格县', '乡城县', '石渠县', '稻城县', + // '色达县','巴塘县','泸定县','得荣县', '西昌市', '美姑县', '昭觉县', '金阳县', '甘洛县', + // '布拖县','雷波县','普格县','宁南县', '喜德县', '会东县', '越西县', '会理县', '盐源县', + // '叙永县','古蔺县','德阳市','广汉市', '什邡市', '绵竹市', '罗江县', '中江县', '绵阳市', + // '江油市','盐亭县','三台县','平武县', '安县', '梓潼县', '广元市', '青川县', '旺苍县', + // '剑阁县','苍溪县','遂宁市','射洪县', '蓬溪县', '大英县', '内江市', '资中县', '隆昌县', + // '威远县','乐山市','夹江县','井研县', '犍为县', '沐川县', '南充市', '阆中市', '营山县', + // '蓬安县','仪陇县','南部县','西充县', '眉山市', '仁寿县', '彭山县', '洪雅县', '丹棱县', + // '青神县','宜宾市','宜宾县','兴文县', '南溪县', '珙 县', '长宁县',' 高 县', '江安县', + // '筠连县','屏山县','广安市','华蓥市', '岳池县', '邻水县', '武胜县', '达州市', '万源市', + // '达县渠','汉县' ,'江县' ,'竹县' ,'雅安市' ,'芦山县' ,'石棉县' ,'名山县', + // '天全县','荥经县','宝兴县','汉源县', '巴中市', '南江县', '平昌县', '通江县', '资阳市', + // '简阳市','安岳县','乐至县','红原县', '汶川县', '阿坝县', '理 县', '小金县', '黑水县', + // '金川县','松潘县','壤塘县','茂 县', '康定县', '丹巴县', '炉霍县', '九龙县', '甘孜县', + // '雅江县','新龙县','道孚县','白玉县', '理塘县', '德格县', '乡城县', '石渠县', '稻城县', + // '色达县','巴塘县','泸定县','得荣县', '西昌市', '美姑县', '昭觉县', '金阳县', '甘洛县', + // '布拖县','雷波县','普格县','宁南县', '喜德县', '会东县', '越西县', '会理县', '盐源县', + // '叙永县','古蔺县','德阳市','广汉市', '什邡市', '绵竹市', '罗江县', '中江县', '绵阳市', + // '江油市','盐亭县','三台县','平武县', '安县', '梓潼县', '广元市', '青川县', '旺苍县', + // '剑阁县','苍溪县','遂宁市','射洪县', '蓬溪县', '大英县', '内江市', '资中县', '隆昌县', + // '威远县','乐山市','夹江县','井研县', '犍为县', '沐川县', '南充市', '阆中市', '营山县', + // '蓬安县','仪陇县','南部县','西充县', '眉山市', '仁寿县', '彭山县', '洪雅县', '丹棱县', + // '青神县','宜宾市','宜宾县','兴文县', '南溪县', '珙 县', '长宁县',' 高 县', '江安县', + // '筠连县','屏山县','广安市','华蓥市', '岳池县', '邻水县', '武胜县', '达州市', '万源市', + // '达县渠','汉县' ,'江县' ,'竹县' ,'雅安市' ,'芦山县' ,'石棉县' ,'名山县', + // '天全县','荥经县','宝兴县','汉源县', '巴中市', '南江县', '平昌县', '通江县', '资阳市', + // '简阳市','安岳县','乐至县','红原县', '汶川县', '阿坝县', '理 县', '小金县', '黑水县', + // '金川县','松潘县','壤塘县','茂 县', '康定县', '丹巴县', '炉霍县', '九龙县', '甘孜县', + // '雅江县','新龙县','道孚县','白玉县', '理塘县', '德格县', '乡城县', '石渠县', '稻城县', + // '色达县','巴塘县','泸定县','得荣县', '西昌市', '美姑县', '昭觉县', '金阳县', '甘洛县', + // '布拖县','雷波县','普格县','宁南县', '喜德县', '会东县', '越西县', '会理县', '盐源县', + // '叙永县','古蔺县','德阳市','广汉市', '什邡市', '绵竹市', '罗江县', '中江县', '绵阳市', + // '江油市','盐亭县','三台县','平武县', '安县', '梓潼县', '广元市', '青川县', '旺苍县', + // '剑阁县','苍溪县','遂宁市','射洪县', '蓬溪县', '大英县', '内江市', '资中县', '隆昌县', + // '威远县','乐山市','夹江县','井研县', '犍为县', '沐川县', '南充市', '阆中市', '营山县', + // '蓬安县','仪陇县','南部县','西充县', '眉山市', '仁寿县', '彭山县', '洪雅县', '丹棱县', + // '青神县','宜宾市','宜宾县','兴文县', '南溪县', '珙 县', '长宁县',' 高 县', '江安县', + // '筠连县','屏山县','广安市','华蓥市', '岳池县', '邻水县', '武胜县', '达州市', '万源市', + // '达县渠','汉县' ,'江县' ,'竹县' ,'雅安市' ,'芦山县' ,'石棉县' ,'名山县', + // '天全县','荥经县','宝兴县','汉源县', '巴中市', '南江县', '平昌县', '通江县', '资阳市', + // '简阳市','安岳县','乐至县','红原县', '汶川县', '阿坝县', '理 县', '小金县', '黑水县', + // '金川县','松潘县','壤塘县','茂 县', '康定县', '丹巴县', '炉霍县', '九龙县', '甘孜县', + // '雅江县','新龙县','道孚县','白玉县', '理塘县', '德格县', '乡城县', '石渠县', '稻城县', + // '色达县','巴塘县','泸定县','得荣县', '西昌市', '美姑县', '昭觉县', '金阳县', '甘洛县', + // '布拖县','雷波县','普格县','宁南县', '喜德县', '会东县', '越西县', '会理县', '盐源县', + // '叙永县','古蔺县','德阳市','广汉市', '什邡市', '绵竹市', '罗江县', '中江县', '绵阳市', + // '江油市','盐亭县','三台县','平武县', '安县', '梓潼县', '广元市', '青川县', '旺苍县', + // '剑阁县','苍溪县','遂宁市','射洪县', '蓬溪县', '大英县', '内江市', '资中县', '隆昌县', + // '威远县','乐山市','夹江县','井研县', '犍为县', '沐川县', '南充市', '阆中市', '营山县', + // '蓬安县','仪陇县','南部县','西充县', '眉山市', '仁寿县', '彭山县', '洪雅县', '丹棱县', + // '青神县','宜宾市','宜宾县','兴文县', '南溪县', '珙 县', '长宁县',' 高 县', '江安县', + // '筠连县','屏山县','广安市','华蓥市', '岳池县', '邻水县', '武胜县', '达州市', '万源市', + // '达县渠','汉县' ,'江县' ,'竹县' ,'雅安市' ,'芦山县' ,'石棉县' ,'名山县', + // '天全县','荥经县','宝兴县','汉源县', '巴中市', '南江县', '平昌县', '通江县', '资阳市', + // '简阳市','安岳县','乐至县','红原县', '汶川县', '阿坝县', '理 县', '小金县', '黑水县', + // '金川县','松潘县','壤塘县','茂 县', '康定县', '丹巴县', '炉霍县', '九龙县', '甘孜县', + // '雅江县','新龙县','道孚县','白玉县', '理塘县', '德格县', '乡城县', '石渠县', '稻城县', + // '色达县','巴塘县','泸定县','得荣县', '西昌市', '美姑县', '昭觉县', '金阳县', '甘洛县', + // '布拖县','雷波县','普格县','宁南县', '喜德县', '会东县', '越西县', '会理县', '盐源县', + // '叙永县','古蔺县','德阳市','广汉市', '什邡市', '绵竹市', '罗江县', '中江县', '绵阳市', + // '江油市','盐亭县','三台县','平武县', '安县', '梓潼县', '广元市', '青川县', '旺苍县', + // '剑阁县','苍溪县','遂宁市','射洪县', '蓬溪县', '大英县', '内江市', '资中县', '隆昌县', + // '威远县','乐山市','夹江县','井研县', '犍为县', '沐川县', '南充市', '阆中市', '营山县', + // '蓬安县','仪陇县','南部县','西充县', '眉山市', '仁寿县', '彭山县', '洪雅县', '丹棱县', + // '青神县','宜宾市','宜宾县','兴文县', '南溪县', '珙 县', '长宁县',' 高 县', '江安县', + // '筠连县','屏山县','广安市','华蓥市', '岳池县', '邻水县', '武胜县', '达州市', '万源市', + // '达县渠','汉县' ,'江县' ,'竹县' ,'雅安市' ,'芦山县' ,'石棉县' ,'名山县', + // '天全县','荥经县','宝兴县','汉源县', '巴中市', '南江县', '平昌县', '通江县', '资阳市', + // '简阳市','安岳县','乐至县','红原县', '汶川县', '阿坝县', '理 县', '小金县', '黑水县', + // '金川县','松潘县','壤塘县','茂 县', '康定县', '丹巴县', '炉霍县', '九龙县', '甘孜县', + // '雅江县','新龙县','道孚县','白玉县', '理塘县', '德格县', '乡城县', '石渠县', '稻城县', + // '色达县','巴塘县','泸定县','得荣县', '西昌市', '美姑县', '昭觉县', '金阳县', '甘洛县', + // '布拖县','雷波县','普格县','宁南县', '喜德县', '会东县', '越西县', '会理县', '盐源县', + // '叙永县','古蔺县','德阳市','广汉市', '什邡市', '绵竹市', '罗江县', '中江县', '绵阳市', + // '江油市','盐亭县','三台县','平武县', '安县', '梓潼县', '广元市', '青川县', '旺苍县', + // '剑阁县','苍溪县','遂宁市','射洪县', '蓬溪县', '大英县', '内江市', '资中县', '隆昌县', + // '威远县','乐山市','夹江县','井研县', '犍为县', '沐川县', '南充市', '阆中市', '营山县', + // '蓬安县','仪陇县','南部县','西充县', '眉山市', '仁寿县', '彭山县', '洪雅县', '丹棱县', + // '青神县','宜宾市','宜宾县','兴文县', '南溪县', '珙 县', '长宁县',' 高 县', '江安县', + // '筠连县','屏山县','广安市','华蓥市', '岳池县', '邻水县', '武胜县', '达州市', '万源市', + // '达县渠','汉县' ,'江县' ,'竹县' ,'雅安市' ,'芦山县' ,'石棉县' ,'名山县', + // '天全县','荥经县','宝兴县','汉源县', '巴中市', '南江县', '平昌县', '通江县', '资阳市', + // '简阳市','安岳县','乐至县','红原县', '汶川县', '阿坝县', '理 县', '小金县', '黑水县', + // '金川县','松潘县','壤塘县','茂 县', '康定县', '丹巴县', '炉霍县', '九龙县', '甘孜县', + // '雅江县','新龙县','道孚县','白玉县', '理塘县', '德格县', '乡城县', '石渠县', '稻城县', + // '色达县','巴塘县','泸定县','得荣县', '西昌市', '美姑县', '昭觉县', '金阳县', '甘洛县', + // '布拖县','雷波县','普格县','宁南县', '喜德县', '会东县', '越西县', '会理县', '盐源县', + // '叙永县','古蔺县','德阳市','广汉市', '什邡市', '绵竹市', '罗江县', '中江县', '绵阳市', + // '江油市','盐亭县','三台县','平武县', '安县', '梓潼县', '广元市', '青川县', '旺苍县', + // '剑阁县','苍溪县','遂宁市','射洪县', '蓬溪县', '大英县', '内江市', '资中县', '隆昌县', + // '威远县','乐山市','夹江县','井研县', '犍为县', '沐川县', '南充市', '阆中市', '营山县', + // '蓬安县','仪陇县','南部县','西充县', '眉山市', '仁寿县', '彭山县', '洪雅县', '丹棱县', + // '青神县','宜宾市','宜宾县','兴文县', '南溪县', '珙 县', '长宁县',' 高 县', '江安县', + // '筠连县','屏山县','广安市','华蓥市', '岳池县', '邻水县', '武胜县', '达州市', '万源市', + // '达县渠','汉县' ,'江县' ,'竹县' ,'雅安市' ,'芦山县' ,'石棉县' ,'名山县', + // '天全县','荥经县','宝兴县','汉源县', '巴中市', '南江县', '平昌县', '通江县', '资阳市', + // '简阳市','安岳县','乐至县','红原县', '汶川县', '阿坝县', '理 县', '小金县', '黑水县', + // '金川县','松潘县','壤塘县','茂 县', '康定县', '丹巴县', '炉霍县', '九龙县', '甘孜县', + // '雅江县','新龙县','道孚县','白玉县', '理塘县', '德格县', '乡城县', '石渠县', '稻城县', + // '色达县','巴塘县','泸定县','得荣县', '西昌市', '美姑县', '昭觉县', '金阳县', '甘洛县', + // '布拖县','雷波县','普格县','宁南县', '喜德县', '会东县', '越西县', '会理县', '盐源县', + // '叙永县','古蔺县','德阳市','广汉市', '什邡市', '绵竹市', '罗江县', '中江县', '绵阳市', + // '江油市','盐亭县','三台县','平武县', '安县', '梓潼县', '广元市', '青川县', '旺苍县', + // '剑阁县','苍溪县','遂宁市','射洪县', '蓬溪县', '大英县', '内江市', '资中县', '隆昌县', + // '威远县','乐山市','夹江县','井研县', '犍为县', '沐川县', '南充市', '阆中市', '营山县', + // '蓬安县','仪陇县','南部县','西充县', '眉山市', '仁寿县', '彭山县', '洪雅县', '丹棱县', + // '青神县','宜宾市','宜宾县','兴文县', '南溪县', '珙 县', '长宁县',' 高 县', '江安县', + // '筠连县','屏山县','广安市','华蓥市', '岳池县', '邻水县', '武胜县', '达州市', '万源市', + // '达县渠','汉县' ,'江县' ,'竹县' ,'雅安市' ,'芦山县' ,'石棉县' ,'名山县', + // '天全县','荥经县','宝兴县','汉源县', '巴中市', '南江县', '平昌县', '通江县', '资阳市', + // '简阳市','安岳县','乐至县','红原县', '汶川县', '阿坝县', '理 县', '小金县', '黑水县', + // '金川县','松潘县','壤塘县','茂 县', '康定县', '丹巴县', '炉霍县', '九龙县', '甘孜县', + // '雅江县','新龙县','道孚县','白玉县', '理塘县', '德格县', '乡城县', '石渠县', '稻城县', + // '色达县','巴塘县','泸定县','得荣县', '西昌市', '美姑县', '昭觉县', '金阳县', '甘洛县', + // '布拖县','雷波县','普格县','宁南县', '喜德县', '会东县', '越西县', '会理县', '盐源县', + // '叙永县','古蔺县','德阳市','广汉市', '什邡市', '绵竹市', '罗江县', '中江县', '绵阳市', + // '江油市','盐亭县','三台县','平武县', '安县', '梓潼县', '广元市', '青川县', '旺苍县', + // '剑阁县','苍溪县','遂宁市','射洪县', '蓬溪县', '大英县', '内江市', '资中县', '隆昌县', + // '威远县','乐山市','夹江县','井研县', '犍为县', '沐川县', '南充市', '阆中市', '营山县', + // '蓬安县','仪陇县','南部县','西充县', '眉山市', '仁寿县', '彭山县', '洪雅县', '丹棱县', + // '青神县','宜宾市','宜宾县','兴文县', '南溪县', '珙 县', '长宁县',' 高 县', '江安县', + // '筠连县','屏山县','广安市','华蓥市', '岳池县', '邻水县', '武胜县', '达州市', '万源市', + // '达县渠','汉县' ,'江县' ,'竹县' ,'雅安市' ,'芦山县' ,'石棉县' ,'名山县', + // '天全县','荥经县','宝兴县','汉源县', '巴中市', '南江县', '平昌县', '通江县', '资阳市', + // '简阳市','安岳县','乐至县','红原县', '汶川县', '阿坝县', '理 县', '小金县', '黑水县', + // '金川县','松潘县','壤塘县','茂 县', '康定县', '丹巴县', '炉霍县', '九龙县', '甘孜县', + // '雅江县','新龙县','道孚县','白玉县', '理塘县', '德格县', '乡城县', '石渠县', '稻城县', + // '色达县','巴塘县','泸定县','得荣县', '西昌市', '美姑县', '昭觉县', '金阳县', '甘洛县', + // '布拖县','雷波县','普格县','宁南县', '喜德县', '会东县', '越西县', '会理县', '盐源县', + // '简阳市','安岳县','乐至县','红原县', '汶川县', '阿坝县', '理 县', '小金县', '黑水县', + // '金川县','松潘县','壤塘县','茂 县', '康定县', '丹巴县', '炉霍县', '九龙县', '甘孜县', + // '雅江县','新龙县','道孚县','白玉县', '理塘县', '德格县', '乡城县', '石渠县', '稻城县', + // '色达县','巴塘县','泸定县','得荣县', '西昌市', '美姑县', '昭觉县', '金阳县', '甘洛县', + // '布拖县','雷波县','普格县','宁南县', '喜德县', '会东县', '越西县', '会理县', '盐源县', + // '叙永县','古蔺县','德阳市','广汉市', '什邡市', '绵竹市', '罗江县', '中江县', '绵阳市', + // '江油市','盐亭县','三台县','平武县', '安县', '梓潼县', '广元市', '青川县', '旺苍县', + // '剑阁县','苍溪县','遂宁市','射洪县', '蓬溪县', '大英县', '内江市', '资中县', '隆昌县', + // '威远县','乐山市','夹江县','井研县', '犍为县', '沐川县', '南充市', '阆中市', '营山县', + // '蓬安县','仪陇县','南部县','西充县', '眉山市', '仁寿县', '彭山县', '洪雅县', '丹棱县', + // '青神县','宜宾市','宜宾县','兴文县', '南溪县', '珙 县', '长宁县',' 高 县', '江安县', + // '筠连县','屏山县','广安市','华蓥市', '岳池县', '邻水县', '武胜县', '达州市', '万源市', + // '达县渠','汉县' ,'江县' ,'竹县' ,'雅安市' ,'芦山县' ,'石棉县' ,'名山县', + // '天全县','荥经县','宝兴县','汉源县', '巴中市', '南江县', '平昌县', '通江县', '资阳市', + // '简阳市','安岳县','乐至县','红原县', '汶川县', '阿坝县', '理 县', '小金县', '黑水县', + // '金川县','松潘县','壤塘县','茂 县', '康定县', '丹巴县', '炉霍县', '九龙县', '甘孜县', + // '雅江县','新龙县','道孚县','白玉县', '理塘县', '德格县', '乡城县', '石渠县', '稻城县', + // '色达县','巴塘县','泸定县','得荣县', '西昌市', '美姑县', '昭觉县', '金阳县', '甘洛县', + // '布拖县','雷波县','普格县','宁南县', '喜德县', '会东县', '越西县', '会理县', '盐源县','叙永县','古蔺县','德阳市','广汉市', '什邡市', '绵竹市', '罗江县', '中江县', '绵阳市', + // '江油市','盐亭县','三台县','平武县', '安县', '梓潼县', '广元市', '青川县', '旺苍县', + // '剑阁县','苍溪县','遂宁市','射洪县', '蓬溪县', '大英县', '内江市', '资中县', '隆昌县', + // '威远县','乐山市','夹江县','井研县', '犍为县', '沐川县', '南充市', '阆中市', '营山县', + // '蓬安县','仪陇县','南部县','西充县', '眉山市', '仁寿县', '彭山县', '洪雅县', '丹棱县', + // '青神县','宜宾市','宜宾县','兴文县', '南溪县', '珙 县', '长宁县',' 高 县', '江安县', + // '筠连县','屏山县','广安市','华蓥市', '岳池县', '邻水县', '武胜县', '达州市', '万源市', + // '达县渠','汉县' ,'江县' ,'竹县' ,'雅安市' ,'芦山县' ,'石棉县' ,'名山县', + // '天全县','荥经县','宝兴县','汉源县', '巴中市', '南江县', '平昌县', '通江县', '资阳市', + // '简阳市','安岳县','乐至县','红原县', '汶川县', '阿坝县', '理 县', '小金县', '黑水县', + // '金川县','松潘县','壤塘县','茂 县', '康定县', '丹巴县', '炉霍县', '九龙县', '甘孜县', + // '雅江县','新龙县','道孚县','白玉县', '理塘县', '德格县', '乡城县', '石渠县', '稻城县', + // '色达县','巴塘县','泸定县','得荣县', '西昌市', '美姑县', '昭觉县', '金阳县', '甘洛县', + // '布拖县','雷波县','普格县','宁南县', '喜德县', '会东县', '越西县', '会理县', '盐源县', + // '叙永县','古蔺县','德阳市','广汉市', '什邡市', '绵竹市', '罗江县', '中江县', '绵阳市', + // '江油市','盐亭县','三台县','平武县', '安县', '梓潼县', '广元市', '青川县', '旺苍县', + // '剑阁县','苍溪县','遂宁市','射洪县', '蓬溪县', '大英县', '内江市', '资中县', '隆昌县', + // '威远县','乐山市','夹江县','井研县', '犍为县', '沐川县', '南充市', '阆中市', '营山县', + // '蓬安县','仪陇县','南部县','西充县', '眉山市', '仁寿县', '彭山县', '洪雅县', '丹棱县', + // '青神县','宜宾市','宜宾县','兴文县', '南溪县', '珙 县', '长宁县',' 高 县', '江安县', + // '筠连县','屏山县','广安市','华蓥市', '岳池县', '邻水县', '武胜县', '达州市', '万源市', + // '达县渠','汉县' ,'江县' ,'竹县' ,'雅安市' ,'芦山县' ,'石棉县' ,'名山县', + // '天全县','荥经县','宝兴县','汉源县', '巴中市', '南江县', '平昌县', '通江县', '资阳市', + // '简阳市','安岳县','乐至县','红原县', '汶川县', '阿坝县', '理 县', '小金县', '黑水县', + // '金川县','松潘县','壤塘县','茂 县', '康定县', '丹巴县', '炉霍县', '九龙县', '甘孜县', + // '雅江县','新龙县','道孚县','白玉县', '理塘县', '德格县', '乡城县', '石渠县', '稻城县', + // '色达县','巴塘县','泸定县','得荣县', '西昌市', '美姑县', '昭觉县', '金阳县', '甘洛县', + // '布拖县','雷波县','普格县','宁南县', '喜德县', '会东县', '越西县', '会理县', '盐源县', + // '叙永县','古蔺县','德阳市','广汉市', '什邡市', '绵竹市', '罗江县', '中江县', '绵阳市', + // '江油市','盐亭县','三台县','平武县', '安县', '梓潼县', '广元市', '青川县', '旺苍县', + // '剑阁县','苍溪县','遂宁市','射洪县', '蓬溪县', '大英县', '内江市', '资中县', '隆昌县', + // '威远县','乐山市','夹江县','井研县', '犍为县', '沐川县', '南充市', '阆中市', '营山县', + // '蓬安县','仪陇县','南部县','西充县', '眉山市', '仁寿县', '彭山县', '洪雅县', '丹棱县', + // '青神县','宜宾市','宜宾县','兴文县', '南溪县', '珙 县', '长宁县',' 高 县', '江安县', + // '筠连县','屏山县','广安市','华蓥市', '岳池县', '邻水县', '武胜县', '达州市', '万源市', + // '达县渠','汉县' ,'江县' ,'竹县' ,'雅安市' ,'芦山县' ,'石棉县' ,'名山县', + // '天全县','荥经县','宝兴县','汉源县', '巴中市', '南江县', '平昌县', '通江县', '资阳市', + // '简阳市','安岳县','乐至县','红原县', '汶川县', '阿坝县', '理 县', '小金县', '黑水县', + // '金川县','松潘县','壤塘县','茂 县', '康定县', '丹巴县', '炉霍县', '九龙县', '甘孜县', + // '雅江县','新龙县','道孚县','白玉县', '理塘县', '德格县', '乡城县', '石渠县', '稻城县', + // '色达县','巴塘县','泸定县','得荣县', '西昌市', '美姑县', '昭觉县', '金阳县', '甘洛县', + // '布拖县','雷波县','普格县','宁南县', '喜德县', '会东县', '越西县', '会理县', '盐源县', + // '叙永县','古蔺县','德阳市','广汉市', '什邡市', '绵竹市', '罗江县', '中江县', '绵阳市', + // '江油市','盐亭县','三台县','平武县', '安县', '梓潼县', '广元市', '青川县', '旺苍县', + // '剑阁县','苍溪县','遂宁市','射洪县', '蓬溪县', '大英县', '内江市', '资中县', '隆昌县', + // '威远县','乐山市','夹江县','井研县', '犍为县', '沐川县', '南充市', '阆中市', '营山县', + // '蓬安县','仪陇县','南部县','西充县', '眉山市', '仁寿县', '彭山县', '洪雅县', '丹棱县', + // '青神县','宜宾市','宜宾县','兴文县', '南溪县', '珙 县', '长宁县',' 高 县', '江安县', + // '筠连县','屏山县','广安市','华蓥市', '岳池县', '邻水县', '武胜县', '达州市', '万源市', + // '达县渠','汉县' ,'江县' ,'竹县' ,'雅安市' ,'芦山县' ,'石棉县' ,'名山县', + // '天全县','荥经县','宝兴县','汉源县', '巴中市', '南江县', '平昌县', '通江县', '资阳市', + // '简阳市','安岳县','乐至县','红原县', '汶川县', '阿坝县', '理 县', '小金县', '黑水县', + // '金川县','松潘县','壤塘县','茂 县', '康定县', '丹巴县', '炉霍县', '九龙县', '甘孜县', + // '雅江县','新龙县','道孚县','白玉县', '理塘县', '德格县', '乡城县', '石渠县', '稻城县', + // '色达县','巴塘县','泸定县','得荣县', '西昌市', '美姑县', '昭觉县', '金阳县', '甘洛县', + // '布拖县','雷波县','普格县','宁南县', '喜德县', '会东县', '越西县', '会理县', '盐源县', + // '叙永县','古蔺县','德阳市','广汉市', '什邡市', '绵竹市', '罗江县', '中江县', '绵阳市', + // '江油市','盐亭县','三台县','平武县', '安县', '梓潼县', '广元市', '青川县', '旺苍县', + // '剑阁县','苍溪县','遂宁市','射洪县', '蓬溪县', '大英县', '内江市', '资中县', '隆昌县', + // '威远县','乐山市','夹江县','井研县', '犍为县', '沐川县', '南充市', '阆中市', '营山县', + // '蓬安县','仪陇县','南部县','西充县', '眉山市', '仁寿县', '彭山县', '洪雅县', '丹棱县', + // '青神县','宜宾市','宜宾县','兴文县', '南溪县', '珙 县', '长宁县',' 高 县', '江安县', + // '筠连县','屏山县','广安市','华蓥市', '岳池县', '邻水县', '武胜县', '达州市', '万源市', + // '达县渠','汉县' ,'江县' ,'竹县' ,'雅安市' ,'芦山县' ,'石棉县' ,'名山县', + // '天全县','荥经县','宝兴县','汉源县', '巴中市', '南江县', '平昌县', '通江县', '资阳市', + // '简阳市','安岳县','乐至县','红原县', '汶川县', '阿坝县', '理 县', '小金县', '黑水县', + // '金川县','松潘县','壤塘县','茂 县', '康定县', '丹巴县', '炉霍县', '九龙县', '甘孜县', + // '雅江县','新龙县','道孚县','白玉县', '理塘县', '德格县', '乡城县', '石渠县', '稻城县', + // '色达县','巴塘县','泸定县','得荣县', '西昌市', '美姑县', '昭觉县', '金阳县', '甘洛县', + // '布拖县','雷波县','普格县','宁南县', '喜德县', '会东县', '越西县', '会理县', '盐源县', + // '叙永县','古蔺县','德阳市','广汉市', '什邡市', '绵竹市', '罗江县', '中江县', '绵阳市', + // '江油市','盐亭县','三台县','平武县', '安县', '梓潼县', '广元市', '青川县', '旺苍县', + // '剑阁县','苍溪县','遂宁市','射洪县', '蓬溪县', '大英县', '内江市', '资中县', '隆昌县', + // '威远县','乐山市','夹江县','井研县', '犍为县', '沐川县', '南充市', '阆中市', '营山县', + // '蓬安县','仪陇县','南部县','西充县', '眉山市', '仁寿县', '彭山县', '洪雅县', '丹棱县', + // '青神县','宜宾市','宜宾县','兴文县', '南溪县', '珙 县', '长宁县',' 高 县', '江安县', + // '筠连县','屏山县','广安市','华蓥市', '岳池县', '邻水县', '武胜县', '达州市', '万源市', + // '达县渠','汉县' ,'江县' ,'竹县' ,'雅安市' ,'芦山县' ,'石棉县' ,'名山县', + // '天全县','荥经县','宝兴县','汉源县', '巴中市', '南江县', '平昌县', '通江县', '资阳市', + // '简阳市','安岳县','乐至县','红原县', '汶川县', '阿坝县', '理 县', '小金县', '黑水县', + // '金川县','松潘县','壤塘县','茂 县', '康定县', '丹巴县', '炉霍县', '九龙县', '甘孜县', + // '雅江县','新龙县','道孚县','白玉县', '理塘县', '德格县', '乡城县', '石渠县', '稻城县', + // '色达县','巴塘县','泸定县','得荣县', '西昌市', '美姑县', '昭觉县', '金阳县', '甘洛县', + // '布拖县','雷波县','普格县','宁南县', '喜德县', '会东县', '越西县', '会理县', '盐源县', + // '叙永县','古蔺县','德阳市','广汉市', '什邡市', '绵竹市', '罗江县', '中江县', '绵阳市', + // '江油市','盐亭县','三台县','平武县', '安县', '梓潼县', '广元市', '青川县', '旺苍县', + // '剑阁县','苍溪县','遂宁市','射洪县', '蓬溪县', '大英县', '内江市', '资中县', '隆昌县', + // '威远县','乐山市','夹江县','井研县', '犍为县', '沐川县', '南充市', '阆中市', '营山县', + // '蓬安县','仪陇县','南部县','西充县', '眉山市', '仁寿县', '彭山县', '洪雅县', '丹棱县', + // '青神县','宜宾市','宜宾县','兴文县', '南溪县', '珙 县', '长宁县',' 高 县', '江安县', + // '筠连县','屏山县','广安市','华蓥市', '岳池县', '邻水县', '武胜县', '达州市', '万源市', + // '达县渠','汉县' ,'江县' ,'竹县' ,'雅安市' ,'芦山县' ,'石棉县' ,'名山县', + // '天全县','荥经县','宝兴县','汉源县', '巴中市', '南江县', '平昌县', '通江县', '资阳市', + // '简阳市','安岳县','乐至县','红原县', '汶川县', '阿坝县', '理 县', '小金县', '黑水县', + // '金川县','松潘县','壤塘县','茂 县', '康定县', '丹巴县', '炉霍县', '九龙县', '甘孜县', + // '雅江县','新龙县','道孚县','白玉县', '理塘县', '德格县', '乡城县', '石渠县', '稻城县', + // '色达县','巴塘县','泸定县','得荣县', '西昌市', '美姑县', '昭觉县', '金阳县', '甘洛县', + // '布拖县','雷波县','普格县','宁南县', '喜德县', '会东县', '越西县', '会理县', '盐源县', + // '叙永县','古蔺县','德阳市','广汉市', '什邡市', '绵竹市', '罗江县', '中江县', '绵阳市', + // '江油市','盐亭县','三台县','平武县', '安县', '梓潼县', '广元市', '青川县', '旺苍县', + // '剑阁县','苍溪县','遂宁市','射洪县', '蓬溪县', '大英县', '内江市', '资中县', '隆昌县', + // '威远县','乐山市','夹江县','井研县', '犍为县', '沐川县', '南充市', '阆中市', '营山县', + // '蓬安县','仪陇县','南部县','西充县', '眉山市', '仁寿县', '彭山县', '洪雅县', '丹棱县', + // '青神县','宜宾市','宜宾县','兴文县', '南溪县', '珙 县', '长宁县',' 高 县', '江安县', + // '筠连县','屏山县','广安市','华蓥市', '岳池县', '邻水县', '武胜县', '达州市', '万源市', + // '达县渠','汉县' ,'江县' ,'竹县' ,'雅安市' ,'芦山县' ,'石棉县' ,'名山县', + // '天全县','荥经县','宝兴县','汉源县', '巴中市', '南江县', '平昌县', '通江县', '资阳市', + // '简阳市','安岳县','乐至县','红原县', '汶川县', '阿坝县', '理 县', '小金县', '黑水县', + // '金川县','松潘县','壤塘县','茂 县', '康定县', '丹巴县', '炉霍县', '九龙县', '甘孜县', + // '雅江县','新龙县','道孚县','白玉县', '理塘县', '德格县', '乡城县', '石渠县', '稻城县', + // '色达县','巴塘县','泸定县','得荣县', '西昌市', '美姑县', '昭觉县', '金阳县', '甘洛县', + // '布拖县','雷波县','普格县','宁南县', '喜德县', '会东县', '越西县', '会理县', '盐源县', + // '叙永县','古蔺县','德阳市','广汉市', '什邡市', '绵竹市', '罗江县', '中江县', '绵阳市', + // '江油市','盐亭县','三台县','平武县', '安县', '梓潼县', '广元市', '青川县', '旺苍县', + // '剑阁县','苍溪县','遂宁市','射洪县', '蓬溪县', '大英县', '内江市', '资中县', '隆昌县', + // '威远县','乐山市','夹江县','井研县', '犍为县', '沐川县', '南充市', '阆中市', '营山县', + // '蓬安县','仪陇县','南部县','西充县', '眉山市', '仁寿县', '彭山县', '洪雅县', '丹棱县', + // '青神县','宜宾市','宜宾县','兴文县', '南溪县', '珙 县', '长宁县',' 高 县', '江安县', + // '筠连县','屏山县','广安市','华蓥市', '岳池县', '邻水县', '武胜县', '达州市', '万源市', + // '达县渠','汉县' ,'江县' ,'竹县' ,'雅安市' ,'芦山县' ,'石棉县' ,'名山县', + // '天全县','荥经县','宝兴县','汉源县', '巴中市', '南江县', '平昌县', '通江县', '资阳市', + // '简阳市','安岳县','乐至县','红原县', '汶川县', '阿坝县', '理 县', '小金县', '黑水县', + // '金川县','松潘县','壤塘县','茂 县', '康定县', '丹巴县', '炉霍县', '九龙县', '甘孜县', + // '雅江县','新龙县','道孚县','白玉县', '理塘县', '德格县', '乡城县', '石渠县', '稻城县', + // '色达县','巴塘县','泸定县','得荣县', '西昌市', '美姑县', '昭觉县', '金阳县', '甘洛县', + // '布拖县','雷波县','普格县','宁南县', '喜德县', '会东县', '越西县', '会理县', '盐源县', + // '叙永县','古蔺县','德阳市','广汉市', '什邡市', '绵竹市', '罗江县', '中江县', '绵阳市', + // '江油市','盐亭县','三台县','平武县', '安县', '梓潼县', '广元市', '青川县', '旺苍县', + // '剑阁县','苍溪县','遂宁市','射洪县', '蓬溪县', '大英县', '内江市', '资中县', '隆昌县', + // '威远县','乐山市','夹江县','井研县', '犍为县', '沐川县', '南充市', '阆中市', '营山县', + // '蓬安县','仪陇县','南部县','西充县', '眉山市', '仁寿县', '彭山县', '洪雅县', '丹棱县', + // '青神县','宜宾市','宜宾县','兴文县', '南溪县', '珙 县', '长宁县',' 高 县', '江安县', + // '筠连县','屏山县','广安市','华蓥市', '岳池县', '邻水县', '武胜县', '达州市', '万源市', + // '达县渠','汉县' ,'江县' ,'竹县' ,'雅安市' ,'芦山县' ,'石棉县' ,'名山县', + // '天全县','荥经县','宝兴县','汉源县', '巴中市', '南江县', '平昌县', '通江县', '资阳市', + // '简阳市','安岳县','乐至县','红原县', '汶川县', '阿坝县', '理 县', '小金县', '黑水县', + // '金川县','松潘县','壤塘县','茂 县', '康定县', '丹巴县', '炉霍县', '九龙县', '甘孜县', + // '雅江县','新龙县','道孚县','白玉县', '理塘县', '德格县', '乡城县', '石渠县', '稻城县', + // '色达县','巴塘县','泸定县','得荣县', '西昌市', '美姑县', '昭觉县', '金阳县', '甘洛县', + // '布拖县','雷波县','普格县','宁南县', '喜德县', '会东县', '越西县', '会理县', '盐源县', + // '叙永县','古蔺县','德阳市','广汉市', '什邡市', '绵竹市', '罗江县', '中江县', '绵阳市', + // '江油市','盐亭县','三台县','平武县', '安县', '梓潼县', '广元市', '青川县', '旺苍县', + // '剑阁县','苍溪县','遂宁市','射洪县', '蓬溪县', '大英县', '内江市', '资中县', '隆昌县', + // '威远县','乐山市','夹江县','井研县', '犍为县', '沐川县', '南充市', '阆中市', '营山县', + // '蓬安县','仪陇县','南部县','西充县', '眉山市', '仁寿县', '彭山县', '洪雅县', '丹棱县', + // '青神县','宜宾市','宜宾县','兴文县', '南溪县', '珙 县', '长宁县',' 高 县', '江安县', + // '筠连县','屏山县','广安市','华蓥市', '岳池县', '邻水县', '武胜县', '达州市', '万源市', + // '达县渠','汉县' ,'江县' ,'竹县' ,'雅安市' ,'芦山县' ,'石棉县' ,'名山县', + // '天全县','荥经县','宝兴县','汉源县', '巴中市', '南江县', '平昌县', '通江县', '资阳市', + // '简阳市','安岳县','乐至县','红原县', '汶川县', '阿坝县', '理 县', '小金县', '黑水县', + // '金川县','松潘县','壤塘县','茂 县', '康定县', '丹巴县', '炉霍县', '九龙县', '甘孜县', + // '雅江县','新龙县','道孚县','白玉县', '理塘县', '德格县', '乡城县', '石渠县', '稻城县', + // '色达县','巴塘县','泸定县','得荣县', '西昌市', '美姑县', '昭觉县', '金阳县', '甘洛县', + // '布拖县','雷波县','普格县','宁南县', '喜德县', '会东县', '越西县', '会理县', '盐源县', + // '叙永县','古蔺县','德阳市','广汉市', '什邡市', '绵竹市', '罗江县', '中江县', '绵阳市', + // '江油市','盐亭县','三台县','平武县', '安县', '梓潼县', '广元市', '青川县', '旺苍县', + // '剑阁县','苍溪县','遂宁市','射洪县', '蓬溪县', '大英县', '内江市', '资中县', '隆昌县', + // '威远县','乐山市','夹江县','井研县', '犍为县', '沐川县', '南充市', '阆中市', '营山县', + // '蓬安县','仪陇县','南部县','西充县', '眉山市', '仁寿县', '彭山县', '洪雅县', '丹棱县', + // '青神县','宜宾市','宜宾县','兴文县', '南溪县', '珙 县', '长宁县',' 高 县', '江安县', + // '筠连县','屏山县','广安市','华蓥市', '岳池县', '邻水县', '武胜县', '达州市', '万源市', + // '达县渠','汉县' ,'江县' ,'竹县' ,'雅安市' ,'芦山县' ,'石棉县' ,'名山县', + // '天全县','荥经县','宝兴县','汉源县', '巴中市', '南江县', '平昌县', '通江县', '资阳市', + // '简阳市','安岳县','乐至县','红原县', '汶川县', '阿坝县', '理 县', '小金县', '黑水县', + // '金川县','松潘县','壤塘县','茂 县', '康定县', '丹巴县', '炉霍县', '九龙县', '甘孜县', + // '雅江县','新龙县','道孚县','白玉县', '理塘县', '德格县', '乡城县', '石渠县', '稻城县', + // '色达县','巴塘县','泸定县','得荣县', '西昌市', '美姑县', '昭觉县', '金阳县', '甘洛县', + // '布拖县','雷波县','普格县','宁南县', '喜德县', '会东县', '越西县', '会理县', '盐源县', + // '叙永县','古蔺县','德阳市','广汉市', '什邡市', '绵竹市', '罗江县', '中江县', '绵阳市', + // '江油市','盐亭县','三台县','平武县', '安县', '梓潼县', '广元市', '青川县', '旺苍县', + // '剑阁县','苍溪县','遂宁市','射洪县', '蓬溪县', '大英县', '内江市', '资中县', '隆昌县', + // '威远县','乐山市','夹江县','井研县', '犍为县', '沐川县', '南充市', '阆中市', '营山县', + // '蓬安县','仪陇县','南部县','西充县', '眉山市', '仁寿县', '彭山县', '洪雅县', '丹棱县', + // '青神县','宜宾市','宜宾县','兴文县', '南溪县', '珙 县', '长宁县',' 高 县', '江安县', + // '筠连县','屏山县','广安市','华蓥市', '岳池县', '邻水县', '武胜县', '达州市', '万源市', + // '达县渠','汉县' ,'江县' ,'竹县' ,'雅安市' ,'芦山县' ,'石棉县' ,'名山县', + // '天全县','荥经县','宝兴县','汉源县', '巴中市', '南江县', '平昌县', '通江县', '资阳市', + // '简阳市','安岳县','乐至县','红原县', '汶川县', '阿坝县', '理 县', '小金县', '黑水县', + // '金川县','松潘县','壤塘县','茂 县', '康定县', '丹巴县', '炉霍县', '九龙县', '甘孜县', + // '雅江县','新龙县','道孚县','白玉县', '理塘县', '德格县', '乡城县', '石渠县', '稻城县', + // '色达县','巴塘县','泸定县','得荣县', '西昌市', '美姑县', '昭觉县', '金阳县', '甘洛县', + // '布拖县','雷波县','普格县','宁南县', '喜德县', '会东县', '越西县', '会理县', '盐源县', + // '叙永县','古蔺县','德阳市','广汉市', '什邡市', '绵竹市', '罗江县', '中江县', '绵阳市', + // '江油市','盐亭县','三台县','平武县', '安县', '梓潼县', '广元市', '青川县', '旺苍县', + // '剑阁县','苍溪县','遂宁市','射洪县', '蓬溪县', '大英县', '内江市', '资中县', '隆昌县', + // '威远县','乐山市','夹江县','井研县', '犍为县', '沐川县', '南充市', '阆中市', '营山县', + // '蓬安县','仪陇县','南部县','西充县', '眉山市', '仁寿县', '彭山县', '洪雅县', '丹棱县', + // '青神县','宜宾市','宜宾县','兴文县', '南溪县', '珙 县', '长宁县',' 高 县', '江安县', + // '筠连县','屏山县','广安市','华蓥市', '岳池县', '邻水县', '武胜县', '达州市', '万源市', + // '达县渠','汉县' ,'江县' ,'竹县' ,'雅安市' ,'芦山县' ,'石棉县' ,'名山县', + // '天全县','荥经县','宝兴县','汉源县', '巴中市', '南江县', '平昌县', '通江县', '资阳市', + // '简阳市','安岳县','乐至县','红原县', '汶川县', '阿坝县', '理 县', '小金县', '黑水县', + // '金川县','松潘县','壤塘县','茂 县', '康定县', '丹巴县', '炉霍县', '九龙县', '甘孜县', + // '雅江县','新龙县','道孚县','白玉县', '理塘县', '德格县', '乡城县', '石渠县', '稻城县', + // '色达县','巴塘县','泸定县','得荣县', '西昌市', '美姑县', '昭觉县', '金阳县', '甘洛县', + // '布拖县','雷波县','普格县','宁南县', '喜德县', '会东县', '越西县', '会理县', '盐源县', + + ] +} \ No newline at end of file diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/common/constants/ChatConstants.ets b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/common/constants/ChatConstants.ets new file mode 100644 index 0000000000000000000000000000000000000000..bc6aa276a77d84378a911064043faeafe3325955 --- /dev/null +++ b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/common/constants/ChatConstants.ets @@ -0,0 +1,224 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * 最佳实践:点击响应优化 + */ +const NICK_NAMES_STR: string = + '故笙、无念、搁浅、九辞、倾慕、世卿、挽歌、初起、九离、顾盼、北筏、汐颜、孤情、梦巷、九笙、屿人、遇见、悔歌、素白、旧人、孤心、九尘、孤凉、夏槿、别遇、遣心、君殇、清念、稚念、浔柒、浅伤、颜染、凉柚、北欢、寒暄、无念、清樽、诀别、醉人梦、颜如故、卿可知、君可见、大太阳、暖洋洋、守墓人、我知道、小苹果、风在说、烟焚散、人牵绊、苏堤雨、美人笑、笑老友、青丝绕、四行泪、安稳随性、南鸢离梦、何必打扰、半世迷离、夏末浅笑、如梦初醒、城南花开、咗鞋佑瑏、才揽风尘、墨染流云、青衫忆笙、倾城之泪、为你封鈊、低头浅笑、哑剧真动、夏花依旧、素年凉音、心安勿忘、冷瞳少女、夙夜难眠、折现浪漫、清风煮酒、各生欢喜、思念复燃、森眸暖光'; + + +function getNickNameArray(): string[] { + let array: string[] = [] + NICK_NAMES_STR.split("、").forEach((s) => { + array.push(s) + }) + return array +} + +export const CHAT_NICK_NAMES: string[] = getNickNameArray() + +export const CHAT_AVATARS: Resource[] = [ + $r('app.media.a1'), + $r("app.media.a2"), + $r('app.media.a3'), + $r("app.media.a4"), + $r('app.media.a5'), + $r("app.media.a6"), + $r('app.media.a7'), + $r("app.media.a8"), + $r('app.media.a9'), + $r("app.media.a10"), + $r('app.media.a11'), + $r("app.media.a12"), + $r('app.media.a13'), + $r("app.media.a14"), + $r('app.media.a15'), + $r("app.media.a16"), + $r('app.media.a17'), + $r("app.media.a18"), + $r("app.media.a19"), + $r("app.media.avataaars"), + $r("app.media.avataaars1"), + $r("app.media.avataaars2"), + $r("app.media.avataaars3"), + $r("app.media.avataaars4"), + $r("app.media.avataaars5"), + $r("app.media.avataaars6"), + $r("app.media.avataaars7"), + $r("app.media.avataaars8"), + $r("app.media.avataaars9"), + $r("app.media.avataaars10"), +] + +export const CHAT_TIMES: string[] = [ + '1分钟前', + '5分钟前', + '27分钟前', + '2小时前', + '09:57', + '00:12:', + '昨天', + '昨天', + '昨天', + '昨天', + '昨天', + '昨天', + '昨天', + '周一', + '周一', + '周一', + '周一', + '周一', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日', + '10月31日' +]; + + +export const CHAT_SNIPPETS: string[] = [ + 'Hello ??', + '好些了吗?要不要帮你带东西', + '今天去哪玩了,怎么没找我?', + '那个动物园你觉得怎么样,看到什么了', + '我们一起去吧!!', + '下班一起去吃饭,最近找到一家还不错的', + '天气不错,晒太阳去', + '最近有个新闻听说没,据说', + '下次一起去,怎么样', + '感觉还好吧,也就', + '有什么事情不愿意讲', + '就这样说吧其实无所谓', + '好的,没问题,包给我放心吧', + '想看下你写的文章', + 'Show Me Your Code', + 'No problem!', + 'Bingo!', + 'Nice try!!', + 'Very yummy!!!', + 'What?', + 'Why not?go go go', + 'Never mind~~', + '美丽的梦何时才能出现', + '世间所有美好', + '看起来,好像很好吃', + '好歹我也是个戴眼镜的', + '我真想把地球沿着这个方向对折一下', + '扭开电视广告多', + '心若没有栖息的地方', + '到哪里都是在流浪', + '有的人聪明得像天气', + '世界是我们的', + '也是那些孩子们的', + '人类一思考上帝就发笑', + '不同的时间不同的地点不同的人群', + '我觉得也OK哈', + '带着看一下行不', + '怕没有时间去做这个了', + '这个也没问题了,我觉得可以', + '你的其实那节课需要再看看', + '你和他确认一下再说吧', + '我们的目标是什么', + '你刚才录制的课程感觉还不错', + '等一下,你那边还有没有问题', + '小明在吗?', + '大的没啥问题', + '小点我们线下去对接下', + '刚才我有个问题', + '这个有个目录的', + '我们语音说下好么', + '这个颜色感觉不太对劲', +]; \ No newline at end of file diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/common/constants/WorldCommonConstants.ets b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/common/constants/WorldCommonConstants.ets new file mode 100644 index 0000000000000000000000000000000000000000..83507e7337e760011e6d4d3d0bf85ffe0542a052 --- /dev/null +++ b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/common/constants/WorldCommonConstants.ets @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * 最佳实践:点击响应优化 + */ +export class CommonConstants { + // font family + static readonly HARMONY_HEI_TI_FONT_FAMILY = 'HarmonyHeiTi'; + static readonly HARMONY_HEITI_MEDIUM_FONT_FAMILY = 'HarmonyHeiTi-Medium'; + static readonly HARMONY_HEITI_BOLD_FONT_FAMILY = 'HarmonyHeiTi-Bold'; + // opacity + static readonly FIRST_LEVEL_OPACITY: number = 0.9; + static readonly SECOND_LEVEL_OPACITY: number = 0.6; + static readonly HALF_OPACITY: number = 0.5; + static readonly THIRD_LEVEL_OPACITY: number = 0.3; + static readonly FOURTH_LEVEL_OPACITY: number = 0.1; + // blur + static readonly REGULAR_BLUR: number = 250; + // blur scale + static readonly BLUR_SCALE: number = 0.15; + // space + static readonly SPACE_12: number = 12; + static readonly SPACE_24: number = 24; + static readonly SPACE_16: number = 16; + static readonly SPACE_20: number = 20; + static readonly SM_SPACE: number = 5 + static readonly MD_SPACE: number = 10 + static readonly LG_SPACE: number = 15 + // maxLines + static readonly MAX_LINE_ONE: number = 1; + static readonly MAX_LINE_TWO: number = 2; + // swiper duration + static readonly SWIPER_DURATION: number = 1000; + // percent + static readonly FULL_PERCENT: string = '100%'; + static readonly PERCENT_70: string = '70%'; + static readonly PERCENT_64: string = '64%'; + // common event + static readonly COLLECTED_EVENT: string = 'collected_event'; + static readonly LIKED_EVENT: string = 'liked_event'; + static readonly LEARNING_EVENT: string = 'learning_event'; + static readonly VIEW_EVENT: string = 'view_event'; + // router path + static readonly DISCOVER_FEED_DETAIL_PAGE = '/discover/ets/pages/FeedDetailPage'; + static readonly DISCOVER_ARTICLE_DETAIL_PAGE = '/discover/ets/pages/ArticleDetailPage'; + // skeleton animation config + static readonly SKELETON_ANIMATION: AnimateParam = { + duration: 400, + tempo: 0.6, + curve: Curve.EaseInOut, + delay: 200, + iterations: -1, + playMode: PlayMode.Alternate + } +} \ No newline at end of file diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/common/constants/WorldConstants.ets b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/common/constants/WorldConstants.ets new file mode 100644 index 0000000000000000000000000000000000000000..7331e267c961511a9019590c11acb7ab3cfc376e --- /dev/null +++ b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/common/constants/WorldConstants.ets @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * 最佳实践:点击响应优化 + */ +export default class Constants { + /** + * percent + */ + static readonly FULL_SCREEN: string = '100%'; + static readonly ACCOUNT_POSITION_X: string = '46%'; + static readonly PERCENT_50 = '50%'; + static readonly PERCENT_90 = '90%'; + /** + * opacity + */ + static readonly FULL_OPACITY: number = 1; + static readonly NONE_OPACITY: number = 0; + /** + * space:SMALL Middle Large + */ + static readonly SMALL_SPACE: number = 5; + static readonly MIDDLE_SPACE: number = 10; + static readonly RESOURCE_LIST_SPACE: number = 12; + static readonly LARGE_SPACE: number = 15; + static readonly ROW_SPACE: number = 16; + /** + * duration + */ + static readonly SHORT_ANIMATION_DURATION: number = 200; + static readonly DEFAULT_DURATION: number = 300; + static readonly LONG_ANIMATION_DURATION: number = 500; + /** + * other + */ + static readonly REFRESH_DELAY: number = 1000; + static readonly ACHIEVEMENT_LIST_LANES_SM: number = 3; + static readonly ACHIEVEMENT_LIST_LANES_MD: number = 5 + static readonly ACHIEVEMENT_LIST_LANES_LG: number = 6; + static readonly COUNT_TWO: number = 2; +} + +/** + * SkeletonData for SkeletonView + */ +export const SkeletonData: SkeType[] = [ + { + isMine: true, + isFeed: false + }, + { + isMine: true, + isFeed: true + }, + { + isMine: true, + isFeed: false + }, + { + isMine: true, + isFeed: true + }, + { + isMine: true, + isFeed: false + }, + { + isMine: true, + isFeed: true + }, +] + +export interface SkeType { + isMine: boolean; + isFeed: boolean; +} \ No newline at end of file diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/common/db/AccountData.ets b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/common/db/AccountData.ets new file mode 100644 index 0000000000000000000000000000000000000000..11bd5b4978b26d34bfe083de82f6f00b5d2ed0d9 --- /dev/null +++ b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/common/db/AccountData.ets @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * 最佳实践:点击响应优化 + */ +export default class AccountData { + id: number = -1; + accountType: number = 0; + typeText: string = ''; + amount: number = 0; +} \ No newline at end of file diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/common/db/AccountTable.ets b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/common/db/AccountTable.ets new file mode 100644 index 0000000000000000000000000000000000000000..567ce02eeea78ba4de76980628ed63e6b1b8d038 --- /dev/null +++ b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/common/db/AccountTable.ets @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * 最佳实践:点击响应优化 + */ +import relationalStore from '@ohos.data.relationalStore'; +import AccountData from './AccountData'; +import Rdb from './Rdb'; + +export default class AccountTable { + private accountTable = new Rdb('accountTable', + 'CREATE TABLE IF NOT EXISTS accountTable(id INTEGER PRIMARY KEY AUTOINCREMENT, accountType INTEGER, ' + + 'typeText TEXT, amount INTEGER)', + ['id', 'accountType', 'typeText', 'amount']); + + query(amount: number, callback: Function, isAll: boolean = true) { + let predicates = new relationalStore.RdbPredicates('accountTable'); + if (!isAll) { + predicates.equalTo('amount', amount); + } + this.accountTable.query(predicates, (resultSet: relationalStore.ResultSet) => { + let count: number = resultSet.rowCount; + if (count === 0 || typeof count === 'string') { + callback([]); + } else { + resultSet.goToFirstRow(); + const result: AccountData[] = []; + // [Start edit_before] + for (let i = 0; i < count; i++) { + let tmp: AccountData = { + id: 0, + accountType: 0, + typeText: '', + amount: 0 + }; + tmp.id = resultSet.getDouble(resultSet.getColumnIndex('id')); + tmp.accountType = resultSet.getDouble(resultSet.getColumnIndex('accountType')); + tmp.typeText = resultSet.getString(resultSet.getColumnIndex('typeText')); + tmp.amount = resultSet.getDouble(resultSet.getColumnIndex('amount')); + result[i] = tmp; + resultSet.goToNextRow(); + } + // [End edit_before] + // [Start edit_after] + const idIndex = resultSet.getColumnIndex("id"); + const accountTypeIndex = resultSet.getColumnIndex("accountType"); + const typeTextIndex = resultSet.getColumnIndex("typeText"); + const amountIndex = resultSet.getColumnIndex("amount"); + for (let i = 0; i < count; i++) { + let tmp: AccountData = { + id: 0, + accountType: 0, + typeText: '', + amount: 0 + }; + tmp.id = resultSet.getDouble(idIndex); + tmp.accountType = resultSet.getDouble(accountTypeIndex); + tmp.typeText = resultSet.getString(typeTextIndex); + tmp.amount = resultSet.getDouble(amountIndex); + result[i] = tmp; + resultSet.goToNextRow(); + } + // [End edit_after] + callback(result); + } + }); + } +} diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/common/db/Rdb.ets b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/common/db/Rdb.ets new file mode 100644 index 0000000000000000000000000000000000000000..b9b232e3be69780969be510a3dc505d713b37d43 --- /dev/null +++ b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/common/db/Rdb.ets @@ -0,0 +1,124 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * 最佳实践:点击响应优化 + */ +import relationalStore from '@ohos.data.relationalStore'; + +export default class Rdb { + private rdbStore: relationalStore.RdbStore | null = null; + private tableName: string; + private sqlCreateTable: string; + private columns: Array; + + constructor(tableName: string, sqlCreateTable: string, columns: Array) { + this.tableName = tableName; + this.sqlCreateTable = sqlCreateTable; + this.columns = columns; + } + + getRdbStore(callback: Function = () => { + }) { + if (!callback || typeof callback === 'undefined' || callback === undefined) { + return; + } + if (this.rdbStore !== null) { + callback(); + return + } + let context: Context = this.getUIContext().getHostContext() as Context; + relationalStore.getRdbStore(context, { + name: 'database.db', + securityLevel: relationalStore.SecurityLevel.S1 + }, (err, rdb) => { + if (err) { + return; + } + this.rdbStore = rdb; + this.rdbStore.executeSql(this.sqlCreateTable); + callback(); + }); + } + + insertData(data: relationalStore.ValuesBucket, callback: Function = () => { + }) { + if (!callback || typeof callback === 'undefined' || callback === undefined) { + return; + } + let resFlag: boolean = false; + const valueBucket: relationalStore.ValuesBucket = data; + if (this.rdbStore) { + this.rdbStore.insert(this.tableName, valueBucket, (err, ret) => { + if (err) { + callback(resFlag); + return; + } + callback(ret); + }); + } + } + + deleteData(predicates: relationalStore.RdbPredicates, callback: Function = () => { + }) { + if (!callback || typeof callback === 'undefined' || callback === undefined) { + return; + } + let resFlag: boolean = false; + if (this.rdbStore) { + this.rdbStore.delete(predicates, (err, ret) => { + if (err) { + callback(resFlag); + return; + } + callback(!resFlag); + }); + } + } + + updateData(predicates: relationalStore.RdbPredicates, data: relationalStore.ValuesBucket, callback: Function = () => { + }) { + if (!callback || typeof callback === 'undefined' || callback === undefined) { + return; + } + let resFlag: boolean = false; + const valueBucket: relationalStore.ValuesBucket = data; + if (this.rdbStore) { + this.rdbStore.update(valueBucket, predicates, (err, ret) => { + if (err) { + callback(resFlag); + return; + } + callback(!resFlag); + }); + } + } + + query(predicates: relationalStore.RdbPredicates, callback: Function = () => { + }) { + if (!callback || typeof callback === 'undefined' || callback === undefined) { + return; + } + if (this.rdbStore) { + this.rdbStore.query(predicates, this.columns, (err, resultSet) => { + if (err) { + return; + } + callback(resultSet); + resultSet.close(); + }); + } + } +} \ No newline at end of file diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/entryability/EntryAbility.ets b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..387cfb419f3ca36ded4b5e4002017dc27ee62d3a --- /dev/null +++ b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * 最佳实践:点击响应优化 + */ +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + } + + onDestroy(): void { + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + return; + } + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + } + + onForeground(): void { + // Ability has brought to foreground + } + + onBackground(): void { + // Ability has back to background + } +} diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..8e4de99282050bad799ac892eb85ac5449364a51 --- /dev/null +++ b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -0,0 +1,16 @@ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit'; + +const DOMAIN = 0x0000; + +export default class EntryBackupAbility extends BackupExtensionAbility { + async onBackup() { + hilog.info(DOMAIN, 'testTag', 'onBackup ok'); + await Promise.resolve(); + } + + async onRestore(bundleVersion: BundleVersion) { + hilog.info(DOMAIN, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion)); + await Promise.resolve(); + } +} \ No newline at end of file diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/model/ChatModel.ets b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/model/ChatModel.ets new file mode 100644 index 0000000000000000000000000000000000000000..ab6b518890be5f7ce24b18095b671facd3e7b3df --- /dev/null +++ b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/model/ChatModel.ets @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * 最佳实践:点击响应优化 + */ +import { CHAT_AVATARS, CHAT_NICK_NAMES, CHAT_SNIPPETS, CHAT_TIMES } from '../common/constants/ChatConstants'; + +export default class ClassifyModel { + id: number; + hasBadge: boolean; + name: string; + snippet: string; + time: string; + hasMute: boolean; + avatar: Resource; + url: string = ""; + + constructor(id: number) { + this.id = id + + + let rand = Math.floor(Math.random() * 2) + if (rand == 0) { + this.hasBadge = false + } else { + this.hasBadge = true + } + + rand = Math.floor(Math.random() * 2) + if (rand == 0) { + this.hasMute = false + } else { + this.hasMute = true + } + + rand = Math.floor(Math.random() * CHAT_NICK_NAMES.length) + this.name = CHAT_NICK_NAMES[rand] + + + rand = Math.floor(Math.random() * CHAT_SNIPPETS.length) + this.snippet = CHAT_SNIPPETS[rand] + + this.time = CHAT_TIMES[id%CHAT_TIMES.length] + + rand = Math.floor(Math.random() * CHAT_AVATARS.length) + this.avatar = CHAT_AVATARS[rand] + + } +} \ No newline at end of file diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/pages/CameraOptPage.ets b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/pages/CameraOptPage.ets new file mode 100644 index 0000000000000000000000000000000000000000..d00f8198d1af925dfc4acf92801352c1390a5ede --- /dev/null +++ b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/pages/CameraOptPage.ets @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * 最佳实践:点击响应优化 + */ +import { camera } from '@kit.CameraKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +// [Start camera_release_after] +let cameraOutput: camera.PreviewOutput; +let cameraInput: camera.CameraInput; +let captureSession: camera.PhotoSession; +let previewOutput: camera.PhotoOutput; + +// [End camera_release_after] + +@Entry +@Component +struct CameraPage { + @State message: string = 'Hello World'; + + // [Start camera_release_after] + // The camera page is triggered once every time it is hidden. + onPageHide() { + setTimeout(this.releaseCamera, 200); + } + + // Release resources + public async releaseCamera() { + try { + // Photo mode session class pause + await captureSession?.stop(); + // Photo mode conversation class release + await captureSession?.release(); + // The photo input object class is closed. + await cameraInput?.close(); + // Preview output object class release + await previewOutput?.release(); + // Photo output object class release + await cameraOutput?.release(); + } catch (e) { + hilog.error(0x00, 'release input output error:', JSON.stringify(e)); + } + } + + // [End camera_release_after] + + build() { + RelativeContainer() { + Text(this.message) + .id('HelloWorld') + .fontSize(50) + .fontWeight(FontWeight.Bold) + .alignRules({ + center: { anchor: '__container__', align: VerticalAlign.Center }, + middle: { anchor: '__container__', align: HorizontalAlign.Center } + }) + } + .height('100%') + .width('100%') + } +} \ No newline at end of file diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/pages/CameraPage.ets b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/pages/CameraPage.ets new file mode 100644 index 0000000000000000000000000000000000000000..9a567d0fc9823b0ef6d9b656c8c0902fe6907590 --- /dev/null +++ b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/pages/CameraPage.ets @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * 最佳实践:点击响应优化 + */ +import { camera } from '@kit.CameraKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +// [Start camera_release_before] +let cameraOutput: camera.PreviewOutput; +let cameraInput: camera.CameraInput; +let captureSession: camera.PhotoSession; +let previewOutput: camera.PhotoOutput; + +// [End camera_release_before] + +@Entry +@Component +struct CameraPage { + @State message: string = 'Hello World'; + + // [Start camera_release_before] + // The camera page is triggered once every time it is hidden. + onPageHide() { + this.releaseCamera(); + } + + // Release resources + public async releaseCamera() { + try { + // Photo mode session class pause + await captureSession?.stop(); + // Photo mode conversation class release + await captureSession?.release(); + // The photo input object class is closed. + await cameraInput?.close(); + // Preview output object class release + await previewOutput?.release(); + // Photo output object class release + await cameraOutput?.release(); + } catch (e) { + hilog.error(0x00, 'release input output error:', JSON.stringify(e)); + } + } + + // [End camera_release_before] + + build() { + RelativeContainer() { + Text(this.message) + .id('HelloWorld') + .fontSize(50) + .fontWeight(FontWeight.Bold) + .alignRules({ + center: { anchor: '__container__', align: VerticalAlign.Center }, + middle: { anchor: '__container__', align: HorizontalAlign.Center } + }) + } + .height('100%') + .width('100%') + } +} \ No newline at end of file diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/pages/CityListPage.ets b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/pages/CityListPage.ets new file mode 100644 index 0000000000000000000000000000000000000000..90304991c0a8c3ed576ddaa81d59997ea993b2c0 --- /dev/null +++ b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/pages/CityListPage.ets @@ -0,0 +1,139 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * 最佳实践:点击响应优化 + */ +import taskpool from '@ohos.taskpool'; +import hiTraceMeter from '@ohos.hiTraceMeter'; +import { AppConstant } from '../common/constants/AppConstant'; +import router from '@ohos.router'; + +const alphabets = ['#', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', + 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']; + +// [Start city_list_page] +@Concurrent +function computeTask(): string[] { + let array: string[] = [] + // AppConstant.CITYS 为需要加载的数据 + for (let t of AppConstant.CITYS) { + array.push(t.trim()) + } + let collator = new Intl.Collator("zh-CN", { localeMatcher: "lookup", usage: "sort" }); + array.sort((a, b) => collator.compare(a, b)) + return array; +} + +@Entry +@Component +struct CityList { + isAsync: boolean = (this.getUIContext().getRouter().getParams() as Record)['isAsync']; + // 界面数据 + @State citys: string[] = [] + private listScroller: Scroller = new Scroller(); + + aboutToAppear() { + this.computeTaskAsync(); // 调用异步运算函数 + } + + // 异步线程 + computeTaskAsync() { + let task: taskpool.Task = new taskpool.Task(computeTask); + taskpool.execute(task).then((res) => { + this.citys = res as string[] + }) + } + + // [StartExclude city_list_page] + onPageShow() { + hiTraceMeter.finishTrace("clickCity", 1); + } + + build() { + Column() { + Row() { + Image($r("app.media.ic_back")) + .width(26).height(26) + .fillColor('#99000000') + .margin(10) + Text('选择地区') + .fontSize(20) + .fontWeight(FontWeight.Bold) + .margin({ bottom: 20, top: 20 }) + .alignSelf(ItemAlign.Center) + .textAlign(TextAlign.Center) + .layoutWeight(1) + Image($r('app.media.ic_public_search')) + .width(26) + .height(26) + .fillColor('#99000000') + .visibility(Visibility.Hidden) + .margin(10) + } + .padding({ left: 5, right: 5 }) + + Row() { + Text('安徽省') + .margin({ left: 25, bottom: 20 }) + .fontSize(17) + .fontWeight(FontWeight.Medium) + Text('城市') + .fontSize(17) + .fontColor(Color.Gray) + .fontWeight(FontWeight.Medium) + .margin({ left: 25, bottom: 20 }) + } + .margin({ top: 10 }) + .width('100%') + .justifyContent(FlexAlign.Start) + + Stack({ alignContent: Alignment.End }) { + + List({ space: 10, scroller: this.listScroller }) { + ForEach(this.isAsync ? this.citys : AppConstant.CITYS, (item: string) => { + ListItem() { + Row() { + Text(item) + .fontSize(17) + } + .padding(17) + .width('100%') + .margin({ left: 5 }) + .justifyContent(FlexAlign.Start) + } + }) + } + .divider({ + strokeWidth: 1, + startMargin: 25, + endMargin: 0, + color: '#ffe9f0f0' + }) + .scrollBar(BarState.Auto) + .width('100%') + .height('100%') + + AlphabetIndexer({ arrayValue: alphabets, selected: 1 }) + .margin({ right: 5 }) + } + } + } + + // [EndExclude city_list_page] +} + +// [End city_list_page] + diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/pages/ConcurrentOptPage.ets b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/pages/ConcurrentOptPage.ets new file mode 100644 index 0000000000000000000000000000000000000000..1a4779e5cfd92abf63d61c887fb57774ff3b649a --- /dev/null +++ b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/pages/ConcurrentOptPage.ets @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * 最佳实践:点击响应优化 + */ +import router from '@ohos.router'; + +@Entry +@Component +struct Index { + build() { + Column() { + Row() { + Image($r("app.media.ic_back")) + .width(26).height(26) + .fillColor('#99000000') + .margin(10) + Text('新建地址') + .fontSize(20) + .fontWeight(FontWeight.Bold) + .margin({ bottom: 20, top: 20 }) + .alignSelf(ItemAlign.Center) + .textAlign(TextAlign.Center) + .layoutWeight(1) + + Image($r('app.media.ic_public_search')) + .width(26) + .height(26) + .fillColor('#99000000') + .visibility(Visibility.Hidden) + .margin(10) + } + .padding({ left: 5, right: 5 }) + + Row() { + Text("收货人 ") + .fontWeight(FontWeight.Medium) + .margin(24) + Text("请填写收货人姓名").fontSize(15).fontColor(Color.Grey) + } + .margin({ top: 15 }) + + Divider().height(1).color('#F1F3F5').opacity(0.8).margin({ left: 24, right: 24 }) + Row() { + Text("手机号码") + .fontWeight(FontWeight.Medium) + .margin(24) + Text("请填写收货人手机号码").fontSize(15).fontColor(Color.Grey) + } + + Divider().height(1).color('#F1F3F5').opacity(0.8).margin({ left: 24, right: 24 }) + Row() { + Text("所在地区") + .fontWeight(FontWeight.Medium) + .margin(24) + Text("省市区县、乡镇等").fontSize(15).fontColor(Color.Grey) + + Button('选择') + .onClick(() => { + // hiTraceMeter.startTrace("clickCity", 1); + this.getUIContext().getRouter().pushUrl({ url: "pages/CityListPage", params: { isAsync: false } }) + }) + .fontSize(12) + .width(56) + .backgroundColor(Color.Orange) + .height(24) + .stateEffect(true) + .margin({ left: 15 }) + .visibility(Visibility.None) + Button('选择') + .onClick(() => { + // hiTraceMeter.startTrace("clickCity", 1); + this.getUIContext().getRouter().pushUrl({ url: "pages/CityListPage", params: { isAsync: true } }) + }) + .fontSize(12) + .width(56) + .height(24) + .backgroundColor(Color.Orange) + .stateEffect(true) + .margin({ left: 5 }) + .visibility(Visibility.Visible) + + } + + Divider().height(1).color('#F1F3F5').opacity(0.8).margin({ left: 24, right: 24 }) + Row() { + Text("详细地址") + .fontWeight(FontWeight.Medium) + .margin(24) + Text("街道、楼牌号等").fontSize(15).fontColor(Color.Grey) + } + + Divider().height(1).color('#F1F3F5').opacity(0.8).margin({ left: 24, right: 24, top: 40 }) + } + .width('100%') + .height('100%') + .justifyContent(FlexAlign.Start) + .alignItems(HorizontalAlign.Start) + } +} \ No newline at end of file diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/pages/CustomContent.ets b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/pages/CustomContent.ets new file mode 100644 index 0000000000000000000000000000000000000000..c2c49242f0ced5720436cb9b81de1c707eaf8473 --- /dev/null +++ b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/pages/CustomContent.ets @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Component +export struct CustomContent { + @Prop color: Color; + + build() { + Column() + .width('100%') + .height('100%') + .backgroundColor(this.color) + } +} \ No newline at end of file diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/pages/Index.ets b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..0b68d1767d2295b83cb89cb35b5a24f7f5ee45d4 --- /dev/null +++ b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * 最佳实践:点击响应优化 + */ +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + RelativeContainer() { + Text(this.message) + .id('HelloWorld') + .fontSize(50) + .fontWeight(FontWeight.Bold) + .alignRules({ + center: { anchor: '__container__', align: VerticalAlign.Center }, + middle: { anchor: '__container__', align: HorizontalAlign.Center } + }) + // syncLoad设置false,或缺省设置,都是异步加载图片 + Image('https://example.com/icon.png') + .syncLoad(false) + } + .height('100%') + .width('100%') + } +} \ No newline at end of file diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/pages/PanGestureDistanceOptPage.ets b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/pages/PanGestureDistanceOptPage.ets new file mode 100644 index 0000000000000000000000000000000000000000..6cd95c5eeecb47d84bfdab4c41c490c556549b95 --- /dev/null +++ b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/pages/PanGestureDistanceOptPage.ets @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * 最佳实践:点击响应优化 + */ +import { hiTraceMeter } from '@kit.PerformanceAnalysisKit' + +@Entry +@Component +struct PanGestureExample { + @State offsetX: number = 0 + @State offsetY: number = 0 + @State positionX: number = 0 + @State positionY: number = 0 + private panOption: PanGestureOptions = new PanGestureOptions({ direction: PanDirection.Left | PanDirection.Right }) + + build() { + Column() { + Column() { + Text('PanGesture offset:\nX: ' + this.offsetX + '\n' + 'Y: ' + this.offsetY) + } + .height(200) + .width(300) + .padding(20) + .border({ width: 3 }) + .margin(50) + .translate({ x: this.offsetX, y: this.offsetY, z: 0 }) // 以组件左上角为坐标原点进行移动 + // 左右拖动触发该手势事件 + .gesture( + PanGesture(this.panOption) + .onActionStart((event: GestureEvent) => { + console.info('Pan start') + hiTraceMeter.startTrace("PanGesture", 1) + }) + .onActionUpdate((event: GestureEvent) => { + if (event) { + this.offsetX = this.positionX + event.offsetX + this.offsetY = this.positionY + event.offsetY + } + }) + .onActionEnd(() => { + this.positionX = this.offsetX + this.positionY = this.offsetY + console.info('Pan end') + hiTraceMeter.finishTrace("PanGesture", 1) + }) + ) + + // [Start pan_gesture_button] + Button('修改PanGesture触发条件') + .onClick(() => { + this.panOption.setDistance(4) + }) + // [End pan_gesture_button] + } + } +} diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/pages/PanGestureDistancePage.ets b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/pages/PanGestureDistancePage.ets new file mode 100644 index 0000000000000000000000000000000000000000..0b46fbef1a7d111d3b1cd59567790d37a5c40dc9 --- /dev/null +++ b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/pages/PanGestureDistancePage.ets @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * 最佳实践:点击响应优化 + */ +// [Start pan_gesture_example] +import { hiTraceMeter } from '@kit.PerformanceAnalysisKit' + +@Entry +@Component +struct PanGestureExample { + @State offsetX: number = 0 + @State offsetY: number = 0 + @State positionX: number = 0 + @State positionY: number = 0 + private panOption: PanGestureOptions = new PanGestureOptions({ direction: PanDirection.Left | PanDirection.Right }) + + build() { + Column() { + Column() { + Text('PanGesture offset:\nX: ' + this.offsetX + '\n' + 'Y: ' + this.offsetY) + } + .height(200) + .width(300) + .padding(20) + .border({ width: 3 }) + .margin(50) + .translate({ x: this.offsetX, y: this.offsetY, z: 0 }) // Move with the upper left corner of the component as the coordinate origin. + // Drag left and right to trigger the gesture event. + .gesture( + PanGesture(this.panOption) + .onActionStart((event: GestureEvent) => { + console.info('Pan start') + hiTraceMeter.startTrace("PanGesture", 1) + }) + .onActionUpdate((event: GestureEvent) => { + if (event) { + this.offsetX = this.positionX + event.offsetX + this.offsetY = this.positionY + event.offsetY + } + }) + .onActionEnd(() => { + this.positionX = this.offsetX + this.positionY = this.offsetY + console.info('Pan end') + hiTraceMeter.finishTrace("PanGesture", 1) + }) + ) + + Button('修改PanGesture触发条件') + .onClick(() => { + this.panOption.setDistance(100) + }) + } + } +} + +// [Start pan_gesture_example] \ No newline at end of file diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/pages/ProfilePage.ets b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/pages/ProfilePage.ets new file mode 100644 index 0000000000000000000000000000000000000000..06729ee7fb2d47ea74fc6320de50478bdb912ce8 --- /dev/null +++ b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/pages/ProfilePage.ets @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * 最佳实践:点击响应优化 + */ +import Constants from '../common/constants/WorldConstants'; +import ChatModel from '../model/ChatModel'; +import { LoadingView } from '../view/LoadingView'; +import router from '@ohos.router'; + +@Entry +@Component +export struct ProfilePage { + itemData: ChatModel = (this.getUIContext().getRouter().getParams() as Record)['itemData']; + @State showLoading: boolean = true + + // page B 转场动画设置 + pageTransition() { + PageTransitionEnter({ type: RouteType.None, duration: 400 }) + .slide(SlideEffect.Right) + PageTransitionExit({ type: RouteType.None, duration: 400 }) + .slide(SlideEffect.Right) + } + + onPageShow() { + setTimeout(() => { + this.showLoading = false + }, 2000) + } + + build() { + Column() { + Stack() { + Column() { + Image($r('app.media.user_background_image')) + .width(Constants.FULL_SCREEN) + .height(220) + .objectFit(ImageFit.Cover) + }.width(Constants.FULL_SCREEN).aspectRatio(3 / 2) + + Column() { + Row({ space: Constants.MIDDLE_SPACE }) { + // [Start image_component] + // The personal page sharing element needs to be the same as the previous page id. + Image(this.itemData.avatar) + .size({ + width: $r('app.float.user_image_size'), + height: $r('app.float.user_image_size') + })// .borderRadius($r('app.float.user_image_border_radius')) + .borderRadius(8) + .margin({ bottom: $r('app.float.user_image_padding'), top: $r('app.float.user_image_padding') }) + .sharedTransition('sharedImage' + this.itemData.id, + { duration: 500, curve: Curve.FastOutSlowIn, delay: 0 }) + // [End image_component] + Text(this.itemData.name) + .fontColor($r('app.color.hmos_color_white')) + .fontSize($r('app.float.user_account_font_size')) + .padding({ bottom: $r('app.float.login_account_padding_bottom') }) + } + .width(Constants.FULL_SCREEN) + .justifyContent(FlexAlign.Start) + .margin({ bottom: '0' }) + + Text('欢迎来到HarmonyOS世界') + .width(Constants.FULL_SCREEN) + .fontSize($r('app.float.login_information_font_size')) + .fontColor($r('app.color.hmos_color_white')) + } + .alignItems(HorizontalAlign.Start) + .padding({ left: $r('app.float.login_account_padding_left') }) + .width(Constants.FULL_SCREEN) + .height($r('app.float.user_background_height')) + } + + if (this.showLoading) { + LoadingView() + } else { + Image($r('app.media.screen_list_img')) + .width(Constants.FULL_SCREEN) + .height('68%') + .objectFit(ImageFit.Fill) + } + } + } +} \ No newline at end of file diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/pages/TabsNegativeExample.ets b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/pages/TabsNegativeExample.ets new file mode 100644 index 0000000000000000000000000000000000000000..818b69b4aea58e898eb570e3f486a17eb798d293 --- /dev/null +++ b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/pages/TabsNegativeExample.ets @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { CustomContent } from './CustomContent'; + +/** + * 最佳实践:合理使用动画-合理设置隐式动画 反例 + */ + +// [Start tabs_negative_example] +@Entry +@Component +struct TabsNegativeExample { + // [StartExclude tabs_negative_example] + @State currentIndex: number = 0; + private list: string[] = ['green', 'blue', 'yellow', 'pink']; + // [EndExclude tabs_negative_example] + private controller: TabsController = new TabsController(); + + // [StartExclude tabs_negative_example] + @Builder + customContent(color: Color) { + Column() + .width('100%') + .height('100%') + .backgroundColor(color) + } + + // [EndExclude tabs_negative_example] + + build() { + Column() { + // [StartExclude tabs_negative_example] + Row({ space: 10 }) { + ForEach(this.list, (item: string, index: number) => { + Text(item) + .textAlign(TextAlign.Center) + .fontSize(16) + .height(32) + .layoutWeight(1) + .fontColor(this.currentIndex === index ? Color.White : Color.Black) + .backgroundColor(this.currentIndex === index ? Color.Blue : '#f2f2f2') + .borderRadius(16) + .onClick(() => { + this.controller.changeIndex(index); + this.currentIndex = index; + }) + }, (item: string, index: number) => JSON.stringify(item) + index) + } + .margin(10) + + // [EndExclude tabs_negative_example] + + Tabs({ barPosition: BarPosition.Start, controller: this.controller }) { + // [StartExclude tabs_negative_example] + TabContent() { + this.customContent(Color.Green) + } + + TabContent() { + this.customContent(Color.Blue) + } + + TabContent() { + this.customContent(Color.Yellow) + } + + TabContent() { + this.customContent(Color.Pink) + } + + // [EndExclude tabs_negative_example] + + } + .barHeight(0) + .layoutWeight(1) + .animationDuration(1000) + .scrollable(false) + } + .width('100%') + } +} + +// [End tabs_negative_example] \ No newline at end of file diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/pages/TabsPositiveExample.ets b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/pages/TabsPositiveExample.ets new file mode 100644 index 0000000000000000000000000000000000000000..2d82166c8ee8a120caeef7dd0cfd45369bcd24fd --- /dev/null +++ b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/pages/TabsPositiveExample.ets @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { CustomContent } from './CustomContent'; + +/** + * 最佳实践:合理使用动画-合理设置隐式动画 正例 + */ + +// [Start tabs_positive_example] +@Entry +@Component +struct TabsPositiveExample { + @State currentIndex: number = 0; + private controller: TabsController = new TabsController(); + private list: string[] = ['green', 'blue', 'yellow', 'pink']; + + @Builder + customContent(color: Color) { + Column() + .width('100%') + .height('100%') + .backgroundColor(color) + } + + build() { + Column() { + Row({ space: 10 }) { + ForEach(this.list, (item: string, index: number) => { + Text(item) + .textAlign(TextAlign.Center) + .fontSize(16) + .height(32) + .layoutWeight(1) + .fontColor(this.currentIndex === index ? Color.White : Color.Black) + .backgroundColor(this.currentIndex === index ? Color.Blue : '#f2f2f2') + .borderRadius(16) + .onClick(() => { + this.currentIndex = index; + this.controller.changeIndex(index); + }) + }, (item: string, index: number) => JSON.stringify(item) + index) + } + .margin(10) + + Tabs({ barPosition: BarPosition.Start, controller: this.controller }) { + TabContent() { + this.customContent(Color.Green) + } + + TabContent() { + this.customContent(Color.Blue) + } + + TabContent() { + this.customContent(Color.Yellow) + } + + TabContent() { + this.customContent(Color.Pink) + } + } + .animationDuration(100) + .layoutWeight(1) + .barHeight(0) + .scrollable(false) + } + .width('100%') + } +} + +// [End tabs_positive_example] diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/pages/VisionOptPage.ets b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/pages/VisionOptPage.ets new file mode 100644 index 0000000000000000000000000000000000000000..84c73c5e288fd284624e48d7b1c4058253b7dbdf --- /dev/null +++ b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/pages/VisionOptPage.ets @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * 最佳实践:点击响应优化 + */ +import { OptChatItemView } from '../view/OptChatItemView'; +import ChatModel from '../model/ChatModel'; +import hiTraceMeter from '@ohos.hiTraceMeter'; + +@Entry +@Component +struct ChatListPage { + @State private listData: ChatModel[] = [] + private COUNT: number = 128 + + // [Start page_a_transition] + // page A Transition animation settings + pageTransition() { + PageTransitionEnter({ type: RouteType.None, duration: 400 }) + .slide(SlideEffect.Left) + PageTransitionExit({ type: RouteType.None, duration: 400 }) + .slide(SlideEffect.Left) + } + + // [Start page_a_transition] + + onPageShow() { + hiTraceMeter.finishTrace("clickChat", 1); + } + + randomData() { + this.listData = [] + for (let i: number = 0; i < this.COUNT; i++) { + this.listData.push(new ChatModel(i)); + } + } + + aboutToAppear() { + this.listData = [] + for (let i: number = 0; i < this.COUNT; i++) { + this.listData.push(new ChatModel(i)); + } + } + + build() { + Column() { + Stack() { + Row() { + Text('留言(' + this.listData.length + ')') + .textAlign(TextAlign.Center) + .fontSize(16) + .border({ width: 0 }) + .padding(10) + .height(65) + }.width('100%').justifyContent(FlexAlign.Center) + + Row() { + Image($r('app.media.ic_public_search')) + .width(26).height(26) + .fillColor('#99000000') + .margin(10) + }.width('100%').justifyContent(FlexAlign.End) + } + + Divider().strokeWidth(1).color('#F1F3F5').opacity(0.8) + Scroll() { + Column() { + ForEach(this.listData, (item: ChatModel) => { + OptChatItemView({ itemData: item }) + .padding({ + left: 24, + right: 24 + }) + .height(74) + Divider().height(1).color('#F1F3F5').opacity(0.8).margin({ left: 72, right: 0 }) + }, (item: ChatModel) => JSON.stringify(item)) + } + } + } + } +} diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/view/ArticleSkeletonView.ets b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/view/ArticleSkeletonView.ets new file mode 100644 index 0000000000000000000000000000000000000000..d3e5083727be331b952cfb4306053fd2fed37a80 --- /dev/null +++ b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/view/ArticleSkeletonView.ets @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * 最佳实践:点击响应优化 + */ +import { CommonConstants } from '../common/constants/WorldCommonConstants'; + +@Preview +@Component +export struct ArticleSkeletonView { + isMine?: boolean = false; + isFeed?: boolean = false; + + build() { + Row() { + Column() { + Column({ space: CommonConstants.SM_SPACE }) { + textArea($r('app.float.card_title_height')) + textArea($r('app.float.card_text_height')) + } + .alignItems(HorizontalAlign.Start) + .layoutWeight(1) + + if (!this.isFeed) { + Row() { + ActionArea() + ActionArea() + ActionArea() + } + .width(CommonConstants.FULL_PERCENT) + .justifyContent(FlexAlign.SpaceBetween) + } else { + Row({ space: CommonConstants.MD_SPACE }) { + Row() + .width($r('app.float.lg_topic_width')) + .topicStyle() + Row() + .width($r('app.float.md_topic_width')) + .topicStyle() + } + .width(CommonConstants.FULL_PERCENT) + .justifyContent(FlexAlign.Start) + } + } + .layoutWeight(1) + .height(CommonConstants.FULL_PERCENT) + .justifyContent(FlexAlign.SpaceAround) + + Stack({ alignContent: Alignment.BottomEnd }) { + if (this.isMine) { + Row() + .width($r('app.float.type_width')) + .height($r('app.float.type_height')) + .backgroundColor($r('app.color.skeleton_color_deep')) + .borderRadius($r('app.float.x_small_border_radius')) + .margin({ bottom: $r('app.float.sm_margin'), right: $r('app.float.sm_margin') }) + .zIndex(1) + } + Row() + .width(CommonConstants.FULL_PERCENT) + .height(CommonConstants.FULL_PERCENT) + .backgroundColor($r('app.color.skeleton_color_light')) + .borderRadius($r('app.float.small_border_radius')) + } + .width($r('app.float.ske_image_width')) + .height($r('app.float.ske_image_height')) + .padding({ left: $r('app.float.large_padding') }) + } + .padding($r('app.float.regular_padding')) + .borderRadius($r('app.float.large_border_radius')) + .backgroundColor(Color.White) + .alignItems(VerticalAlign.Top) + .justifyContent(FlexAlign.SpaceAround) + .width(CommonConstants.FULL_PERCENT) + .height($r('app.float.card_height')) + } +} + +@Builder +function ActionArea() { + Row() + .width($r('app.float.action_area_width')) + .height($r('app.float.action_area_height')) + .backgroundColor($r('app.color.skeleton_color_medium')) +} + +@Styles +function topicStyle() { + .height($r('app.float.topic_height')) + .backgroundColor($r('app.color.skeleton_color_medium')) + .borderRadius($r('app.float.x_small_border_radius')) +} + +@Builder +function textArea(height: number | Resource) { + Row() + .width(CommonConstants.FULL_PERCENT) + .height(height) + .backgroundColor($r('app.color.skeleton_color_medium')) +} \ No newline at end of file diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/view/LoadingView.ets b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/view/LoadingView.ets new file mode 100644 index 0000000000000000000000000000000000000000..be9a2803204631bdeca8c55c4a2bed61f4e2c43f --- /dev/null +++ b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/view/LoadingView.ets @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * 最佳实践:点击响应优化 + */ +import { CommonConstants } from '../common/constants/WorldCommonConstants'; +import Constants, { SkeletonData, SkeType } from '../common/constants/WorldConstants'; +import { ArticleSkeletonView } from './ArticleSkeletonView'; + +@Preview +@Component +export struct LoadingView { + @State columnBgColor: Color = Color.Gray; + @State listOpacity: number = 1; + + // [Start start_animation] + // Skeleton diagram, presenting skeleton animation in a fading way. + startAnimation(): void { + this.getUIContext().animateTo(CommonConstants.SKELETON_ANIMATION, () => { + this.listOpacity = CommonConstants.HALF_OPACITY; + }); + } + + // Skeletal diagram layout + build() { + Row() { + List({ space: Constants.RESOURCE_LIST_SPACE }) { + ForEach(SkeletonData, (item: SkeType) => { + ListItem() { + ArticleSkeletonView({ isMine: item.isMine, isFeed: item.isFeed }) + } + }) + } + .padding({ + left: '12vp', + right: '12vp' + }) + .lanes(1) + .layoutWeight(1) + .scrollBar(BarState.Off) + + Row() + .layoutWeight(0) + .backgroundColor($r('app.color.skeleton_color_medium')) + } + .width('100%') + .opacity(this.listOpacity) + .onAppear(() => { + this.startAnimation(); + }) + } + + // [End start_animation] +} \ No newline at end of file diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/view/OptChatItemView.ets b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/view/OptChatItemView.ets new file mode 100644 index 0000000000000000000000000000000000000000..2d4cfb480de1d6f219a7ab6ddc6e104d67e0419b --- /dev/null +++ b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/ets/view/OptChatItemView.ets @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * 最佳实践:点击响应优化 + */ +import ChatModel from '../model/ChatModel' +import router from '@ohos.router' + +@Component +export struct OptChatItemView { + @Prop itemData: ChatModel + + build() { + RelativeContainer() { + Badge({ value: "", style: { badgeSize: this.itemData.hasBadge ? 8 : 0, badgeColor: '#FA2A2D' } }) { + // [Start shared_image] + // Use the avatar as a shared element in the list and specify the id as sharedImage+this.itemData.id + Image(this.itemData.avatar) + .height('40vp') + .width('40vp') + .borderRadius(8) + .sharedTransition('sharedImage' + this.itemData.id, { duration: 500, curve: Curve.FastOutSlowIn, delay: 0 }) + // [End shared_image] + } + .id('head') + .height('40vp') + .width('40vp') + .alignRules({ + center: { anchor: "__container__", align: VerticalAlign.Center }, + left: { anchor: "__container__", align: HorizontalAlign.Start } + }) + .onClick(() => { + this.getUIContext().getRouter().pushUrl({ url: 'pages/ProfilePage', params: { itemData: this.itemData } }) + }) + + Text(this.itemData.name) + .fontSize('16.0fp') + .textOverflow({ overflow: TextOverflow.Ellipsis }) + .fontColor('# ff182431') + .maxLines(1) + .fontWeight(FontWeight.Medium) + .padding({ left: '12vp' }) + .height(22) + .alignRules({ + top: { anchor: 'head', align: VerticalAlign.Top }, + left: { anchor: 'head', align: HorizontalAlign.End } + }) + .id('name') + Text(this.itemData.time) + .fontColor('# 66182431') + .fontSize('12fp') + .maxLines(1) + .height(22) + .alignRules({ + top: { anchor: 'head', align: VerticalAlign.Top }, + right: { anchor: '__container__', align: HorizontalAlign.End } + }) + .id("time") + + Text() { + Span(this.itemData.snippet.replace(new RegExp("/[\r\n]/g"), " ")) + .fontSize('14fp') + .fontColor('#66182431') + } + .maxLines(1) + .textOverflow({ overflow: TextOverflow.Ellipsis }) + .width('100%') + .height(19) + .margin({ top: '2vp' }) + .padding({ left: '12vp' }) + .alignRules({ + top: { anchor: 'name', align: VerticalAlign.Bottom }, + left: { anchor: 'head', align: HorizontalAlign.End } + }) + .id('content') + + if (this.itemData.hasMute) { + Image($r('app.media.ic_public_donotdisturb')) + .width(14) + .height(14) + .fillColor('#86182431') + .margin(2) + .alignRules({ + top: { anchor: 'time', align: VerticalAlign.Bottom }, + right: { anchor: '__container__', align: HorizontalAlign.End } + }) + .id('mute') + } + } + .width('100%').height('100%') + } +} \ No newline at end of file diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/main/module.json5 b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..5f6f8e183e9195d8178183502bf018e80c02f9a1 --- /dev/null +++ b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/module.json5 @@ -0,0 +1,36 @@ +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "phone" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:layered_image", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ] + } +} \ No newline at end of file diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/element/color.json b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..902dbc9079b34bd40af6bd289171ce3454b6055d --- /dev/null +++ b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/element/color.json @@ -0,0 +1,116 @@ +{ + "color": [ + { + "name": "white", + "value": "#FFFFFF" + }, + { + "name": "start_window_background", + "value": "#FFFFFF" + }, + { + "name": "gray_shadow", + "value": "#55000000" + }, + { + "name": "trans_parent", + "value": "#00000000" + }, + { + "name": "light_blue", + "value": "#007DFF" + }, + { + "name": "grey_light", + "value": "#F1F3F5" + }, + { + "name": "share_item_content_font", + "value": "#182431" + }, + { + "name": "theme_blue_color", + "value": "#0A59F0" + }, + { + "name": "theme_blue_background_color", + "value": "#1A0A59F7" + }, + { + "name": "hmos_black", + "value": "#FF000000" + }, + { + "name": "hmos_medium_black", + "value": "#99000000" + }, + { + "name": "hmos_regular_gray", + "value": "#66000000" + }, + { + "name": "hmos_light_white", + "value": "#F1F3F5" + }, + { + "name": "hmos_background_color_white", + "value": "#FAFAFA" + }, + { + "name": "hmos_color_white", + "value": "#FFFFFF" + }, + { + "name": "skeleton_color_medium", + "value": "#FFF2F3F4" + }, + { + "name": "reload_title_color", + "value": "#99000000" + }, + { + "name": "no_more_divider_color", + "value": "#0D000000" + }, + { + "name": "no_more_title_color", + "value": "#66000000" + }, + { + "name": "main_red_color", + "value": "#FF3E50" + }, + { + "name": "skeleton_color_deep", + "value": "#1A000000" + }, + { + "name": "skeleton_color_light", + "value": "#FFECECEC" + }, + { + "name": "theme_black_color", + "value": "#000000" + }, + { + "name": "theme_yellow_color", + "value": "#EB9500" + }, + { + "name": "collected_bg_color", + "value": "#1AFFA200" + }, + { + "name": "action_button_bg_color", + "value": "#1A000000" + }, + { + "name": "liked_bg_color", + "value": "#1AFF3E50" + }, + { + "name": "skeleton_color", + "value": "#ECECEC" + } + ] +} \ No newline at end of file diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/element/float.json b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..6bf473e4d81ac5efb6ca8ac2bad17abf7cb38589 --- /dev/null +++ b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/element/float.json @@ -0,0 +1,504 @@ +{ + "float": [ + { + "name": "default_font_size", + "value": "16fp" + }, + { + "name": "small_margin", + "value": "4vp" + }, + { + "name": "medium_margin", + "value": "8vp" + }, + { + "name": "regular_margin", + "value": "10vp" + }, + { + "name": "large_margin", + "value": "12vp" + }, + { + "name": "large_padding", + "value": "16vp" + }, + { + "name": "large_border_radius", + "value": "16vp" + }, + { + "name": "topic_margin_right", + "value": "25vp" + }, + { + "name": "topic_margin_bottom", + "value": "5vp" + }, + { + "name": "header_height", + "value": "40vp" + }, + { + "name": "action_button_margin_right", + "value": "4vp" + }, + { + "name": "title_font_size", + "value": "14fp" + }, + { + "name": "brief_font_size", + "value": "12fp" + }, + { + "name": "title_margin_bottom", + "value": "4vp" + }, + { + "name": "card_height", + "value": "102vp" + }, + { + "name": "image_border_radius", + "value": "12vp" + }, + { + "name": "login_size", + "value": "30vp" + }, + { + "name": "account_image_size", + "value": "30vp" + }, + { + "name": "account_padding_top", + "value": "40vp" + }, + { + "name": "list_padding", + "value": "12vp" + }, + { + "name": "achievements_count_padding_top", + "value": "10vp" + }, + { + "name": "achievements_count_padding_left", + "value": "12vp" + }, + { + "name": "achievements_count_padding_bottom", + "value": "10vp" + }, + { + "name": "achievement_image_size_sm", + "value": "84vp" + }, + { + "name": "achievement_image_size_md", + "value": "96vp" + }, + { + "name": "achievement_image_size_lg", + "value": "106vp" + }, + { + "name": "xxl_padding_margin", + "value": "24vp" + }, + { + "name": "md_padding_margin", + "value": "12vp" + }, + { + "name": "achievement_list_padding", + "value": "12vp" + }, + { + "name": "resource_image_height", + "value": "64vp" + }, + { + "name": "resource_image_width", + "value": "108vp" + }, + { + "name": "resource_type_font_size", + "value": "10fp" + }, + { + "name": "resource_type_font_padding", + "value": "6vp" + }, + { + "name": "resource_type_font_margin_left_right", + "value": "5vp" + }, + { + "name": "resource_type_font_margin_top_bottom", + "value": "3vp" + }, + { + "name": "resource_type_font_border_radius", + "value": "5vp" + }, + { + "name": "topics_font_size", + "value": "10fp" + }, + { + "name": "topics_font_border_radius", + "value": "4vp" + }, + { + "name": "topics_font_border_padding_left_right", + "value": "8vp" + }, + { + "name": "topics_padding_top", + "value": "8vp" + }, + { + "name": "topics_font_border_padding_top_bottom", + "value": "2vp" + }, + { + "name": "star_icon_width", + "value": "16vp" + }, + { + "name": "like_icon_width", + "value": "22vp" + }, + { + "name": "view_count_icon_width", + "value": "36vp" + }, + { + "name": "resource_list_border_radius", + "value": "24vp" + }, + { + "name": "resource_list_margin_10", + "value": "10vp" + }, + { + "name": "mine_tab_font_size", + "value": "16fp" + }, + { + "name": "nav_title_font_size", + "value": "24fp" + }, + { + "name": "mine_tab_margin", + "value": "5vp" + }, + { + "name": "divider_width_32", + "value": "32vp" + }, + { + "name": "user_portrait_border_radius", + "value": "15vp" + }, + { + "name": "tabs_border_radius", + "value": "20vp" + }, + { + "name": "tab_bar_height", + "value": "56vp" + }, + { + "name": "user_padding_top", + "value": "32vp" + }, + { + "name": "user_image_size", + "value": "90vp" + }, + { + "name": "user_image_border_radius", + "value": "40vp" + }, + { + "name": "user_image_padding", + "value": "15vp" + }, + { + "name": "user_account_font_size", + "value": "20fp" + }, + { + "name": "login_account_padding_bottom", + "value": "2vp" + }, + { + "name": "login_account_padding_left", + "value": "12vp" + }, + { + "name": "login_information_font_size", + "value": "14fp" + }, + { + "name": "account_margin_bottom", + "value": "15vp" + }, + { + "name": "topics_select_width", + "value": "24vp" + }, + { + "name": "topics_select_height", + "value": "24vp" + }, + { + "name": "achievement_list_padding_left_right", + "value": "6vp" + }, + { + "name": "mine_page_padding", + "value": "12vp" + }, + { + "name": "tab_bar_width", + "value": "200vp" + }, + { + "name": "user_background_height", + "value": "200vp" + }, + { + "name": "none_view_image_size", + "value": "120vp" + }, + { + "name": "none_view_image_padding", + "value": "120vp" + }, + { + "name": "lg_padding_margin_left", + "value": "16vp" + }, + { + "name": "none_view_description_padding", + "value": "8vp" + }, + { + "name": "enlarge_img_size", + "value": "36vp" + }, + { + "name": "page_padding", + "value": "12vp" + }, + { + "name": "small_padding", + "value": "8vp" + }, + { + "name": "ssm_text_size", + "value": "10fp" + }, + { + "name": "small_text_size", + "value": "12fp" + }, + { + "name": "normal_text_size1", + "value": "14fp" + }, + { + "name": "title_text_size", + "value": "20fp" + }, + { + "name": "loading_img_margin", + "value": "260vp" + }, + { + "name": "loading_img_size", + "value": "72vp" + }, + { + "name": "failure_img_size", + "value": "120vp" + }, + { + "name": "loading_more_img_size", + "value": "24vp" + }, + { + "name": "failed_title_margin", + "value": "8vp" + }, + { + "name": "reload_btn_height", + "value": "32vp" + }, + { + "name": "reload_btn_width", + "value": "80vp" + }, + { + "name": "reload_btn_radius", + "value": "16vp" + }, + { + "name": "action_button_width", + "value": "56vp" + }, + { + "name": "regular_border_radius", + "value": "12vp" + }, + { + "name": "small_border_radius", + "value": "8vp" + }, + { + "name": "x_small_border_radius", + "value": "4vp" + }, + { + "name": "default_text_margin", + "value": "12vp" + }, + { + "name": "reload_height", + "value": "80vp" + }, + { + "name": "lg_topic_width", + "value": "56vp" + }, + { + "name": "md_topic_width", + "value": "43vp" + }, + { + "name": "topic_height", + "value": "16vp" + }, + { + "name": "action_area_width", + "value": "56vp" + }, + { + "name": "action_area_height", + "value": "20vp" + }, + { + "name": "card_title_height", + "value": "20vp" + }, + { + "name": "card_text_height", + "value": "20vp" + }, + { + "name": "ske_image_height", + "value": "64vp" + }, + { + "name": "ske_image_width", + "value": "108vp" + }, + { + "name": "regular_padding", + "value": "12vp" + }, + { + "name": "type_width", + "value": "28vp" + }, + { + "name": "type_height", + "value": "16vp" + }, + { + "name": "sm_margin", + "value": "5vp" + }, + { + "name": "view_area_width", + "value": "55vp" + }, + { + "name": "view_area_height", + "value": "18vp" + }, + { + "name": "view_area_border_radius", + "value": "8vp" + }, + { + "name": "feed_image_height", + "value": "96vp" + }, + { + "name": "brief_area_width", + "value": "132vp" + }, + { + "name": "brief_area_height", + "value": "12vp" + }, + { + "name": "feed_height", + "value": "174vp" + }, + { + "name": "feed_width", + "value": "156vp" + }, + { + "name": "topic_width", + "value": "132vp" + }, + { + "name": "no_more_layout_margin", + "value": "10vp" + }, + { + "name": "default_icon_width", + "value": "16vp" + }, + { + "name": "xl_padding_margin", + "value": "20vp" + }, + { + "name": "lg_padding_margin", + "value": "16vp" + }, + { + "name": "sm_padding_margin", + "value": "8vp" + }, + { + "name": "xs_padding_margin", + "value": "4vp" + }, + { + "name": "interactive_area_height", + "value": "72vp" + }, + { + "name": "interactive_button_height", + "value": "40vp" + }, + { + "name": "interactive_bar_icon_size", + "value": "22vp" + }, + { + "name": "icon_size", + "value": "16vp" + } + ] +} \ No newline at end of file diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/element/string.json b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..f94595515a99e0c828807e243494f57f09251930 --- /dev/null +++ b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/a1.jpg b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/a1.jpg new file mode 100644 index 0000000000000000000000000000000000000000..c2677424c013677c2bc8bcd8948841f7e5274c1e Binary files /dev/null and b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/a1.jpg differ diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/a10.jpg b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/a10.jpg new file mode 100644 index 0000000000000000000000000000000000000000..e0440ee14f845be5434269e1205daa0b2e9e1ce5 Binary files /dev/null and b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/a10.jpg differ diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/a11.jpg b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/a11.jpg new file mode 100644 index 0000000000000000000000000000000000000000..b137818ff34c1015bc6e2dadfcb57b271b1f1a8d Binary files /dev/null and b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/a11.jpg differ diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/a12.jpg b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/a12.jpg new file mode 100644 index 0000000000000000000000000000000000000000..48f0f4b2d9538a02e3047e076994f60bf1603de6 Binary files /dev/null and b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/a12.jpg differ diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/a13.jpg b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/a13.jpg new file mode 100644 index 0000000000000000000000000000000000000000..7a8d887e360fa5973cbb499b1fd09ac29a8cb608 Binary files /dev/null and b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/a13.jpg differ diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/a14.jpg b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/a14.jpg new file mode 100644 index 0000000000000000000000000000000000000000..1dedf35f66408e4065f8326025382d46ef0e4dc8 Binary files /dev/null and b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/a14.jpg differ diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/a15.jpg b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/a15.jpg new file mode 100644 index 0000000000000000000000000000000000000000..2b08f192cf0eb6876d70151e22b944156e4216f1 Binary files /dev/null and b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/a15.jpg differ diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/a16.jpg b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/a16.jpg new file mode 100644 index 0000000000000000000000000000000000000000..f01c8fed23d7583491cf5ff44dcf41a76f6db017 Binary files /dev/null and b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/a16.jpg differ diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/a17.jpg b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/a17.jpg new file mode 100644 index 0000000000000000000000000000000000000000..791811c7693c2d6f1f4f73e96bf1c040102323be Binary files /dev/null and b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/a17.jpg differ diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/a18.jpg b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/a18.jpg new file mode 100644 index 0000000000000000000000000000000000000000..10ef48d289f5ea86938ab4a9793b397de5d032e8 Binary files /dev/null and b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/a18.jpg differ diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/a19.jpg b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/a19.jpg new file mode 100644 index 0000000000000000000000000000000000000000..35d8512922188d2a94fdc78e33b6631d0fff5c8e Binary files /dev/null and b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/a19.jpg differ diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/a2.jpg b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/a2.jpg new file mode 100644 index 0000000000000000000000000000000000000000..1135a28bcaf2064ed61fd32aecd6843998d6d5cb Binary files /dev/null and b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/a2.jpg differ diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/a3.jpg b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/a3.jpg new file mode 100644 index 0000000000000000000000000000000000000000..ba75a54e9b70e702b6be0cc4e3735feffd64e7e4 Binary files /dev/null and b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/a3.jpg differ diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/a4.jpg b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/a4.jpg new file mode 100644 index 0000000000000000000000000000000000000000..82c4727c069e0f73f2c7a5ed1245a3bc04fc2a29 Binary files /dev/null and b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/a4.jpg differ diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/a5.jpg b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/a5.jpg new file mode 100644 index 0000000000000000000000000000000000000000..6967598dada065c5f3fe76cd3bd58702e6197de9 Binary files /dev/null and b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/a5.jpg differ diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/a6.jpg b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/a6.jpg new file mode 100644 index 0000000000000000000000000000000000000000..97c4ffc6f7ff764b5321bfbcb6cc715227d95fd9 Binary files /dev/null and b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/a6.jpg differ diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/a7.jpg b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/a7.jpg new file mode 100644 index 0000000000000000000000000000000000000000..448bfd3013648eb2755c154ad1223ad3dd4ec10d Binary files /dev/null and b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/a7.jpg differ diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/a8.jpg b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/a8.jpg new file mode 100644 index 0000000000000000000000000000000000000000..576c16b9f9abc2a034ebc35ff77caf6cfaf796a7 Binary files /dev/null and b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/a8.jpg differ diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/a9.jpg b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/a9.jpg new file mode 100644 index 0000000000000000000000000000000000000000..42c7039e680e22e4f63be6b6120d408d02aaa91a Binary files /dev/null and b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/a9.jpg differ diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/avataaars.png b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/avataaars.png new file mode 100644 index 0000000000000000000000000000000000000000..22edf463fd08d8bf6753b4fa6b278326ecf71ef2 Binary files /dev/null and b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/avataaars.png differ diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/avataaars1.png b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/avataaars1.png new file mode 100644 index 0000000000000000000000000000000000000000..5f1417a62d5015b47455b4c98b533f4b0a4a4ccf Binary files /dev/null and b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/avataaars1.png differ diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/avataaars10.png b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/avataaars10.png new file mode 100644 index 0000000000000000000000000000000000000000..f323be1e7c06d38d4be4850b1ecfc4aa250a80f7 Binary files /dev/null and b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/avataaars10.png differ diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/avataaars2.png b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/avataaars2.png new file mode 100644 index 0000000000000000000000000000000000000000..466a7c51e8773aa5d75ad21f0f2c9aec9d2e8b46 Binary files /dev/null and b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/avataaars2.png differ diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/avataaars3.png b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/avataaars3.png new file mode 100644 index 0000000000000000000000000000000000000000..ff35a368197ddd09eef259caa03160cb0cb0d23d Binary files /dev/null and b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/avataaars3.png differ diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/avataaars4.png b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/avataaars4.png new file mode 100644 index 0000000000000000000000000000000000000000..548bc8607bcdd19d7f5de9478bbb09e0d9d7e308 Binary files /dev/null and b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/avataaars4.png differ diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/avataaars5.png b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/avataaars5.png new file mode 100644 index 0000000000000000000000000000000000000000..c41245b3cfdf189e9aefd687968de5f606dca1bc Binary files /dev/null and b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/avataaars5.png differ diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/avataaars6.png b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/avataaars6.png new file mode 100644 index 0000000000000000000000000000000000000000..437f686655d5f05d33e5939050b7cecda555b193 Binary files /dev/null and b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/avataaars6.png differ diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/avataaars7.png b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/avataaars7.png new file mode 100644 index 0000000000000000000000000000000000000000..9b132351caadeb091215c630f2ac53c707fe18f4 Binary files /dev/null and b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/avataaars7.png differ diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/avataaars8.png b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/avataaars8.png new file mode 100644 index 0000000000000000000000000000000000000000..a2e3de93a2fa9026cbf60f4b29ed42c8cdd1fd10 Binary files /dev/null and b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/avataaars8.png differ diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/avataaars9.png b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/avataaars9.png new file mode 100644 index 0000000000000000000000000000000000000000..f98ecce7d69848a76c3a06af8be046b60f121c60 Binary files /dev/null and b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/avataaars9.png differ diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/background.png b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d Binary files /dev/null and b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/background.png differ diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/foreground.png b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902 Binary files /dev/null and b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/foreground.png differ diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/ic_back.svg b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/ic_back.svg new file mode 100644 index 0000000000000000000000000000000000000000..d22772355f336e8cc0225969a09f5c58b545fbe5 --- /dev/null +++ b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/ic_back.svg @@ -0,0 +1,15 @@ + + + Public/ic_public_back + + + + + + + + + + \ No newline at end of file diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/ic_public_donotdisturb.svg b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/ic_public_donotdisturb.svg new file mode 100644 index 0000000000000000000000000000000000000000..80adbae322096c1ae1443d0759c525fff1a9005b --- /dev/null +++ b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/ic_public_donotdisturb.svg @@ -0,0 +1,17 @@ + + + Public/ic_public_donotdisturb + + + + + + + + + + \ No newline at end of file diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/ic_public_search.svg b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/ic_public_search.svg new file mode 100644 index 0000000000000000000000000000000000000000..513824136a50b7adcbea754dd5f6ff8ea34c0ad7 --- /dev/null +++ b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/ic_public_search.svg @@ -0,0 +1,15 @@ + + + Public/ic_public_search + + + + + + + + + + \ No newline at end of file diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/layered_image.json b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..4f9ad6307a2bc56beb6d0fce0a49cbf213b20a74 --- /dev/null +++ b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/layered_image.json @@ -0,0 +1,6 @@ +{ + "layered-image": { + "background": "$media:background", + "foreground": "$media:foreground" + } +} \ No newline at end of file diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/screen_list_img.jpg b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/screen_list_img.jpg new file mode 100644 index 0000000000000000000000000000000000000000..50402774e9fdefa501eacd2c32b0fb26972ff985 Binary files /dev/null and b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/screen_list_img.jpg differ diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/startIcon.png b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/startIcon.png differ diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/user_background_image.png b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/user_background_image.png new file mode 100644 index 0000000000000000000000000000000000000000..2a5eb29191f4393f04954733652ae244a5f1f664 Binary files /dev/null and b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/media/user_background_image.png differ diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/profile/backup_config.json b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/profile/backup_config.json @@ -0,0 +1,3 @@ +{ + "allowToBackupRestore": true +} \ No newline at end of file diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/profile/main_pages.json b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..6771f82fd0287e0a1f1e04b21134be8c9911f745 --- /dev/null +++ b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,9 @@ +{ + "src": [ + "pages/Index", + "pages/CityListPage", + "pages/ProfilePage", + "pages/ConcurrentOptPage", + "pages/VisionOptPage" + ] +} diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/dark/element/color.json b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..79b11c2747aec33e710fd3a7b2b3c94dd9965499 --- /dev/null +++ b/PerformanceOptimization/OptimizationAppDelay/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/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/en_US/element/string.json b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/en_US/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..f94595515a99e0c828807e243494f57f09251930 --- /dev/null +++ b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/en_US/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/zh_CN/element/string.json b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/zh_CN/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..597ecf95e61d7e30367c22fe2f8638008361b044 --- /dev/null +++ b/PerformanceOptimization/OptimizationAppDelay/entry/src/main/resources/zh_CN/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "模块描述" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/mock/mock-config.json5 b/PerformanceOptimization/OptimizationAppDelay/entry/src/mock/mock-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..7a73a41bfdf76d6f793007240d80983a52f15f97 --- /dev/null +++ b/PerformanceOptimization/OptimizationAppDelay/entry/src/mock/mock-config.json5 @@ -0,0 +1,2 @@ +{ +} \ No newline at end of file diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/ohosTest/ets/test/Ability.test.ets b/PerformanceOptimization/OptimizationAppDelay/entry/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..85c78f67579d6e31b5f5aeea463e216b9b141048 --- /dev/null +++ b/PerformanceOptimization/OptimizationAppDelay/entry/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,35 @@ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }) + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }) + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }) + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }) + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + hilog.info(0x0000, 'testTag', '%{public}s', 'it begin'); + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }) + }) +} \ No newline at end of file diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/ohosTest/ets/test/List.test.ets b/PerformanceOptimization/OptimizationAppDelay/entry/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..794c7dc4ed66bd98fa3865e07922906e2fcef545 --- /dev/null +++ b/PerformanceOptimization/OptimizationAppDelay/entry/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,5 @@ +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/ohosTest/module.json5 b/PerformanceOptimization/OptimizationAppDelay/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..55725a929993a8a18b3808d41ef037759440488b --- /dev/null +++ b/PerformanceOptimization/OptimizationAppDelay/entry/src/ohosTest/module.json5 @@ -0,0 +1,13 @@ +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/test/List.test.ets b/PerformanceOptimization/OptimizationAppDelay/entry/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..bb5b5c3731e283dd507c847560ee59bde477bbc7 --- /dev/null +++ b/PerformanceOptimization/OptimizationAppDelay/entry/src/test/List.test.ets @@ -0,0 +1,5 @@ +import localUnitTest from './LocalUnit.test'; + +export default function testsuite() { + localUnitTest(); +} \ No newline at end of file diff --git a/PerformanceOptimization/OptimizationAppDelay/entry/src/test/LocalUnit.test.ets b/PerformanceOptimization/OptimizationAppDelay/entry/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..969668d0890d5c282797bc1b6a1f22786ed53a7c --- /dev/null +++ b/PerformanceOptimization/OptimizationAppDelay/entry/src/test/LocalUnit.test.ets @@ -0,0 +1,33 @@ +import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it } from '@ohos/hypium'; + +export default function localUnitTest() { + describe('localUnitTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }); + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }); + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }); + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }); + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }); + }); +} \ No newline at end of file diff --git a/PerformanceOptimization/OptimizationAppDelay/hvigor/hvigor-config.json5 b/PerformanceOptimization/OptimizationAppDelay/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..5bebc9755447385d82ce4138f54d991b1f85f348 --- /dev/null +++ b/PerformanceOptimization/OptimizationAppDelay/hvigor/hvigor-config.json5 @@ -0,0 +1,22 @@ +{ + "modelVersion": "5.0.5", + "dependencies": { + }, + "execution": { + // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */ + // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */ + // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */ + // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */ + // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */ + }, + "logging": { + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ + }, + "debugging": { + // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */ + }, + "nodeOptions": { + // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/ + // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/ + } +} diff --git a/PerformanceOptimization/OptimizationAppDelay/hvigorfile.ts b/PerformanceOptimization/OptimizationAppDelay/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..f3cb9f1a87a81687554a76283af8df27d8bda775 --- /dev/null +++ b/PerformanceOptimization/OptimizationAppDelay/hvigorfile.ts @@ -0,0 +1,6 @@ +import { appTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/PerformanceOptimization/OptimizationAppDelay/oh-package-lock.json5 b/PerformanceOptimization/OptimizationAppDelay/oh-package-lock.json5 new file mode 100644 index 0000000000000000000000000000000000000000..7fcf818273347b97063c0c0a151bb14770ca1c79 --- /dev/null +++ b/PerformanceOptimization/OptimizationAppDelay/oh-package-lock.json5 @@ -0,0 +1,27 @@ +{ + "meta": { + "stableOrder": true + }, + "lockfileVersion": 3, + "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", + "specifiers": { + "@ohos/hamock@1.0.0": "@ohos/hamock@1.0.0", + "@ohos/hypium@1.0.21": "@ohos/hypium@1.0.21" + }, + "packages": { + "@ohos/hamock@1.0.0": { + "name": "@ohos/hamock", + "version": "1.0.0", + "integrity": "sha512-K6lDPYc6VkKe6ZBNQa9aoG+ZZMiwqfcR/7yAVFSUGIuOAhPvCJAo9+t1fZnpe0dBRBPxj2bxPPbKh69VuyAtDg==", + "resolved": "https://ohpm.openharmony.cn/ohpm/@ohos/hamock/-/hamock-1.0.0.har", + "registryType": "ohpm" + }, + "@ohos/hypium@1.0.21": { + "name": "@ohos/hypium", + "version": "1.0.21", + "integrity": "sha512-iyKGMXxE+9PpCkqEwu0VykN/7hNpb+QOeIuHwkmZnxOpI+dFZt6yhPB7k89EgV1MiSK/ieV/hMjr5Z2mWwRfMQ==", + "resolved": "https://ohpm.openharmony.cn/ohpm/@ohos/hypium/-/hypium-1.0.21.har", + "registryType": "ohpm" + } + } +} \ No newline at end of file diff --git a/PerformanceOptimization/OptimizationAppDelay/oh-package.json5 b/PerformanceOptimization/OptimizationAppDelay/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..a8aff0c5aff22d78aa26fd19c3861f4320e951ff --- /dev/null +++ b/PerformanceOptimization/OptimizationAppDelay/oh-package.json5 @@ -0,0 +1,10 @@ +{ + "modelVersion": "5.0.5", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.21", + "@ohos/hamock": "1.0.0" + } +} diff --git a/PerformanceOptimization/OptimizationAppMemoryUsage/.gitignore b/PerformanceOptimization/OptimizationAppMemoryUsage/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b --- /dev/null +++ b/PerformanceOptimization/OptimizationAppMemoryUsage/.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/PerformanceOptimization/OptimizationAppMemoryUsage/AppScope/app.json5 b/PerformanceOptimization/OptimizationAppMemoryUsage/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..8d27d7b99fb26baf0e892e8b12ad35af0d2ce050 --- /dev/null +++ b/PerformanceOptimization/OptimizationAppMemoryUsage/AppScope/app.json5 @@ -0,0 +1,10 @@ +{ + "app": { + "bundleName": "com.example.optimizationappmemoryusage", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:layered_image", + "label": "$string:app_name" + } +} diff --git a/PerformanceOptimization/OptimizationAppMemoryUsage/AppScope/resources/base/element/string.json b/PerformanceOptimization/OptimizationAppMemoryUsage/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..baf2ce90c93d2d345f61c5e5a9b491cc23ddb487 --- /dev/null +++ b/PerformanceOptimization/OptimizationAppMemoryUsage/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "OptimizationAppMemoryUsage" + } + ] +} diff --git a/PerformanceOptimization/OptimizationAppMemoryUsage/AppScope/resources/base/media/background.png b/PerformanceOptimization/OptimizationAppMemoryUsage/AppScope/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/PerformanceOptimization/OptimizationAppMemoryUsage/AppScope/resources/base/media/background.png differ diff --git a/PerformanceOptimization/OptimizationAppMemoryUsage/AppScope/resources/base/media/foreground.png b/PerformanceOptimization/OptimizationAppMemoryUsage/AppScope/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/PerformanceOptimization/OptimizationAppMemoryUsage/AppScope/resources/base/media/foreground.png differ diff --git a/PerformanceOptimization/OptimizationAppMemoryUsage/AppScope/resources/base/media/layered_image.json b/PerformanceOptimization/OptimizationAppMemoryUsage/AppScope/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/PerformanceOptimization/OptimizationAppMemoryUsage/AppScope/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/PerformanceOptimization/OptimizationAppMemoryUsage/build-profile.json5 b/PerformanceOptimization/OptimizationAppMemoryUsage/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..9e87e7e6f19020fe21192844709f192cec80fd44 --- /dev/null +++ b/PerformanceOptimization/OptimizationAppMemoryUsage/build-profile.json5 @@ -0,0 +1,42 @@ +{ + "app": { + "signingConfigs": [], + "products": [ + { + "name": "default", + "signingConfig": "default", + "targetSdkVersion": "5.0.5(17)", + "compatibleSdkVersion": "5.0.5(17)", + "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/PerformanceOptimization/OptimizationAppMemoryUsage/code-linter.json5 b/PerformanceOptimization/OptimizationAppMemoryUsage/code-linter.json5 new file mode 100644 index 0000000000000000000000000000000000000000..073990fa45394e1f8e85d85418ee60a8953f9b99 --- /dev/null +++ b/PerformanceOptimization/OptimizationAppMemoryUsage/code-linter.json5 @@ -0,0 +1,32 @@ +{ + "files": [ + "**/*.ets" + ], + "ignore": [ + "**/src/ohosTest/**/*", + "**/src/test/**/*", + "**/src/mock/**/*", + "**/node_modules/**/*", + "**/oh_modules/**/*", + "**/build/**/*", + "**/.preview/**/*" + ], + "ruleSet": [ + "plugin:@performance/recommended", + "plugin:@typescript-eslint/recommended" + ], + "rules": { + "@security/no-unsafe-aes": "error", + "@security/no-unsafe-hash": "error", + "@security/no-unsafe-mac": "warn", + "@security/no-unsafe-dh": "error", + "@security/no-unsafe-dsa": "error", + "@security/no-unsafe-ecdsa": "error", + "@security/no-unsafe-rsa-encrypt": "error", + "@security/no-unsafe-rsa-sign": "error", + "@security/no-unsafe-rsa-key": "error", + "@security/no-unsafe-dsa-key": "error", + "@security/no-unsafe-dh-key": "error", + "@security/no-unsafe-3des": "error" + } +} \ No newline at end of file diff --git a/PerformanceOptimization/OptimizationAppMemoryUsage/entry/.gitignore b/PerformanceOptimization/OptimizationAppMemoryUsage/entry/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/PerformanceOptimization/OptimizationAppMemoryUsage/entry/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/PerformanceOptimization/OptimizationAppMemoryUsage/entry/build-profile.json5 b/PerformanceOptimization/OptimizationAppMemoryUsage/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..4d611879c7913fb0610c686e2399258ab3a6dad1 --- /dev/null +++ b/PerformanceOptimization/OptimizationAppMemoryUsage/entry/build-profile.json5 @@ -0,0 +1,28 @@ +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/PerformanceOptimization/OptimizationAppMemoryUsage/entry/hvigorfile.ts b/PerformanceOptimization/OptimizationAppMemoryUsage/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..c6edcd90486dd5a853cf7d34c8647f08414ca7a3 --- /dev/null +++ b/PerformanceOptimization/OptimizationAppMemoryUsage/entry/hvigorfile.ts @@ -0,0 +1,6 @@ +import { hapTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/PerformanceOptimization/OptimizationAppMemoryUsage/entry/obfuscation-rules.txt b/PerformanceOptimization/OptimizationAppMemoryUsage/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/PerformanceOptimization/OptimizationAppMemoryUsage/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/PerformanceOptimization/OptimizationAppMemoryUsage/entry/oh-package.json5 b/PerformanceOptimization/OptimizationAppMemoryUsage/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..248c3b7541a589682a250f86a6d3ecf7414d2d6a --- /dev/null +++ b/PerformanceOptimization/OptimizationAppMemoryUsage/entry/oh-package.json5 @@ -0,0 +1,10 @@ +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/main/ets/cpps/AddCpp.cpp b/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/main/ets/cpps/AddCpp.cpp new file mode 100644 index 0000000000000000000000000000000000000000..20918240d6ca506663f17581c689edf9eef6d281 --- /dev/null +++ b/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/main/ets/cpps/AddCpp.cpp @@ -0,0 +1,76 @@ +// [Start add_cpp] +#include "napi/native_api.h" +#define DATASIZE (4 * 1024 * 1024) +#include "purgeable_memory/purgeable_memory.h" + +bool ModifyFunc(void *data, size_t size, void *param) { + data = param; + return true; +} +// Business definition object type +class ReqObj; +static napi_value Add(napi_env env, napi_callback_info info) +{ + size_t requireArgc = 2; + size_t argc = 2; + napi_value args[2] = {nullptr}; + napi_get_cb_info(env, info, &argc, args , nullptr, nullptr); + napi_valuetype valuetype0; + napi_typeof(env, args[0], &valuetype0); + napi_valuetype valuetype1; + napi_typeof(env, args[1], &valuetype1); + double value0; + napi_get_value_double(env, args[0], &value0); + double value1; + napi_get_value_double(env, args[1], &value1); + double result = value0 + value1; + // Create a PurgeableMemory object + OH_PurgeableMemory *pPurgmem = OH_PurgeableMemory_Create(DATASIZE, ModifyFunc, &result); + // Read the object + OH_PurgeableMemory_BeginRead(pPurgmem); + // Get the size of PurgeableMemory object + size_t size = OH_PurgeableMemory_ContentSize(pPurgmem); + // Get the content of the PurgeableMemory object + ReqObj *pReqObj = (ReqObj *)OH_PurgeableMemory_GetContent(pPurgmem); + // Read the end of the PurgeableMemory object + OH_PurgeableMemory_EndRead(pPurgmem); + + // Modify the PurgeableMemory object + OH_PurgeableMemory_BeginWrite(pPurgmem); + // Declare the parameters of the extended creation function + double newResult = value0 + value0; + // Update PurgeableMemory object reconstruction rules + OH_PurgeableMemory_AppendModify(pPurgmem, ModifyFunc, &newResult); + // End of modifying the PurgeableMemory object + OH_PurgeableMemory_EndWrite(pPurgmem); + // Destroyed object + OH_PurgeableMemory_Destroy(pPurgmem); + napi_value sum; + napi_create_double(env, result, &sum); + return sum; +} +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + { "add", nullptr, Add, nullptr, nullptr, nullptr, napi_default, nullptr } + }; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void*)0), + .reserved = { 0 }, +}; +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) +{ + napi_module_register(&demoModule); +} +// [End add_cpp] \ No newline at end of file diff --git a/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/main/ets/entryability/EntryAbility.ets b/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..ea52f4922caa3f998d4bc4b2a5781b17bd177774 --- /dev/null +++ b/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,27 @@ +// [Start listen_memory_change] +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; +import { LRUCacheUtil } from '../utils/LRUCacheUtil'; + +export default class EntryAbility extends UIAbility { + // Monitor the changes in memory + onMemoryLevel(level: AbilityConstant.MemoryLevel): void { + // Execute memory management policies according to changes in memory + if (level === AbilityConstant.MemoryLevel.MEMORY_LEVEL_CRITICAL) { + console.log('The memory of device is critical, release memory.'); + if (!LRUCacheUtil.getInstance().isEmpty()) { + LRUCacheUtil.getInstance().clearCache(); + } + } + } + + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } +}; +// [End listen_memory_change] \ No newline at end of file diff --git a/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..8e4de99282050bad799ac892eb85ac5449364a51 --- /dev/null +++ b/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -0,0 +1,16 @@ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit'; + +const DOMAIN = 0x0000; + +export default class EntryBackupAbility extends BackupExtensionAbility { + async onBackup() { + hilog.info(DOMAIN, 'testTag', 'onBackup ok'); + await Promise.resolve(); + } + + async onRestore(bundleVersion: BundleVersion) { + hilog.info(DOMAIN, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion)); + await Promise.resolve(); + } +} \ No newline at end of file diff --git a/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/main/ets/pages/Demo.ets b/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/main/ets/pages/Demo.ets new file mode 100644 index 0000000000000000000000000000000000000000..7c7e7a0b8a989530e2b169bc827001b902190c8a --- /dev/null +++ b/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/main/ets/pages/Demo.ets @@ -0,0 +1,42 @@ +// [Start demo_page] +import { LRUCacheUtil } from '../utils/LRUCacheUtil'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + aboutToAppear(): void { + let lruCache = LRUCacheUtil.getInstance(); + // Add a to lrucache + lruCache.putCache('nation',10); + // Add another to lrucache + lruCache.putCache('menu',8); + // Query value through key + let result0 = lruCache.getCache('2') as number; + console.log('result0:' + result0); + // Delete the specified key and its associated values from the current buffer + let result1 = lruCache.remove('2'); + console.log('result1:' + result1); + // Check whether the current buffer contains the specified object + let result2 = lruCache.contains('1'); + console.log('result2:' + result2); + // Set a new capacity size + let result4 = lruCache.updateCapacity(110); + console.log('result4:' + result4); + } + + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} +// [End demo_page] \ No newline at end of file diff --git a/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/main/ets/pages/ImagePage.ets b/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/main/ets/pages/ImagePage.ets new file mode 100644 index 0000000000000000000000000000000000000000..6a73eaa3c6f0658a582cb7073e42b50078529b85 --- /dev/null +++ b/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/main/ets/pages/ImagePage.ets @@ -0,0 +1,12 @@ +@Component +struct ImagePage { + build() { + // [Start image_page] + Column() { + Image($r('app.media.startIcon')) + .width("500px") + .height("500px") + } + // [End image_page] + } +} \ No newline at end of file diff --git a/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/main/ets/pages/Index.ets b/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..ab56f6e2a2d9e97fb93c619c31642fdae5a96694 --- /dev/null +++ b/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,155 @@ +// [Start network_connection] +import { connection } from '@kit.NetworkKit'; +import { BusinessError } from '@kit.BasicServicesKit'; +import { promptAction } from '@kit.ArkUI'; +import { Logger } from '../utils/Logger'; + +@Entry +@Component +struct Index { + @State networkId: string = '123'; + @State netMessage: string = '初始化网络成功'; + @State connectionMessage: string = '链接成功'; + @State netStateMessage: string = ''; + @State hostName: string = ''; + @State ip: string = ''; + private controller: TabsController = new TabsController(); + private netHandle: connection.NetHandle | null = null; + private netCon: connection.NetConnection | null = null; + scroller: Scroller = new Scroller(); + + aboutToDisappear(): void { + // unregister NetConnection + this.unUseNetworkRegister; + } + + build() { + Column() { + Text('Hello Word') + .fontSize(20) + .fontWeight(FontWeight.Bold) + .textAlign(TextAlign.Start) + .margin({ left: 10 }) + .width(100) + + Column() { + Row() { + Text('Title') + .fontSize(16) + .margin(20) + .fontWeight(FontWeight.Medium) + Blank() + Toggle({ type: ToggleType.Switch, isOn: false }) + .selectedColor(Color.Blue) + .margin({ right: 20 }) + .width(20) + .height(100) + .onChange((isOn) => { + if (isOn) { + this.useNetworkRegister(); + } else { + this.unUseNetworkRegister(); + } + }) + } + .height(100) + .borderRadius(10) + .margin({ left: 10, right: 10 }) + .width(200) + .backgroundColor(Color.Black) + + TextArea({ text: this.netStateMessage }) + .fontSize(16) + .width(200) + .height(100) + .margin(10) + .borderRadius(10) + .textAlign(TextAlign.Start) + .focusOnTouch(false) + + Button('Clear') + .fontSize(18) + .width(200) + .height(40) + .margin({ + left: 10, + right: 10, + bottom: 10 + }) + .onClick(() => { + this.netStateMessage = ''; + }) + Blank() + } + .height(100) + .justifyContent(FlexAlign.Start) + } + .width(200) + } + + getConnectionProperties() { + connection.getDefaultNet().then((netHandle: connection.NetHandle) => { + connection.getConnectionProperties(netHandle, (error: BusinessError, connectionProperties: connection.ConnectionProperties) => { + if (error) { + this.connectionMessage = '连接错误'; + Logger.error('getConnectionProperties error:' + error.code + error.message); + return; + } + this.connectionMessage = '连接' + connectionProperties.interfaceName + + 'developer.huawei.com' + connectionProperties.domains + + '/cn' + JSON.stringify(connectionProperties.linkAddresses) + + '/doc' + JSON.stringify(connectionProperties.routes) + + '/best-pratices' + JSON.stringify(connectionProperties.dnses) + + 'btpa-memory-optimization' + connectionProperties.mtu + '\n'; + }) + }); + } + + useNetworkRegister() { + this.netCon = connection.createNetConnection(); + this.netStateMessage += '连接'; + this.netCon.register((error) => { + if (error) { + Logger.error('register error:' + error.message); + return; + } + this.getUIContext().getPromptAction().showToast({ + message: '连接成功', + duration: 1000 + }); + }) + this.netCon.on('netAvailable', (netHandle) => { + this.netStateMessage += '连接' + netHandle.netId + '\n'; + }) + this.netCon.on('netBlockStatusChange', (data) => { + this.netStateMessage += '更换' + data.netHandle.netId + '\n'; + }) + this.netCon.on('netCapabilitiesChange', (data) => { + this.netStateMessage += 'id' + data.netHandle.netId + + 'cap' + JSON.stringify(data.netCap) + '\n'; + }) + this.netCon.on('netConnectionPropertiesChange', (data) => { + this.netStateMessage += 'id' + data.netHandle.netId + + 'propertis' + JSON.stringify(data.connectionProperties) + '\n'; + }) + } + + unUseNetworkRegister() { + if (this.netCon) { + this.netCon.unregister((error: BusinessError) => { + if (error) { + Logger.error('unregister error:' + error.message); + return; + } + this.getUIContext().getPromptAction().showToast({ + message: 'message', + duration: 1000 + }); + this.netStateMessage += 'listener'; + }) + } else { + this.netStateMessage += 'listener_fail'; + } + } +} +// [End network_connection] \ No newline at end of file diff --git a/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/main/ets/utils/CMakeLists.txt b/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/main/ets/utils/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..5a74a0e2aed14809c8d734ba6c2d3f3e7fddbf71 --- /dev/null +++ b/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/main/ets/utils/CMakeLists.txt @@ -0,0 +1,12 @@ +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.4.1) +project(MyNativeApplication) +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) +if(DEFINED PACKAGE_FIND_FILE) + include(${PACKAGE_FIND_FILE}) +endif() +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) +add_library(entry SHARED napi_init.cpp) +# 引入libpurgeable_memory_ndk.z.so动态链接库 +target_link_libraries(entry PUBLIC libace_napi.z.so libpurgeable_memory_ndk.z.so) \ No newline at end of file diff --git a/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/main/ets/utils/LRUCacheUtil.ets b/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/main/ets/utils/LRUCacheUtil.ets new file mode 100644 index 0000000000000000000000000000000000000000..e6dbc491d08a87e634752dcdcb7a57ef1667e145 --- /dev/null +++ b/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/main/ets/utils/LRUCacheUtil.ets @@ -0,0 +1,61 @@ +// [Start lru_cache_util] +import { util } from '@kit.ArkTS'; + +export class LRUCacheUtil { + private static instance: LRUCacheUtil; + private lruCache: util.LRUCache; + + private constructor() { + this.lruCache = new util.LRUCache(64); + } + + // Get the singleton of LRUCacheUtil + public static getInstance(): LRUCacheUtil { + if (!LRUCacheUtil.instance) { + LRUCacheUtil.instance = new LRUCacheUtil(); + } + return LRUCacheUtil.instance; + } + + // Determine whether the lruCache cache is empty + public isEmpty(): boolean { + return this.lruCache.isEmpty(); + } + + // Get the capacity of lruCache + public getCapacity(): number { + return this.lruCache.getCapacity(); + } + + // Reset the capacity of lruCache + public updateCapacity(newCapacity: number) { + this.lruCache.updateCapacity(newCapacity); + } + + // Add cache to lruCache + public putCache(key: string, value: Object) { + this.lruCache.put(key, value); + } + + // Delete the cache corresponding to the key + public remove(key: string) { + this.lruCache.remove(key); + } + + // Get the cache corresponding to the key + public getCache(key: string): Object | undefined { + return this.lruCache.get(key); + } + + // Determine whether the cache corresponding to the key is included. + public contains(key: string): boolean { + return this.lruCache.contains(key); + } + + // Clear the cached data and reset the size of lruCache + public clearCache() { + this.lruCache.clear(); + this.lruCache.updateCapacity(64); + } +} +// [End lru_cache_util] \ No newline at end of file diff --git a/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/main/ets/utils/Logger.ets b/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/main/ets/utils/Logger.ets new file mode 100644 index 0000000000000000000000000000000000000000..b94c1fc674136cc26c0f31e61ad3cf475d80a32a --- /dev/null +++ b/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/main/ets/utils/Logger.ets @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { hilog } from '@kit.PerformanceAnalysisKit'; + +export class Logger { + static error(arg0: string) { + throw new Error('Method not implemented.'); + } + private domain: number; + private prefix: string; + private format: string = "%{public}s, %{public}s"; + + constructor(prefix: string) { + this.prefix = prefix; + this.domain = 0xFF00; + } + + debug(...args: Object[]): void { + hilog.debug(this.domain, this.prefix, this.format, args); + } + + info(...args: Object[]): void { + hilog.info(this.domain, this.prefix, this.format, args); + } + + warn(...args: Object[]): void { + hilog.warn(this.domain, this.prefix, this.format, args); + } + + error(...args: Object[]): void { + hilog.error(this.domain, this.prefix, this.format, args); + } +} + +export default new Logger('[LandscapePortraitToggle]'); diff --git a/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/main/module.json5 b/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..ad219d733f6afa5ea07f85f580208b08cc3b9041 --- /dev/null +++ b/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/main/module.json5 @@ -0,0 +1,50 @@ +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "phone" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:layered_image", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "EntryBackupAbility", + "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets", + "type": "backup", + "exported": false, + "metadata": [ + { + "name": "ohos.extension.backup", + "resource": "$profile:backup_config" + } + ], + } + ] + } +} \ No newline at end of file diff --git a/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/main/resources/base/element/color.json b/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/PerformanceOptimization/OptimizationAppMemoryUsage/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/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/main/resources/base/element/float.json b/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..33ea22304f9b1485b5f22d811023701b5d4e35b6 --- /dev/null +++ b/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} diff --git a/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/main/resources/base/element/string.json b/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..f94595515a99e0c828807e243494f57f09251930 --- /dev/null +++ b/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/main/resources/base/media/background.png b/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/main/resources/base/media/background.png differ diff --git a/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/main/resources/base/media/foreground.png b/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/main/resources/base/media/foreground.png differ diff --git a/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/main/resources/base/media/layered_image.json b/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/PerformanceOptimization/OptimizationAppMemoryUsage/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/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/main/resources/base/media/startIcon.png b/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/main/resources/base/media/startIcon.png differ diff --git a/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/main/resources/base/profile/backup_config.json b/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/main/resources/base/profile/backup_config.json @@ -0,0 +1,3 @@ +{ + "allowToBackupRestore": true +} \ No newline at end of file diff --git a/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/main/resources/base/profile/main_pages.json b/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce --- /dev/null +++ b/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/main/resources/dark/element/color.json b/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..79b11c2747aec33e710fd3a7b2b3c94dd9965499 --- /dev/null +++ b/PerformanceOptimization/OptimizationAppMemoryUsage/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/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/mock/mock-config.json5 b/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/mock/mock-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..7a73a41bfdf76d6f793007240d80983a52f15f97 --- /dev/null +++ b/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/mock/mock-config.json5 @@ -0,0 +1,2 @@ +{ +} \ No newline at end of file diff --git a/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/ohosTest/ets/test/Ability.test.ets b/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..85c78f67579d6e31b5f5aeea463e216b9b141048 --- /dev/null +++ b/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,35 @@ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }) + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }) + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }) + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }) + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + hilog.info(0x0000, 'testTag', '%{public}s', 'it begin'); + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }) + }) +} \ No newline at end of file diff --git a/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/ohosTest/ets/test/List.test.ets b/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..794c7dc4ed66bd98fa3865e07922906e2fcef545 --- /dev/null +++ b/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,5 @@ +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/ohosTest/module.json5 b/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..509a3a28a3e6be8d7f98cc563fa8195657d77d1d --- /dev/null +++ b/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/ohosTest/module.json5 @@ -0,0 +1,11 @@ +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "phone" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/test/List.test.ets b/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..bb5b5c3731e283dd507c847560ee59bde477bbc7 --- /dev/null +++ b/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/test/List.test.ets @@ -0,0 +1,5 @@ +import localUnitTest from './LocalUnit.test'; + +export default function testsuite() { + localUnitTest(); +} \ No newline at end of file diff --git a/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/test/LocalUnit.test.ets b/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..165fc1615ee8618b4cb6a622f144a9a707eee99f --- /dev/null +++ b/PerformanceOptimization/OptimizationAppMemoryUsage/entry/src/test/LocalUnit.test.ets @@ -0,0 +1,33 @@ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function localUnitTest() { + describe('localUnitTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }); + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }); + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }); + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }); + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }); + }); +} \ No newline at end of file diff --git a/PerformanceOptimization/OptimizationAppMemoryUsage/hvigor/hvigor-config.json5 b/PerformanceOptimization/OptimizationAppMemoryUsage/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..5bebc9755447385d82ce4138f54d991b1f85f348 --- /dev/null +++ b/PerformanceOptimization/OptimizationAppMemoryUsage/hvigor/hvigor-config.json5 @@ -0,0 +1,22 @@ +{ + "modelVersion": "5.0.5", + "dependencies": { + }, + "execution": { + // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */ + // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */ + // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */ + // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */ + // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */ + }, + "logging": { + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ + }, + "debugging": { + // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */ + }, + "nodeOptions": { + // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/ + // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/ + } +} diff --git a/PerformanceOptimization/OptimizationAppMemoryUsage/hvigorfile.ts b/PerformanceOptimization/OptimizationAppMemoryUsage/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..f3cb9f1a87a81687554a76283af8df27d8bda775 --- /dev/null +++ b/PerformanceOptimization/OptimizationAppMemoryUsage/hvigorfile.ts @@ -0,0 +1,6 @@ +import { appTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/PerformanceOptimization/OptimizationAppMemoryUsage/oh-package-lock.json5 b/PerformanceOptimization/OptimizationAppMemoryUsage/oh-package-lock.json5 new file mode 100644 index 0000000000000000000000000000000000000000..7fcf818273347b97063c0c0a151bb14770ca1c79 --- /dev/null +++ b/PerformanceOptimization/OptimizationAppMemoryUsage/oh-package-lock.json5 @@ -0,0 +1,27 @@ +{ + "meta": { + "stableOrder": true + }, + "lockfileVersion": 3, + "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", + "specifiers": { + "@ohos/hamock@1.0.0": "@ohos/hamock@1.0.0", + "@ohos/hypium@1.0.21": "@ohos/hypium@1.0.21" + }, + "packages": { + "@ohos/hamock@1.0.0": { + "name": "@ohos/hamock", + "version": "1.0.0", + "integrity": "sha512-K6lDPYc6VkKe6ZBNQa9aoG+ZZMiwqfcR/7yAVFSUGIuOAhPvCJAo9+t1fZnpe0dBRBPxj2bxPPbKh69VuyAtDg==", + "resolved": "https://ohpm.openharmony.cn/ohpm/@ohos/hamock/-/hamock-1.0.0.har", + "registryType": "ohpm" + }, + "@ohos/hypium@1.0.21": { + "name": "@ohos/hypium", + "version": "1.0.21", + "integrity": "sha512-iyKGMXxE+9PpCkqEwu0VykN/7hNpb+QOeIuHwkmZnxOpI+dFZt6yhPB7k89EgV1MiSK/ieV/hMjr5Z2mWwRfMQ==", + "resolved": "https://ohpm.openharmony.cn/ohpm/@ohos/hypium/-/hypium-1.0.21.har", + "registryType": "ohpm" + } + } +} \ No newline at end of file diff --git a/PerformanceOptimization/OptimizationAppMemoryUsage/oh-package.json5 b/PerformanceOptimization/OptimizationAppMemoryUsage/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..a8aff0c5aff22d78aa26fd19c3861f4320e951ff --- /dev/null +++ b/PerformanceOptimization/OptimizationAppMemoryUsage/oh-package.json5 @@ -0,0 +1,10 @@ +{ + "modelVersion": "5.0.5", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.21", + "@ohos/hamock": "1.0.0" + } +}