diff --git a/ApiUsingStandards/README.md b/ApiUsingStandards/README.md index 758e3646f4538e4f4a480fc3af761327b42a26e3..d3beb85e82c68fbe4d046ee4860b67cb8ef392ee 100644 --- a/ApiUsingStandards/README.md +++ b/ApiUsingStandards/README.md @@ -4,9 +4,29 @@ 本示例是《易错API的使用规范》最佳实践中的代码示例片段。 -##### 使用说明 - -进入首面,点击按钮,分别进入示例页面。 +### 使用说明 + +进入首面,加载示例逻辑。 + + +### 工程目录 + +``` +├──entry/src/main/ets +│ ├──entryability +│ │ └──EntryAbility.ets // 入口类 +│ ├──entrybackupability +│ │ └──EntryBackupAbility.ets // 数据备份类 +│ └──pages +│ ├──animate1.ets // 示例页面 +│ ├──animate2.ets // 示例页面 +│ ├──AVImageGenerator.ets // 示例页面 +│ ├──camera.ets // 示例页面 +│ ├──Index.ets // 示例页面 +│ ├──playStateCallback.ets // 示例页面 +│ └──StyleExample.ets // 示例页面 +└──entry/src/main/resources // 应用资源目录 +``` ### 具体实现 diff --git a/ApiUsingStandards/entry/src/main/module.json5 b/ApiUsingStandards/entry/src/main/module.json5 index a1cea8b6a4560cee7bda7a2db52f310c035ab6c8..ad219d733f6afa5ea07f85f580208b08cc3b9041 100644 --- a/ApiUsingStandards/entry/src/main/module.json5 +++ b/ApiUsingStandards/entry/src/main/module.json5 @@ -5,9 +5,7 @@ "description": "$string:module_desc", "mainElement": "EntryAbility", "deviceTypes": [ - "phone", - "tablet", - "2in1" + "phone" ], "deliveryWithInstall": true, "installationFree": false, diff --git a/ApiUsingStandards/entry/src/main/resources/base/element/string.json b/ApiUsingStandards/entry/src/main/resources/base/element/string.json index f94595515a99e0c828807e243494f57f09251930..9ce98bfb9ff4c08bd128cf4ca71326277260f640 100644 --- a/ApiUsingStandards/entry/src/main/resources/base/element/string.json +++ b/ApiUsingStandards/entry/src/main/resources/base/element/string.json @@ -10,7 +10,7 @@ }, { "name": "EntryAbility_label", - "value": "label" + "value": "ApiUsingStandards" } ] } \ No newline at end of file diff --git a/ApiUsingStandards/oh-package.json5 b/ApiUsingStandards/oh-package.json5 index 75e4e229db0f608fc3d9471c8819d0e52fb403c5..60ef03cdf1b3f06de3df44880fb15d89e87bc1f5 100644 --- a/ApiUsingStandards/oh-package.json5 +++ b/ApiUsingStandards/oh-package.json5 @@ -4,7 +4,5 @@ "dependencies": { }, "devDependencies": { - "@ohos/hypium": "1.0.21", - "@ohos/hamock": "1.0.0" } } diff --git a/AppAspectProgrammingDesign/README.md b/AppAspectProgrammingDesign/README.md index eab3f84f47ce8dc5d14631ab79c35da11d297172..7c20508f3f78160c529d1f511dc44228fcb35c98 100644 --- a/AppAspectProgrammingDesign/README.md +++ b/AppAspectProgrammingDesign/README.md @@ -4,9 +4,32 @@ 本示例是《应用切面编程设计》最佳实践中的代码示例片段。 -##### 使用说明 - -进入首面,点击按钮,分别进入示例页面。 +### 使用说明 + +进入首面,加载示例逻辑。 + +### 工程目录 + +``` +├──entry/src/main/ets +│ ├──entryability +│ │ └──EntryAbility.ets // 入口类 +│ ├──entrybackupability +│ │ └──EntryBackupAbility.ets // 备份恢复类 +│ └──pages +│ ├──Index.ets // 示例页面 +│ ├──Index1.ets // 示例页面 +│ ├──Index2.ets // 示例页面 +│ ├──Index3.ets // 示例页面 +│ ├──Index4.ets // 示例页面 +│ ├──Index5.ets // 示例页面 +│ ├──Index6.ets // 示例页面 +│ ├──Index7.ets // 示例页面 +│ ├──Index8.ets // 示例页面 +│ ├──Index9.ets // 示例页面 +│ └──Index10.ets // 示例页面 +└──entry/src/main/resources // 应用资源目录 +``` ### 具体实现 diff --git a/AppAspectProgrammingDesign/entry/src/main/module.json5 b/AppAspectProgrammingDesign/entry/src/main/module.json5 index a1cea8b6a4560cee7bda7a2db52f310c035ab6c8..ad219d733f6afa5ea07f85f580208b08cc3b9041 100644 --- a/AppAspectProgrammingDesign/entry/src/main/module.json5 +++ b/AppAspectProgrammingDesign/entry/src/main/module.json5 @@ -5,9 +5,7 @@ "description": "$string:module_desc", "mainElement": "EntryAbility", "deviceTypes": [ - "phone", - "tablet", - "2in1" + "phone" ], "deliveryWithInstall": true, "installationFree": false, diff --git a/AppAspectProgrammingDesign/entry/src/main/resources/base/element/string.json b/AppAspectProgrammingDesign/entry/src/main/resources/base/element/string.json index f94595515a99e0c828807e243494f57f09251930..162ff06f3016378f5490c97cae44fff1199ea814 100644 --- a/AppAspectProgrammingDesign/entry/src/main/resources/base/element/string.json +++ b/AppAspectProgrammingDesign/entry/src/main/resources/base/element/string.json @@ -10,7 +10,7 @@ }, { "name": "EntryAbility_label", - "value": "label" + "value": "AppAspectProgrammingDesign" } ] } \ No newline at end of file diff --git a/ClickResponseOptimization/README.md b/ClickResponseOptimization/README.md index ee2a083b4c69208d7176bf0b2dee7b60962d42d4..38e03fd7ad17ae5eed7a11d13f08937efdc058c7 100644 --- a/ClickResponseOptimization/README.md +++ b/ClickResponseOptimization/README.md @@ -4,9 +4,44 @@ 本示例是《点击响应时延分析》最佳实践中的代码示例片段。 -##### 使用说明 - -进入首面,点击按钮,分别进入示例页面。 +### 使用说明 + +进入首面,加载示例逻辑。 + + +### 工程目录 + +``` +├──entry/src/main/ets +│ ├──common/constants +│ │ ├──AppConstant.ets // app常量 +│ │ ├──ChatConstants.ets // chat常量 +│ │ ├──WorldCommonConstants.ets // 公共常量 +│ │ └──WorldConstants.ets // 公共常量 +│ ├──common/db +│ │ ├──AccountData.ets // account数据 +│ │ ├──AccountTable.ets // account表 +│ │ └──Rdb.ets // rdb工具类 +│ ├──entryability +│ │ └──EntryAbility.ets // 入口类 +│ ├──model +│ │ └──ChatModel.ets // chat数据模型 +│ ├──pages +│ │ ├──CameraOptPage.ets // 示例页面 +│ │ ├──CameraPage.ets // 示例页面 +│ │ ├──CityListPage.ets // 示例页面 +│ │ ├──ConcurrentOptPage.ets // 示例页面 +│ │ ├──Index.ets // 首页 +│ │ ├──PanGestureDistanceOptPage.ets // 示例页面 +│ │ ├──PanGestureDistancePage.ets // 示例页面 +│ │ ├──ProfilePage.ets // 示例页面 +│ │ └──VisionOptPage.ets // 示例页面 +│ └──view +│ ├──ArticleSkeletonView.ets // 骨架屏view +│ ├──LoadingView.ets // 加载view +│ └──OptChatItemView.ets // 优化后的chat view +└──entry/src/main/resources // 应用资源目录 +``` ### 具体实现 diff --git a/ClickResponseOptimization/entry/obfuscation-rules.txt b/ClickResponseOptimization/entry/obfuscation-rules.txt index 985b2aeb7658286b17bd26eab8f217c3fe75ea8b..a1dfa0bd175984dc49e641436aa67b1de1b8abeb 100644 --- a/ClickResponseOptimization/entry/obfuscation-rules.txt +++ b/ClickResponseOptimization/entry/obfuscation-rules.txt @@ -15,4 +15,8 @@ # 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 +# -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/ClickResponseOptimization/entry/src/main/resources/base/element/string.json b/ClickResponseOptimization/entry/src/main/resources/base/element/string.json index f94595515a99e0c828807e243494f57f09251930..c622bd7ced26f4ec40d3baefc11a90f1502469db 100644 --- a/ClickResponseOptimization/entry/src/main/resources/base/element/string.json +++ b/ClickResponseOptimization/entry/src/main/resources/base/element/string.json @@ -10,7 +10,7 @@ }, { "name": "EntryAbility_label", - "value": "label" + "value": "ClickResponseOptimization" } ] } \ No newline at end of file diff --git a/ClickResponseOptimization/entry/src/main/resources/zh_CN/element/string.json b/ClickResponseOptimization/entry/src/main/resources/zh_CN/element/string.json index 597ecf95e61d7e30367c22fe2f8638008361b044..c999478abae583b3eaa8c936905ab327cb3d5127 100644 --- a/ClickResponseOptimization/entry/src/main/resources/zh_CN/element/string.json +++ b/ClickResponseOptimization/entry/src/main/resources/zh_CN/element/string.json @@ -10,7 +10,7 @@ }, { "name": "EntryAbility_label", - "value": "label" + "value": "点击响应优化" } ] } \ No newline at end of file diff --git a/ComponentReuse/README.md b/ComponentReuse/README.md index b523843fee6d42ce690f3e59633551c824b4e1cd..bfd29ada7208f9bbf771165664779fa8b7f2c74d 100644 --- a/ComponentReuse/README.md +++ b/ComponentReuse/README.md @@ -16,14 +16,14 @@ HarmonyOS应用框架提供了组件复用能力:可复用组件树上移除 |-----------------------------------------|-----------------------------------------| | ![image](screenshots/device/mode_3.gif) | ![image](screenshots/device/mode_4.gif) | -#### 使用说明 +### 使用说明 -1. 点击“减少组件复用的嵌套层级”按钮,进入二级页面“附近的人”, 滑动列表。 -2. 点击“精准控制组件刷新范围”按钮,进入二级页面“附近的人”, 滑动列表。 -3. 点击“使用reuseId标记不同的组件”按钮,进入二级页面“附近的人”, 滑动列表。 -4. 点击“复用组件创建时的@State变量入参”按钮,进入二级页面“附近的人”, 滑动列表。 +1. 点击“减少组件复用的嵌套层级”按钮,进入二级页面, 滑动列表。 +2. 点击“精准控制组件刷新范围”按钮,进入二级页面, 滑动列表。 +3. 点击“使用reuseId标记不同的组件”按钮,进入二级页面, 滑动列表。 +4. 点击“复用组件创建时的@State变量入参”按钮,进入二级页面, 滑动列表。 -## 工程目录 +### 工程目录 ``` ├──entry/src/main/ets @@ -39,7 +39,7 @@ HarmonyOS应用框架提供了组件复用能力:可复用组件树上移除 │ │ ├──BasicDataSource.ets // 数据适配器基类 │ │ ├──ColorData.ets // 二级页面“文字列表”的数据适配器 │ │ └──FriendMomentData.ets // 二级页面“附近的人”/“图文列表”/“网名列表”的数据适配器 -│ ├──pages.ets +│ ├──pages │ │ ├──ImproveReuseHitRate.ets // 提升复用命中率 │ │ ├──Index.ets // 首页 │ │ ├──ReuseNested.ets // 复用嵌套 @@ -57,7 +57,7 @@ HarmonyOS应用框架提供了组件复用能力:可复用组件树上移除 不涉及 -## 约束与限制 +### 约束与限制 * 本示例仅支持标准系统上运行,支持设备:华为手机。 * HarmonyOS系统:HarmonyOS 5.0.5 Release及以上。 diff --git a/ComponentReuse/README_EN.md b/ComponentReuse/README_EN.md index 07403082a46f32b66022be100a116409e8242f3e..b7d2c2d72e20c7cf76e229a47684c920520e9344 100644 --- a/ComponentReuse/README_EN.md +++ b/ComponentReuse/README_EN.md @@ -39,7 +39,7 @@ The practices describe how to use the component reuse mechanism to improve the a │ │ ├──BasicDataSource.ets // Basic data adapter │ │ ├──ColorData.ets // Data adapter of Text list on the level-2 page │ │ └──FriendMomentData.ets // Data adapter of Nearby people, Image-text list, and Username list on the level-2 page -│ ├──pages.ets +│ ├──pages │ │ ├──ImproveReuseHitRate.ets // Improve reuse HitRate │ │ ├──Index.ets // Home page │ │ ├──ReuseNested.ets // Reuse nested diff --git a/ComponentReuse/entry/src/main/ets/model/ColorData.ets b/ComponentReuse/entry/src/main/ets/model/ColorData.ets index 2477328f8f42ba7e28b93ca08a37ec7b22bb90b5..8740e9a01075dfed669503608f350720290911af 100644 --- a/ComponentReuse/entry/src/main/ets/model/ColorData.ets +++ b/ComponentReuse/entry/src/main/ets/model/ColorData.ets @@ -17,6 +17,12 @@ import { BasicDataSource, ColorModel } from './BasicDataSource'; export class ColorData extends BasicDataSource { textColorData: Array = []; + private context: Context | undefined = undefined; + + constructor(context?: Context) { + super(); + this.context = context; + } public totalCount(): number { return this.textColorData.length; @@ -42,7 +48,7 @@ export class ColorData extends BasicDataSource { let colorModel: ColorModel = new ColorModel('', '', Color.White); colorModel.id = Math.floor(this.totalCount() / 10) + i.toString(); colorModel.text = - getContext().resourceManager.getStringSync($r('app.string.update_component_title'), parseInt(colorModel.id) + 1); + this.context!.resourceManager.getStringSync($r('app.string.update_component_title'), parseInt(colorModel.id) + 1); colorModel.color = color[i]; this.pushData(colorModel); } diff --git a/ComponentReuse/entry/src/main/ets/model/FriendMomentData.ets b/ComponentReuse/entry/src/main/ets/model/FriendMomentData.ets index d7cdbaef9672f94331277a89eae619a0646059bb..c6af2a7dc101a917a3a45ab803dd1381c5a34a43 100644 --- a/ComponentReuse/entry/src/main/ets/model/FriendMomentData.ets +++ b/ComponentReuse/entry/src/main/ets/model/FriendMomentData.ets @@ -20,9 +20,11 @@ import { Constants } from '../common/Constants'; export class FriendMomentsData extends BasicDataSource { private friendMoments: Array = []; private mode: string | undefined = ''; + private context: Context | undefined = undefined; - constructor(mode?: string) { + constructor(context?: Context,mode?: string) { super(); + this.context = context; this.mode = mode; } @@ -43,7 +45,7 @@ export class FriendMomentsData extends BasicDataSource { } public async getFriendMomentFromRawFile(): Promise { - const resourceManager = getContext().resourceManager; + const resourceManager = this.context!.resourceManager; const res = await resourceManager.getRawFileContent('mockFriendMomentOneModelData.json'); const textDecoder = util.TextDecoder.create(); const friendMomentArray = (JSON.parse(textDecoder.decodeToString(res)) as FriendMomentsData).friendMoments; diff --git a/ComponentReuse/entry/src/main/ets/view/PageListSlideToHistory.ets b/ComponentReuse/entry/src/main/ets/view/PageListSlideToHistory.ets index cc35bc15018a5fec9b0f7591b96c3b816221287c..fe641679fcb3fcf0e359a75db0d7e38850cfede2 100644 --- a/ComponentReuse/entry/src/main/ets/view/PageListSlideToHistory.ets +++ b/ComponentReuse/entry/src/main/ets/view/PageListSlideToHistory.ets @@ -25,7 +25,7 @@ export struct PageListSlideToHistory { private readonly ANIMATION_DURATION: number = 500; private readonly DEFAULT_VISIBLE_BTN_INDEX: number = 3; // Show jump history button when scroll more than 3 item private readonly LIST_CACHE_COUNT: number = 3; - private momentData: FriendMomentsData = new FriendMomentsData(); + private momentData: FriendMomentsData = new FriendMomentsData(this.getUIContext().getHostContext()); private listScroller: ListScroller = new ListScroller(); private historyOffset: number = 0; private isHistoricalRecord: boolean = false; diff --git a/ComponentReuse/entry/src/main/ets/view/UpdaterComponent.ets b/ComponentReuse/entry/src/main/ets/view/UpdaterComponent.ets index 8dc2597a837b51e6b95a44d2f414ebfa3a680af0..b8843afbe2952840a1350d1461eb42c94f35bcf6 100644 --- a/ComponentReuse/entry/src/main/ets/view/UpdaterComponent.ets +++ b/ComponentReuse/entry/src/main/ets/view/UpdaterComponent.ets @@ -39,7 +39,7 @@ export class MyTextUpdater extends AttributeUpdater { // [StartExclude opt_updater] @Component export struct UpdaterComponent { - private colorData: ColorData = new ColorData(); + private colorData: ColorData = new ColorData(this.getUIContext().getHostContext()); private readonly LIST_CACHE_COUNT: number = 5; private readonly LIST_SPACE: number = 18; diff --git a/ComponentReuse/entry/src/main/ets/view/WithFuncParam.ets b/ComponentReuse/entry/src/main/ets/view/WithFuncParam.ets index 963ea7b67ec78ccc03d80bb29cd94fed420cdc72..2c8ff2a9373281b2cd43c82819909c155bafa3f4 100644 --- a/ComponentReuse/entry/src/main/ets/view/WithFuncParam.ets +++ b/ComponentReuse/entry/src/main/ets/view/WithFuncParam.ets @@ -24,7 +24,8 @@ import { FriendMomentsData } from '../model/FriendMomentData'; struct WithFuncParam { @State sum: number = 0; // [StartExclude opt_funcParam] - private momentData: FriendMomentsData = new FriendMomentsData(Constants.NAV_DESTINATION_ITEM_3); + private momentData: FriendMomentsData = + new FriendMomentsData(this.getUIContext().getHostContext(), Constants.NAV_DESTINATION_ITEM_3); private readonly LIST_CACHE_COUNT: number = 5; private readonly LIST_SPACE: number = 18; // [EndExclude opt_funcParam] diff --git a/ComponentReuse/entry/src/main/ets/view/WithReuseId.ets b/ComponentReuse/entry/src/main/ets/view/WithReuseId.ets index 462b1a7afa32b27d0d3f5914fb1435c749538d96..c702345d2244c108315602c26532671871144874 100644 --- a/ComponentReuse/entry/src/main/ets/view/WithReuseId.ets +++ b/ComponentReuse/entry/src/main/ets/view/WithReuseId.ets @@ -23,7 +23,7 @@ import { FriendMomentsData } from '../model/FriendMomentData' @Component struct WithReuseId { // [StartExclude opt_reuseId] - private momentData: FriendMomentsData = new FriendMomentsData(); + private momentData: FriendMomentsData = new FriendMomentsData(this.getUIContext().getHostContext()); private readonly LIST_CACHE_COUNT: number = 5; private readonly LIST_SPACE: number = 18; diff --git a/ComponentReuse/entry/src/main/resources/en_US/element/string.json b/ComponentReuse/entry/src/main/resources/en_US/element/string.json index 1c04e82de4ae97336282418d1fad24937a2689c0..02cb0a9a0dc390b10bb7c79737968c21db6bb6cc 100644 --- a/ComponentReuse/entry/src/main/resources/en_US/element/string.json +++ b/ComponentReuse/entry/src/main/resources/en_US/element/string.json @@ -10,7 +10,7 @@ }, { "name": "EntryAbility_label", - "value": "label" + "value": "ComponentReuse" }, { "name": "nav_destination_item0", diff --git a/HapAndHarDependHar/README.md b/HapAndHarDependHar/README.md index 25571c313df47884c2aadcdbea1aa24006c385c2..9223b93be64191ea6d2f2be418819ad4591a805e 100644 --- a/HapAndHarDependHar/README.md +++ b/HapAndHarDependHar/README.md @@ -4,14 +4,31 @@ 本示例是《模块化设计》最佳实践中的代码示例片段。 -##### 使用说明 - -进入首面,点击按钮,分别进入示例页面。 +### 使用说明 + +进入首面,加载示例逻辑。 + +### 工程目录 +``` +├──entry/src/main/ets +│ ├──entryability +│ │ └──EntryAbility.ets // Ability入口类 +│ └──pages +│ └──Index.ets // 首页 +├──har_common/src/main/ets +│ ├──components +│ │ └──MainPage.ets // common模块中MainPage +│ └──utils +│ └──Utils.ets // 工具类 +└──har_library/src/main/ets + └──components/mainpage + └──MainPage.ets // library模块中MainPage +``` ### 具体实现 -1. 分别包括三个模块:主业务模块entry,公共模块har_commont,库模块har_library +1. 分别包括三个模块:主业务模块entry,公共模块har_common,库模块har_library ### 相关权限 diff --git a/HapAndHarDependHar/entry/obfuscation-rules.txt b/HapAndHarDependHar/entry/obfuscation-rules.txt index 985b2aeb7658286b17bd26eab8f217c3fe75ea8b..a1dfa0bd175984dc49e641436aa67b1de1b8abeb 100644 --- a/HapAndHarDependHar/entry/obfuscation-rules.txt +++ b/HapAndHarDependHar/entry/obfuscation-rules.txt @@ -15,4 +15,8 @@ # 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 +# -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/HapAndHarDependHar/entry/src/main/resources/base/element/string.json b/HapAndHarDependHar/entry/src/main/resources/base/element/string.json index f94595515a99e0c828807e243494f57f09251930..47d750c25c23e102a481e5ab3727ee748db572cf 100644 --- a/HapAndHarDependHar/entry/src/main/resources/base/element/string.json +++ b/HapAndHarDependHar/entry/src/main/resources/base/element/string.json @@ -10,7 +10,7 @@ }, { "name": "EntryAbility_label", - "value": "label" + "value": "HapAndHarDependHar" } ] } \ No newline at end of file diff --git a/HapAndHarDependHar/har_common/obfuscation-rules.txt b/HapAndHarDependHar/har_common/obfuscation-rules.txt index 985b2aeb7658286b17bd26eab8f217c3fe75ea8b..a1dfa0bd175984dc49e641436aa67b1de1b8abeb 100644 --- a/HapAndHarDependHar/har_common/obfuscation-rules.txt +++ b/HapAndHarDependHar/har_common/obfuscation-rules.txt @@ -15,4 +15,8 @@ # 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 +# -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/HapAndHarDependHar/har_library/obfuscation-rules.txt b/HapAndHarDependHar/har_library/obfuscation-rules.txt index 985b2aeb7658286b17bd26eab8f217c3fe75ea8b..a1dfa0bd175984dc49e641436aa67b1de1b8abeb 100644 --- a/HapAndHarDependHar/har_library/obfuscation-rules.txt +++ b/HapAndHarDependHar/har_library/obfuscation-rules.txt @@ -15,4 +15,8 @@ # 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 +# -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/JSCrash/README.md b/JSCrash/README.md index 87b927c81b77044891d2a853fa5f262eb76a8a80..e60141283905625d990873407c0d88635d07be1d 100644 --- a/JSCrash/README.md +++ b/JSCrash/README.md @@ -43,7 +43,7 @@ ### 约束与限制 -1. 本示例仅支持标准系统上运行,支持设备:华为手机、华为PC/2in1设备、华为平板。 +1. 本示例仅支持标准系统上运行,支持设备:华为手机。 2. HarmonyOS系统:HarmonyOS NEXT 5.0.5 Release及以上。 diff --git a/JSCrash/entry/src/main/ets/pages/Index.ets b/JSCrash/entry/src/main/ets/pages/Index.ets index 841fa4da997d915d282019f72b90246e2b07b50f..35886cdece20cb73bb5a77e0298468a9d52c75bc 100644 --- a/JSCrash/entry/src/main/ets/pages/Index.ets +++ b/JSCrash/entry/src/main/ets/pages/Index.ets @@ -18,10 +18,6 @@ struct Index { middle: { anchor: '__container__', align: HorizontalAlign.Center } }) .onClick(() => { - // [Start xiaoming] - let test:string = "{name:'xiaoming' age:10}"; - let result:object = JSON.parse(test); - // [End xiaoming] this.message = 'Welcome'; }) } diff --git a/JSCrash/entry/src/main/module.json5 b/JSCrash/entry/src/main/module.json5 index a1cea8b6a4560cee7bda7a2db52f310c035ab6c8..ad219d733f6afa5ea07f85f580208b08cc3b9041 100644 --- a/JSCrash/entry/src/main/module.json5 +++ b/JSCrash/entry/src/main/module.json5 @@ -5,9 +5,7 @@ "description": "$string:module_desc", "mainElement": "EntryAbility", "deviceTypes": [ - "phone", - "tablet", - "2in1" + "phone" ], "deliveryWithInstall": true, "installationFree": false, diff --git a/JSCrash/entry/src/main/resources/base/element/string.json b/JSCrash/entry/src/main/resources/base/element/string.json index f94595515a99e0c828807e243494f57f09251930..fe7f30a579005c28973798a23aafb25485fd0ad5 100644 --- a/JSCrash/entry/src/main/resources/base/element/string.json +++ b/JSCrash/entry/src/main/resources/base/element/string.json @@ -10,7 +10,7 @@ }, { "name": "EntryAbility_label", - "value": "label" + "value": "JSCrash" } ] } \ No newline at end of file diff --git a/LibuvDevelopment/README.md b/LibuvDevelopment/README.md index ea10fe83b9e75b87da53a9e90a2c021e45f68e66..03fad0ef0882ec2df39693e8213e3bd1cf733155 100644 --- a/LibuvDevelopment/README.md +++ b/LibuvDevelopment/README.md @@ -4,11 +4,24 @@ 本示例是《libuv使用规范及案例》最佳实践中的代码示例片段。 -##### 使用说明 +### 使用说明 -进入首面,点击按钮,分别进入示例页面。 +进入首面,加载示例逻辑。 +### 工程目录 + +``` +├──entry/src/main/ets +│ ├──entryability +│ │ └──EntryAbility.ets // 入口类 +│ ├──entrybackupability +│ │ └──EntryBackupAbility.ets // 数据备份类 +│ └──pages +│ └──Index.ets // 示例页面 +└──entry/src/main/resources // 应用资源目录 +``` + ### 具体实现 1. 主要介绍libuv使用规范及案例,提供代码示例。 diff --git a/LibuvDevelopment/entry/src/main/module.json5 b/LibuvDevelopment/entry/src/main/module.json5 index a1cea8b6a4560cee7bda7a2db52f310c035ab6c8..ad219d733f6afa5ea07f85f580208b08cc3b9041 100644 --- a/LibuvDevelopment/entry/src/main/module.json5 +++ b/LibuvDevelopment/entry/src/main/module.json5 @@ -5,9 +5,7 @@ "description": "$string:module_desc", "mainElement": "EntryAbility", "deviceTypes": [ - "phone", - "tablet", - "2in1" + "phone" ], "deliveryWithInstall": true, "installationFree": false, diff --git a/LibuvDevelopment/entry/src/main/resources/base/element/string.json b/LibuvDevelopment/entry/src/main/resources/base/element/string.json index f94595515a99e0c828807e243494f57f09251930..5d298c928386f90ceeb0573710a0a9d92cf956a2 100644 --- a/LibuvDevelopment/entry/src/main/resources/base/element/string.json +++ b/LibuvDevelopment/entry/src/main/resources/base/element/string.json @@ -10,7 +10,7 @@ }, { "name": "EntryAbility_label", - "value": "label" + "value": "LibuvDevelopment" } ] } \ No newline at end of file diff --git a/NodeAPIDevelopment/README.md b/NodeAPIDevelopment/README.md index b586a1d1fbd9328504399fbdadd90ef8c647b904..854f1da46506b4508f40a2c986851d8ebe13a3b1 100644 --- a/NodeAPIDevelopment/README.md +++ b/NodeAPIDevelopment/README.md @@ -4,10 +4,26 @@ 本示例是《Node-API开发规范》最佳实践中的代码示例片段。 -##### 使用说明 - -进入首面,点击按钮,分别进入示例页面。 - +### 使用说明 + +进入首面,加载示例逻辑。 + + +### 工程目录 + +``` +├──entry/src/main/ets +│ ├──entryability +│ │ └──EntryAbility.ets // 入口类 +│ ├──entrybackupability +│ │ └──EntryBackupAbility.ets // 数据备份类 +│ ├──pages +│ │ ├──Index.ets // 示首页 +│ │ └──Test.ets // 示例页面 +│ └──view +│ └──Worker.ets // worker示例 +└──entry/src/main/resources // 应用资源目录 +``` ### 具体实现 diff --git a/NodeAPIDevelopment/entry/src/main/module.json5 b/NodeAPIDevelopment/entry/src/main/module.json5 index a1cea8b6a4560cee7bda7a2db52f310c035ab6c8..ad219d733f6afa5ea07f85f580208b08cc3b9041 100644 --- a/NodeAPIDevelopment/entry/src/main/module.json5 +++ b/NodeAPIDevelopment/entry/src/main/module.json5 @@ -5,9 +5,7 @@ "description": "$string:module_desc", "mainElement": "EntryAbility", "deviceTypes": [ - "phone", - "tablet", - "2in1" + "phone" ], "deliveryWithInstall": true, "installationFree": false, diff --git a/NodeAPIDevelopment/entry/src/main/resources/base/element/string.json b/NodeAPIDevelopment/entry/src/main/resources/base/element/string.json index f94595515a99e0c828807e243494f57f09251930..cd60dc68f3202aba1eda130ff00e4578a26b5709 100644 --- a/NodeAPIDevelopment/entry/src/main/resources/base/element/string.json +++ b/NodeAPIDevelopment/entry/src/main/resources/base/element/string.json @@ -10,7 +10,7 @@ }, { "name": "EntryAbility_label", - "value": "label" + "value": "NodeAPIDevelopment" } ] } \ No newline at end of file diff --git a/Privacy/README.md b/Privacy/README.md index 870130d6f7e1923608e6a0f4b9d398f8c3f04f53..2db609eb1c2e0fae7fb05ab786508a478fe1ae4f 100644 --- a/Privacy/README.md +++ b/Privacy/README.md @@ -4,9 +4,23 @@ 本示例是应用安全编码实践、应用资产保护设计、应用代码混淆、网络连接安全配置四篇最佳实践中的代码示例片段。 -##### 使用说明 +### 使用说明 -本示例为最佳实践示例代码,开发者可以查阅官网最佳实践下应用安全编码实践、应用资产保护设计、应用代码混淆、网络连接安全配置四篇最佳实践学习。 +进入首面,加载示例逻辑。 + + +### 工程目录 + +``` +├──privacy/src/main/ets +│ ├──privacyability +│ │ └──PrivacyAbility.ets // 入口类 +│ ├──privacybackupability +│ │ └──PrivacyBackupAbility.ets // 数据备份类 +│ └──pages +│ └──Index.ets // 示例页面 +└──entry/src/main/resources // 应用资源目录 +``` ### 相关权限 diff --git a/Privacy/privacy/src/main/module.json5 b/Privacy/privacy/src/main/module.json5 index 2f1ce9ad0cdaa43b9be2cae7072d3c87704314d4..1e9e31049bbcca2867e12d7078f609a77096f564 100644 --- a/Privacy/privacy/src/main/module.json5 +++ b/Privacy/privacy/src/main/module.json5 @@ -5,9 +5,7 @@ "description": "$string:module_desc", "mainElement": "PrivacyAbility", "deviceTypes": [ - "phone", - "tablet", - "2in1" + "phone" ], "deliveryWithInstall": true, "installationFree": false, diff --git a/Privacy/privacy/src/main/resources/base/element/string.json b/Privacy/privacy/src/main/resources/base/element/string.json index 4aeaabf1612bd4f19a3208e044f80a49b0d731d1..b4d2fd4bc1840c9c273bbe1208696963fe37886b 100644 --- a/Privacy/privacy/src/main/resources/base/element/string.json +++ b/Privacy/privacy/src/main/resources/base/element/string.json @@ -10,7 +10,7 @@ }, { "name": "PrivacyAbility_label", - "value": "label" + "value": "Privacy" } ] } \ No newline at end of file diff --git a/RationalUseOfFrontEndResources/README.md b/RationalUseOfFrontEndResources/README.md index 5d08e95fa26a2f1b559c3b9a0d6f7730dc506649..0a8292b8aaf72518670f2f46b4b9b2057ffca5d0 100644 --- a/RationalUseOfFrontEndResources/README.md +++ b/RationalUseOfFrontEndResources/README.md @@ -5,18 +5,16 @@ APM(Application Performance Management)是一种用于监控和管理应用程序性能的解决方案。它通过收集、分析和报告应用程序的性能数据,帮助开发和运维团队快速定位并解决应用程序问题,提高应用程序的可靠性和性能。HarmonyOS 提供了完善的 HiAppEvent 机制,帮助开发者上报稳定性、性能等应用事件,开发者可以利用它构建自身的 APM 系统。 低功耗是指设备在执行各种任务时,通过应用一系列技术和策略来减少能耗,从而延长电池寿命和设备使用时间。手机等移动设备因其便携、移动的特性,续航时间的长短直接影响用户对品牌的体验和满意度。 -### 工程结构&模块类型 +### 工程结构 ``` ├──entry/src/main/ets/ -│ ├──mock -│ │ └──GoodsMock.ets // 模拟数据类 │ ├──entryability -│ │ └──EntryAbility.ets // 配置类 -│ └──model -│ │ └──GoodsModel.ets // 类型声明 +│ │ └──EntryAbility.ets // 程序入口类 +│ └──entrybackupability +│ │ └──EntryBackupAbility.ets // 备份类 │ └──pages -│ └──Index.ets // 程序入口类 +│ └──Index.ets // 入口页面 │ └──MonitorCrash.ets // 崩溃监测实践文章配套代码 │ └──MusicPlayRule.ets // 音乐播放场景低功耗规则文章配套代码 │ └──NavigationAndPositioningRule.ets // 导航定位场景低功耗规则文章配套代码 diff --git a/RationalUseOfFrontEndResources/entry/src/main/ets/pages/VideoSceneEncoding.cpp b/RationalUseOfFrontEndResources/entry/src/main/cpp/VideoSceneEncoding.cpp similarity index 47% rename from RationalUseOfFrontEndResources/entry/src/main/ets/pages/VideoSceneEncoding.cpp rename to RationalUseOfFrontEndResources/entry/src/main/cpp/VideoSceneEncoding.cpp index 7321b30114941f72ed8e63ed7fdc4f10f02144f8..4229226b0f40400c657d1ab8ad6d3c36c45f4f12 100644 --- a/RationalUseOfFrontEndResources/entry/src/main/ets/pages/VideoSceneEncoding.cpp +++ b/RationalUseOfFrontEndResources/entry/src/main/cpp/VideoSceneEncoding.cpp @@ -1,4 +1,21 @@ - +/* + * Copyright (c) 2025 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. + */ + +#include +#include +#include /** * 视频场景编解码低功耗规则 */ @@ -13,5 +30,5 @@ const char *name = OH_AVCapability_GetName(capability); // Hard solution: Create H264 decoder. When there are multiple optional decoders, the system will create the most suitable decoder OH_AVCodec *videoDec = OH_VideoDecoder_CreateByMime(OH_AVCODEC_MIMETYPE_VIDEO_AVC); // Hard solution: Create H265 decoder -OH_AVCodec *videoDec = OH_VideoDecoder_CreateByMime(OH_AVCODEC_MIMETYPE_VIDEO_HEVC); +OH_AVCodec *videoDecH = OH_VideoDecoder_CreateByMime(OH_AVCODEC_MIMETYPE_VIDEO_HEVC); // [End VideoSceneEncoding] \ No newline at end of file diff --git a/RationalUseOfFrontEndResources/entry/src/main/module.json5 b/RationalUseOfFrontEndResources/entry/src/main/module.json5 index a1cea8b6a4560cee7bda7a2db52f310c035ab6c8..ad219d733f6afa5ea07f85f580208b08cc3b9041 100644 --- a/RationalUseOfFrontEndResources/entry/src/main/module.json5 +++ b/RationalUseOfFrontEndResources/entry/src/main/module.json5 @@ -5,9 +5,7 @@ "description": "$string:module_desc", "mainElement": "EntryAbility", "deviceTypes": [ - "phone", - "tablet", - "2in1" + "phone" ], "deliveryWithInstall": true, "installationFree": false, diff --git a/RationalUseOfFrontEndResources/entry/src/main/resources/base/element/string.json b/RationalUseOfFrontEndResources/entry/src/main/resources/base/element/string.json index f94595515a99e0c828807e243494f57f09251930..370c36047c0736cb62ba8e3c82bb29cae2952947 100644 --- a/RationalUseOfFrontEndResources/entry/src/main/resources/base/element/string.json +++ b/RationalUseOfFrontEndResources/entry/src/main/resources/base/element/string.json @@ -10,7 +10,7 @@ }, { "name": "EntryAbility_label", - "value": "label" + "value": "RationalUseOfFrontEndResources" } ] } \ No newline at end of file diff --git a/StabilityCodingSpecification/DevEcoStaticCheck/src/main/module.json5 b/StabilityCodingSpecification/DevEcoStaticCheck/src/main/module.json5 index 5d96966c895dab6d7573ca5a9dc256cf65ac3176..f2f3e7bf0893f32fe7d2181be938169f926420c6 100644 --- a/StabilityCodingSpecification/DevEcoStaticCheck/src/main/module.json5 +++ b/StabilityCodingSpecification/DevEcoStaticCheck/src/main/module.json5 @@ -5,9 +5,7 @@ "description": "$string:module_desc", "mainElement": "DevEcoStaticCheckAbility", "deviceTypes": [ - "phone", - "tablet", - "2in1" + "phone" ], "deliveryWithInstall": true, "installationFree": false, diff --git a/StabilityCodingSpecification/DevEcoStaticCheck/src/main/resources/base/element/string.json b/StabilityCodingSpecification/DevEcoStaticCheck/src/main/resources/base/element/string.json index 18f3a211cf341fd7db82ddf7c6e8fab573c4d729..3500f95bcc2057c8e94e7483be807b70b381470e 100644 --- a/StabilityCodingSpecification/DevEcoStaticCheck/src/main/resources/base/element/string.json +++ b/StabilityCodingSpecification/DevEcoStaticCheck/src/main/resources/base/element/string.json @@ -10,7 +10,7 @@ }, { "name": "DevEcoStaticCheckAbility_label", - "value": "label" + "value": "DevEcoStaticCheck" } ] } \ No newline at end of file diff --git a/StabilityCodingSpecification/README.md b/StabilityCodingSpecification/README.md index 82c5f3fd740bd0e91e50c2402dc771d7d9705919..1dca25d7d83778ade37254b9cc5cafbea15268da 100644 --- a/StabilityCodingSpecification/README.md +++ b/StabilityCodingSpecification/README.md @@ -4,9 +4,24 @@ 本示例是《NDK开发ArkTS侧编码规范》《使用DevEco Studio静态检测编码规范》最佳实践中的代码示例片段。 -##### 使用说明 +### 使用说明 + +进入首面,加载示例逻辑。 + + +### 工程目录 + +``` +├──DevEcoStaticCheck/src/main/ets +│ ├──devecostaticcheckability +│ │ └──DevEcoStaticCheckAbility.ets // 入口类 +│ └──pages +│ ├──Index.ets // 示例页面 +│ ├──Index2.ets // 示例页面 +│ └──Index3.ets // 示例页面 +└──entry/src/main/resources // 应用资源目录 +``` -进入首面,点击按钮,分别进入示例页面。 ### 具体实现 diff --git a/ThreadIssueDetection/README.md b/ThreadIssueDetection/README.md index ea8f771cd8234411f76839e2f42f2a207ad91bee..761f0b004024adbe1101ed2a4e0067f2f5634b2f 100644 --- a/ThreadIssueDetection/README.md +++ b/ThreadIssueDetection/README.md @@ -4,11 +4,25 @@ 本示例是《使用TSan检测线程问题》最佳实践中的代码示例片段。 -##### 使用说明 +### 使用说明 -进入首面,点击按钮,分别进入示例页面。 +进入首面,加载示例逻辑。 +### 工程目录 + +``` +├──entry/src/main/ets +│ ├──entryability +│ │ └──EntryAbility.ets // 入口类 +│ ├──entrybackupability +│ │ └──EntryBackupAbility.ets // 备份恢复类 +│ └──pages +│ ├──UseTSANToDetectThreadingIssues.ets // 示例页面 +│ └──Index.ets // 首页 +└──entry/src/main/resources // 应用资源目录 +``` + ### 具体实现 1. 主要介绍如何使用TSan检测线程,提供代码示例。 diff --git a/ThreadIssueDetection/entry/src/main/module.json5 b/ThreadIssueDetection/entry/src/main/module.json5 index a1cea8b6a4560cee7bda7a2db52f310c035ab6c8..ad219d733f6afa5ea07f85f580208b08cc3b9041 100644 --- a/ThreadIssueDetection/entry/src/main/module.json5 +++ b/ThreadIssueDetection/entry/src/main/module.json5 @@ -5,9 +5,7 @@ "description": "$string:module_desc", "mainElement": "EntryAbility", "deviceTypes": [ - "phone", - "tablet", - "2in1" + "phone" ], "deliveryWithInstall": true, "installationFree": false, diff --git a/ThreadIssueDetection/entry/src/main/resources/base/element/string.json b/ThreadIssueDetection/entry/src/main/resources/base/element/string.json index f94595515a99e0c828807e243494f57f09251930..a1f956d811bfc470d2f477226f6a959b4d47decf 100644 --- a/ThreadIssueDetection/entry/src/main/resources/base/element/string.json +++ b/ThreadIssueDetection/entry/src/main/resources/base/element/string.json @@ -10,7 +10,7 @@ }, { "name": "EntryAbility_label", - "value": "label" + "value": "ThreadIssueDetection" } ] } \ No newline at end of file diff --git a/customPlugin/README.md b/customPlugin/README.md index f921614f93b7e3c327c1285a2bf6657a1e9e3c8d..5944414b45304f1a723910fb54c3f4eb5877f735 100644 --- a/customPlugin/README.md +++ b/customPlugin/README.md @@ -3,32 +3,30 @@ ### 介绍 在进行编译构建的过程中,开发者可以通过定制hvigor插件,扩展构建逻辑,实现个性化的打包流程。 -定制hvigor插件,通常有以下目的: -满足自定义任务需求。 -每个项目可能有独特的构建需求和流程,定制插件可以根据项目的具体要求来扩展hvigor构建的功能。 +### 使用说明 -加强构建任务可维护性。 -定制插件可以将某些复杂的构建逻辑封装在同一个地方,使得项目的构建配置更加清晰和易于维护。可以自动化执行某些特定任务,减少手动干预,确保构建过程的一致可靠。 +编译工程,得到hvigor插件逻辑的编译产物。 -提升团队协作效率。 -在团队开发中,定制插件可以确保所有团队成员使用相同的构建流程和标准,减少因个人配置差异导致的问题,从而提升团队协作的效率。 - -### 工程结构&模块类型 +### 工程结构 ``` ├──entry/src/main/ets/ -│ ├──mock -│ │ └──GoodsMock.ets // 模拟数据类 │ ├──entryability -│ │ └──EntryAbility.ets // 配置类 -│ └──model -│ │ └──GoodsModel.ets // 类型声明 +│ │ └──EntryAbility.ets // 入口类 +│ ├──entrybackupability +│ │ └──EntryBackupAbility.ets // 备份恢复类 │ └──pages -│ └──Index.ets // 程序入口类 +│ └──Index.ets // 示例页面 +├──library/src/main/ets +│ └──components +│ └──MainPage.ets // library模块中MainPage └──entry/src/main/resource // 应用静态资源目录 ``` +### 相关权限 + +不涉及。 ### 约束与限制 diff --git a/customPlugin/entry/src/main/module.json5 b/customPlugin/entry/src/main/module.json5 index a1cea8b6a4560cee7bda7a2db52f310c035ab6c8..ad219d733f6afa5ea07f85f580208b08cc3b9041 100644 --- a/customPlugin/entry/src/main/module.json5 +++ b/customPlugin/entry/src/main/module.json5 @@ -5,9 +5,7 @@ "description": "$string:module_desc", "mainElement": "EntryAbility", "deviceTypes": [ - "phone", - "tablet", - "2in1" + "phone" ], "deliveryWithInstall": true, "installationFree": false, diff --git a/customPlugin/entry/src/main/resources/base/element/string.json b/customPlugin/entry/src/main/resources/base/element/string.json index f94595515a99e0c828807e243494f57f09251930..71113f812d5120034ec203e97aa448873fde7398 100644 --- a/customPlugin/entry/src/main/resources/base/element/string.json +++ b/customPlugin/entry/src/main/resources/base/element/string.json @@ -10,7 +10,7 @@ }, { "name": "EntryAbility_label", - "value": "label" + "value": "customPlugin" } ] } \ No newline at end of file