OpenHarmony APP Development Basics

introduction

This article sorts out the basic knowledge required to engage in OpenHarmony application development from five aspects: the structure of the OpenHarmony application package, Ability development, UI development, the directory structure of the OpenHarmony application project, and the programming language.

References:

OpenHarmony工程介绍
https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ohos-project-overview-0000001218440650
快速开始、开发
https://docs.openharmony.cn/pages/v3.1/zh-cn/application-dev/application-dev-guide.md/
入门、开发
https://developer.harmonyos.com/cn/docs/documentation/doc-guides/document-outline-js-ets-0000001282486428

1. The structure of the Hongmeng application package

1. The release form of Hongmeng application is APP Pack (Application Package, APP for short), which consists of one or more HAP (Harmony Ability Package) packages and a pack.info file describing the properties of APP Pack (automatically generated by the IDE when compiling) composition.

insert image description here

entry2. Each HAP corresponds to a Module in the Hongmeng application project directory. For example, the folder named in the Hongmeng project shown in the figure below is a Module. When compiling the Hongmeng application project, each Module can be compiled into a HAP.

insert image description here

3. There are two types of HAP in Hongmeng APP: Entry HAP and Feature HAP.

(1)Entry HAP

Entry-type HAP is the main module (entry module) in the APP, which is equivalent to the application program entry for a specific device. When the APP is opened in a certain device, the Entry HAP for this device will be run first. This means that there is only one Entry HAP in the APP installed on the device; however, there can be multiple Entry-type Modules in the Hongmeng project to adapt to different types of devices or different types of devices of the same type, as follows As shown in the figure.

https://developer.harmonyos.com/cn/docs/documentation/doc-guides/add_new_module-0000001053223741#section18939175113911

insert image description here

In addition, Entry HAP can be installed and run independently on the device.

(2)Feature HAP

Feature-type HAP is a feature module (optional module) in an APP. An APP can have one or more Feature HAPs, or not. Only the Feature HAP including Ability can run independently on the device.

4. A HAP (Module) is composed of Ability, resources, third-party libraries and configuration files.

(1)Ability

A HAP may contain one or more Abilities, or may not contain Abilities.

Ability has two models: FA model and Stage model. For details, see the second part of this article: Ability Development.

Ability is the abstraction of the capabilities of Hongmeng applications. It is the core part of Hongmeng applications and the smallest unit of system scheduling applications. DevEco Studio provides many Ability templates for developers to use. When we develop the Hongmeng application, we mainly write the code of Ability. The part in the red box in the figure below is the code of Page Ability in an FA model:

insert image description here

(2) Library files

Library files are third-party codes that applications need to rely on, such as binary files such as so, jar, bin, and har, and are generally stored in libsdirectories.

(3) Resource files

The resource files required by the application include character strings, pictures, audio, etc., and are stored in resourcesthe directory, which is convenient for developers to use and maintain. For details, see the classification of resource files:

https://docs.openharmony.cn/pages/v3.1/zh-cn/application-dev/quick-start/basic-resource-file-categories.md/
https://developer.harmonyos.com/cn/docs/documentation/doc-guides/basic-resource-file-categories-0000001052066099

(4) configuration file

Various configuration information of HAP is collected in the configuration file. For the models (FA model, Stage model) used by the Ability contained in HAP, the configuration files of HAP are also different. See:

应用包结构说明(FA模型)
https://docs.openharmony.cn/pages/v3.1/zh-cn/application-dev/quick-start/package-structure.md/
应用包结构说明(Stage模型)
https://docs.openharmony.cn/pages/v3.1/zh-cn/application-dev/quick-start/stage-structure.md/

2. Ability development

Ability框架概述
https://docs.openharmony.cn/pages/v3.1/zh-cn/application-dev/ability/ability-brief.md/

Ability has two models: FA model and Stage model.

1. FA model

API 8 and earlier applications can only be developed using the FA model.

The FA model divides Ability into two types: FA (Feature Ability) and PA (Particle Ability).

FA (Feature Ability) supports Page Ability, and a Page Ability can contain one or more pages (ie Page); PA supports Service Ability, Data Ability, and Form Ability.

FA (Feature Ability) has a UI interface (see the third part of this article: UI development); PA (Particle Ability) has no UI interface.

https://docs.openharmony.cn/pages/v3.1/zh-cn/application-dev/ability/fa-brief.md/

2. Stage model

Starting from API 9, the Ability framework introduces the Stage model as the second application framework form. The Stage model divides Ability into two categories: Ability and ExtensionAbility. ExtensionAbility is extended to a series of ExtensionAbility such as ServiceExtensionAbility, FormExtensionAbility, and DataShareExtensionAbility, so that Meet more usage scenarios.

https://docs.openharmony.cn/pages/v3.1/zh-cn/application-dev/ability/stage-brief.md/

3. UI development

UI框架
https://docs.openharmony.cn/pages/v3.1/zh-cn/application-dev/quick-start/start-overview.md/#ui%E6%A1%86%E6%9E%B6

OpenHarmony provides a set of UI development framework, namely the Ark development framework (ArkUI framework). The Ark development framework can provide developers with the necessary capabilities for application UI development, such as various components, layout calculations, animation capabilities, UI interaction, and drawing.

The Ark development framework provides two development paradigms for developers with different purposes and technical backgrounds: the Web-like development paradigm based on JS extensions (referred to as "Web-like development paradigm") , and the declarative development paradigm based on TS extensions (referred to as "declarative development paradigm") . The following is a simple comparison of the two development paradigms.

development paradigm name language ecology UI update method Applicable scene For people
Web-like development paradigm JS language data driven update Apps and cards with simpler interfaces Web front-end developer
Declarative Development Paradigm Extended TS language (eTS) data driven update Programs with greater complexity and greater teamwork Mobile system application developer, system application developer

For JS language development, the low-code method is supported in DevEco Studio V2.2 Beta1 and later versions.

For eTS language development, the low-code method is supported in DevEco Studio V3.0 Beta3 and later versions.

方舟开发框架概述
https://docs.openharmony.cn/pages/v3.1/zh-cn/application-dev/ui/arkui-overview.md/
基于JS扩展的类Web开发范式
https://docs.openharmony.cn/pages/v3.1/zh-cn/application-dev/ui/ui-js-overview.md/
基于TS扩展的声明式开发范式
https://docs.openharmony.cn/pages/v3.1/zh-cn/application-dev/ui/ui-ts-overview.md/

4. Directory structure of Hongmeng Application Project

According to Ability's model (FA, Stage) and programming language (eTS, JS, C++), the directory structure of the OpenHarmony APP project has the following five types:

1. eTS project directory structure (FA model)

https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ohos-project-overview-0000001218440650#section4154183910141

2. JS project directory structure (FA model)

https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ohos-project-overview-0000001218440650#section199109862914

3. C++ project directory structure (FA model)

https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ohos-project-overview-0000001218440650#section3732132312179

4. eTS project directory structure (Stage model)

https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ohos-project-overview-0000001218440650#section56487581904

5. C++ project directory structure (Stage model)

https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ohos-project-overview-0000001218440650#section11993659193917

5. Programming language

Engage in Hongmeng application development, in C++ project, C++ language is used; in JS project, in addition to JavaScript language, HML and CSS are also used; in eTS project, eTS language is used.

The eTS language is a superset of the TS (Type Script) language, and TS is a superset of JavaScript.

HML Syntax Reference

https://gitee.com/openharmony/docs/blob/OpenHarmony-3.1-Release/zh-cn/application-dev/ui/js-framework-syntax-hml.md

https://developer.harmonyos.com/cn/docs/documentation/doc-guides/js-framework-syntax-hml-0000000000611413

CSS Syntax Reference

https://gitee.com/openharmony/docs/blob/OpenHarmony-3.1-Release/zh-cn/application-dev/ui/js-framework-syntax-css.md

https://www.runoob.com/css/css-tutorial.html 

https://www.runoob.com/cssref/css-reference.html

JS Syntax Reference

https://gitee.com/openharmony/docs/blob/OpenHarmony-3.1-Release/zh-cn/application-dev/ui/js-framework-syntax-js.md

https://www.runoob.com/js/js-tutorial.html

TypeScript Syntax Reference

https://www.runoob.com/typescript/ts-tutorial.html

https://www.runoob.com/manual/gitbook/TypeScript/_book/





Guess you like

Origin blog.csdn.net/u013819452/article/details/126627424