小工具知识网

当前位置: 首页 > 行业知识 > 鸿蒙开发(二)-项目结构

行业知识

鸿蒙开发(二)-项目结构

2026-11-14 06:24:00 来源:互联网转载

鸿蒙开发(二)-项目结构

上���文章我们讲了如何配置鸿蒙开发的基础环境,以及创建了第一个鸿蒙程序。

这篇我们讲述了鸿蒙应用的项目目录结构。

如图所示:我们切换项目project可以看到。

另一种则是Ohos模式:

  1. AppScope->app.json5 应用的全局配置

    {  "app": {    "bundleName": "com.zh.test",    "vendor": "example",    "versionCode": 1000000,    "versionName": "1.0.0",    "icon": "$media:app_icon",    "label": "$string:app_name"  }}

    包含包名,icon,label等信息。

    vendor 为应用程序的供应商,默认如上为example

  2. entry: 应用/服务模块,编译构建生成一个HAP.

    entry->src->main->ets: 存放ArkTsUI源码,包含entryability以及pages

    entry->src->main->resources:资源文件,如icon,字符串,布局文件等。

    entry->src->main->module.json5:模块配置文件,包含abilities以及pages的配置

    entry->src->build-profile.json5 :模块信息,taget等

    entry->src->hvigorfile.ts :

    entry->src->oh-package.json5 :配置三方依赖

    {  "name": "entry",  "version": "1.0.0",  "description": "Please describe the basic information.",  "main": "",  "author": "",  "license": "",  "dependencies": {}}
  3. build.profile.json5:应用级配置,如签名,产品配置等信息

    默认配置如下:

    {  "app": {    "signingConfigs": [],    "compileSdkVersion": 9,    "compatibleSdkVersion": 9,    "products": [      {        "name": "default",        "signingConfig": "default",      }    ]  },  "modules": [    {      "name": "entry",      "srcPath": "./entry",      "targets": [        {          "name": "default",          "applyToProducts": [            "default"          ]        }      ]    }  ]}
  4. hvigorfile.ts:应用级编译构建任务脚本.

    默认配置如下:

    // Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently.export { appTasks } from '@ohos/hvigor-ohos-plugin';
  5. local.properties :

    # This file is automatically generated by DevEco Studio.# Do not modify this file -- YOUR CHANGES WILL BE ERASED!## This file should *NOT* be checked into Version Control Systems,# as it contains information specific to your local configuration.## For customization when using a Version Control System, please read the header note.hwsdk.dir=E:/harmony_os_sdknodejs.dir=C:/Users/zj/nodejs

    这里配置了OpenHarmony SDK的路径, 以及node.js的路径。

  6. oh-package.json5

上一篇:揭秘堡垒机,网络安全的关键守护者角色

下一篇:中兴服务器工厂在哪里?