一、ArkUI框架
ArkUI框架是鸿蒙开发中使用的一套UI框架,类似于Android或iOS中的UI一样,具备了界面布局、动画、UI交互等基本功能。方舟开发框架采用了基于ArkTS语言的声明式开发范式。UI的更新方式采用数据驱动。
二、应用模型
应用模型,就是应用程序运行所必须具备的能力和运行机制。
Stage模型是 HarmonyOS API 9开始新增的应用模型,是官方主推并且会长期支持的应用模型。
三、项目的目录结构
1.app.json5配置文件
{
"app": {
"bundleName": "com.example.myapplication",
"vendor": "example",
"versionCode": 1000000,
"versionName": "1.0.0",
"icon": "$media:app_icon",
"label": "$string:app_name"
}
}
2.module.json5配置文件
{
"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:ability_desc",
"icon": "$media:icon",
"label": "$string:ability_label",
"startWindowIcon": "$media:startIcon",
"startWindowBackground": "$color:start_window_background",
"exported": true,
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
]
}
]
}
}
3.模块级build-profile.json5配置文件
{
"apiType": "stageMode",
"buildOption": {
},
"buildOptionSet": [
{
"name": "release",
"arkOptions": {
"obfuscation": {
"ruleOptions": {
"enable": true,
"files": [
"./obfuscation-rules.txt"
]
}
}
}
},
],
"targets": [
{
"name": "default"
},
{
"name": "ohosTest",
}
]
}
4.模块级构建脚本hvigorfile.ts文件
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. */
}
5.obfuscation-rules.txt混淆规则文件
# 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
6.应用级配置信息build-profile.json5文件
{
"app": {
"signingConfigs": [
{
"name": "default",
"type": "HarmonyOS",
"material": {
"certpath": "C:\\Users\\Administrator\\.ohos\\config\\default_HarmonyApp_T1-S6iZ5p-kYEzQIOXqUYs2QX3JtFcQCwPW0T9qQpaU=.cer",
"storePassword": "0000001A1B842713EB4D0EA640734AC141FF59A3959AEFAE0BF8F0C3CAC53A13D7B9BD06AE028D3CDB95",
"keyAlias": "debugKey",
"keyPassword": "0000001A8002906FA9CC8755245FC0169F97D0818626A0A037F70168BB2D75BB3628859BD21E246A96B4",
"profile": "C:\\Users\\Administrator\\.ohos\\config\\default_HarmonyApp_T1-S6iZ5p-kYEzQIOXqUYs2QX3JtFcQCwPW0T9qQpaU=.p7b",
"signAlg": "SHA256withECDSA",
"storeFile": "C:\\Users\\Administrator\\.ohos\\config\\default_HarmonyApp_T1-S6iZ5p-kYEzQIOXqUYs2QX3JtFcQCwPW0T9qQpaU=.p12"
}
}
],
"products": [
{
"name": "default",
"signingConfig": "default",
"compileSdkVersion": "4.1.0(11)",
"compatibleSdkVersion": "4.1.0(11)",
"runtimeOS": "HarmonyOS",
}
],
"buildModeSet": [
{
"name": "debug",
},
{
"name": "release"
}
]
},
"modules": [
{
"name": "entry",
"srcPath": "./entry",
"targets": [
{
"name": "default",
"applyToProducts": [
"default"
]
}
]
}
]
}
7.应用级构建脚本文件hvigorifile.ts
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. */
}