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

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

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

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

如图所示:我们切换项目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_sdk
    nodejs.dir=C:/Users/zj/nodejs

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

  6. oh-package.json5

相关推荐
&岁月不待人&8 分钟前
实现弹窗随键盘上移居中
java·kotlin
残*影14 分钟前
Spring Bean的初始化过程是怎么样的?
java·后端·spring
黎䪽圓20 分钟前
【Java多线程从青铜到王者】单例设计模式(八)
java·开发语言·设计模式
Java技术小馆21 分钟前
面试被问 Java为什么有这么多O
java·后端·面试
崔lc38 分钟前
Springboot项目集成Ai模型(阿里云百炼-DeepSeek)
java·spring boot·后端·ai
异常君1 小时前
Java 中 String 的不可变性与 final 设计:核心原理与性能实践
java·面试·代码规范
耀耀_很无聊1 小时前
03_跨域问题解决
java·spring boot·跨域·satoken
hshpy1 小时前
LangChain in java
java·langchain·flask
xtmatao1 小时前
JAVA开发工具——IntelliJ IDEA
java·ide·intellij-idea
寒山李白1 小时前
Spring Boot面试题精选汇总
java·spring boot·后端·面试