提交 6ad61de3 编写于 作者: E ester.zhou

Update docs (9869)

Signed-off-by: Nester.zhou <ester.zhou@huawei.com>
上级 b3466bf4
......@@ -22,8 +22,8 @@ import stats from '@ohos.bundleState';
| function queryAppUsagePriorityGroup(callback: AsyncCallback&lt;number&gt;): void | Queries the priority group of this application. This API uses an asynchronous callback to return the result.|
| function queryAppUsagePriorityGroup(): Promise&lt;number&gt;; | Queries the priority group of this application. This API uses a promise to return the result.|
| function isIdleState(bundleName: string, callback: AsyncCallback&lt;boolean&gt;): void | Checks whether the application specified by **bundleName** is in the idle state. |
| function getRecentlyUsedModules(callback: AsyncCallback&lt;BundleActiveModuleInfo&gt;): void | Obtains the number of FA usage records specified by **1000**.|
| function getRecentlyUsedModules(maxNum: number, callback: AsyncCallback&lt;BundleActiveModuleInfo&gt;): void | Obtains the number of FA usage records specified by **maxNum**.|
| function getRecentlyUsedModules(callback: AsyncCallback&lt;BundleActiveModuleInfo&gt;): void | Obtains a maximum of 1000 FA usage records. |
| function getRecentlyUsedModules(maxNum: number, callback: AsyncCallback&lt;BundleActiveModuleInfo&gt;): void | Obtains the number of FA usage records specified by **maxNum**, which cannot exceed 1000.|
| function queryAppNotificationNumber(begin: number, end: number, callback: AsyncCallback&lt;Array&lt;BundleActiveEventState&gt;&gt;): void | Queries the number of notifications from all applications based on the specified start time and end time.|
| function queryBundleActiveEventStates(begin: number, end: number, callback: AsyncCallback&lt;Array&lt;BundleActiveEventState&gt;&gt;): void | Queries statistics about system events (hibernation, wakeup, unlocking, and screen locking) that occur between the specified start time and end time.|
| function queryAppUsagePriorityGroup(bundleName : string, callback: AsyncCallback&lt;number&gt;): void | Queries the priority group of the application specified by **bundleName**. This API uses an asynchronous callback to return the result.|
......@@ -326,14 +326,14 @@ import stats from '@ohos.bundleState';
```js
import stats from '@ohos.bundleState'
// Promise mode without parameters
// Promise mode when bundleName is not specified
stats.queryAppUsagePriorityGroup().then(res => {
console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup promise succeeded. result: ' + JSON.stringify(res));
}).catch(err => {
console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup promise failed. because: ' + err.code);
});
// Asynchronous callback mode without parameters
// Asynchronous callback mode when bundleName is not specified
stats.queryAppUsagePriorityGroup((err, res) => {
if (err) {
console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup callback failed. because: ' + err.code);
......@@ -341,16 +341,16 @@ import stats from '@ohos.bundleState';
console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup callback succeeded. result: ' + JSON.stringify(res));
}
});
// Promise mode with parameters
stats.queryAppUsagePriorityGroup(this.bundleName).then(res => {
let bundleName = "com.ohos.camera";
// Promise mode when bundleName is specified
stats.queryAppUsagePriorityGroup(bundleName).then(res => {
console.log('BUNDLE_ACTIVE QueryPackageGroup promise succeeded. result: ' + JSON.stringify(res));
}).catch(err => {
console.log('BUNDLE_ACTIVE QueryPackageGroup promise failed. because: ' + err.code);
});
// Asynchronous callback mode with parameters
stats.queryAppUsagePriorityGroup(this.bundleName, (err, res) => {
// Asynchronous callback mode when bundleName is specified
stats.queryAppUsagePriorityGroup(bundleName, (err, res) => {
if (err) {
console.log('BUNDLE_ACTIVE QueryPackageGroup callback failed. because: ' + err.code);
} else {
......@@ -437,3 +437,4 @@ import stats from '@ohos.bundleState';
}
});
```
......@@ -41,7 +41,7 @@ Checks whether the application specified by **bundleName** is in the idle state.
| Name | Type | Mandatory | Description |
| ---------- | ---------------------------- | ---- | ---------------------------------------- |
| bundleName | string | Yes | Bundle name of an application. |
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result. If the value of <b class="+ topic/ph hi-d/b " id="b597417553714">bundleName</b> is valid, <b class="+ topic/ph hi-d/b " id="b1897411555719">null</b> will be returned.|
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result. Returns the idle state of the application if the specified **bundleName** is valid; returns **null** otherwise.|
**Example**
......@@ -73,7 +73,7 @@ Checks whether the application specified by **bundleName** is in the idle state.
| Type | Description |
| ---------------------- | ---------------------------------------- |
| Promise&lt;boolean&gt; | Promise used to return the result. If the value of **bundleName** is valid, **null** will be returned.|
| Promise&lt;boolean&gt; | Promise used to return the result. Returns the idle state of the application if the specified **bundleName** is valid; returns **null** otherwise.|
**Example**
......@@ -275,7 +275,7 @@ Queries the application usage duration statistics in the specified time frame at
| Type | Description |
| ---------------------------------------- | ---------------------------------------- |
| Promise&lt;Array&lt;[BundleStateInfo](#bundlestateinfo)&gt;&gt; | Promise used to return the result.|
| Promise&lt;Array&lt;[BundleStateInfo](#bundlestateinfo)&gt;&gt; | Promise used to return the result. |
**Example**
......@@ -309,7 +309,7 @@ Queries events of all applications based on the specified start time and end tim
| -------- | ---------------------------------------- | ---- | --------------------------------------- |
| begin | number | Yes | Start time. |
| end | number | Yes | End time. |
| callback | AsyncCallback&lt;Array&lt;[BundleActiveState](#bundleactivestate)&gt;&gt; | Yes | Callback used to return the result.|
| callback | AsyncCallback&lt;Array&lt;[BundleActiveState](#bundleactivestate)&gt;&gt; | Yes | Callback used to return the result. |
**Example**
......@@ -350,7 +350,7 @@ Queries events of all applications based on the specified start time and end tim
| Type | Description |
| ---------------------------------------- | -------------------------------------- |
| Promise&lt;Array&lt;[BundleActiveState](#bundleactivestate)&gt;&gt; | Promise used to return the result.|
| Promise&lt;Array&lt;[BundleActiveState](#bundleactivestate)&gt;&gt; | Promise used to return the result. |
**Example**
......@@ -380,7 +380,7 @@ Queries events of this application based on the specified start time and end tim
| -------- | ---------------------------------------- | ---- | --------------------------------------- |
| begin | number | Yes | Start time. |
| end | number | Yes | End time. |
| callback | AsyncCallback&lt;Array&lt;[BundleActiveState](#bundleactivestate)&gt;&gt; | Yes | Callback used to return the result.|
| callback | AsyncCallback&lt;Array&lt;[BundleActiveState](#bundleactivestate)&gt;&gt; | Yes | Callback used to return the result. |
**Example**
......@@ -417,7 +417,7 @@ Queries events of this application based on the specified start time and end tim
| Type | Description |
| ---------------------------------------- | -------------------------------------- |
| Promise&lt;Array&lt;[BundleActiveState](#bundleactivestate)&gt;&gt; | Promise used to return the result.|
| Promise&lt;Array&lt;[BundleActiveState](#bundleactivestate)&gt;&gt; | Promise used to return the result. |
**Example**
......@@ -455,7 +455,7 @@ Obtains the number of FA usage records specified by **maxNum**. This API uses a
| Type | Description |
| ---------------------------------------- | ---------------------------------- |
| Promise&lt;Array&lt;[BundleActiveModuleInfo](#bundleactivemoduleinfo9)&gt;&gt; | Promise used to return the result.|
| Promise&lt;Array&lt;[BundleActiveModuleInfo](#bundleactivemoduleinfo9)&gt;&gt; | Promise used to return the result. |
**Example**
......@@ -486,7 +486,7 @@ Obtains the number of FA usage records specified by **maxNum**. This API uses a
getRecentlyUsedModules(callback: AsyncCallback&lt;Array&lt;BundleActiveModuleInfo&gt;&gt;): void
This API uses an asynchronous callback to return at most 1000 records sorted by time (most recent first).
Obtains FA usage records. This API uses an asynchronous callback to return a maximum of 1000 FA usage records sorted by time in descending order.
**Required permissions**: ohos.permission.BUNDLE_ACTIVE_INFO
......@@ -498,7 +498,7 @@ This API uses an asynchronous callback to return at most 1000 records sorted by
| Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | ----------------------------------- |
| callback | AsyncCallback&lt;Array&lt;[BundleActiveModuleInfo](#bundleactivemoduleinfo9)&gt;&gt; | Yes | Callback used to return the result.|
| callback | AsyncCallback&lt;Array&lt;[BundleActiveModuleInfo](#bundleactivemoduleinfo9)&gt;&gt; | Yes | Callback used to return the result. |
**Example**
......@@ -532,8 +532,8 @@ Obtains the number of FA usage records specified by **maxNum**. This API uses an
| Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | ----------------------------------- |
| maxNum | number | Yes | Maximum number of returned records. The maximum and default value is **1000**.|
| callback | AsyncCallback&lt;Array&lt;[BundleActiveModuleInfo](#bundleactivemoduleinfo9)&gt;&gt; | Yes | Callback used to return the result.|
| maxNum | number | Yes | Maximum number of returned records. The maximum value is **1000**.|
| callback | AsyncCallback&lt;Array&lt;[BundleActiveModuleInfo](#bundleactivemoduleinfo9)&gt;&gt; | Yes | Callback used to return the result. |
**Example**
......@@ -578,14 +578,14 @@ Queries the priority group of the application specified by **bundleName**. If **
**Example**
```javascript
// Promise with bundleName
// Promise mode when bundleName is specified
let bundleName = "com.ohos.camera";
bundleState.queryAppUsagePriorityGroup(bundleName).then( res => {
console.log('BUNDLE_ACTIVE QueryPackageGroup promise succeeded. result: ' + JSON.stringify(res));
}).catch( err => {
console.log('BUNDLE_ACTIVE QueryPackageGroup promise failed. because: ' + err.code);
});
// Promise without bundleName
// Promise mode when bundleName is not specified
bundleState.queryAppUsagePriorityGroup().then( res => {
console.log('BUNDLE_ACTIVE QueryPackageGroup promise succeeded. result: ' + JSON.stringify(res));
}).catch( err => {
......@@ -597,7 +597,7 @@ bundleState.queryAppUsagePriorityGroup().then( res => {
queryAppUsagePriorityGroup(callback: AsyncCallback&lt;number&gt;): void
Queries the priority group of the current application . This API uses an asynchronous callback to return the result.
Queries the priority group of this application. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.BUNDLE_ACTIVE_INFO
......@@ -609,7 +609,7 @@ Queries the priority group of the current application . This API uses an asynchr
| Name | Type | Mandatory | Description |
| ---------- | --------------------- | ---- | ---------------------------------------- |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the result. |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the result. |
**Example**
......@@ -639,8 +639,8 @@ Queries the priority group of the application specified by **bundleName**. This
| Name | Type | Mandatory | Description |
| ---------- | --------------------- | ---- | ---------------------------------------- |
| bundleName | string | Yes | Bundle name of the target application.|
| callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the result. |
| bundleName | string | Yes | Bundle name of the target application.|
| callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the result. |
**Example**
......@@ -678,7 +678,7 @@ Sets the group for the application specified by **bundleName**. This API uses a
| Type | Description |
| ------------- | ------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
| Promise&lt;void&gt; | Promise used to return the result. |
**Example**
......@@ -711,7 +711,7 @@ Sets the group for the application specified by **bundleName**. This API uses an
| ---------- | ------------------- | ---- | ------------------------- |
| bundleName | string | Yes | Bundle name of an application. |
| newGroup | [GroupType](#grouptype) | Yes | Application group. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Example**
......@@ -750,7 +750,7 @@ Registers a callback for application group changes. When an application group of
| Type | Description |
| ------------- | ----------------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
| Promise&lt;void&gt; | Promise used to return the result. |
**Example**
......@@ -827,7 +827,7 @@ Deregisters the callback for application group changes. This API uses a promise
| Type | Description |
| ------------- | ------------------------ |
| Promise&lt;void&gt; | Promise used to return the result.|
| Promise&lt;void&gt; | Promise used to return the result. |
**Example**
......@@ -892,7 +892,7 @@ Queries statistics about system events (hibernation, wakeup, unlocking, and scre
| Type | Description |
| ---------------------------------------- | ---------------------------------------- |
| Promise&lt;Array&lt;[BundleActiveEventState](#bundleactiveeventstate9)&gt;&gt; | Promise used to return the result.|
| Promise&lt;Array&lt;[BundleActiveEventState](#bundleactiveeventstate9)&gt;&gt; | Promise used to return the result. |
**Example**
......@@ -923,7 +923,7 @@ Queries statistics about system events (hibernation, wakeup, unlocking, and scre
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| begin | number | Yes | Start time. |
| end | number | Yes | End time. |
| callback | AsyncCallback&lt;Array&lt;[BundleActiveEventState](#bundleactiveeventstate9)&gt;&gt; | Yes | Callback used to return the result.|
| callback | AsyncCallback&lt;Array&lt;[BundleActiveEventState](#bundleactiveeventstate9)&gt;&gt; | Yes | Callback used to return the result. |
**Example**
......@@ -961,7 +961,7 @@ Queries the number of notifications from all applications based on the specified
| Type | Description |
| ---------------------------------------- | ---------------------------------------- |
| Promise&lt;Array&lt;[BundleActiveEventState](#bundleactiveeventstate9)&gt;&gt; | Promise used to return the result.|
| Promise&lt;Array&lt;[BundleActiveEventState](#bundleactiveeventstate9)&gt;&gt; | Promise used to return the result. |
**Example**
......@@ -992,7 +992,7 @@ Queries the number of notifications from all applications based on the specified
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| begin | number | Yes | Start time. |
| end | number | Yes | End time. |
| callback | AsyncCallback&lt;Array&lt;[BundleActiveEventState](#bundleactiveeventstate9)&gt;&gt; | Yes | Callback used to return the result.|
| callback | AsyncCallback&lt;Array&lt;[BundleActiveEventState](#bundleactiveeventstate9)&gt;&gt; | Yes | Callback used to return the result. |
**Example**
......@@ -1012,6 +1012,8 @@ Provides the information about the FA usage.
**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App
**System API**: This is a system API and cannot be called by third-party applications.
| Name | Type | Mandatory | Description |
| -------------------- | ---------------------------------------- | ---- | ----------------------------- |
| deviceId | string | No | ID of the device to which the FA belongs. |
......@@ -1033,6 +1035,8 @@ Provides the FA widget usage information.
**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App
**System API**: This is a system API and cannot be called by third-party applications.
| Name | Type | Mandatory | Description |
| ---------------- | ------ | ---- | ----------- |
| formName | string | Yes | Widget name. |
......@@ -1047,6 +1051,8 @@ Provides the application group changes returned through a callback.
**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
**System API**: This is a system API and cannot be called by third-party applications.
| Name | Type | Mandatory| Description |
| ---------------- | ------ | ---- | ---------------- |
| appUsageOldGroup | number | Yes | Application group before the change.|
......@@ -1135,6 +1141,8 @@ Enumerates the application group types.
**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
**System API**: This is a system API and cannot be called by third-party applications.
| Name | Default Value | Description |
| ------------------ | ---- | ----------------- |
| ACTIVE_GROUP_ALIVE | 10 | Group of active applications. |
......
# ArkUI
## Introduction
ArkUI is a UI development framework that provides what you'll need to develop application UIs in OpenHarmony, including UI components, animations, drawing, interaction events, and JavaScript API extension mechanisms. ArkUI comes with two development paradigms: eTS-based declarative development paradigm (declarative development paradigm for short) and JavaScript-compatible web-like development paradigm (web-like development paradigm for short).
**Framework Structure**
![en-us_image_0000001267647869](../application-dev/ui/figures/en-us_image_0000001267647869.png)
As shown above, the two development paradigms share the UI backend engine and language runtime. The UI backend engine implements the six basic capabilities of ArkUI. The declarative development paradigm does not require the JS Framework for managing the page DOM. As such, it has more streamlined rendering and update links and less memory usage. This makes the declarative development paradigm a better choice for building application UIs.
## Directory Structure
The ArkUI source code is stored in **/foundation/arkui**. The following shows the directory structure.
```
/foundation/arkui
├── ace_engine # ArkUI
├── ace_engine_lite # Lite ArkUI
└── napi # JS APIs for extending the native development module
```
## Repositories Involved
**ArkUI**
[arkui\_ace\_engine](https://gitee.com/openharmony/arkui_ace_engine)
[arkui\_ace\_engine\_lite](https://gitee.com/openharmony/arkui_ace_engine_lite)
[arkui\_napi](https://gitee.com/openharmony/arkui_napi)
# JS UI Framework<a name="EN-US_TOPIC_0000001087318673"></a>
## Introduction<a name="section11660541593"></a>
The OpenHarmony JS UI framework provides basic, container, and canvas UI components and standard CSS animation capabilities. It supports the web-development-like programming paradigm.
- **Web-development-like paradigm**
The JS UI framework supports languages that are similar to those for web development, such as HTML and CSS. You can use them to describe the page layout and style, and use JavaScript \(conforming to the ECMAScript specification\) for page behavior. This paradigm allows you to avoid code for UI state switching. The view configuration information is intuitive.
**Figure 1** JS UI framework<a name="fig15956152211427"></a>
![](figures/en-us_image_0000001077953992.png)
The JS UI framework consists of the application, framework, engine, and porting layers.
- **Application**
Contains applications with Feature Abilities \(FAs\) developed with the JS UI framework. The FA application in this document refers to the application with FAs developed using JavaScript.
- **Framework**
Parses UI pages and provides the Model-View-ViewModel \(MVVM\), page routing, custom components and more for front end development.
- **Engine**
Accomplishes animation parsing, Document Object Model \(DOM\) building, layout computing, rendering command–based building and drawing, and event management.
- **Porting Layer**
Abstracts the platform layer to provide interfaces for the interconnection with the OS. For example, interconnections of events, rendering pipelines, and lifecycles.
## Directory Structure<a name="section179173014915"></a>
The source code of the framework is stored in **/foundation/ace**. The following shows the directory structure.
```
/foundation/ace
├── ace_engine # JS UI framework
├── ace_engine_lite # JS UI framework for the mini system and above
└── napi # JS APIs for extending the native development module
```
## Usage<a name="section1711605017917"></a>
- JavaScript FA development directory
After a project is created, its **js** directory is displayed.
**Figure 2** Development directory<a name="fig343917486112"></a>
![](figures/development-directory.png "development-directory")
The **i18n** directory stores JSON files for various locales. A **pages** subfolder contains multiple pages and each consists of **.hml**, **.css**, and **.js** files.
- **main \> js \> default \> i18n \> en-US.json**: defines the variables displayed on pages in English. Similarly, **zh-CN.json** defines the page content in Chinese.
```
{
"strings": {
"hello": "Hello",
"world": "World"
}
}
```
- **main \> js \> default \> pages \> index \> index.hml**: describes the layout of the **index** page, components used on the page, and the hierarchy of these components. For example, there is a text component for displaying **Hello World**.
```
<div class ="container">
<text class ="title">
{{ $t('strings.hello') }} {{title}}
</text>
</div>
```
- **main \> js \> default \> pages \> index \> index.css**: defines the style of the **index** page. For example, the following **index.css** code snippet describes how **container** and **title** will be displayed on the page:
```
.container {
flex-direction: column;
justify-content: center;
align-items: center;
}
.title {
font-size: 100px;
}
```
- **main \> js \> default \> pages \> index \> index.js**: defines the service logic on the **index** page, such as data binding and event processing. In this example, the string **World** is assigned to **title**.
```
export default {
data: {
title: '',
},
onInit() {
this.title = this.$t('strings.world');
},
}
```
## Repositories Involved<a name="section1599816111011"></a>
JS UI framework
[arkui\_ace\_engine](https://gitee.com/openharmony/arkui_ace_engine)
[arkui\_ace\_engine\_lite](https://gitee.com/openharmony/arkui_ace_engine_lite)
[ace\_napi](https://gitee.com/openharmony/ace_napi)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册