Hello everyone, I am a coder, a coder with ten years of work experience, dedicated to the pursuit of technology.
Recently, some friends often ask me about the directory structure of Hongmeng project. Let me talk about the directory structure developed by Hongmeng.
I finally have time today to give you a detailed explanation.
Mainly from two aspects, Java project structure and Js project structure.
Why are we talking about two? This reflects the benefits of hongmeng development, Hongmeng development is too convenient, can use Java development, also can use Js development.
Choose and develop based on personal preference or expertise.
That’s right. Let’s do it.
1. Java project directory structure
The Java project directory structure is shown in the following figure.
-
Gradle: The gradle configuration file is automatically generated by the system and does not need to be modified.
-
Entry: Default startup module (main module), directory for developers to write source files and develop resource files.
-
Boole. json: Boolean
-
Color. Json: color
-
Float. json: floating point type
-
Intarray. json: integer array
-
Integer. Json: integer
-
The pattern. Json: style
-
Json: plural form
-
Strarray. json: string array
-
String. json: string value.
-
Entry >libs: Used to store the dependency file -jar package of the Entry module.
-
Entry > SRC >main>Java: Used to store Java source code.
-
Entry > SRC > Main > Resources: Stores resource files used by applications, such as graphics, multimedia, strings, and layout files.
- Entry > SRC >main>config.json: HAP manifest file. For details, see config.json Configuration file Introduction.
- Entry > SRC > Test: Directory where code is written to unit test code, running on the local Java Virtual machine (JVM).
- Entry >.gitignore: Identifies files that need to be ignored for git version management.
- Entry >build.gradle: Compilation configuration file for the Entry module.
2. Js project directory structure
The JS project directory structure is shown in the following figure.
-
Common directory: Optional for storing common resource files, such as media resources, custom components, and JS documents.
-
I18n directory: This directory is optional. It is used to store JSON files in multiple languages. In this directory, you can define content to be displayed in different languages, such as application text entries and image paths.
-
Pages directory: The Pages folder can contain one or more pages, and each page needs to create a folder (index in the figure). The page folder contains three types of files: CSS, JS, and HML files.
-
Pages >index> index.hML file: The HML file defines the layout structure of the page, the components used, and the hierarchy of those components.
-
Pages >index>index. CSS file: THE CSS file defines the style and layout of a page, including style selectors and various style properties.
-
Pages >index>index.js file: the js file describes the behavior logic of the page. This file defines all logical relations used in the page, such as data, events, etc.
-
Resources: Optional, used to store resource configuration files, such as global style and multi-resolution loading configuration files.
-
App.js files: Global JavaScript logic files and application lifecycle management.
The typical development directory structure of JS service cards (Entry/SRC /main/ JS /module) is as follows:
Figure 1 Directory structure
Files in the directory structure are classified as follows:
- HML template file at the end of.hml, which is used to develop the template layout structure of the page.
- .css The CSS style file at the end, which is used to develop page styles.
- Json file at the end of the.json file, which is used to develop variables and action events for use.
The functions of each folder:
- The Pages directory stores card template pages.
- The common directory is used to store common resource files, such as image resources.
- The Resources directory is used to store resource configuration files, such as multi-resolution load configuration files.
- The i18N directory is used to configure resources in different language scenarios, such as application text entries and image paths.
instructions
I18n and Resources are development reserved folders and cannot be renamed.
Apply resource access rules
Application resources can be accessed through absolute paths or relative paths. In this development framework, absolute paths start with “/” and relative paths start with “./” or “.. / “. The specific access rules are as follows:
- To reference code files, use relative paths, such as.. / common/style.css. CSS.
- You are advised to use an absolute path to reference resource files. PNG, for example, /common/xxx.png.
- Common code files and resource files are recommended to be placed under common and accessed through rules 1 and 2.
- The CSS style file uses the URL () function to create data types, such as URL (/common/xxx.png).
Original is not easy, useful attention. I’ll give you a triple if I help you. Thanks for your support.
Feel good friends, remember to help me @programmer cartoon programming **, a thumbs up and attention yo, bixin bixin ~**
Source: the public, “code charge” growth to the author: code working links: the original HongMeng | about HongMeng development project structure and use
Attached with the programmer necessary booklet, booklet copyright belongs to the author, Gitee address: code worker /haomonyDevelop