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

update docs

Signed-off-by: Nester.zhou <ester.zhou@huawei.com>
上级 b1cd0da0
...@@ -18,10 +18,10 @@ OpenHarmony provides a UI development framework, known as ArkUI. ArkUI provides ...@@ -18,10 +18,10 @@ OpenHarmony provides a UI development framework, known as ArkUI. ArkUI provides
ArkUI comes with two development paradigms: JavaScript-based web-like development paradigm (web-like development paradigm for short) and TypeScript-based declarative development paradigm (declarative development paradigm for short). You can choose whichever development paradigm that aligns with your practice. ArkUI comes with two development paradigms: JavaScript-based web-like development paradigm (web-like development paradigm for short) and TypeScript-based declarative development paradigm (declarative development paradigm for short). You can choose whichever development paradigm that aligns with your practice.
| **Development&nbsp;Paradigm** | **Language** | **UI&nbsp;Update&nbsp;Mode** | **Applicable&nbsp;To** | **Intended&nbsp;Audience** | | **Development Paradigm** | **Language** | **UI Update Mode** | **Applicable To** | **Intended Audience** |
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| Web-like&nbsp;development&nbsp;paradigm | JavaScript | Data-driven | Applications&nbsp;and&nbsp;service&nbsp;widgets&nbsp;with&nbsp;simple&nbsp;UIs | Frontend&nbsp;web&nbsp;developers | | Web-like development paradigm | JavaScript | Data-driven | Applications and service widgets with simple UIs | Frontend web developers |
| Declarative&nbsp;development&nbsp;paradigm | Extended&nbsp;TypeScript&nbsp;(eTS) | Data-driven | Applications&nbsp;involving&nbsp;technological&nbsp;sophistication&nbsp;and&nbsp;teamwork | Mobile&nbsp;application&nbsp;and&nbsp;system&nbsp;application&nbsp;developers | | Declarative development paradigm | Extended TypeScript (eTS) | Data-driven | Applications involving technological sophistication and teamwork | Mobile application and system application developers |
For DevEco Studio V2.2 Beta1 and later versions, both the traditional coding mode and the low-code mode are supported when the JS language is used for development. For DevEco Studio V2.2 Beta1 and later versions, both the traditional coding mode and the low-code mode are supported when the JS language is used for development.
......
# Getting Started with eTS in the Low-Code Approach # Getting Started with eTS in the Low-Code Approach
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>This feature is supported in DevEco Studio V3.0 Beta3 and later versions. > **NOTE**<br/>This feature is supported in DevEco Studio V3.0 Beta3 and later versions.
> >
> The component lineup that supports low-code development in eTS is now at its preliminary stage and will be expanding in coming versions. > The component lineup that supports low-code development in eTS is now at its preliminary stage and will be expanding in coming versions.
> >
......
# Getting Started with eTS in the Traditional Coding Approach # Getting Started with eTS in the Traditional Coding Approach
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>To use eTS, your DevEco Studio must be V3.0.0.601 Beta1 or later. > **NOTE**<br/>To use eTS, your DevEco Studio must be V3.0.0.601 Beta1 or later.
> >
> For best possible results, use [DevEco Studio V3.0.0.900 Beta3](https://developer.harmonyos.com/cn/develop/deveco-studio#download_beta_openharmony) for your development. > For best possible results, use [DevEco Studio V3.0.0.900 Beta3](https://developer.harmonyos.com/cn/develop/deveco-studio#download_beta_openharmony) for your development.
...@@ -20,17 +20,18 @@ ...@@ -20,17 +20,18 @@
## eTS Project Files ## eTS Project Files
- **entry** : OpenHarmony project module, which can be built into an ability package ([HAP](../../glossary.md#hap)). - **entry**: OpenHarmony project module, which can be built into an ability package ([HAP](../../glossary.md#hap)).
- **src &gt; main &gt; ets** : a collection of eTS source code. - **src &gt; main &gt; ets**: a collection of eTS source code.
- **src &gt; main &gt; ets &gt; MainAbility** : entry to your application/service. - **src &gt; main &gt; ets &gt; MainAbility**: entry to your application/service.
- **src &gt; main &gt; ets &gt; MainAbility &gt; pages** : pages contained in **MainAbility**. - **src &gt; main &gt; ets &gt; MainAbility &gt; pages**: pages contained in **MainAbility**.
- **src &gt; main &gt; ets &gt; MainAbility &gt; app.ets** : ability lifecycle file. - **src &gt; main &gt; ets &gt; MainAbility &gt; pages &gt; index.ets**: the first page in the pages list, that is, the home page of your application.
- **src &gt; main &gt; resources** : a collection of resource files used by your application/service, such as graphics, multimedia, character strings, and layout files. - **src &gt; main &gt; ets &gt; MainAbility &gt; app.ets**: ability lifecycle file.
- **src &gt; main &gt; config.json** : module configuration file. This file describes the global configuration information of the application/service, the device-specific configuration information, and the configuration information of the HAP file. - **src &gt; main &gt; resources**: a collection of resource files used by your application/service, such as graphics, multimedia, character strings, and layout files.
- **build-profile.json5** : current module information and build configuration options, including **buildOption target**. - **src &gt; main &gt; config.json**: module configuration file. This file describes the global configuration information of the application/service, the device-specific configuration information, and the configuration information of the HAP file.
- **hvigorfile.js** : module-level compilation and build task script. You can customize related tasks and code implementation. - **build-profile.json5**: current module information and build configuration options, including **buildOption target**.
- **build-profile.json5** : application-level configuration information, including the signature and product configuration. - **hvigorfile.js**: module-level compilation and build task script. You can customize related tasks and code implementation.
- **hvigorfile.js** : application-level compilation and build task script. - **build-profile.json5**: application-level configuration information, including the signature and product configuration.
- **hvigorfile.js**: application-level compilation and build task script.
## Building the First Page ## Building the First Page
...@@ -63,7 +64,7 @@ ...@@ -63,7 +64,7 @@
2. Add a **&lt;Button&gt;** component. 2. Add a **&lt;Button&gt;** component.
On the default page, add a **&lt;Button&gt;** component to accept user clicks and implement redirection to another page. The sample code in the **index.ets** file is shown below: On the default page, add a **&lt;Button&gt;** component to respond to user clicks and implement redirection to another page. The sample code in the **index.ets** file is shown below:
```ts ```ts
...@@ -79,7 +80,7 @@ ...@@ -79,7 +80,7 @@
Text(this.message) Text(this.message)
.fontSize(50) .fontSize(50)
.fontWeight(FontWeight.Bold) .fontWeight(FontWeight.Bold)
// Add a button to accept user clicks. // Add a button to respond to user clicks.
Button() { Button() {
Text('Next') Text('Next')
.fontSize(30) .fontSize(30)
...@@ -178,7 +179,7 @@ You can implement page redirection through the page router, which finds the targ ...@@ -178,7 +179,7 @@ You can implement page redirection through the page router, which finds the targ
Text(this.message) Text(this.message)
.fontSize(50) .fontSize(50)
.fontWeight(FontWeight.Bold) .fontWeight(FontWeight.Bold)
// Add a button to accept user clicks. // Add a button to respond to user clicks.
Button() { Button() {
Text('Next') Text('Next')
.fontSize(30) .fontSize(30)
...@@ -264,4 +265,4 @@ You can implement page redirection through the page router, which finds the targ ...@@ -264,4 +265,4 @@ You can implement page redirection through the page router, which finds the targ
![en-us_image_0000001217526428](figures/en-us_image_0000001217526428.png) ![en-us_image_0000001217526428](figures/en-us_image_0000001217526428.png)
Congratulations! You have finished developing your OpenHarmony application in eTS in the traditional coding approach. To learn more about OpenHarmony, see [OpenHarmony Overview](../application-dev-guide.md) Congratulations! You have finished developing your OpenHarmony application in eTS in the traditional coding approach. To learn more about OpenHarmony, see [OpenHarmony Overview](../application-dev-guide.md).
# Getting Started with JavaScript in the Low-Code Approach # Getting Started with JavaScript in the Low-Code Approach
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>This feature will be available in DevEco Studio V2.2 Beta1 and later versions. > **NOTE**<br/>This feature will be available in DevEco Studio V2.2 Beta1 and later versions.
> >
> For best possible results, use [DevEco Studio V3.0.0.900 Beta3](https://developer.harmonyos.com/cn/develop/deveco-studio#download_beta_openharmony) for your development. > For best possible results, use [DevEco Studio V3.0.0.900 Beta3](https://developer.harmonyos.com/cn/develop/deveco-studio#download_beta_openharmony) for your development.
...@@ -37,10 +37,11 @@ After the project synchronization is complete, a low-code directory structure is ...@@ -37,10 +37,11 @@ After the project synchronization is complete, a low-code directory structure is
![en-us_image_0000001223558810](figures/en-us_image_0000001223558810.png) ![en-us_image_0000001223558810](figures/en-us_image_0000001223558810.png)
- **entry &gt; src &gt; main &gt; js &gt; MainAbility &gt; pages &gt; index &gt; index.js** : defines logical relationships, such as data and events, used on low-code pages. For details, see [JavaScript](../ui/js-framework-syntax-js.md). If multiple low-code development pages are created, a page folder and the corresponding **.js** file will be created for each of these pages. - **entry &gt; src &gt; main &gt; js &gt; MainAbility &gt; pages &gt; index &gt; index.js**: defines logical relationships, such as data and events, used on low-code pages. For details, see [JavaScript](../ui/js-framework-syntax-js.md). If multiple low-code development pages are created, a page folder and the corresponding **.js** file will be created for each of these pages.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>To avoid build errors when using the low-code development page, make sure the directory where the corresponding **.js** file is located does not contain **.hml** or **.css** files. For example, in the preceding example, no **.hml** or **.css** file is allowed in **js** &gt; **MainAbility** &gt; **pages** &gt; **index**. > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>To avoid build errors when using the low-code development page, make sure the directory where the corresponding **.js** file is located does not contain **.hml** or **.css** files. For example, in the preceding example, no **.hml** or **.css** file is allowed in **js** &gt; **MainAbility** &gt; **pages** &gt; **index**.
> >
- **entry &gt; src &gt; main &gt; supervisual &gt; MainAbility &gt; pages &gt; index &gt; index.visual** : stores the data model of the low-code development page. You can double-click the file to open the low-code development page. If multiple low-code development pages are created, a page folder and the corresponding **.visual** file will be created for each of these pages. - **entry &gt; src &gt; main &gt; supervisual &gt; MainAbility &gt; pages &gt; index &gt; index.visual**: stores the data model of the low-code development page. You can double-click the file to open the low-code development page. If multiple low-code development pages are created, a page folder and the corresponding **.visual** file will be created for each of these pages.
## Building the First Page ## Building the First Page
...@@ -170,4 +171,4 @@ You can implement page redirection through the [page router](../ui/ui-js-buildin ...@@ -170,4 +171,4 @@ You can implement page redirection through the [page router](../ui/ui-js-buildin
![en-us_image_0000001262127855](figures/en-us_image_0000001262127855.png) ![en-us_image_0000001262127855](figures/en-us_image_0000001262127855.png)
Congratulations! You have finished developing your OpenHarmony app in JavaScript in the low-code approach. To learn more about OpenHarmony, see [OpenHarmony Overview](../application-dev-guide.md) Congratulations! You have finished developing your OpenHarmony app in JavaScript in the low-code approach. To learn more about OpenHarmony, see [OpenHarmony Overview](../application-dev-guide.md).
# Getting Started with JavaScript in the Traditional Coding Approach # Getting Started with JavaScript in the Traditional Coding Approach
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>For best possible results, use [DevEco Studio V3.0.0.900 Beta3](https://developer.harmonyos.com/cn/develop/deveco-studio#download_beta_openharmony) for your development. > **NOTE**<br/>For best possible results, use [DevEco Studio V3.0.0.900 Beta3](https://developer.harmonyos.com/cn/develop/deveco-studio#download_beta_openharmony) for your development.
>
## Creating a JavaScript Project ## Creating a JavaScript Project
...@@ -19,7 +18,7 @@ ...@@ -19,7 +18,7 @@
## JavaScript Project Files ## JavaScript Project Files
- **entry** : OpenHarmony project module, which can be built into an ability package ([HAP](../../glossary.md#hap)). - **entry**: OpenHarmony project module, which can be built into an ability package ([HAP](../../glossary.md#hap)).
- **src &gt; main &gt; js**: a collection of JS source code. - **src &gt; main &gt; js**: a collection of JS source code.
- **src &gt; main &gt; js &gt; MainAbility**: entry to your application/service. - **src &gt; main &gt; js &gt; MainAbility**: entry to your application/service.
- **src &gt; main &gt; js &gt; MainAbility &gt; i18n**: resources in different languages, for example, UI strings and image paths. - **src &gt; main &gt; js &gt; MainAbility &gt; i18n**: resources in different languages, for example, UI strings and image paths.
...@@ -51,7 +50,7 @@ ...@@ -51,7 +50,7 @@
2. Add a button and bind the **onclick** method to this button. 2. Add a button and bind the **onclick** method to this button.
On the default page, add an **&lt;input&gt;** component of the button type to accept user clicks and implement redirection to another page. The sample code in the **index.hml** file is shown below: On the default page, add an **&lt;input&gt;** component of the button type to respond to user clicks and implement redirection to another page. The sample code in the **index.hml** file is shown below:
```html ```html
...@@ -221,4 +220,4 @@ You can implement page redirection through the [page router](../ui/ui-js-buildin ...@@ -221,4 +220,4 @@ You can implement page redirection through the [page router](../ui/ui-js-buildin
![en-us_image_0000001217527892](figures/en-us_image_0000001217527892.png) ![en-us_image_0000001217527892](figures/en-us_image_0000001217527892.png)
Congratulations! You have finished developing your OpenHarmony application in JavaScript in the traditional coding approach. To learn more about OpenHarmony, see [OpenHarmony Overview](../application-dev-guide.md) Congratulations! You have finished developing your OpenHarmony application in JavaScript in the traditional coding approach. To learn more about OpenHarmony, see [OpenHarmony Overview](../application-dev-guide.md).
# SysCap Usage Guidelines # SysCap
## Overview ## Overview
...@@ -53,7 +53,7 @@ Right-click the project directory and choose **Import Product Compatibility ID** ...@@ -53,7 +53,7 @@ Right-click the project directory and choose **Import Product Compatibility ID**
The IDE automatically configures the associated capability set and required capability set based on the settings supported by the created project. You can modify the capability sets when necessary. The IDE automatically configures the associated capability set and required capability set based on the settings supported by the created project. You can modify the capability sets when necessary.
You can add APIs to the associated capability set in the IDE by adding system capabilities. However, note that these APIs may not be supported on the device. Therefore, check whether these APIs are supported before using them. You can add APIs to the associated capability set in the IDE by adding system capabilities. However, note that these APIs may not be supported on the device. Therefore, check whether these APIs are supported before using them.
Exercise caution when modifying the required capability set. Incorrect modifications may cause the application to unable to be distributed to the target device. Exercise caution when modifying the required capability set. Incorrect modifications may result in the application being unable to be distributed to the target device.
``` ```
/* syscap.json */ /* syscap.json */
...@@ -91,7 +91,7 @@ Exercise caution when modifying the required capability set. Incorrect modificat ...@@ -91,7 +91,7 @@ Exercise caution when modifying the required capability set. Incorrect modificat
### Single-Device Application Development ### Single-Device Application Development
By default, the association capability set and required system capability set of the application are the same as the supported system capability set of the device. Exercise caution when modifying the required capability set. By default, the associated capability set and required system capability set of the application are the same as the supported system capability set of the device. Exercise caution when modifying the required capability set.
![image-20220326065124911](figures/image-20220326065124911.png) ![image-20220326065124911](figures/image-20220326065124911.png)
...@@ -99,7 +99,7 @@ By default, the association capability set and required system capability set of ...@@ -99,7 +99,7 @@ By default, the association capability set and required system capability set of
### Cross-Device Application Development ### Cross-Device Application Development
By default, the associated capability set of the application is the union of multiple devices' supported capability sets. The capability sets must be the intersection. By default, the associated capability set of an application is the union of multiple devices' supported capability sets, while the required capability set is the intersection of the devices' supported capability sets.
![image-20220326065201867](figures/image-20220326065201867.png) ![image-20220326065201867](figures/image-20220326065201867.png)
...@@ -158,7 +158,7 @@ authenticator.execute('FACE_ONLY', 'S1', (err, result) => { ...@@ -158,7 +158,7 @@ authenticator.execute('FACE_ONLY', 'S1', (err, result) => {
### How Do SysCap Differences Arise Between Devices ### How Do SysCap Differences Arise Between Devices
The SysCap of devices varies according to the component combination defined by the product solution vendor. The following figure shows the overall process. The device SysCaps in product solutions vary according to the component combination defined by the product solution vendor. The following figure shows the overall process.
![image-20220326072448840](figures/image-20220326072448840.png) ![image-20220326072448840](figures/image-20220326072448840.png)
...@@ -172,8 +172,8 @@ The SysCap of devices varies according to the component combination defined by t ...@@ -172,8 +172,8 @@ The SysCap of devices varies according to the component combination defined by t
5. The SysCap set is encoded to generate the PCID. You can import the PCID to the IDE and decode it into SysCap. During development, compatibility processing is performed to mitigate the SysCap differences of devices. 5. The SysCap set is encoded to generate the PCID. You can import the PCID to the IDE and decode it into SysCap. During development, compatibility processing is performed to mitigate the SysCap differences of devices.
6. System parameters deployed on devices contain the SysCap set. The system provides native interfaces and application interfaces for components and applications to check whether a SysCap set is available. 6. System parameters deployed on devices contain the SysCap set. The system provides native interfaces and application interfaces for components and applications to check whether a specific SysCap is available.
7. During application development, the SysCap required by the application is encoded into the Required Product Compatibility ID (RPCID) and written into the application installation package. During application installation, the package manager decodes the RPCID to obtain the SysCap required by the application and compares it with the SysCap of the device. If the SysCap required by the application is met, the application can be installed. 7. During application development, the SysCap required by the application is encoded into the Required Product Compatibility ID (RPCID) and written into the application installation package. During application installation, the package manager decodes the RPCID to obtain the SysCap required by the application and compares it with the SysCap of the device. If the SysCap required by the application is met, the application can be installed.
8. When an application is running, the **canIUse** API can be used to query whether the SysCap is compatible with the device. 8. When an application is running on a device, the **canIUse** API can be used to query whether the device is compatible with a specific SysCap.
# Upload and Download # Upload and Download
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. > **NOTE**<br>The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
## Modules to Import ## Modules to Import
...@@ -17,16 +16,16 @@ import request from '@ohos.request'; ...@@ -17,16 +16,16 @@ import request from '@ohos.request';
- HTTPS is supported by default. To support HTTP, you need to add **network** to the **config.json** file and set the **cleartextTraffic** attribute to **true**. - HTTPS is supported by default. To support HTTP, you need to add **network** to the **config.json** file and set the **cleartextTraffic** attribute to **true**.
``` ```
"deviceConfig": { "deviceConfig": {
"default": { "default": {
"network": { "network": {
"cleartextTraffic": true "cleartextTraffic": true
}
...
} }
...
} }
``` }
```
## Constants ## Constants
...@@ -84,11 +83,13 @@ Uploads files. This API uses a promise to return the result. ...@@ -84,11 +83,13 @@ Uploads files. This API uses a promise to return the result.
**Example** **Example**
```js ```js
request.upload({ url: 'https://patch' }).then((data) => { let file1 = { filename: "test", name: "test", uri: "internal://cache/test.jpg", type: "jpg" };
uploadTask = data; let uploadTask;
}).catch((err) => { request.upload({ url: 'https://patch', files: [file1] }).then((data) => {
console.error('Failed to request the upload. Cause: ' + JSON.stringify(err)); uploadTask = data;
}) }).catch((err) => {
console.error('Failed to request the upload. Cause: ' + JSON.stringify(err));
})
``` ```
...@@ -112,13 +113,15 @@ Uploads files. This API uses an asynchronous callback to return the result. ...@@ -112,13 +113,15 @@ Uploads files. This API uses an asynchronous callback to return the result.
**Example** **Example**
```js ```js
request.upload({ url: 'https://patch' }, (err, data) => { let file1 = { filename: "test", name: "test", uri: "internal://cache/test.jpg", type: "jpg" };
if (err) { let uploadTask;
console.error('Failed to request the upload. Cause: ' + JSON.stringify(err)); request.upload({ url: 'https://patch', files: [file1] }, (err, data) => {
return; if (err) {
} console.error('Failed to request the upload. Cause: ' + JSON.stringify(err));
uploadTask = data; return;
}); }
uploadTask = data;
});
``` ```
...@@ -154,10 +157,10 @@ Parameters of the callback function ...@@ -154,10 +157,10 @@ Parameters of the callback function
**Example** **Example**
```js ```js
uploadTask.on('progress', function callback(uploadedSize, totalSize) { uploadTask.on('progress', function callback(uploadedSize, totalSize) {
console.info("upload totalSize:" + totalSize + " uploadedSize:" + uploadedSize); console.info("upload totalSize:" + totalSize + " uploadedSize:" + uploadedSize);
} }
); );
``` ```
...@@ -187,10 +190,10 @@ Parameters of the callback function ...@@ -187,10 +190,10 @@ Parameters of the callback function
**Example** **Example**
```js ```js
uploadTask.on('headerReceive', function callback(headers){ uploadTask.on('headerReceive', function callback(headers){
console.info("upOnHeader headers:" + JSON.stringify(headers)); console.info("upOnHeader headers:" + JSON.stringify(headers));
} }
); );
``` ```
...@@ -221,10 +224,10 @@ Parameters of the callback function ...@@ -221,10 +224,10 @@ Parameters of the callback function
**Example** **Example**
```js ```js
uploadTask.off('progress', function callback(uploadedSize, totalSize) { uploadTask.off('progress', function callback(uploadedSize, totalSize) {
console.info('uploadedSize: ' + uploadedSize, 'totalSize: ' + totalSize); console.info('uploadedSize: ' + uploadedSize, 'totalSize: ' + totalSize);
} }
); );
``` ```
...@@ -254,10 +257,10 @@ Parameters of the callback function ...@@ -254,10 +257,10 @@ Parameters of the callback function
**Example** **Example**
```js ```js
uploadTask.off('headerReceive', function callback(headers) { uploadTask.off('headerReceive', function callback(headers) {
console.info("upOnHeader headers:" + JSON.stringify(headers)); console.info("upOnHeader headers:" + JSON.stringify(headers));
} }
); );
``` ```
...@@ -280,15 +283,15 @@ Removes this upload task. This API uses a promise to return the result. ...@@ -280,15 +283,15 @@ Removes this upload task. This API uses a promise to return the result.
**Example** **Example**
```js ```js
uploadTask.remove().then((result) => { uploadTask.remove().then((result) => {
if (result) { if (result) {
console.info('Upload task removed successfully. '); console.info('Upload task removed successfully. ');
} else { } else {
console.error('Failed to remove the upload task. '); console.error('Failed to remove the upload task. ');
} }
}).catch((err) => { }).catch((err) => {
console.error('Failed to remove the upload task. Cause: ' + JSON.stringify(err)); console.error('Failed to remove the upload task. Cause: ' + JSON.stringify(err));
}); });
``` ```
...@@ -311,17 +314,17 @@ Removes this upload task. This API uses an asynchronous callback to return the r ...@@ -311,17 +314,17 @@ Removes this upload task. This API uses an asynchronous callback to return the r
**Example** **Example**
```js ```js
uploadTask.remove((err, result) => { uploadTask.remove((err, result) => {
if (err) { if (err) {
console.error('Failed to remove the upload task. Cause: ' + JSON.stringify(err)); console.error('Failed to remove the upload task. Cause: ' + JSON.stringify(err));
return; return;
} }
if (result) { if (result) {
console.info('Upload task removed successfully.'); console.info('Upload task removed successfully.');
} else { } else {
console.error('Failed to remove the upload task.'); console.error('Failed to remove the upload task.');
} }
}); });
``` ```
...@@ -384,13 +387,14 @@ Downloads files. This API uses a promise to return the result. ...@@ -384,13 +387,14 @@ Downloads files. This API uses a promise to return the result.
**Example** **Example**
```js ```js
request.download({ url: 'https://xxxx/xxxx.hap' }).then((data) => { let downloadTask;
downloadTask = data; request.download({ url: 'https://xxxx/xxxx.hap' }).then((data) => {
}).catch((err) => { downloadTask = data;
console.error('Failed to request the download. Cause: ' + JSON.stringify(err)); }).catch((err) => {
}) console.error('Failed to request the download. Cause: ' + JSON.stringify(err));
``` })
```
## request.download ## request.download
...@@ -413,14 +417,15 @@ Downloads files. This API uses an asynchronous callback to return the result. ...@@ -413,14 +417,15 @@ Downloads files. This API uses an asynchronous callback to return the result.
**Example** **Example**
```js ```js
request.download({ url: 'https://xxxx/xxxxx.hap', let downloadTask;
filePath: 'xxx/xxxxx.hap'}, (err, data) => { request.download({ url: 'https://xxxx/xxxxx.hap',
if (err) { filePath: 'xxx/xxxxx.hap'}, (err, data) => {
console.error('Failed to request the download. Cause: ' + JSON.stringify(err)); if (err) {
return; console.error('Failed to request the download. Cause: ' + JSON.stringify(err));
} return;
downloadTask = data; }
}); downloadTask = data;
});
``` ```
...@@ -456,12 +461,6 @@ Parameters of the callback function ...@@ -456,12 +461,6 @@ Parameters of the callback function
**Example** **Example**
```js ```js
request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> {
if (err) {
console.error('Failed to request download. Cause:' + err);
return;
}
downloadTask = data;
downloadTask.on('progress', function download_callback(receivedSize, totalSize) { downloadTask.on('progress', function download_callback(receivedSize, totalSize) {
console.info("download receivedSize:" + receivedSize + " totalSize:" + totalSize); console.info("download receivedSize:" + receivedSize + " totalSize:" + totalSize);
} }
...@@ -497,17 +496,11 @@ Parameters of the callback function ...@@ -497,17 +496,11 @@ Parameters of the callback function
**Example** **Example**
```js ```js
request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> { downloadTask .off('progress', function download_callback(receivedSize, totalSize) {
if (err) { console.info("download receivedSize:" + receivedSize + " totalSize:" + totalSize);
console.error('Failed to request download. Cause:' + err); }
return; );
} });
downloadTask = data;
downloadTask .off('progress', function download_callback(receivedSize, totalSize) {
console.info("download receivedSize:" + receivedSize + " totalSize:" + totalSize);
}
);
});
``` ```
...@@ -531,17 +524,11 @@ Subscribes to a download event. This API uses an asynchronous callback to return ...@@ -531,17 +524,11 @@ Subscribes to a download event. This API uses an asynchronous callback to return
**Example** **Example**
```js ```js
request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> { downloadTask.on('complete', function callback() {
if (err) { console.info('Download task completed.');
console.error('Failed to request download. Cause:' + err); }
return; );
} });
downloadTask= data;
downloadTask.on('complete', function callback() {
console.info('Download task completed.');
}
);
});
``` ```
...@@ -559,23 +546,17 @@ Unsubscribes from the download event. This API uses an asynchronous callback to ...@@ -559,23 +546,17 @@ Unsubscribes from the download event. This API uses an asynchronous callback to
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes | Event type.<br/>- **complete**: download task completion event.<br/>- **pause**: download task pause event.<br/>- **remove**: download task removal event. | | type | string | Yes | Event type.<br/>- **'complete'**: download task completion event.<br/>- **'pause'**: download task pause event.<br/>- **remove**: download task removal event. |
| callback | function | No | Callback used to return the result. | | callback | function | No | Callback used to return the result. |
**Example** **Example**
```js ```js
request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> { downloadTask.off('complete', function callback() {
if (err) { console.info('Download task completed.');
console.error('Failed to request download. Cause:' + JSON.stringify(err)); }
return; );
} });
downloadTask = data;
downloadTask.off('complete', function callback() {
console.info('Download task completed.');
}
);
});
``` ```
...@@ -604,18 +585,12 @@ Parameters of the callback function ...@@ -604,18 +585,12 @@ Parameters of the callback function
**Example** **Example**
```js ```js
request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> { downloadTask.on('fail', function callBack(err) {
if (err) { console.info('Download task failed. Cause:' + err);
console.error('Failed to request download. Cause:' + err); }
return; );
} });
downloadTask = data;
downloadTask.on('fail', function callBack(err) {
console.info('Download task failed. Cause:' + err);
}
);
});
``` ```
...@@ -645,12 +620,6 @@ Parameters of the callback function ...@@ -645,12 +620,6 @@ Parameters of the callback function
**Example** **Example**
```js ```js
request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> {
if (err) {
console.error('Failed to request download. Cause:' + err);
return;
}
downloadTask = data;
downloadTask.off('fail', function callBack(err) { downloadTask.off('fail', function callBack(err) {
console.info('Download task failed. Cause:' + err); console.info('Download task failed. Cause:' + err);
} }
...@@ -709,17 +678,17 @@ Removes this download task. This API uses an asynchronous callback to return the ...@@ -709,17 +678,17 @@ Removes this download task. This API uses an asynchronous callback to return the
**Example** **Example**
```js ```js
downloadTask.remove((err, result)=>{ downloadTask.remove((err, result)=>{
if(err) { if(err) {
console.error('Failed to remove the download task.'); console.error('Failed to remove the download task.');
return; return;
} }
if (result) { if (result) {
console.info('Download task removed.'); console.info('Download task removed.');
} else { } else {
console.error('Failed to remove the download task.'); console.error('Failed to remove the download task.');
} }
}); });
``` ```
...@@ -742,11 +711,11 @@ Queries this download task. This API uses a promise to return the result. ...@@ -742,11 +711,11 @@ Queries this download task. This API uses a promise to return the result.
**Example** **Example**
```js ```js
downloadTask.query().then((downloadInfo) => { downloadTask.query().then((downloadInfo) => {
console.info('Download task queried. Data:' + JSON.stringify(downloadInfo)) console.info('Download task queried. Data:' + JSON.stringify(downloadInfo))
}) .catch((err) => { }) .catch((err) => {
console.error('Failed to query the download task. Cause:' + err) console.error('Failed to query the download task. Cause:' + err)
}); });
``` ```
...@@ -769,13 +738,13 @@ Queries this download task. This API uses an asynchronous callback to return the ...@@ -769,13 +738,13 @@ Queries this download task. This API uses an asynchronous callback to return the
**Example** **Example**
```js ```js
downloadTask.query((err, downloadInfo)=>{ downloadTask.query((err, downloadInfo)=>{
if(err) { if(err) {
console.error('Failed to query the download mimeType. Cause:' + JSON.stringify(err)); console.error('Failed to query the download mimeType. Cause:' + JSON.stringify(err));
} else { } else {
console.info('download query success. data:'+ JSON.stringify(downloadInfo)); console.info('download query success. data:'+ JSON.stringify(downloadInfo));
} }
}); });
``` ```
...@@ -798,11 +767,11 @@ Queries **MimeType** of this download task. This API uses a promise to return th ...@@ -798,11 +767,11 @@ Queries **MimeType** of this download task. This API uses a promise to return th
**Example** **Example**
```js ```js
downloadTask.queryMimeType().then((data) => { downloadTask.queryMimeType().then((data) => {
console.info('Download task queried. Data:' + JSON.stringify(data)); console.info('Download task queried. Data:' + JSON.stringify(data));
}).catch((err) => { }).catch((err) => {
console.error('Failed to query the download MimeType. Cause:' + JSON.stringify(err)) console.error('Failed to query the download MimeType. Cause:' + JSON.stringify(err))
}); });
``` ```
...@@ -825,13 +794,13 @@ Queries **MimeType** of this download task. This API uses an asynchronous callba ...@@ -825,13 +794,13 @@ Queries **MimeType** of this download task. This API uses an asynchronous callba
**Example** **Example**
```js ```js
downloadTask.queryMimeType((err, data)=>{ downloadTask.queryMimeType((err, data)=>{
if(err) { if(err) {
console.error('Failed to query the download mimeType. Cause:' + JSON.stringify(err)); console.error('Failed to query the download mimeType. Cause:' + JSON.stringify(err));
} else { } else {
console.info('Download task queried. data:' + JSON.stringify(data)); console.info('Download task queried. data:' + JSON.stringify(data));
} }
}); });
``` ```
...@@ -854,15 +823,15 @@ Pauses this download task. This API uses a promise to return the result. ...@@ -854,15 +823,15 @@ Pauses this download task. This API uses a promise to return the result.
**Example** **Example**
```js ```js
downloadTask.pause().then((result) => { downloadTask.pause().then((result) => {
if (result) { if (result) {
console.info('Download task paused. '); console.info('Download task paused. ');
} else { } else {
console.error('Failed to pause the download task. Cause:' + JSON.stringify(result)); console.error('Failed to pause the download task. Cause:' + JSON.stringify(result));
} }
}).catch((err) => { }).catch((err) => {
console.error('Failed to pause the download task. Cause:' + JSON.stringify(err)); console.error('Failed to pause the download task. Cause:' + JSON.stringify(err));
}); });
``` ```
...@@ -885,17 +854,17 @@ Pauses this download task. This API uses an asynchronous callback to return the ...@@ -885,17 +854,17 @@ Pauses this download task. This API uses an asynchronous callback to return the
**Example** **Example**
```js ```js
downloadTask.pause((err, result)=>{ downloadTask.pause((err, result)=>{
if(err) { if(err) {
console.error('Failed to pause the download task. Cause:' + JSON.stringify(err)); console.error('Failed to pause the download task. Cause:' + JSON.stringify(err));
return; return;
} }
if (result) { if (result) {
console.info('Download task paused. '); console.info('Download task paused. ');
} else { } else {
console.error('Failed to pause the download task. Cause:' + JSON.stringify(result)); console.error('Failed to pause the download task. Cause:' + JSON.stringify(result));
} }
}); });
``` ```
...@@ -918,16 +887,16 @@ Resumes this download task. This API uses a promise to return the result. ...@@ -918,16 +887,16 @@ Resumes this download task. This API uses a promise to return the result.
**Example** **Example**
```js ```js
downloadTask.resume().then((result) => { downloadTask.resume().then((result) => {
if (result) { if (result) {
console.info('Download task resumed.') console.info('Download task resumed.')
} else { } else {
console.error('Failed to resume the download task. '); console.error('Failed to resume the download task. ');
} }
console.info('Download task resumed.') console.info('Download task resumed.')
}).catch((err) => { }).catch((err) => {
console.error('Failed to resume the download task. Cause:' + err); console.error('Failed to resume the download task. Cause:' + err);
}); });
``` ```
...@@ -950,17 +919,17 @@ Resumes this download task. This API uses an asynchronous callback to return the ...@@ -950,17 +919,17 @@ Resumes this download task. This API uses an asynchronous callback to return the
**Example** **Example**
```js ```js
downloadTask.resume((err, result)=>{ downloadTask.resume((err, result)=>{
if (err) { if (err) {
console.error('Failed to resume the download task. Cause:' + err); console.error('Failed to resume the download task. Cause:' + err);
return; return;
} }
if (result) { if (result) {
console.info('Download task resumed.'); console.info('Download task resumed.');
} else { } else {
console.error('Failed to resume the download task.'); console.error('Failed to resume the download task.');
} }
}); });
``` ```
...@@ -975,7 +944,7 @@ downloadTask.resume((err, result)=>{ ...@@ -975,7 +944,7 @@ downloadTask.resume((err, result)=>{
| enableMetered | boolean | No | Download allowed in metered connections. | | enableMetered | boolean | No | Download allowed in metered connections. |
| enableRoaming | boolean | No | Download allowed on a roaming network. | | enableRoaming | boolean | No | Download allowed on a roaming network. |
| description | string | No | Description of the download session. | | description | string | No | Description of the download session. |
| filePath<sup>7+</sup> | string | No | Download path. (The default path is [ERROR:Invalid link:en-us_topic_0000001135742582.xml#xref8132147102215,link:en-us_topic_0000001127125012.xml#section1856519365229](en-us_topic_0000001127125012.xml#section1856519365229)).<br/>- filePath:'workspace/test.txt': The **workspace** directory is created in the default path to store files.<br/>- filePath:'test.txt': Files are stored in the default path.<br/>- filePath:'workspace/': The **workspace** directory is created in the default path to store files. | | filePath<sup>7+</sup> | string | No | Download path. (The default value is **'internal://cache/'**).<br/>- filePath:'workspace/test.txt': The **workspace** directory is created in the default path to store files.<br/>- filePath:'test.txt': Files are stored in the default path.<br/>- filePath:'workspace/': The **workspace** directory is created in the default path to store files. |
| networkType | number | No | Network type allowed for download. | | networkType | number | No | Network type allowed for download. |
| title | string | No | Title of the download session. | | title | string | No | Title of the download session. |
......
# Settings # Settings
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > **NOTE**<br>
> The initial APIs of this module are supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version.
...@@ -23,21 +23,24 @@ Obtains the URI of a data item. ...@@ -23,21 +23,24 @@ Obtains the URI of a data item.
**System capability**: SystemCapability.Applictaions.settings.Core **System capability**: SystemCapability.Applictaions.settings.Core
- Parameters **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| name | string | Yes| Name of the target data item. Data items can be classified as follows:<br> <ul><li>Existing data items in the database, for example:<br></li> <ul><li>Brightness: 'settings.screen.brightness'<br> </li> <li>Time format: 'settings.time.format'<br> </li></ul> <li>Custom data items</li></ul>|
- Return value | Name| Type| Mandatory| Description|
| Type| Description| | -------- | -------- | -------- | -------- |
| -------- | -------- | | name | string | Yes| Name of the target data item. Data items can be classified as follows:<br> <ul><li>Existing data items in the database, for example:<br></li> <ul><li>Brightness: 'settings.screen.brightness'<br> </li> <li>Time format: 'settings.time.format'<br> </li></ul> <li>Custom data items</li></ul>|
| string | URI of the data item.|
- Example **Return value**
```typescript
// Obtain the URI of a data item. | Type| Description|
let urivar = settings.getUriSync('settings.screen.brightness'); | -------- | -------- |
``` | string | URI of the data item.|
**Example**
```typescript
// Obtain the URI of a data item.
let urivar = settings.getUriSync('settings.screen.brightness');
```
## settings.getValueSync ## settings.getValueSync
...@@ -48,28 +51,30 @@ Obtains the value of a data item. ...@@ -48,28 +51,30 @@ Obtains the value of a data item.
**System capability**: SystemCapability.Applictaions.settings.Core **System capability**: SystemCapability.Applictaions.settings.Core
- Parameters **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| dataAbilityHelper | [DataAbilityHelper](js-apis-dataAbilityHelper.md) | Yes| **DataAbilityHelper** class.| | dataAbilityHelper | [DataAbilityHelper](js-apis-dataAbilityHelper.md) | Yes| **DataAbilityHelper** class.|
| name | string | Yes| Name of the target data item. Data items can be classified as follows:<br> <ul><li>Existing data items in the database, for example:<br></li> <ul><li>Brightness: 'settings.screen.brightness'<br> </li> <li>Time format: 'settings.time.format'<br> </li></ul> <li>Custom data items</li></ul>| | name | string | Yes| Name of the target data item. Data items can be classified as follows:<br> <ul><li>Existing data items in the database, for example:<br></li> <ul><li>Brightness: 'settings.screen.brightness'<br> </li> <li>Time format: 'settings.time.format'<br> </li></ul> <li>Custom data items</li></ul>|
| defValue | string | Yes| Default value This parameter is user-defined. If it is not found in the database, the default value is returned.| | defValue | string | Yes| Default value This parameter is user-defined. If it is not found in the database, the default value is returned.|
**Return value**
| Type| Description|
| -------- | -------- |
| string | Value of the data item.|
- Return value **Example**
| Type| Description|
| -------- | -------- |
| string | Value of the data item.|
- Example ```typescript
```typescript
import featureAbility from '@ohos.ability.featureAbility'; import featureAbility from '@ohos.ability.featureAbility';
// Obtain the value of 'settings.screen.brightness' (this data item already exists in the database). // Obtain the value of 'settings.screen.brightness' (this data item already exists in the database).
let brightness = 'settings.screen.brightness'; let brightness = 'settings.screen.brightness';
let uri = settings.getUriSync(brightness); let uri = settings.getUriSync(brightness);
let helper = featureAbility.acquireDataAbilityHelper(uri); let helper = featureAbility.acquireDataAbilityHelper(uri);
let value = settings.getValueSync(helper, brightness, '10'); let value = settings.getValueSync(helper, brightness, '10');
``` ```
## settings.setValueSync ## settings.setValueSync
...@@ -77,32 +82,36 @@ Obtains the value of a data item. ...@@ -77,32 +82,36 @@ Obtains the value of a data item.
setValueSync(dataAbilityHelper: DataAbilityHelper, name: string, value: string): boolean setValueSync(dataAbilityHelper: DataAbilityHelper, name: string, value: string): boolean
Sets the value of a data item. Sets the value of a data item.
If the specified data item exists in the database, the **setValueSync** method updates the value of the data item. If the data item does not exist in the database, the **setValueSync** method inserts the data item into the database. If the specified data item exists in the database, the **setValueSync** method updates the value of the data item. If the data item does not exist in the database, the **setValueSync** method inserts the data item into the database.
**Required permissions**: ohos.permission.WRITE_SYSTEM_SETTING **Required permissions**: ohos.permission.WRITE_SYSTEM_SETTING
**System capability**: SystemCapability.Applictaions.settings.Core **System capability**: SystemCapability.Applictaions.settings.Core
- Parameters **Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | Name| Type| Mandatory| Description|
| dataAbilityHelper | [DataAbilityHelper](js-apis-dataAbilityHelper.md) | Yes| **DataAbilityHelper** class.| | -------- | -------- | -------- | -------- |
| name | string | Yes| Name of the target data item. Data items can be classified as follows:<br> <ul><li>Existing data items in the database, for example:<br></li> <ul><li>Brightness: 'settings.screen.brightness'<br> </li> <li>Time format: 'settings.time.format'<br> </li></ul> <li>Custom data items</li></ul>| | dataAbilityHelper | [DataAbilityHelper](js-apis-dataAbilityHelper.md) | Yes| **DataAbilityHelper** class.|
| value | string | Yes| Value of the data item.| | name | string | Yes| Name of the target data item. Data items can be classified as follows:<br> <ul><li>Existing data items in the database, for example:<br></li> <ul><li>Brightness: 'settings.screen.brightness'<br> </li> <li>Time format: 'settings.time.format'<br> </li></ul> <li>Custom data items</li></ul>|
| value | string | Yes| Value of the data item.|
- Return value **Return value**
| Type| Description|
| -------- | -------- |
| boolean | Result indicating whether the value is set successfully. Returns **true** if the value is set successfully; returns **false** otherwise.|
- Example | Type| Description|
```typescript | -------- | -------- |
| boolean | Result indicating whether the value is set successfully. Returns **true** if the value is set successfully; returns **false** otherwise.|
**Example**
```typescript
import featureAbility from '@ohos.ability.featureAbility'; import featureAbility from '@ohos.ability.featureAbility';
// Update the value of 'settings.screen.brightness'. (As this data item exists in the database, the setValueSync // Update the value of 'settings.screen.brightness'. (As this data item exists in the database, the setValueSync
method will update the value of the data item.) method will update the value of the data item.)
let brightness = 'settings.screen.brightness'; let brightness = 'settings.screen.brightness';
let uri = settings.getUriSync(brightness); let uri = settings.getUriSync(brightness);
let helper = featureAbility.acquireDataAbilityHelper(uri); let helper = featureAbility.acquireDataAbilityHelper(uri);
let ret = settings.setValueSync(helper, brightness, '100'); let ret = settings.setValueSync(helper, brightness, '100');
``` ```
\ No newline at end of file
# System Parameter # System Parameter
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > **NOTE**<br>
> - The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. > - The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> - This is a system API and cannot be called by third-party applications. > - This is a system API and cannot be called by third-party applications.
...@@ -24,7 +24,7 @@ Obtains the value of the attribute with the specified key. ...@@ -24,7 +24,7 @@ Obtains the value of the attribute with the specified key.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| key | string | Yes| Key of the system attribute.| | key | string | Yes| Key of the system attribute.|
| def | string | No| Default Value| | def | string | No| Default value.|
**Return value** **Return value**
...@@ -88,7 +88,7 @@ Obtains the value of the attribute with the specified key. This API uses an asyn ...@@ -88,7 +88,7 @@ Obtains the value of the attribute with the specified key. This API uses an asyn
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| key | string | Yes| Key of the system attribute.| | key | string | Yes| Key of the system attribute.|
| def | string | Yes| Default Value| | def | string | Yes| Default value.|
| callback | AsyncCallback&lt;string&gt; | Yes| Callback used to return the result.| | callback | AsyncCallback&lt;string&gt; | Yes| Callback used to return the result.|
**Example** **Example**
...@@ -121,7 +121,7 @@ Obtains the value of the attribute with the specified key. This API uses a promi ...@@ -121,7 +121,7 @@ Obtains the value of the attribute with the specified key. This API uses a promi
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| key | string | Yes| Key of the system attribute.| | key | string | Yes| Key of the system attribute.|
| def | string | No| Default Value| | def | string | No| Default value.|
**Return value** **Return value**
...@@ -171,7 +171,7 @@ try { ...@@ -171,7 +171,7 @@ try {
``` ```
## parameter.set(key: string, value: string, callback: AsyncCallback&lt;void&gt;) ## parameter.set
set(key: string, value: string, callback: AsyncCallback&lt;void&gt;): void set(key: string, value: string, callback: AsyncCallback&lt;void&gt;): void
...@@ -184,7 +184,7 @@ Sets a value for the attribute with the specified key. This API uses an asynchro ...@@ -184,7 +184,7 @@ Sets a value for the attribute with the specified key. This API uses an asynchro
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| key | string | Yes| Key of the system attribute.| | key | string | Yes| Key of the system attribute.|
| def | string | Yes| Default Value| | value | string | Yes| System attribute value to set.|
| 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** **Example**
...@@ -203,9 +203,9 @@ try { ...@@ -203,9 +203,9 @@ try {
``` ```
## parameter.set(key: string, def?: string) ## parameter.set
set(key: string, def?: string): Promise&lt;string&gt; set(key: string, value: string): Promise&lt;void&gt;
Sets a value for the attribute with the specified key. This API uses a promise to return the result. Sets a value for the attribute with the specified key. This API uses a promise to return the result.
...@@ -216,13 +216,13 @@ Sets a value for the attribute with the specified key. This API uses a promise t ...@@ -216,13 +216,13 @@ Sets a value for the attribute with the specified key. This API uses a promise t
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| key | string | Yes| Key of the system attribute.| | key | string | Yes| Key of the system attribute.|
| def | string | No| Default Value| | value| string | Yes | System attribute value to set.|
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;string&gt; | Promise used to return the execution result.| | Promise&lt;void&gt; | Promise used to return the execution result.|
**Example** **Example**
......
# Work Scheduler # Work Scheduler
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/> > **NOTE**<br/>
> The initial APIs of this module are supported since API version 9. API version 9 is a canary version for trial use. The APIs of this version may be unstable. > The initial APIs of this module are supported since API version 9. API version 9 is a canary version for trial use. The APIs of this version may be unstable.
...@@ -100,7 +100,7 @@ Obtains the latest task status. This API uses an asynchronous callback to return ...@@ -100,7 +100,7 @@ Obtains the latest task status. This API uses an asynchronous callback to return
``` ```
workScheduler.getWorkStatus(50, (err, res) => { workScheduler.getWorkStatus(50, (err, res) => {
if (err) { if (err) {
console.info('workschedulerLog getWorkStatus failed, because:' + err.data); console.info('workschedulerLog getWorkStatus failed, because:' + err.code);
} else { } else {
for (let item in res) { for (let item in res) {
console.info('workschedulerLog getWorkStatus success,' + item + ' is:' + res[item]); console.info('workschedulerLog getWorkStatus success,' + item + ' is:' + res[item]);
...@@ -136,7 +136,7 @@ Obtains the latest task status. This API uses a promise to return the result. ...@@ -136,7 +136,7 @@ Obtains the latest task status. This API uses a promise to return the result.
console.info('workschedulerLog getWorkStatus success,' + item + ' is:' + res[item]); console.info('workschedulerLog getWorkStatus success,' + item + ' is:' + res[item]);
} }
}).catch((err) => { }).catch((err) => {
console.info('workschedulerLog getWorkStatus failed, because:' + err.data); console.info('workschedulerLog getWorkStatus failed, because:' + err.code);
}) })
``` ```
...@@ -151,7 +151,7 @@ Obtains all tasks associated with this application. This API uses an asynchronou ...@@ -151,7 +151,7 @@ Obtains all tasks associated with this application. This API uses an asynchronou
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | -------------------- | ---- | ------------------------------- | | -------- | -------------------- | ---- | ------------------------------- |
| callback | AsyncCallback\<void> | Yes | Callback used to return all tasks associated with the current application.| | callback | AsyncCallback\<void> | Yes | Callback used to return all tasks associated with the current application. |
**Return value** **Return value**
...@@ -164,7 +164,7 @@ Obtains all tasks associated with this application. This API uses an asynchronou ...@@ -164,7 +164,7 @@ Obtains all tasks associated with this application. This API uses an asynchronou
``` ```
workScheduler.obtainAllWorks((err, res) =>{ workScheduler.obtainAllWorks((err, res) =>{
if (err) { if (err) {
console.info('workschedulerLog obtainAllWorks failed, because:' + err.data); console.info('workschedulerLog obtainAllWorks failed, because:' + err.code);
} else { } else {
console.info('workschedulerLog obtainAllWorks success, data is:' + JSON.stringify(res)); console.info('workschedulerLog obtainAllWorks success, data is:' + JSON.stringify(res));
} }
...@@ -182,7 +182,7 @@ Obtains all tasks associated with this application. This API uses a promise to r ...@@ -182,7 +182,7 @@ Obtains all tasks associated with this application. This API uses a promise to r
| Type | Description | | Type | Description |
| -------------------------------------- | ------------------------------ | | -------------------------------------- | ------------------------------ |
| Promise<Array\<[WorkInfo](#workinfo)>> | Promise used to return all tasks associated with the current application.| | Promise<Array\<[WorkInfo](#workinfo)>> | Promise used to return all tasks associated with the current application. |
**Example** **Example**
...@@ -190,7 +190,7 @@ Obtains all tasks associated with this application. This API uses a promise to r ...@@ -190,7 +190,7 @@ Obtains all tasks associated with this application. This API uses a promise to r
workScheduler.obtainAllWorks().then((res) => { workScheduler.obtainAllWorks().then((res) => {
console.info('workschedulerLog obtainAllWorks success, data is:' + JSON.stringify(res)); console.info('workschedulerLog obtainAllWorks success, data is:' + JSON.stringify(res));
}).catch((err) => { }).catch((err) => {
console.info('workschedulerLog obtainAllWorks failed, because:' + err.data); console.info('workschedulerLog obtainAllWorks failed, because:' + err.code);
}) })
``` ```
...@@ -233,7 +233,7 @@ Checks whether the last execution of the specified task timed out. This API uses ...@@ -233,7 +233,7 @@ Checks whether the last execution of the specified task timed out. This API uses
``` ```
workScheduler.isLastWorkTimeOut(500, (err, res) =>{ workScheduler.isLastWorkTimeOut(500, (err, res) =>{
if (err) { if (err) {
console.info('workschedulerLog isLastWorkTimeOut failed, because:' + err.data); console.info('workschedulerLog isLastWorkTimeOut failed, because:' + err.code);
} else { } else {
console.info('workschedulerLog isLastWorkTimeOut success, data is:' + res); console.info('workschedulerLog isLastWorkTimeOut success, data is:' + res);
} }
...@@ -267,7 +267,7 @@ Checks whether the last execution of the specified task timed out. This API uses ...@@ -267,7 +267,7 @@ Checks whether the last execution of the specified task timed out. This API uses
console.info('workschedulerLog isLastWorkTimeOut success, data is:' + res); console.info('workschedulerLog isLastWorkTimeOut success, data is:' + res);
}) })
.catch(err => { .catch(err => {
console.info('workschedulerLog isLastWorkTimeOut failed, because:' + err.data); console.info('workschedulerLog isLastWorkTimeOut failed, because:' + err.code);
}); });
``` ```
...@@ -291,6 +291,8 @@ Provides detailed information about the task. ...@@ -291,6 +291,8 @@ Provides detailed information about the task.
| repeatCycleTime | number | No | Repeat interval. | | repeatCycleTime | number | No | Repeat interval. |
| repeatCount | number | No | Number of repeat times. | | repeatCount | number | No | Number of repeat times. |
| isPersisted | boolean | No | Whether to enable persistent storage for the task. | | isPersisted | boolean | No | Whether to enable persistent storage for the task. |
| isDeepIdle | boolean | No | Whether the device needs to enter the idle state. |
| idleWaitTime | number | No | Time to wait in the idle state. |
## NetworkType ## NetworkType
Enumerates the network types that can trigger the task. Enumerates the network types that can trigger the task.
...@@ -319,7 +321,7 @@ Enumerates the charging types that can trigger the task. ...@@ -319,7 +321,7 @@ Enumerates the charging types that can trigger the task.
| CHARGING_PLUGGED_WIRELESS | 3 | Wireless charging. | | CHARGING_PLUGGED_WIRELESS | 3 | Wireless charging. |
## BatteryStatus ## BatteryStatus
Enumerates the battery status that can trigger the task. Enumerates the battery states that can trigger the task.
**System capability**: SystemCapability.ResourceSchedule.WorkScheduler **System capability**: SystemCapability.ResourceSchedule.WorkScheduler
...@@ -330,7 +332,7 @@ Enumerates the battery status that can trigger the task. ...@@ -330,7 +332,7 @@ Enumerates the battery status that can trigger the task.
| BATTERY_STATUS_LOW_OR_OKAY | 2 | The battery level is restored from low to normal, or a low battery alert is displayed.| | BATTERY_STATUS_LOW_OR_OKAY | 2 | The battery level is restored from low to normal, or a low battery alert is displayed.|
## StorageRequest ## StorageRequest
Enumerates the storage status that can trigger the task. Enumerates the storage states that can trigger the task.
**System capability**: SystemCapability.ResourceSchedule.WorkScheduler **System capability**: SystemCapability.ResourceSchedule.WorkScheduler
......
# AnimatorProperty # AnimatorProperty
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > **NOTE**<br>
> This animation is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. > This animation is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
...@@ -18,21 +18,21 @@ When the universal attributes of a component change, you can create an **Animato ...@@ -18,21 +18,21 @@ When the universal attributes of a component change, you can create an **Animato
- Curve enums - Curve enums
| Name | Description | | Name | Description |
| -------- | -------- | | -------- | -------- |
| Linear | The animation speed keeps unchanged. | | Linear | The animation speed keeps unchanged. |
| Ease | The animation starts at a low speed and then accelerates. It slows down before the animation ends. The cubic-bezier curve (0.25, 0.1, 0.25, 1.0) is used. | | Ease | The animation starts at a low speed and then accelerates. It slows down before the animation ends. The cubic-bezier curve (0.25, 0.1, 0.25, 1.0) is used. |
| EaseIn | The animation starts at a low speed. The cubic-bezier curve (0.42, 0.0, 1.0, 1.0) is used. | | EaseIn | The animation starts at a low speed. The cubic-bezier curve (0.42, 0.0, 1.0, 1.0) is used. |
| EaseOut | The animation ends at a low speed. The cubic-bezier curve (0.0, 0.0, 0.58, 1.0) is used. | | EaseOut | The animation ends at a low speed. The cubic-bezier curve (0.0, 0.0, 0.58, 1.0) is used. |
| EaseInOut | The animation starts and ends at a low speed. The cubic-bezier curve (0.42, 0.0, 0.58, 1.0) is used. | | EaseInOut | The animation starts and ends at a low speed. The cubic-bezier curve (0.42, 0.0, 0.58, 1.0) is used. |
| FastOutSlowIn | The animation uses the standard cubic-bezier curve (0.4, 0.0, 0.2, 1.0). | | FastOutSlowIn | The animation uses the standard cubic-bezier curve (0.4, 0.0, 0.2, 1.0). |
| LinearOutSlowIn | The animation uses the deceleration cubic-bezier curve (0.0, 0.0, 0.2, 1.0). | | LinearOutSlowIn | The animation uses the deceleration cubic-bezier curve (0.0, 0.0, 0.2, 1.0). |
| FastOutLinearIn | The animation uses the acceleration cubic-bezier curve (0.4, 0.0, 1.0, 1.0). | | FastOutLinearIn | The animation uses the acceleration cubic-bezier curve (0.4, 0.0, 1.0, 1.0). |
| ExtremeDeceleration | The animation uses the extreme deceleration cubic-bezier curve (0.0, 0.0, 0.0, 1.0). | | ExtremeDeceleration | The animation uses the extreme deceleration cubic-bezier curve (0.0, 0.0, 0.0, 1.0). |
| Sharp | The animation uses the sharp cubic-bezier curve (0.33, 0.0, 0.67, 1.0). | | Sharp | The animation uses the sharp cubic-bezier curve (0.33, 0.0, 0.67, 1.0). |
| Rhythm | The animation uses the rhythm cubic-bezier curve (0.7, 0.0, 0.2, 1.0). | | Rhythm | The animation uses the rhythm cubic-bezier curve (0.7, 0.0, 0.2, 1.0). |
| Smooth | The animation uses the smooth cubic-bezier curve (0.4, 0.0, 0.4, 1.0). | | Smooth | The animation uses the smooth cubic-bezier curve (0.4, 0.0, 0.4, 1.0). |
| Friction | Damping curve. The cubic-bezier curve (0.2, 0.0, 0.2, 1.0) is used. | | Friction | Damping curve. The cubic-bezier curve (0.2, 0.0, 0.2, 1.0) is used. |
## Example ## Example
......
# Blank # Blank
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > **NOTE**<br>
> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. > This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
...@@ -23,24 +23,25 @@ None ...@@ -23,24 +23,25 @@ None
Blank(min?: Length) Blank(min?: Length)
- Parameters - Parameters
| Name | Type | Mandatory | Default Value | Description | | Name | Type | Mandatory | Default Value | Description |
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| min | Length | No | 0 | Minimum size of the **&lt;Blank&gt;** component in the container along the main axis. | | min | Length | No | 0 | Minimum size of the **&lt;Blank&gt;** component in the container along the main axis. |
## Attributes ## Attributes
| Name | Type | Default Value | Description | | Name | Type | Default Value | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| color | Color | 0x00000000 | Color to fill the blank. | | color | Color | 0x00000000 | Color to fill the blank. |
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
>
> - Universal attribute methods are not supported. > - Universal attribute methods are not supported.
## Example ## Example
``` ```
@Entry @Entry
@Component @Component
......
# Button # Button
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > **NOTE**<br>This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
> >
> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
The **&lt;Button&gt;** component represents a component that can trigger actions. The **&lt;Button&gt;** component represents a component that can trigger actions.
......
# Checkbox # Checkbox
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > **NOTE**<br>
> This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. > This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version.
......
# CheckboxGroup # CheckboxGroup
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > **NOTE**<br>
> This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. > This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version.
The **\<CheckboxGroup>** component is used to select or deselect all check boxes in a group. The **\<CheckboxGroup>** component is used to select or deselect all check boxes in a group.
...@@ -27,19 +27,19 @@ Creates a check box group so that you can select or deselect all check boxes in ...@@ -27,19 +27,19 @@ Creates a check box group so that you can select or deselect all check boxes in
## Attributes ## Attributes
| Name| Type| Default Value| Description| | Name| Type| Default Value| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| selectAll | bool | false | Whether to select all.| | selectAll | bool | false | Whether to select all.|
| selectedColor | Color | - | Color of the selected check box.| | selectedColor | Color | - | Color of the selected check box.|
## Events ## Events
| Name| Description| | Name| Description|
| -------- | -------- | | -------- | -------- |
| onChange (callback: (names: Array&lt;string&gt;, status: SelectStatus) => void ) |Triggered when the selection status of the check box group or any check box wherein changes.<br>- **names**: names of all selected check boxes in the group.<br>- **status**: selection status.| | onChange (callback: (names: Array&lt;string&gt;, status: SelectStatus) => void ) |Triggered when the selection status of the check box group or any check box wherein changes.<br>- **names**: names of all selected check boxes in the group.<br>- **status**: selection status.|
- SelectStatus enums - SelectStatus enums
| Name | Description| | Name | Description|
| ----- | -------------------- | | ----- | -------------------- |
| All | All check boxes in the group are selected.| | All | All check boxes in the group are selected.|
| Part | Some check boxes in the group are selected.| | Part | Some check boxes in the group are selected.|
......
# DataPanel # DataPanel
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > **NOTE**<br>
> This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. > This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version.
...@@ -23,17 +23,17 @@ None ...@@ -23,17 +23,17 @@ None
DataPanel(value:{values: number[], max?: number, type?: DataPanelType}) DataPanel(value:{values: number[], max?: number, type?: DataPanelType})
- Parameters - Parameters
| Name | Type | Mandatory | Default Value | Description | | Name | Type | Mandatory | Default Value | Description |
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| values | number[] | Yes | - | Value list. A maximum of nine values are supported. | | values | number[] | Yes | - | Value list. A maximum of nine values are supported. |
| max | number | No | 100 | - When set to a value greater than 0, this parameter indicates the maximum value in the **values** list.<br/>- When set to a value equal to or smaller than 0, this parameter indicates the sum of values in the **values** list. The values are displayed in proportion. | | max | number | No | 100 | - When set to a value greater than 0, this parameter indicates the maximum value in the **values** list.<br/>- When set to a value equal to or smaller than 0, this parameter indicates the sum of values in the **values** list. The values are displayed in proportion. |
| type<sup>8+</sup> | DataPanelType | No | DataPanelType.Circle | Type of the data panel. | | type<sup>8+</sup> | DataPanelType | No | DataPanelType.Circle | Type of the data panel. |
- DataPanelType enums - DataPanelType enums
| Name | Description | | Name | Description |
| -------- | -------- | | -------- | -------- |
| Line | Line data panel. | | Line | Line data panel. |
| Circle | Circle data panel. | | Circle | Circle data panel. |
......
# DatePicker # DatePicker
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > **NOTE**<br>
> This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. > This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version.
......
# Navigation # Navigation
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > **NOTE**<br>
> This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. > This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version.
...@@ -29,37 +29,37 @@ Creates a component that can automatically display the navigation bar, title, an ...@@ -29,37 +29,37 @@ Creates a component that can automatically display the navigation bar, title, an
| Name | Type | Default Value | Description | | Name | Type | Default Value | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| title | string \| [CustomBuilder](../../ui/ts-types.md)<sup>8+</sup> | - | Page title. | | title | string \| [CustomBuilder](../../ui/ts-types.md) | - | Page title. |
| subtitle | string | - | Subtitle of the page. | | subtitle | string | - | Subtitle of the page. |
| menus | Array&lt;NavigationMenuItem&gt; \| [CustomBuilder](../../ui/ts-types.md)<sup>8+</sup> | - | Menu in the upper right corner of the page. | | menus | Array&lt;NavigationMenuItem&gt; \| [CustomBuilder](../../ui/ts-types.md) | - | Menu in the upper right corner of the page. |
| titleMode | NavigationTitleMode | NavigationTitleMode.Free | Display mode of the page title bar. | | titleMode | NavigationTitleMode | NavigationTitleMode.Free | Display mode of the page title bar. |
| toolBar | {<br/>items:[<br/>Object<br/>] }<br/>\| [CustomBuilder](../../ui/ts-types.md)<sup>8+</sup> | - | Content of the toolbar.<br/>**items**: all items on the toolbar. | | toolBar | {<br/>items:[<br/>Object<br/>] }<br/>\| [CustomBuilder](../../ui/ts-types.md) | - | Content of the toolbar.<br/>**items**: all items on the toolbar. |
| hideToolBar | boolean | false | Whether to hide the toolbar.<br/>**true**: Hide the toolbar.<br/>**false**: Show the toolbar. | | hideToolBar | boolean | false | Whether to hide the toolbar.<br/>**true**: Hide the toolbar.<br/>**false**: Show the toolbar. |
| hideTitleBar | boolean | false | Whether to hide the title bar. | | hideTitleBar | boolean | false | Whether to hide the title bar. |
| hideBackButton | boolean | false | Whether to hide the back button. | | hideBackButton | boolean | false | Whether to hide the back button. |
- NavigationMenuItem attributes - NavigationMenuItem attributes
| Name | Type | Mandatory | Default Value | Description | | Name | Type | Mandatory | Default Value | Description |
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| value | string | Yes | - | Text of an option on the menu bar. | | value | string | Yes | - | Text of an option on the menu bar. |
| icon | string | No | - | Icon path of an option on the menu bar. | | icon | string | No | - | Icon path of an option on the menu bar. |
| action | () =&gt; void | No | - | Callback invoked when an option is selected. | | action | () =&gt; void | No | - | Callback invoked when an option is selected. |
- Object attributes - Object attributes
| Name | Type | Mandatory | Default Value | Description | | Name | Type | Mandatory | Default Value | Description |
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| value | string | Yes | - | Text of an option on the toolbar. | | value | string | Yes | - | Text of an option on the toolbar. |
| icon | string | No | - | Icon path of an option on the toolbar. | | icon | string | No | - | Icon path of an option on the toolbar. |
| action | () =&gt; void | No | - | Callback invoked when an option is selected. | | action | () =&gt; void | No | - | Callback invoked when an option is selected. |
- NavigationTitleMode enums - NavigationTitleMode enums
| Name | Description | | Name | Description |
| -------- | -------- | | -------- | -------- |
| Free | When the content is a scrollable component, the title shrinks as the content scrolls up (the subtitle fades out with its size remaining unchanged) and restores as the content scrolls down. | | Free | When the content is a scrollable component, the title shrinks as the content scrolls up (the subtitle fades out with its size remaining unchanged) and restores as the content scrolls down. |
| Mini | The mode is fixed at mini mode (icon + main title and subtitle). | | Mini | The mode is fixed at mini mode (icon + main title and subtitle). |
| Full | The mode is fixed at full mode (main title and subtitle). | | Full | The mode is fixed at full mode (main title and subtitle). |
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > **NOTE**
> Currently, only the scrollable component **&lt;List&gt;** is supported. > Currently, only the scrollable component **&lt;List&gt;** is supported.
......
...@@ -55,7 +55,7 @@ controller: SearchController = new SearchController() ...@@ -55,7 +55,7 @@ controller: SearchController = new SearchController()
``` ```
#### caretPosition #### caretPosition
creatPosition(value: number): viod creatPosition(value: number): void
Sets the position of the caret. Sets the position of the caret.
......
# Text # Text
> **NOTE**<br/>
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. > This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
The **&lt;Text&gt;** component is used to display a paragraph of textual information. The **\<Text>** component is used to display a piece of textual information.
## Required Permissions ## Required Permissions
...@@ -15,7 +14,7 @@ None ...@@ -15,7 +14,7 @@ None
## Child Components ## Child Components
The **&lt;Text&gt;** component can contain the child component [<Span>](ts-basic-components-span.md). This component can contain the [\<Span>](ts-basic-components-span.md) child component.
## APIs ## APIs
...@@ -23,60 +22,70 @@ The **&lt;Text&gt;** component can contain the child component [<Span>](ts-basic ...@@ -23,60 +22,70 @@ The **&lt;Text&gt;** component can contain the child component [<Span>](ts-basic
Text(content?: string) Text(content?: string)
- Parameters - Parameters
| Name | Type | Mandatory | Default Value | Description | | Name| Type| Mandatory| Default Value| Description|
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| content | string | No | '' | Text content, which is the content of the child component **&lt;Span&gt;**. This parameter does not take effect when the child component **&lt;Span&gt;** is contained. | | content | string | No| '' | Text content. This parameter does not take effect when the child component **\<Span>** is contained.|
## Attributes ## Attributes
| Name | Type | Default Value | Description | | Name| Type| Default Value| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| textAlign | TextAlign | TextAlign.Start | Text alignment mode of multiple lines of text. | | textAlign | TextAlign | TextAlign.Start | Text alignment mode of multiple lines of text.|
| textOverflow | {overflow: TextOverflow} | {overflow: TextOverflow.Clip} | Display mode when the text is too long. | | textOverflow | {overflow: TextOverflow} | {overflow: TextOverflow.Clip} | Display mode when the text is too long.<br>**NOTE**<br>Text is truncated at the transition between words. To truncate text in the middle of a word, add **\u200B** between characters. |
| maxLines | number | Infinity | Maximum number of lines in the text. | | maxLines | number | Infinity | Maximum number of lines in the text.|
| lineHeight | Length | - | Text line height. If the value is less than or equal to **0**, the line height is not limited and the font size is adaptive. If the value of the number type, the unit fp is used. | | lineHeight | Length | - | Text line height. If the value is less than or equal to **0**, the line height is not limited and the font size is adaptive. If the value of the number type, the unit fp is used.|
| decoration | {<br/>type: TextDecorationType,<br/>color?: Color<br/>} | {<br/>type: TextDecorationType.None,<br/>color: Color.Black<br/>} | Style and color of the text decorative line. | | decoration | {<br>type: TextDecorationType,<br>color?: Color<br>} | {<br>type: TextDecorationType.None,<br>color: Color.Black<br>} | Style and color of the text decorative line.|
| baselineOffset | Length | - | Offset of the text baseline. | | baselineOffset | Length | - | Offset of the text baseline.|
| textCase | TextCase | TextCase.Normal | Text case. | | textCase | TextCase | TextCase.Normal | Text case.|
| copyOption<sup>9+</sup> | boolean\|CopyOption | false | Whether copy and paste is allowed.|
- TextAlign enums - TextAlign enums
| Name | Description | | Name| Description|
| -------- | -------- | | -------- | -------- |
| Center | The text is center-aligned. | | Center | The text is center-aligned.|
| Start | The text is aligned with the direction in which the text is written. | | Start | The text is aligned with the direction in which the text is written.|
| End | The text is aligned with the opposite direction in which the text is written. | | End | The text is aligned with the opposite direction in which the text is written.|
- TextOverflow enums - TextOverflow enums
| Name | Description | | Name| Description|
| -------- | -------- | | -------- | -------- |
| Clip | Extra text is truncated. | | Clip | Extra text is truncated.|
| Ellipsis | The ellipsis (...) is used for extra-long text. | | Ellipsis | An ellipsis (...) is used to represent clipped text.|
| None | No truncation or ellipsis is used for extra-long text. | | None | No truncation or ellipsis is used for extra-long text.|
- TextDecorationType enums - TextDecorationType enums
| Name | Description | | Name| Description|
| -------- | -------- | | -------- | -------- |
| Underline | An underline is used. | | Underline | Line under the text.|
| LineThrough | A strikethrough is used. | | LineThrough | Line through the text.|
| Overline | An overline is used. | | Overline | Line over the text.|
| None | No decorative line is used. | | None | No decorative lines.|
- TextCase enums - TextCase enums
| Name | Description |
| Name | Description |
| --------- | -------------------- |
| Normal | The original case of the text is retained.|
| LowerCase | All letters in the text are in lowercase. |
| UpperCase | All letters in the text are in uppercase. |
- CopyOption<sup>9+</sup> enums
| Name| Description|
| -------- | -------- | | -------- | -------- |
| Normal | The original case of the text is retained. | | InApp | Intra-application copy and paste is allowed.|
| LowerCase | All letters in the text are in lowercase. | | LocalDevice | Intra-device copy and paste is allowed.|
| UpperCase | All letters in the text are in uppercase. | | CrossDevice | Cross-device copy and paste is allowed.|
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > **NOTE**<br/>
> The **&lt;Text&gt;** component cannot contain both the text and the child component **&lt;Span&gt;**. If both of them exist, only the content in **&lt;Span&gt;** is displayed. > If the **\<Text>** component contains both the text and the **\<Span>** child component, only the content in **\<Span>** is displayed.
## Example ## Example
```ts
``` // xxx.ets
@Entry @Entry
@Component @Component
struct TextExample1 { struct TextExample1 {
...@@ -93,7 +102,7 @@ struct TextExample1 { ...@@ -93,7 +102,7 @@ struct TextExample1 {
Text('This is the setting of textOverflow to Clip text content This is the setting of textOverflow to Clip text content.') Text('This is the setting of textOverflow to Clip text content This is the setting of textOverflow to Clip text content.')
.textOverflow({ overflow: TextOverflow.Clip }) .textOverflow({ overflow: TextOverflow.Clip })
.maxLines(1).fontSize(12).border({ width: 1 }).padding(10) .maxLines(1).fontSize(12).border({ width: 1 }).padding(10)
Text('This is set textOverflow to Ellipsis text content This is set textOverflow to Ellipsis text content.') Text('This is set textOverflow to Ellipsis text content This is set textOverflow to Ellipsis text content.'.split('').join('\u200B'))
.textOverflow({ overflow: TextOverflow.Ellipsis }) .textOverflow({ overflow: TextOverflow.Ellipsis })
.maxLines(1).fontSize(12).border({ width: 1 }).padding(10) .maxLines(1).fontSize(12).border({ width: 1 }).padding(10)
...@@ -114,8 +123,8 @@ struct TextExample1 { ...@@ -114,8 +123,8 @@ struct TextExample1 {
![en-us_image_0000001257138337](figures/en-us_image_0000001257138337.gif) ![en-us_image_0000001257138337](figures/en-us_image_0000001257138337.gif)
```ts
``` // xxx.ets
@Entry @Entry
@Component @Component
struct TextExample2 { struct TextExample2 {
......
# Flex # Flex
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > **NOTE**<br/>
> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. > This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
The **&lt;Flex&gt;** component allows for an elastic layout. The **\<Flex>** component allows for an elastic layout.
## Required Permissions ## Required Permissions
...@@ -22,46 +22,45 @@ This component can contain child components. ...@@ -22,46 +22,45 @@ This component can contain child components.
Flex(options?: { direction?: FlexDirection, wrap?: FlexWrap, justifyContent?: FlexAlign, alignItems?: ItemAlign, alignContent?: FlexAlign }) Flex(options?: { direction?: FlexDirection, wrap?: FlexWrap, justifyContent?: FlexAlign, alignItems?: ItemAlign, alignContent?: FlexAlign })
Creates a standard **&lt;Flex&gt;** component. Creates a standard **\<Flex>** component.
- Parameters - Parameters
| Name | Type | Mandatory | Default Value | Description | | Name | Type | Mandatory | Default Value | Description |
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| direction | FlexDirection | No | FlexDirection.Row | Direction in which child components are arranged in the **&lt;Flex&gt;** component, that is, the direction of the main axis. | | direction | FlexDirection | No | FlexDirection.Row | Direction in which child components are arranged in the **\<Flex>** component, that is, the direction of the main axis. |
| wrap | FlexWrap | No | FlexWrap.NoWrap | Whether the **&lt;Flex&gt;** component has a single line or multiple lines. | | wrap | FlexWrap | No | FlexWrap.NoWrap | Whether the **\<Flex>** component has a single line or multiple lines. |
| justifyContent | FlexAlign | No | FlexAlign.Start | Alignment mode of the child components in the **&lt;Flex&gt;** component along the main axis. | | justifyContent | FlexAlign | No | FlexAlign.Start | Alignment mode of the child components in the **\<Flex>** component along the main axis. |
| alignItems | [ItemAlign](ts-appendix-enums.md#itemalign-enums) | No | ItemAlign.Stretch | Alignment mode of the child components in the **&lt;Flex&gt;** component along the cross axis. | | alignItems | [ItemAlign](ts-appendix-enums.md#itemalign-enums) | No | ItemAlign.Stretch | Alignment mode of the child components in the **\<Flex>** component along the cross axis. |
| alignContent | FlexAlign | No | FlexAlign.Start | Alignment mode of the child components in a multi-line **&lt;Flex&gt;** component along the cross axis. This parameter is valid only when **wrap** is set to **Wrap** or **WrapReverse**. | | alignContent | FlexAlign | No | FlexAlign.Start | Alignment mode of the child components in a multi-line **\<Flex>** component along the cross axis. This parameter is valid only when **wrap** is set to **Wrap** or **WrapReverse**. |
- FlexDirection enums - FlexDirection enums
| Name | Description | | Name | Description |
| -------- | -------- | | -------- | -------- |
| Row | The child components are arranged in the same direction as the main axis runs along the rows. | | Row | The child components are arranged in the same direction as the main axis runs along the rows. |
| RowReverse | The child components are arranged opposite to the **Row** direction. | | RowReverse | The child components are arranged opposite to the **Row** direction. |
| Column | The child components are arranged in the same direction as the main axis runs down the columns. | | Column | The child components are arranged in the same direction as the main axis runs down the columns. |
| ColumnReverse | The child components are arranged opposite to the **Column** direction. | | ColumnReverse | The child components are arranged opposite to the **Column** direction. |
- FlexWrap enums - FlexWrap enums
| Name | Description | | Name | Description |
| -------- | -------- | | -------- | -------- |
| NoWrap | The child components in the **&lt;Flex&gt;** component are arranged in a single line, and they may overflow. | | NoWrap | The child components in the **&lt;Flex&gt;** component are arranged in a single line, and they may overflow. |
| Wrap | The child components in the **&lt;Flex&gt;** component are arranged in multiple lines, and they may overflow. | | Wrap | The child components in the **&lt;Flex&gt;** component are arranged in multiple lines, and they may overflow. |
| WrapReverse | The child components in the **&lt;Flex&gt;** component are reversely arranged in multiple lines, and they may overflow. | | WrapReverse | The child components in the **&lt;Flex&gt;** component are reversely arranged in multiple lines, and they may overflow. |
- FlexAlign enums - FlexAlign enums
| Name | Description | | Name | Description |
| -------- | -------- | | -------- | -------- |
| Start | The child components are aligned with the start edge of the main axis. The first component is aligned with the main-start, and subsequent components are aligned with the previous one. | | Start | The child components are aligned with the start edge of the main axis. The first component is aligned with the main-start, and subsequent components are aligned with the previous one. |
| Center | The child components are aligned in the center of the main axis. The space between the first component and the main-start is the same as that between the last component and the main-end. | | Center | The child components are aligned in the center of the main axis. The space between the first component and the main-start is the same as that between the last component and the main-end. |
| End | The child components are aligned with the end edge of the main axis. The last component is aligned with the main-end, and other components are aligned with the next one. | | End | The child components are aligned with the end edge of the main axis. The last component is aligned with the main-end, and other components are aligned with the next one. |
| SpaceBetween | The child components are evenly distributed along the main axis. The first component is aligned with the main-start, the last component is aligned with the main-end, and the remaining components are distributed so that the space between any two adjacent components is the same. | | SpaceBetween | The child components are evenly distributed along the main axis. The first component is aligned with the main-start, the last component is aligned with the main-end, and the remaining components are distributed so that the space between any two adjacent components is the same. |
| SpaceAround | The child components are evenly distributed along the main axis, with a half-size space on either end. The space between any two adjacent components is the same. The space between the first component and main-start, and that between the last component and cross-main are both half the size of the space between two adjacent components. | | SpaceAround | The child components are evenly distributed along the main axis, with a half-size space on either end. The space between any two adjacent components is the same. The space between the first component and main-start, and that between the last component and cross-main are both half the size of the space between two adjacent components. |
| SpaceEvenly | The child components are equally distributed along the main axis. The space between the first component and main-start, the space between the last component and main-end, and the space between two adjacent components are the same. | | SpaceEvenly | The child components are equally distributed along the main axis. The space between the first component and main-start, the space between the last component and main-end, and the space between two adjacent components are the same. |
## Example ## Example
``` ```
// Example 01 // Example 01
@Entry @Entry
......
...@@ -103,7 +103,7 @@ scroller.currentOffset(): Object ...@@ -103,7 +103,7 @@ scroller.currentOffset(): Object
Obtains the scrolling offset. Obtains the scrolling offset.
- Return values - Return value
| Type | Description | | Type | Description |
| -------- | -------- | | -------- | -------- |
| {<br/>xOffset: number,<br/>yOffset: number<br/>} | **xOffset**: horizontal scrolling offset.<br/>**yOffset**: vertical scrolling offset. | | {<br/>xOffset: number,<br/>yOffset: number<br/>} | **xOffset**: horizontal scrolling offset.<br/>**yOffset**: vertical scrolling offset. |
......
# Interpolation Calculation # Interpolation Calculation
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > **NOTE**<br>
> This animation is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. > This animation is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
## Modules to Import ## Modules to Import
``` ```
import curves from '@ohos.curves' import curves from '@ohos.curves'
``` ```
...@@ -15,7 +15,7 @@ import curves from '@ohos.curves' ...@@ -15,7 +15,7 @@ import curves from '@ohos.curves'
## Required Permissions ## Required Permissions
None N/A
## curves.init ## curves.init
...@@ -27,11 +27,11 @@ Implements initialization for the interpolation curve, which is used to create a ...@@ -27,11 +27,11 @@ Implements initialization for the interpolation curve, which is used to create a
- Parameters - Parameters
| Name | Type | Mandatory | Default Value | Description | | Name | Type | Mandatory | Default Value | Description |
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| curve | Curve | No | Linear | Curve object. | | curve | Curve | No | Linear | Curve object. |
- Return values - Return value<br>
Curve object. Curve object.
...@@ -44,12 +44,13 @@ Constructs a step curve object. ...@@ -44,12 +44,13 @@ Constructs a step curve object.
- Parameters - Parameters
| Name | Type | Mandatory | Default Value | Description | | Name | Type | Mandatory | Default Value | Description |
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| count | number | Yes | - | Number of steps. Must be a positive integer. | | count | number | Yes | - | Number of steps. Must be a positive integer. |
| end | boolean | No | true | Step change at the start or end point of each interval. Defaults to **true**, indicating that the step change occurs at the end point. | | end | boolean | No | true | Step change at the start or end point of each interval. Defaults to **true**, indicating that the step change occurs at the end point. |
- Return values - Return value
Curve object. Curve object.
...@@ -62,14 +63,15 @@ Constructs a third-order Bezier curve object. The curve value must be between 0 ...@@ -62,14 +63,15 @@ Constructs a third-order Bezier curve object. The curve value must be between 0
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| x1 | number | Yes | Horizontal coordinate of the first point on the Bezier curve. | | x1 | number | Yes | Horizontal coordinate of the first point on the Bezier curve. |
| y1 | number | Yes | Vertical coordinate of the first point on the Bezier curve. | | y1 | number | Yes | Vertical coordinate of the first point on the Bezier curve. |
| x2 | number | Yes | Horizontal coordinate of the second point on the Bezier curve. | | x2 | number | Yes | Horizontal coordinate of the second point on the Bezier curve. |
| y2 | number | Yes | Vertical coordinate of the second point on the Bezier curve. | | y2 | number | Yes | Vertical coordinate of the second point on the Bezier curve. |
- Return values - Return value
Curve object. Curve object.
...@@ -82,20 +84,21 @@ Constructs a spring curve object. ...@@ -82,20 +84,21 @@ Constructs a spring curve object.
- Parameters - Parameters
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| velocity | number | Yes | Initial velocity. | | velocity | number | Yes | Initial velocity. |
| mass | number | Yes | Mass. | | mass | number | Yes | Mass. |
| stiffness | number | Yes | Stiffness. | | stiffness | number | Yes | Stiffness. |
| damping | number | Yes | Damping. | | damping | number | Yes | Damping. |
- Return values - Return value
Curve object. Curve object.
## Example ## Example
``` ```
import Curves from '@ohos.curves' import Curves from '@ohos.curves'
let curve1 = Curves.init() // Create a default linear interpolation curve. let curve1 = Curves.init() // Create a default linear interpolation curve.
...@@ -106,13 +109,13 @@ let curve3 = Curves.cubicBezier(0.1, 0.0, 0.1, 1.0) // Create a third-order Bezi ...@@ -106,13 +109,13 @@ let curve3 = Curves.cubicBezier(0.1, 0.0, 0.1, 1.0) // Create a third-order Bezi
Curve objects can be created only by the preceding APIs. Curve objects can be created only by the preceding APIs.
| API | Description | | API | Description |
| -------- | -------- | | -------- | -------- |
| interpolate(time: number): number | Calculation function of the interpolation curve. Passing a normalized time parameter to this function returns the current interpolation.<br/>**time**: indicates the current normalized time. The value ranges from 0 to 1.<br/>The curve interpolation corresponding to the normalized time point is returned. | | interpolate(time: number): number | Calculation function of the interpolation curve. Passing a normalized time parameter to this function returns the current interpolation.<br/>**time**: indicates the current normalized time. The value ranges from 0 to 1.<br/>The curve interpolation corresponding to the normalized time point is returned. |
- Example - Example
``` ```
import Curves from '@ohos.curves' import Curves from '@ohos.curves'
let curve = Curves.init(Curve.EaseIn) // Create an interpolation curve which is slow and then fast by default. let curve = Curves.init(Curve.EaseIn) // Create an interpolation curve which is slow and then fast by default.
...@@ -122,7 +125,7 @@ let curve3 = Curves.cubicBezier(0.1, 0.0, 0.1, 1.0) // Create a third-order Bezi ...@@ -122,7 +125,7 @@ let curve3 = Curves.cubicBezier(0.1, 0.0, 0.1, 1.0) // Create a third-order Bezi
## Example ## Example
``` ```
import Curves from '@ohos.curves' import Curves from '@ohos.curves'
@Entry @Entry
......
# Matrix Transformation # Matrix Transformation
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > **NOTE**<br>
> This animation is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. > This animation is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
...@@ -31,30 +31,30 @@ Matrix constructor, which is used to create a 4x4 matrix by using the input para ...@@ -31,30 +31,30 @@ Matrix constructor, which is used to create a 4x4 matrix by using the input para
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| array | Array&lt;number&gt; | Yes | [1, 0, 0, 0,<br/>0, 1, 0, 0,<br/>0, 0, 1, 0,<br/>0, 0, 0, 1] | A number array whose length is 16 (4 x 4). For details, see the parameter description. | | array | Array&lt;number&gt; | Yes | [1, 0, 0, 0,<br/>0, 1, 0, 0,<br/>0, 0, 1, 0,<br/>0, 0, 0, 1] | A number array whose length is 16 (4 x 4). For details, see the parameter description. |
- Return values - Return value
| Type | Description | | Type | Description |
| -------- | -------- | | -------- | -------- |
| Object | 4x4 matrix object created based on the input parameter. | | Object | 4x4 matrix object created based on the input parameter. |
- Parameter description - Parameter description
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| m00 | number | Yes | Scaling value of the x-axis. Defaults to **1** for the unit matrix. | | m00 | number | Yes | Scaling value of the x-axis. Defaults to **1** for the unit matrix. |
| m01 | number | Yes | The second value, which is affected by the rotation of the x, y, and z axes. | | m01 | number | Yes | The second value, which is affected by the rotation of the x, y, and z axes. |
| m02 | number | Yes | The third value, which is affected by the rotation of the x, y, and z axes. | | m02 | number | Yes | The third value, which is affected by the rotation of the x, y, and z axes. |
| m03 | number | Yes | Meaningless. | | m03 | number | Yes | Meaningless. |
| m10 | number | Yes | The fifth value, which is affected by the rotation of the x, y, and z axes. | | m10 | number | Yes | The fifth value, which is affected by the rotation of the x, y, and z axes. |
| m11 | number | Yes | Scaling value of the y-axis. Defaults to **1** for the unit matrix. | | m11 | number | Yes | Scaling value of the y-axis. Defaults to **1** for the unit matrix. |
| m12 | number | Yes | The seventh value, which is affected by the rotation of the x, y, and z axes. | | m12 | number | Yes | The seventh value, which is affected by the rotation of the x, y, and z axes. |
| m13 | number | Yes | Meaningless. | | m13 | number | Yes | Meaningless. |
| m20 | number | Yes | The ninth value, which is affected by the rotation of the x, y, and z axes. | | m20 | number | Yes | The ninth value, which is affected by the rotation of the x, y, and z axes. |
| m21 | number | Yes | The tenth value, which is affected by the rotation of the x, y, and z axes. | | m21 | number | Yes | The tenth value, which is affected by the rotation of the x, y, and z axes. |
| m22 | number | Yes | Scaling value of the z-axis. Defaults to **1** for the unit matrix. | | m22 | number | Yes | Scaling value of the z-axis. Defaults to **1** for the unit matrix. |
| m23 | number | Yes | Meaningless. | | m23 | number | Yes | Meaningless. |
| m30 | number | Yes | Translation value of the x-axis, in px. Defaults to **0** for the unit matrix. | | m30 | number | Yes | Translation value of the x-axis, in px. Defaults to **0** for the unit matrix. |
| m31 | number | Yes | Translation value of the y-axis, in px. Defaults to **0** for the unit matrix. | | m31 | number | Yes | Translation value of the y-axis, in px. Defaults to **0** for the unit matrix. |
| m32 | number | Yes | Translation value of the z-axis, in px. Defaults to **0** for the unit matrix. | | m32 | number | Yes | Translation value of the z-axis, in px. Defaults to **0** for the unit matrix. |
| m33 | number | Yes | Valid in homogeneous coordinates, presenting the perspective projection effect. | | m33 | number | Yes | Valid in homogeneous coordinates, presenting the perspective projection effect. |
- Example - Example
...@@ -76,10 +76,10 @@ identity(): Object ...@@ -76,10 +76,10 @@ identity(): Object
Matrix initialization function. Can return a unit matrix object. Matrix initialization function. Can return a unit matrix object.
- Return values - Return value
| Type | Description | | Type | Description |
| -------- | -------- | | -------- | -------- |
| Object | Unit matrix object. | | Object | Unit matrix object. |
- Example - Example
...@@ -102,10 +102,10 @@ copy(): Object ...@@ -102,10 +102,10 @@ copy(): Object
Matrix copy function, which is used to copy the current matrix object. Matrix copy function, which is used to copy the current matrix object.
- Return values - Return value
| Type | Description | | Type | Description |
| -------- | -------- | | -------- | -------- |
| Object | Copy object of the current matrix. | | Object | Copy object of the current matrix. |
- Example - Example
...@@ -147,14 +147,14 @@ Matrix overlay function, which is used to overlay the effects of two matrices to ...@@ -147,14 +147,14 @@ Matrix overlay function, which is used to overlay the effects of two matrices to
- Parameters - Parameters
| Name | Type | Mandatory | Default Value | Description | | Name | Type | Mandatory | Default Value | Description |
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| matrix | Matrix4 | Yes | - | Matrix object to be overlaid. | | matrix | Matrix4 | Yes | - | Matrix object to be overlaid. |
- Return values - Return value
| Type | Description | | Type | Description |
| -------- | -------- | | -------- | -------- |
| Object | Object after matrix overlay. | | Object | Object after matrix overlay. |
- Example - Example
...@@ -188,10 +188,10 @@ invert(): Object ...@@ -188,10 +188,10 @@ invert(): Object
Matrix inverse function. Can return an inverse matrix of the current matrix object, that is, get an opposite effect. Matrix inverse function. Can return an inverse matrix of the current matrix object, that is, get an opposite effect.
- Return values - Return value
| Type | Description | | Type | Description |
| -------- | -------- | | -------- | -------- |
| Object | Inverse matrix object of the current matrix. | | Object | Inverse matrix object of the current matrix. |
- Example - Example
...@@ -212,17 +212,17 @@ Matrix translation function, which is used to add the translation effect to the ...@@ -212,17 +212,17 @@ Matrix translation function, which is used to add the translation effect to the
- Parameters - Parameters
| Name | Type | Mandatory | Default Value | Description | | Name | Type | Mandatory | Default Value | Description |
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| x | number | No | 0 | Translation distance of the x-axis, in px. | | x | number | No | 0 | Translation distance of the x-axis, in px. |
| y | number | No | 0 | Translation distance of the y-axis, in px. | | y | number | No | 0 | Translation distance of the y-axis, in px. |
| z | number | No | 0 | Translation distance of the z-axis, in px. | | z | number | No | 0 | Translation distance of the z-axis, in px. |
- Return values - Return value
| Type | Description | | Type | Description |
| -------- | -------- | | -------- | -------- |
| Object | Matrix object after the translation effect is added. | | Object | Matrix object after the translation effect is added. |
- Example - Example
...@@ -254,19 +254,19 @@ Matrix scaling function, which is used to add the scaling effect to the x, y, an ...@@ -254,19 +254,19 @@ Matrix scaling function, which is used to add the scaling effect to the x, y, an
- Parameters - Parameters
| Name | Type | Mandatory | Default Value | Description | | Name | Type | Mandatory | Default Value | Description |
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| x | number | No | 1 | Scaling multiple of the x-axis. | | x | number | No | 1 | Scaling multiple of the x-axis. |
| y | number | No | 1 | Scaling multiple of the y-axis. | | y | number | No | 1 | Scaling multiple of the y-axis. |
| z | number | No | 1 | Scaling multiple of the z-axis. | | z | number | No | 1 | Scaling multiple of the z-axis. |
| centerX | number | No | 0 | X coordinate of the center point. | | centerX | number | No | 0 | X coordinate of the center point. |
| centerY | number | No | 0 | Y coordinate of the center point. | | centerY | number | No | 0 | Y coordinate of the center point. |
- Return values - Return value
| Type | Description | | Type | Description |
| -------- | -------- | | -------- | -------- |
| Object | Matrix object after the scaling effect is added. | | Object | Matrix object after the scaling effect is added. |
- Example - Example
...@@ -298,20 +298,20 @@ Matrix rotation function, which is used to add the rotation effect to the x, y, ...@@ -298,20 +298,20 @@ Matrix rotation function, which is used to add the rotation effect to the x, y,
- Parameters - Parameters
| Name | Type | Mandatory | Default Value | Description | | Name | Type | Mandatory | Default Value | Description |
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| x | number | No | 1 | X coordinate of the rotation axis vector. | | x | number | No | 1 | X coordinate of the rotation axis vector. |
| y | number | No | 1 | Y coordinate of the rotation axis vector. | | y | number | No | 1 | Y coordinate of the rotation axis vector. |
| z | number | No | 1 | Z coordinate of the rotation axis vector. | | z | number | No | 1 | Z coordinate of the rotation axis vector. |
| angle | number | No | 0 | Rotation angle. | | angle | number | No | 0 | Rotation angle. |
| centerX | number | No | 0 | X coordinate of the center point. | | centerX | number | No | 0 | X coordinate of the center point. |
| centerY | number | No | 0 | Y coordinate of the center point. | | centerY | number | No | 0 | Y coordinate of the center point. |
- Return values - Return value
| Type | Description | | Type | Description |
| -------- | -------- | | -------- | -------- |
| Object | Matrix object after the rotation effect is added. | | Object | Matrix object after the rotation effect is added. |
- Example - Example
...@@ -343,15 +343,15 @@ Matrix point transformation function, which is used to apply the current transfo ...@@ -343,15 +343,15 @@ Matrix point transformation function, which is used to apply the current transfo
- Parameters - Parameters
| Name | Type | Mandatory | Default Value | Description | | Name | Type | Mandatory | Default Value | Description |
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| point | Point | Yes | - | Point to be transformed. | | point | Point | Yes | - | Point to be transformed. |
- Return values - Return value
| Type | Description | | Type | Description |
| -------- | -------- | | -------- | -------- |
| Point | Point object after matrix transformation | | Point | Point object after matrix transformation |
- Example - Example
......
# Video # Video
> **NOTE**<br>
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. > This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
The **\<Video>** component provides a video player.
## Required Permissions
To use online videos, you need to add the **ohos.permission.INTERNET** permission to the corresponding **abilities** in the **config.json** or **module.json** file, whichever is appropriate.
The **&lt;Video&gt;** component provides a video player. ```
"abilities":[
{
...
"permissions": ["ohos.permission.INTERNET],
...
}
]
```
## Child Components ## Child Components
The **&lt;Video&gt;** component does not support any child component. Not supported
## APIs ## APIs
...@@ -18,47 +30,47 @@ The **&lt;Video&gt;** component does not support any child component. ...@@ -18,47 +30,47 @@ The **&lt;Video&gt;** component does not support any child component.
Video(value: VideoOptions) Video(value: VideoOptions)
- VideoOptions attributes - VideoOptions attributes
| Name | Type | Mandatory | Default Value | Description | | Name| Type| Mandatory| Default Value| Description|
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| src | string | No | - | Path of the video source. | | src | string \| [Resource](../../ui/ts-types.md) | No| - | Path of the video source, which can be a local path or a URL.<br>The video resources can be stored in the **video** or **rawfile** folder under **resources**.<br>The path can include a **dataability://** prefix, which is used to access the video path provided by a Data ability. For details about the path, see [Data Ability Development](../../ability/fa-dataability.md).|
| currentProgressRate | number \| PlaybackSpeed<sup>8+</sup> | No | 1.0 \| PlaybackSpeed.Speed_Forward_1_00_X | Video playback speed.<br/>> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>> The value of the number type can only be **0.75**, **1.0**, **1.25**, **1.75**, or **2.0**.<br/>> <br/>> | | currentProgressRate | number \| PlaybackSpeed<sup>8+</sup> | No| 1.0 \| PlaybackSpeed.<br>Speed_Forward_1_00_X | Video playback speed.<br>> **NOTE**<br>> The value of the number type can only be **0.75**, **1.0**, **1.25**, **1.75**, or **2.0**.<br>|
| previewUri | string \| PixelMap<sup>8+</sup> \|[Resource](../../ui/ts-types.md) | No | - | Path of the preview image. | | previewUri | string \| PixelMap<sup>8+</sup> \| [Resource](../../ui/ts-types.md) | No| - | Path of the preview image.|
| controller | [VideoController](#videocontroller) | No | - | Controller. | | controller | [VideoController](#videocontroller) | No| - | Controller.|
- PlaybackSpeed<sup>8+</sup> - PlaybackSpeed<sup>8+</sup>
| Name | Description | | Name| Description|
| -------- | -------- | | -------- | -------- |
| Speed_Forward_0_75_X | 0.75x playback speed. | | Speed_Forward_0_75_X | 0.75x playback speed.|
| Speed_Forward_1_00_X | 1x playback speed. | | Speed_Forward_1_00_X | 1x playback speed.|
| Speed_Forward_1_25_X | 1.25x playback speed. | | Speed_Forward_1_25_X | 1.25x playback speed.|
| Speed_Forward_1_75_X | 1.75x playback speed. | | Speed_Forward_1_75_X | 1.75x playback speed.|
| Speed_Forward_2_00_X | 2x playback speed. | | Speed_Forward_2_00_X | 2x playback speed.|
## Attributes ## Attributes
| Name | Type | Default Value | Description | | Name| Type| Default Value| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| muted | boolean | false | Whether the video is muted. | | muted | boolean | false | Whether the video is muted.|
| autoPlay | boolean | false | Whether the video is automatically played. | | autoPlay | boolean | false | Whether to enable auto play.|
| controls | boolean | true | Whether the video playback control bar is displayed. | | controls | boolean | true | Whether to display the video playback control bar.|
| objectFit | [ImageFit](ts-basic-components-image.md) | Cover | Video display mode. | | objectFit | [ImageFit](ts-basic-components-image.md) | Cover | Video scale type. |
| loop | boolean | false | Whether a single video is played cyclically. | | loop | boolean | false | Whether to repeat the video.|
## Events ## Events
| Name | Description | | Name| Description|
| -------- | -------- | | -------- | -------- |
| onStart() =&gt; void | Triggered when the video is played. | | onStart() =&gt; void | Triggered when the video is played.|
| onPause() =&gt; void | Triggered when the video playback is paused. | | onPause() =&gt; void | Triggered when the video playback is paused.|
| onFinish() =&gt; void | Triggered when the video playback is finished. | | onFinish() =&gt; void | Triggered when the video playback is finished.|
| onError() =&gt; void | Triggered when the video playback fails. | | onError() =&gt; void | Triggered when the video playback fails.|
| onPrepared(event?: { duration: number }) =&gt; void | Triggered when video preparation is complete. The video duration (in seconds) is obtained from **duration**. | | onPrepared(event?: { duration: number }) =&gt; void | Triggered when video preparation is complete. The video duration (in seconds) is obtained from **duration**.|
| onSeeking(event?: { time: number }) =&gt; void | Triggered to report the time (in seconds) when the progress bar is being dragged. | | onSeeking(event?: { time: number }) =&gt; void | Triggered to report the time (in seconds) when the progress bar is being dragged.|
| onSeeked(event?: { time: number }) =&gt; void | Triggered to report the playback time (in seconds) when the user finishes dragging the progress bar. | | onSeeked(event?: { time: number }) =&gt; void | Triggered to report the playback time (in seconds) when the user finishes dragging the progress bar.|
| onUpdate(event?: { time: number }) =&gt; void | Triggered once per 250 ms when the playback progress changes. The unit of the current playback time is second. | | onUpdate(event?: { time: number }) =&gt; void | Triggered once per 250 ms when the playback progress changes. The unit of the current playback time is second.|
## VideoController ## VideoController
...@@ -72,6 +84,7 @@ A **VideoController** object can control one or more videos. ...@@ -72,6 +84,7 @@ A **VideoController** object can control one or more videos.
controller: VideoController = new VideoController(); controller: VideoController = new VideoController();
``` ```
### start ### start
start(): void start(): void
...@@ -97,9 +110,9 @@ setCurrentTime(value: number) ...@@ -97,9 +110,9 @@ setCurrentTime(value: number)
Sets the video playback position. Sets the video playback position.
- Parameters - Parameters
| Name | Type | Mandatory | Default Value | Description | | Name| Type| Mandatory| Default Value| Description|
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| value | number | Yes | - | Video playback position. | | value | number | Yes| - | Video playback position.|
### requestFullscreen ### requestFullscreen
...@@ -108,9 +121,9 @@ requestFullscreen(value: boolean) ...@@ -108,9 +121,9 @@ requestFullscreen(value: boolean)
Requests full-screen mode. Requests full-screen mode.
- Parameters - Parameters
| Name | Type | Mandatory | Default Value | Description | | Name| Type| Mandatory| Default Value| Description|
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| value | number | Yes | false | Whether the playback is in full-screen mode. | | value | number | Yes| false | Whether the playback is in full-screen mode.|
### exitFullscreen ### exitFullscreen
...@@ -125,33 +138,34 @@ setCurrentTime(value: number, seekMode: SeekMode) ...@@ -125,33 +138,34 @@ setCurrentTime(value: number, seekMode: SeekMode)
Sets the video playback position with the specified seek mode. Sets the video playback position with the specified seek mode.
- Parameters - Parameters
| Name | Type | Mandatory | Default Value | Description | | Name| Type| Mandatory| Default Value| Description|
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| value | number | Yes | - | Video playback position. | | value | number | Yes| - | Video playback position.|
| seekMode | SeekMode | Yes | - | Seek mode. | | seekMode | SeekMode | Yes| - | Seek mode.|
- SeekMode<sup>8+</sup> - SeekMode<sup>8+</sup>
| Name | Description | | Name| Description|
| -------- | -------- | | -------- | -------- |
| PreviousKeyframe | Seeks to the nearest previous keyframe. | | PreviousKeyframe | Seeks to the nearest previous keyframe.|
| NextKeyframe | Seeks to the nearest next keyframe. | | NextKeyframe | Seeks to the nearest next keyframe.|
| ClosestKeyframe | Seeks to the nearest keyframe. | | ClosestKeyframe | Seeks to the nearest keyframe.|
| Accurate | Seeks to a specific frame, regardless of whether the frame is a keyframe. | | Accurate | Seeks to a specific frame, regardless of whether the frame is a keyframe.|
## Example
## Example
``` ```ts
// xxx.ets
@Entry @Entry
@Component @Component
struct VideoCreateComponent { struct VideoCreateComponent {
@State srcs: string = "/resources/video/video1.mp4"; @State srcs: Resource = $rawfile('video1');
@State previewUris: string = "/resources/image/media.JPG"; @State previewUris: Resource = $r('app.media.img');
@State currentProgressRates: number = 1; @State currentProgressRates: number = 1;
@State autoPlays: boolean = false; @State autoPlays: boolean = false;
@State controlsss: boolean = true; @State controlsss: boolean = true;
myVideoController: VideoController = new VideoController(); controller: VideoController = new VideoController();
@State startStaus: boolean = true; @State startStaus: boolean = true;
build() { build() {
Column() { Column() {
...@@ -159,7 +173,7 @@ struct VideoCreateComponent { ...@@ -159,7 +173,7 @@ struct VideoCreateComponent {
src: this.srcs, src: this.srcs,
previewUri: this.previewUris, previewUri: this.previewUris,
currentProgressRate: this.currentProgressRates, currentProgressRate: this.currentProgressRates,
controller: this.myVideoController controller: this.controller
}).width(700).height(500) }).width(700).height(500)
.autoPlay(this.autoPlays) .autoPlay(this.autoPlays)
.controls(this.controlsss) .controls(this.controlsss)
...@@ -189,18 +203,10 @@ struct VideoCreateComponent { ...@@ -189,18 +203,10 @@ struct VideoCreateComponent {
}) })
Row() { Row() {
Button("src").onClick(() => { Button("src").onClick(() => {
if (this.srcs == "/resources/video/video1.mp4") { this.srcs = $rawfile('video2');
this.srcs = "/resources/video/video2.mp4";
} else {
this.srcs = "/resources/video/video1.mp4";
}
}); });
Button("previewUri").onClick(() => { Button("previewUri").onClick(() => {
if (this.previewUris == "/resources/image/media.JPG") { this.previewUris = $r('app.media.img1');
this.previewUris = "/resources/image/sinlin.png";
} else {
this.previewUris = "/resources/image/media.JPG";
}
}); });
Button("controlsss").onClick(() => { Button("controlsss").onClick(() => {
this.controlsss = !this.controlsss; this.controlsss = !this.controlsss;
...@@ -209,19 +215,19 @@ struct VideoCreateComponent { ...@@ -209,19 +215,19 @@ struct VideoCreateComponent {
Row() { Row() {
Button("start").onClick(() => { Button("start").onClick(() => {
this.myVideoController.start(); this.controller.start();
}); });
Button("pause").onClick(() => { Button("pause").onClick(() => {
this.myVideoController.pause(); this.controller.pause();
}); });
Button("stop").onClick(() => { Button("stop").onClick(() => {
this.myVideoController.stop(); this.controller.stop();
}); });
} }
Row() { Row() {
Button("setCurrentTime").onClick(() => { Button("setCurrentTime").onClick(() => {
this.myVideoController.setCurrentTime(9, SeekMode.Accurate); this.controller.setCurrentTime(9, SeekMode.Accurate);
}); });
} }
} }
......
...@@ -30,9 +30,6 @@ By default, the attributes in the AppStorage are changeable. If needed, AppStora ...@@ -30,9 +30,6 @@ By default, the attributes in the AppStorage are changeable. If needed, AppStora
| Clear | void | boolean | Deletes all attributes. If any of the attributes is being referenced by a state variable, false is returned. | | Clear | void | boolean | Deletes all attributes. If any of the attributes is being referenced by a state variable, false is returned. |
| IsMutable | key: string | boolean | Specifies whether the attribute exists and can be changed. | | IsMutable | key: string | boolean | Specifies whether the attribute exists and can be changed. |
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**:
> Currently, the API can process only basic data and cannot modify a value in an object.
## Synchronization Between AppStorage and Components ## Synchronization Between AppStorage and Components
...@@ -90,4 +87,4 @@ struct ComponentA { ...@@ -90,4 +87,4 @@ struct ComponentA {
} }
``` ```
Each time the user clicks the Count button, the value of this.varA will increase by 1. This variable is synchronized with varA in the AppStorage. Each time the user clicks the language icon, the value of languageCode in the AppStorage will be changed, and the change will be synchronized to the this.lang variable. Each time the user clicks the **Count** button, the value of **this.varA** will increase by 1. This variable is synchronized with varA in the AppStorage. Each time the user clicks the language icon, the value of **languageCode** in the AppStorage will be changed, and the change will be synchronized to the **this.lang** variable.
...@@ -20,17 +20,17 @@ import WorkSchedulerExtensionAbility from '@ohos.WorkSchedulerExtensionAbility'; ...@@ -20,17 +20,17 @@ import WorkSchedulerExtensionAbility from '@ohos.WorkSchedulerExtensionAbility';
**Table 1** Major workScheduler APIs **Table 1** Major workScheduler APIs
API | Description API | Description
------------------------------------------------------------ | ------------------------------------------------------------ ---------------------------------------------------------|-----------------------------------------
function startWork(work: WorkInfo): boolean; | Starts a Work Scheduler task. function startWork(work: WorkInfo): boolean; | Starts a Work Scheduler task.
function stopWork(work: WorkInfo, needCancel?: boolean): boolean; | Stops a Work Scheduler task. function stopWork(work: WorkInfo, needCancel?: boolean): boolean; | Stops a Work Scheduler task.
function getWorkStatus(workId: number, callback: AsyncCallback<WorkInfo>): void; | Obtains the status of a Work Scheduler task. This method uses an asynchronous callback to return the result. function getWorkStatus(workId: number, callback: AsyncCallback<WorkInfo>): void;| Obtains the status of a Work Scheduler task. This method uses an asynchronous callback to return the result.
function getWorkStatus(workId: number): Promise<WorkInfo>; | Obtains the status of a Work Scheduler task. This method uses a promise to return the result. function getWorkStatus(workId: number): Promise<WorkInfo>; | Obtains the status of a Work Scheduler task. This method uses a promise to return the result.
function obtainAllWorks(callback: AsyncCallback<void>): Array<WorkInfo>; | Obtains Work Scheduler tasks. This method uses an asynchronous callback to return the result. function obtainAllWorks(callback: AsyncCallback<void>): Array<WorkInfo>;| Obtains Work Scheduler tasks. This method uses an asynchronous callback to return the result.
function obtainAllWorks(): Promise<Array<WorkInfo>>; | Obtains Work Scheduler tasks. This method uses a promise to return the result. function obtainAllWorks(): Promise<Array<WorkInfo>>;| Obtains Work Scheduler tasks. This method uses a promise to return the result.
function stopAndClearWorks(): boolean; | Stops and clears Work Scheduler tasks. function stopAndClearWorks(): boolean;| Stops and clears Work Scheduler tasks.
function isLastWorkTimeOut(workId: number, callback: AsyncCallback<void>): boolean; | Checks whether the last execution of the specified task has timed out. This method uses an asynchronous callback to return the result. It is applicable to repeated tasks. function isLastWorkTimeOut(workId: number, callback: AsyncCallback<void>): boolean;| Checks whether the last execution of the specified task has timed out. This method uses an asynchronous callback to return the result. It is applicable to repeated tasks.
function isLastWorkTimeOut(workId: number): Promise<boolean>; | Checks whether the last execution of the specified task has timed out. This method uses a promise to return the result. It is applicable to repeated tasks. function isLastWorkTimeOut(workId: number): Promise<boolean>;| Checks whether the last execution of the specified task has timed out. This method uses a promise to return the result. It is applicable to repeated tasks.
**Table 2** WorkInfo parameters **Table 2** WorkInfo parameters
...@@ -40,7 +40,7 @@ workId | Work ID. Mandatory.|number ...@@ -40,7 +40,7 @@ workId | Work ID. Mandatory.|number
bundleName | Name of the Work Scheduler task bundle. Mandatory.|string bundleName | Name of the Work Scheduler task bundle. Mandatory.|string
abilityName | Name of the component to be notified by a Work Scheduler callback.|string abilityName | Name of the component to be notified by a Work Scheduler callback.|string
networkType | Network type.| NetworkType networkType | Network type.| NetworkType
isCharging | Whether the device is charging.| bool isCharging | Whether the device is charging.| boolean
chargerType | Charging type.| ChargingType chargerType | Charging type.| ChargingType
batteryLevel | Battery level.| number batteryLevel | Battery level.| number
batteryStatus| Battery status.| BatteryStatus batteryStatus| Battery status.| BatteryStatus
...@@ -61,7 +61,7 @@ function onWorkStop(work: WorkInfo): void; | Triggered when the Work Scheduler t ...@@ -61,7 +61,7 @@ function onWorkStop(work: WorkInfo): void; | Triggered when the Work Scheduler t
**Implementing WorkSchedulerExtensionAbility** **Implementing WorkSchedulerExtensionAbility**
import WorkSchedulerExtensionAbility from '@ohos.WorkSchedulerExtensionAbility'; import WorkSchedulerExtensionAbility from '@ohos.WorkSchedulerExtensionAbility';
export default class MyWorkSchedulerExtensionAbility extends WorkSchedulerExtensionAbility { export default class MyWorkSchedulerExtensionAbility extends WorkSchedulerExtensionAbility {
onWorkStart(workInfo) { onWorkStart(workInfo) {
console.log('MyWorkSchedulerExtensionAbility onWorkStart' + JSON.stringify(workInfo)); console.log('MyWorkSchedulerExtensionAbility onWorkStart' + JSON.stringify(workInfo));
...@@ -74,8 +74,10 @@ function onWorkStop(work: WorkInfo): void; | Triggered when the Work Scheduler t ...@@ -74,8 +74,10 @@ function onWorkStop(work: WorkInfo): void; | Triggered when the Work Scheduler t
**Registering a Work Scheduler Task** **Registering a Work Scheduler Task**
import workScheduler from '@ohos.workScheduler'; import workScheduler from '@ohos.workScheduler';
let workInfo = { let workInfo = {
workId: 1, workId: 1,
batteryLevel:50, batteryLevel:50,
...@@ -93,7 +95,7 @@ function onWorkStop(work: WorkInfo): void; | Triggered when the Work Scheduler t ...@@ -93,7 +95,7 @@ function onWorkStop(work: WorkInfo): void; | Triggered when the Work Scheduler t
import workScheduler from '@ohos.workScheduler'; import workScheduler from '@ohos.workScheduler';
let workInfo = { let workInfo = {
workId: 1, workId: 1,
batteryLevel:50, batteryLevel:50,
...@@ -113,7 +115,7 @@ function onWorkStop(work: WorkInfo): void; | Triggered when the Work Scheduler t ...@@ -113,7 +115,7 @@ function onWorkStop(work: WorkInfo): void; | Triggered when the Work Scheduler t
workScheduler.getWorkStatus(50, (err, res) => { workScheduler.getWorkStatus(50, (err, res) => {
if (err) { if (err) {
console.info('workschedulerLog getWorkStatus failed, because:' + err.data); console.info('workschedulerLog getWorkStatus failed, because:' + err.code);
} else { } else {
for (let item in res) { for (let item in res) {
console.info('workschedulerLog getWorkStatuscallback success,' + item + ' is:' + res[item]); console.info('workschedulerLog getWorkStatuscallback success,' + item + ' is:' + res[item]);
...@@ -129,7 +131,7 @@ function onWorkStop(work: WorkInfo): void; | Triggered when the Work Scheduler t ...@@ -129,7 +131,7 @@ function onWorkStop(work: WorkInfo): void; | Triggered when the Work Scheduler t
console.info('workschedulerLog getWorkStatus success,' + item + ' is:' + res[item]); console.info('workschedulerLog getWorkStatus success,' + item + ' is:' + res[item]);
} }
}).catch((err) => { }).catch((err) => {
console.info('workschedulerLog getWorkStatus failed, because:' + err.data); console.info('workschedulerLog getWorkStatus failed, because:' + err.code);
}) })
...@@ -139,7 +141,7 @@ function onWorkStop(work: WorkInfo): void; | Triggered when the Work Scheduler t ...@@ -139,7 +141,7 @@ function onWorkStop(work: WorkInfo): void; | Triggered when the Work Scheduler t
workScheduler.obtainAllWorks((err, res) =>{ workScheduler.obtainAllWorks((err, res) =>{
if (err) { if (err) {
console.info('workschedulerLog obtainAllWorks failed, because:' + err.data); console.info('workschedulerLog obtainAllWorks failed, because:' + err.code);
} else { } else {
console.info('workschedulerLog obtainAllWorks success, data is:' + JSON.stringify(res)); console.info('workschedulerLog obtainAllWorks success, data is:' + JSON.stringify(res));
} }
...@@ -150,7 +152,7 @@ function onWorkStop(work: WorkInfo): void; | Triggered when the Work Scheduler t ...@@ -150,7 +152,7 @@ function onWorkStop(work: WorkInfo): void; | Triggered when the Work Scheduler t
workScheduler.obtainAllWorks().then((res) => { workScheduler.obtainAllWorks().then((res) => {
console.info('workschedulerLog obtainAllWorks success, data is:' + JSON.stringify(res)); console.info('workschedulerLog obtainAllWorks success, data is:' + JSON.stringify(res));
}).catch((err) => { }).catch((err) => {
console.info('workschedulerLog obtainAllWorks failed, because:' + err.data); console.info('workschedulerLog obtainAllWorks failed, because:' + err.code);
}) })
**Stopping and Clearing Work Scheduler Tasks** **Stopping and Clearing Work Scheduler Tasks**
...@@ -164,7 +166,7 @@ function onWorkStop(work: WorkInfo): void; | Triggered when the Work Scheduler t ...@@ -164,7 +166,7 @@ function onWorkStop(work: WorkInfo): void; | Triggered when the Work Scheduler t
workScheduler.isLastWorkTimeOut(500, (err, res) =>{ workScheduler.isLastWorkTimeOut(500, (err, res) =>{
if (err) { if (err) {
console.info('workschedulerLog isLastWorkTimeOut failed, because:' + err.data); console.info('workschedulerLog isLastWorkTimeOut failed, because:' + err.code);
} else { } else {
console.info('workschedulerLog isLastWorkTimeOut success, data is:' + res); console.info('workschedulerLog isLastWorkTimeOut success, data is:' + res);
} }
...@@ -177,6 +179,6 @@ function onWorkStop(work: WorkInfo): void; | Triggered when the Work Scheduler t ...@@ -177,6 +179,6 @@ function onWorkStop(work: WorkInfo): void; | Triggered when the Work Scheduler t
console.info('workschedulerLog isLastWorkTimeOut success, data is:' + res); console.info('workschedulerLog isLastWorkTimeOut success, data is:' + res);
}) })
.catch(err => { .catch(err => {
console.info('workschedulerLog isLastWorkTimeOut failed, because:' + err.data); console.info('workschedulerLog isLastWorkTimeOut failed, because:' + err.code);
}); });
}) })
...@@ -14,7 +14,7 @@ Each application can subscribe to common events as required. After your applicat ...@@ -14,7 +14,7 @@ Each application can subscribe to common events as required. After your applicat
### Architecture ### Architecture
![](figures/cesfwk_architecture_diagram.png) ![]( figures/cesfwk_architecture_diagram.png "CES Architecture")
## Directory Structure ## Directory Structure
...@@ -36,10 +36,10 @@ Each application can subscribe to common events as required. After your applicat ...@@ -36,10 +36,10 @@ Each application can subscribe to common events as required. After your applicat
## How to Use ## How to Use
For details, see *CommonEvent Development Guidelines*. For details, see [Common Event Development](../application-dev/notification/common-event.md).
## Repositories Involved ## Repositories Involved
Common Event and Notification Common Event and Notification
**notification_ces_standard** [**notification_ces_standard**](https://gitee.com/openharmony/notification_ces_standard)
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册