Standard system
@@ -60,6 +60,7 @@ OpenHarmony provides the following two types of Docker environments for you to q
+
## Preparations
Before using the Docker environment, perform the following operations:
@@ -77,12 +78,10 @@ The Docker image of OpenHarmony is hosted on [HUAWEI CLOUD SWR](https://console
### Setting Up the Docker Environment for Mini-System Devices \(reference memory ≥ 128 KB\) and Small-System Devices \(reference memory ≥ 1 MB\)
-**Method 1: Obtaining the Docker image from HUAWEI CLOUD SWR**
-
1. Obtain the Docker image.
```
- docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:0.0.5
+ docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:0.0.6
```
2. Go to the root directory of OpenHarmony code and run the following command to access the Docker build environment:
@@ -90,43 +89,13 @@ The Docker image of OpenHarmony is hosted on [HUAWEI CLOUD SWR](https://console
Run the following command in Ubuntu:
```
- docker run -it -v $(pwd):/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:0.0.5
- ```
-
- Run the following command in Windows \(assuming that the source code directory is **D:\\OpenHarmony**\):
-
- ```
- docker run -it -v D:\OpenHarmony:/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:0.0.5
- ```
-
-
-**Method 2: Using the Dockerfile to Build a Local Docker Image**
-
-1. Obtain the Dockerfile script for a local Docker image.
-
- ```
- git clone https://gitee.com/openharmony/docs.git
- ```
-
-2. Go to the directory of the Dockerfile code and run the following command to build the Docker image:
-
- ```
- cd docs/docker
- ./build.sh
- ```
-
-3. Go to the root directory of OpenHarmony code and run the following command to access the Docker build environment:
-
- Run the following command in Ubuntu:
-
- ```
- docker run -it -v $(pwd):/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:0.0.5
+ docker run -it -v $(pwd):/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:0.0.6
```
Run the following command in Windows \(assuming that the source code directory is **D:\\OpenHarmony**\):
```
- docker run -it -v D:\OpenHarmony:/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:0.0.5
+ docker run -it -v D:\OpenHarmony:/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:0.0.6
```
@@ -164,8 +133,6 @@ hb set
### Setting Up the Docker Environment for Standard-System Devices \(reference memory ≥ 128 MB\)
-**Method 1: Obtaining the Docker image from HUAWEI CLOUD SWR**
-
1. Obtain the Docker image.
```
@@ -179,28 +146,6 @@ hb set
```
-**Method 2: Using the Dockerfile to Build a Local Docker Image**
-
-1. Obtain the Dockerfile script for a local Docker image.
-
- ```
- git clone https://gitee.com/openharmony/docs.git
- ```
-
-2. Go to the directory of the Dockerfile code and run the following command to build the Docker image:
-
- ```
- cd docs/docker/standard
- ./build.sh
- ```
-
-3. Go to the root directory of OpenHarmony code and run the following command to access the Docker build environment:
-
- ```
- docker run -it -v $(pwd):/home/openharmony openharmony-docker-standard:0.0.7
- ```
-
-
### Building for Standard-System Devices \(reference memory ≥ 128 MB\)
Run the following script to start building for standard-system devices \(reference memory ≥ 128 MB\).
@@ -209,7 +154,7 @@ Run the following script to start building for standard-system devices \(referen
./build.sh --product-name {product_name} --ccache
```
-**product\_name** indicates the platform supported by the current distribution, for example, Hi3516D V300 and RK3568.
+**product\_name** indicates the platform supported by the current distribution, for example, Hi3516DV300 and rk3568.
Files generated during building are stored in the **out/{device_name}/** directory, and the generated image is stored in the **out/{device_name}/packages/phone/images/** directory.
diff --git a/en/device-dev/quick-start/quickstart-standard-docker-environment.md b/en/device-dev/quick-start/quickstart-standard-docker-environment.md
index 34d557772b9d5a80846bf587cd38348f57084abd..9374bb781fcdcd4c8a58d3070648e74756f3073c 100644
--- a/en/device-dev/quick-start/quickstart-standard-docker-environment.md
+++ b/en/device-dev/quick-start/quickstart-standard-docker-environment.md
@@ -61,8 +61,6 @@ By default, the downloaded prebuilts binary file is stored in **OpenHarmony\_2.
## Obtaining the Docker Environment
-**Method 1: Obtaining the Docker image from HUAWEI CLOUD SWR**
-
1. Obtain the Docker image.
```
@@ -76,28 +74,6 @@ By default, the downloaded prebuilts binary file is stored in **OpenHarmony\_2.
```
-**Method 2: Using the Dockerfile to Build a Local Docker Image**
-
-1. Obtain the Dockerfile script for a local Docker image.
-
- ```
- git clone https://gitee.com/openharmony/docs.git
- ```
-
-2. Go to the directory of the Dockerfile code and run the following command to build the Docker image:
-
- ```
- cd docs/docker/standard
- ./build.sh
- ```
-
-3. Go to the root directory of source code and run the following command to access the Docker build environment:
-
- ```
- docker run -it -v $(pwd):/home/openharmony openharmony-docker-standard:0.0.7
- ```
-
-
## Building Source Code
1. Run the following script to start building for standard-system devices \(reference memory ≥ 128 MB\).
@@ -106,7 +82,7 @@ By default, the downloaded prebuilts binary file is stored in **OpenHarmony\_2.
./build.sh --product-name {product_name} --ccache
```
- **product\_name** indicates the platform supported by the current distribution, for example, Hi3516D V300, rk3568.
+ **product\_name** indicates the platform supported by the current distribution, for example, Hi3516DV300, rk3568.
Files generated during building are stored in the **out/{device_name}/** directory, and the generated image is stored in the **out/{device_name}/packages/phone/images/** directory.
diff --git a/en/device-dev/subsystems/subsys-data-relational-database-guide.md b/en/device-dev/subsystems/subsys-data-relational-database-guide.md
index 44a0b1829249264fb99aff7cf998dd6a4de43b38..d668fc922079dfa5b38633d6c7a9c65a88351942 100644
--- a/en/device-dev/subsystems/subsys-data-relational-database-guide.md
+++ b/en/device-dev/subsystems/subsys-data-relational-database-guide.md
@@ -68,7 +68,7 @@ The RDB provides APIs for inserting, deleting, updating, and querying data in th
Table 5 API for deleting data
| Class| API| Description|
| ---- | ---- | ---- |
- | RdbStore | int Delete(int &deletedRows, const AbsRdbPredicates &predicates) | Deletes data. - **deletedRows**: specifies the number of rows to delete.
- **predicates**: specifies the table name and conditions for deleting the data. **AbsRdbPredicates** has the following classes:
- **RdbPredicates**: specifies update conditions by calling its methods, such as **equalTo**.
- **RawRdbPredicates**: specifies the table name, **whereClause** and **whereArgs** only.
|
+ | RdbStore | int Delete(int &deletedRows, const AbsRdbPredicates &predicates) | Deletes data. - **deletedRows**: specifies the number of rows to delete.
- **predicates**: specifies the table name and conditions for deleting the data. **AbsRdbPredicates** has the following classes:
- **RdbPredicates**: specifies delete conditions by calling its methods, such as **equalTo**.
- **RawRdbPredicates**: specifies the table name, **whereClause** and **whereArgs** only.
|
- Updating data
diff --git a/en/readme/DeviceProfile.md b/en/readme/DeviceProfile.md
new file mode 100644
index 0000000000000000000000000000000000000000..29653fb13b515c0c88d00f1ca819745f1a1a4397
--- /dev/null
+++ b/en/readme/DeviceProfile.md
@@ -0,0 +1,189 @@
+# DeviceProfile
+
+## Introduction
+
+DeviceProfile is used to manage device hardware capabilities and system software features. A typical device profile includes the device type, device name, OS type, and OS version. By allowing quick access to local and remote device profiles, DeviceProfile lays the foundation for initiating distributed services. It provides the following features:
+
+- Querying, inserting, and deleting local device profile information
+- Querying remote device profile information
+- Synchronizing profile information across devices
+- Subscribing to remote device profile changes
+
+Below is the architecture of the DeviceProfile subsystem.
+
+## Architecture
+
+**Figure 1** Architecture of the DeviceProfile subsystem
+
+
+
+## Directory Structure
+
+The main code directory structure of DeviceProfile is as follows:
+
+```
+├── interfaces
+│ └── innerkits
+│ └── distributeddeviceprofile // Internal APIs
+├── ohos.build
+├── sa_profile // SAID profile
+│ ├── 6001.xml
+│ └── BUILD.gn
+├── services
+│ └── distributeddeviceprofile
+│ ├── BUILD.gn
+│ ├── include
+│ │ ├── contentsensor // Header file for content sensor data collection
+│ │ ├── dbstorage // Header file for database operations
+│ │ ├── devicemanager // Header file for device management
+│ │ └── subscribemanager // Header file for subscription management
+│ ├── src
+│ │ ├── contentsensor // Implementation of content sensor data collection
+│ │ ├── dbstorage // Implementation of database operations
+│ │ ├── devicemanager // Implementation of device management
+│ │ ├── subscribemanager // Implementation of subscription management
+│ └── test // Test cases
+└── tools
+ └── dp // Auxiliary test tool
+```
+
+## Constraints
+
+- The devices between which you want to set up a connection must be in the same LAN.
+- Before setting up a connection between two devices, you must bind the devices. For details about the binding process, see relevant descriptions in the Security subsystem readme file.
+
+## Usage
+
+### Querying Profile Information
+
+* Parameters of GetDeviceProfile
+
+| Name| Type| Mandatory| Description|
+| --------- | ---------------------------- | ---- | ----------------------------------- |
+| deviceId | std::string | Yes| ID of the device whose profile is to be queried. A null value indicates the local device.|
+| serviceId | std::string | Yes| Service ID (ID of the service data record).|
+| profile | ServiceCharacteristicProfile | Yes| Return value.|
+
+* Example
+
+```c++
+// Declare the return value.
+ServiceCharacteristicProfile profile;
+// Call GetDeviceProfile.
+DistributedDeviceProfileClient::GetInstance().GetDeviceProfile(deviceId, serviceId, profile);
+std::string jsonData = profile.GetCharacteristicProfileJson();
+result.append("jsonData:" + jsonData + "\n");
+```
+
+### Inserting Profile Information
+
+* Parameters of PutDeviceProfile
+
+| Name| Type| Mandatory| Description|
+| --------- | ---------------------------- | ---- | ----------------------------------- |
+| profile | ServiceCharacteristicProfile | Yes| Profile information to insert.|
+
+* Example
+
+```c++
+// Declare and fill in the data to insert.
+ServiceCharacteristicProfile profile;
+profile.SetServiceId(serviceId);
+profile.SetServiceType(serviceType);
+nlohmann::json j;
+j["testVersion"] = "3.0.0";
+j["testApiLevel"] = API_LEVEL;
+profile.SetCharacteristicProfileJson(j.dump());
+// Call PutDeviceProfile.
+DistributedDeviceProfileClient::GetInstance().PutDeviceProfile(profile);
+```
+
+### Deleting Profile Information
+
+* Parameters of DeleteDeviceProfile
+
+| Name| Type| Mandatory| Description|
+| --------- | ---------------------------- | ---- | ----------------------------------- |
+| serviceId | std::string | Yes| ID of the service record to delete.|
+
+* Example
+
+```c++
+// Declare and fill in the data to delete.
+std::string serviceId = "test";
+// DeleteDeviceProfile
+DistributedDeviceProfileClient::GetInstance().DeleteDeviceProfile(serviceId);
+```
+
+### Synchronizing Profile Information
+
+* Parameters of SyncDeviceProfile
+
+| Name| Type| Mandatory| Description|
+| --------- | ---------------------------- | ---- | ----------------------------------- |
+| syncOption| SyncOption | Yes| Synchronization mode and range.|
+| syncCb | IProfileEventCallback | Yes| Callback used to return the synchronization result.|
+
+* Example
+
+```c++
+// Define the synchronization mode and range.
+SyncOptions syncOption;
+syncOption.SetSyncMode((OHOS::DistributedKv::SyncMode)atoi(mode.c_str()));
+for (const auto& deviceId : deviceIds) {
+ syncOption.AddDevice(deviceId);
+}
+// Call SyncDeviceProfile.
+DistributedDeviceProfileClient::GetInstance().SyncDeviceProfile(syncOption,
+ std::make_shared());
+```
+
+### Subscribing to Profile Events (Synchronization and Change Events)
+
+* Parameters of SubscribeProfileEvents
+
+| Name| Type| Mandatory| Description|
+| -------------- | ---------------------------- | ---- | ----------------------------------- |
+| subscribeInfos | SubscribeInfo | Yes| Type of the event to subscribe to.|
+| eventCb | IProfileEventCallback | Yes| Callback for the subscribed event.|
+| failedEvents | ProfileEvent | Yes| Failure event.|
+
+* Example
+
+```c++
+auto callback = std::make_shared();
+std::list subscribeInfos;
+ExtraInfo extraInfo;
+extraInfo["deviceId"] = deviceId;
+extraInfo["serviceIds"] = serviceIds;
+
+// Subscribe to the EVENT_PROFILE_CHANGED event.
+SubscribeInfo info1;
+info1.profileEvent = ProfileEvent::EVENT_PROFILE_CHANGED;
+info1.extraInfo = std::move(extraInfo);
+subscribeInfos.emplace_back(info1);
+
+// Subscribe to the EVENT_SYNC_COMPLETED event.
+SubscribeInfo info2;
+info2.profileEvent = ProfileEvent::EVENT_SYNC_COMPLETED;
+info2.extraInfo = std::move(extraInfo);
+subscribeInfos.emplace_back(info2);
+
+std::list failedEvents;
+// Call SubscribeProfileEvents.
+DistributedDeviceProfileClient::GetInstance().SubscribeProfileEvents(subscribeInfos,
+ callback, failedEvents);
+sleep(SUBSCRIBE_SLEEP_TIME);
+std::list profileEvents;
+profileEvents.emplace_back(ProfileEvent::EVENT_PROFILE_CHANGED);
+failedEvents.clear();
+// Cancel the subscription.
+DistributedDeviceProfileClient::GetInstance().UnsubscribeProfileEvents(profileEvents,
+ callback, failedEvents);
+```
+
+## Repositories Involved
+
+**DeviceProfile subsystem**
+
+[device\_profile\_core](https://gitee.com/openharmony/device_profile_core)
diff --git a/en/readme/figures/dp-architecture.png b/en/readme/figures/dp-architecture.png
new file mode 100644
index 0000000000000000000000000000000000000000..6d4573646c6b950b3e571d94ee09816397dd1d73
Binary files /dev/null and b/en/readme/figures/dp-architecture.png differ
diff --git a/en/readme/figures/multimedia-architecture.png b/en/readme/figures/multimedia-architecture.png
new file mode 100644
index 0000000000000000000000000000000000000000..7c5341b63aa9ff48f3edfe48ed590a4cec8a3935
Binary files /dev/null and b/en/readme/figures/multimedia-architecture.png differ
diff --git a/en/readme/multimedia.md b/en/readme/multimedia.md
index c26c892898ccec4d4f1a442dc2a9e5abd623f27c..5c42b3425d8e33adb51ff38bb1e0ead7ec0ca8ea 100755
--- a/en/readme/multimedia.md
+++ b/en/readme/multimedia.md
@@ -8,23 +8,24 @@ This subsystem offers various media services covering audio, videos, and cameras
- Audio playback and recording
- Video playback and recording
-
- Photographing and recording \(with cameras\)
-## Architecture
-
-**Figure 1** Common architecture of the multimedia subsystem
-
-
-
+## System Architecture
-**Figure 2** Architecture of the multimedia subsystem suitable for the small system
+**Figure 1** Architecture of the multimedia subsystem
+
-
-
-**Figure 3** Multimedia service flow for the small system
-
+- **Media**: provides playback and recording APIs for applications, and invokes the Gstreamer, Histreamer, or other engines through cross-process calling or direct calling.
+ - For the mini system, the media component invokes Histreamer to support audio playback.
+ - For the small system, the media component invokes recorder_lite to support audio/video recording and invokes player_lite by default to support audio/video playback. If the system variable **debug.media_service.histreamer** is set to **1**, the component invokes Histreamer to support audio/video playback. For details, see [syspara Module](https://device.harmonyos.com/en/docs/documentation/guide/subsys-boot-syspara-0000001063362360) or [syspara_lite](https://gitee.com/openharmony/startup_syspara_lite).
+ - For the standard system, the media component invokes Gstreamer to support audio/video playback and recording.
+- **Audio**: supports audio input and output, policy management, and audio focus management.
+- **Camera**: provides camera operation APIs for preview, photographing, and video recording.
+- **Image**: supports encoding and decoding of common image formats.
+- **MediaLibrary**: supports local and distributed media data access management.
+- **Histreamer**: a lightweight media engine that supports file/network streaming media input, audio/video decoding and playback, audio/video encoding and recording, and plugin extension.
+- **Gstreamer**: an open-source GStreamer engine that supports streaming media, audio and video playback, and recording.
## Directory Structure
@@ -59,6 +60,13 @@ The structure of the repository directory is as follows:
│ ├── figures # Architecture and process figures of the playback and recording module for the standard system
│ ├── frameworks # Playback and recording framework implementation for the standard system
│ └── interfaces # Playback and recording module APIs for the standard system
+├── histreamer # Histreamer engine
+│ └── engine # Media engine
+│ ├── player # Encapsulated player
+│ ├── foundation # Basic tools
+│ ├── pipeline # Pipeline framework
+│ └── plugin # Plugin framework
+│ └── plugins # Platform software plugins
└── utils # Subsystem utility module
└── lite # Utility module for the small system
├── figures # Architecture and process figures of the utility module for the small system
@@ -94,9 +102,10 @@ Load the kernel and related drivers before installing the repository. For detail
[multimedia\_utils\_lite](https://gitee.com/openharmony/multimedia_utils_lite)
+[multimedia\_histreamer](https://gitee.com/openharmony/multimedia_histreamer)
+
[multimedia\_camera\_standard](https://gitee.com/openharmony/multimedia_camera_standard)
[multimedia\_audio\_standard](https://gitee.com/openharmony/multimedia_audio_standard)
[multimedia\_media\_standard](https://gitee.com/openharmony/multimedia_media_standard)
-
diff --git a/en/release-notes/OpenHarmony-2-0-canary.md b/en/release-notes/OpenHarmony-2-0-Canary.md
similarity index 100%
rename from en/release-notes/OpenHarmony-2-0-canary.md
rename to en/release-notes/OpenHarmony-2-0-Canary.md
diff --git a/en/release-notes/OpenHarmony-v3.0.1-LTS.md b/en/release-notes/OpenHarmony-v3.0.1-LTS.md
new file mode 100644
index 0000000000000000000000000000000000000000..93c97e5a99e41cfd30bc037c52959b655999d205
--- /dev/null
+++ b/en/release-notes/OpenHarmony-v3.0.1-LTS.md
@@ -0,0 +1,167 @@
+# OpenHarmony 3.0.1 LTS
+
+## Version Description
+
+OpenHarmony 3.0.1 LTS is a maintenance version with a tag of OpenHarmony 3.0 LTS. This version has rectified certain issues detected in OpenHarmony 3.0 LTS.
+
+
+## Version Mapping
+
+**Table 1** Version mapping of software and tools
+
+| Software/Tool| Version| Remarks|
+| -------- | -------- | -------- |
+| OpenHarmony | 3.0.1 LTS | NA |
+| SDK | 3.0.0.0 (API Version 7 release) | NA |
+| (Optional) HUAWEI DevEco Studio| 3.0 Beta1 | Recommended for developing OpenHarmony applications|
+| (Optional) HUAWEI DevEco Device Tool| 2.2 Beta2 | Recommended for developing OpenHarmony smart devices|
+
+
+## Source Code Acquisition
+
+
+### Acquiring Source Code Using the repo Tool
+
+Method 1 \(recommended\): Use the **repo** tool to download the source code over SSH. \(You must have an SSH public key for access to Gitee.\)
+
+```
+repo init -u git@gitee.com:openharmony/manifest.git -b refs/tags/OpenHarmony-v3.0.1-LTS --no-repo-verify
+repo sync -c
+repo forall -c 'git lfs pull'
+```
+
+Method 2: Use the **repo** tool to download the source code over HTTPS.
+
+```
+repo init -u https://gitee.com/openharmony/manifest.git -b refs/tags/OpenHarmony-v3.0.1-LTS --no-repo-verify
+repo sync -c
+repo forall -c 'git lfs pull'
+```
+
+
+### Acquiring Source Code from Mirrors
+
+**Table 2** Mirrors for acquiring source code
+
+| LTS Code| Version| Mirror| SHA-256 Checksum|
+| -------- | -------- | -------- | -------- |
+| Full code base (for mini, small, and standard systems)| 3.0.1 | [Download](https://repo.huaweicloud.com/harmonyos/os/3.0.1/code-v3.0.1-LTS.tar.gz) | [Download](https://repo.huaweicloud.com/harmonyos/os/3.0.1/code-v3.0.1-LTS.tar.gz.sha256) |
+| Standard system solution (binary)| 3.0.1 | [Download](https://repo.huaweicloud.com/harmonyos/os/3.0.1/standard.tar.gz) | [Download](https://repo.huaweicloud.com/harmonyos/os/3.0.1/standard.tar.gz.sha256) |
+| Hi3861 solution (binary)| 3.0.1 | [Download](https://repo.huaweicloud.com/harmonyos/os/3.0.1/hispark_pegasus.tar.gz) | [Download](https://repo.huaweicloud.com/harmonyos/os/3.0.1/hispark_pegasus.tar.gz.sha256) |
+| Hi3518 solution (binary)| 3.0.1 | [Download](https://repo.huaweicloud.com/harmonyos/os/3.0.1/hispark_aries.tar.gz) | [Download](https://repo.huaweicloud.com/harmonyos/os/3.0.1/hispark_aries.tar.gz.sha256) |
+| Hi3516 solution-LiteOS (binary)| 3.0.1 | [Download](https://repo.huaweicloud.com/harmonyos/os/3.0.1/hispark_taurus.tar.gz) | [Download](https://repo.huaweicloud.com/harmonyos/os/3.0.1/hispark_taurus.tar.gz.sha256) |
+| Hi3516 solution-Linux (binary)| 3.0.1 | [Download](https://repo.huaweicloud.com/harmonyos/os/3.0.1/hispark_taurus_linux.tar.gz) | [Download](https://repo.huaweicloud.com/harmonyos/os/3.0.1/hispark_taurus_linux.tar.gz.sha256) |
+
+
+
+## What's New
+
+This version has the following updates to OpenHarmony 3.0 LTS.
+
+
+### Feature Updates
+
+This version does not involve feature updates.
+
+
+### API Updates
+
+This version does not involve API updates.
+
+
+### Chip and Development Board Adaptation
+
+For details about the adaptation status, see [SIG-Devboard](https://gitee.com/openharmony/community/blob/master/sig/sig-devboard/sig_devboard.md).
+
+
+## Resolved Issues
+
+**Table 3** Issues resolved for the mini and small systems
+
+| Issue No.| Description|
+| -------- | -------- |
+| [I4BJFU](https://gitee.com/openharmony/kernel_liteos_a/issues/I4BJFU) | An error occurs when the dyload_posix module removes a file.|
+| [I42N33](https://gitee.com/openharmony/third_party_mksh/issues/I42N33) | During the integration test, the Ctrl+C operation does not function after the **cat** command is run. A device restart is required.|
+| [I4C8BO](https://gitee.com/openharmony/docs/issues/I4C8BO?from=project-issue) | The basic functions of the media subsystem (on a mini- or small-system device) are abnormal when Hi3516D V300 or Hi3518E V300 is burnt and configured by following the instructions in the official website.|
+| [I4BWKC](https://gitee.com/openharmony/drivers_framework/issues/I4BWKC) | The camera driver on the Hi3516D V300 board does not function properly in the pressure test.|
+| [I4BW0G](https://gitee.com/openharmony/drivers_framework/issues/I4BW0G) | The **ResetDriver** interface of the Hi3516D V300 board fails to be called.|
+| [I4C7ZK](https://gitee.com/openharmony/multimedia_camera_lite/issues/I4C7ZK) | For Hi3516D V300, the resident memory of the small system exceeds the baseline.|
+| [I434P1](https://gitee.com/openharmony/multimedia_camera_lite/issues/I434P1) | For Hi3518E V300, the resident memory exceeds the baseline.|
+| [I48IM7](https://gitee.com/openharmony/hiviewdfx_hilog/issues/I48IM7) | During the HiLog pressure test, the hilogd restarts unexpectedly, and the hilog commands cannot be used.|
+| [I4EGMD](https://gitee.com/openharmony/aafwk_aafwk_lite/issues/I4EGMD) | The serialization and deserialization methods of **Want** are defective.|
+| [I4CED3](https://gitee.com/openharmony/account_os_account/issues/I4CED3) | The JS API returns both "err" and "data" in one message.|
+| [I4BXZ1](https://gitee.com/openharmony/app_samples/issues/I4BXZ1) | The **\** component does not respond to clicks.|
+| [I4CMMH](https://gitee.com/openharmony/ace_ace_engine/issues/I4CMMH) | The display effect of the **\** component is abnormal.|
+| [I4CE7D](https://gitee.com/openharmony/miscservices_inputmethod/issues/I4CE7D) | The response time of the edit box is inappropriate.|
+| [I4HI4C](https://gitee.com/openharmony/ai_engine/issues/I4HI4C) | There is a failed item of the TDD test on a small-system device. This failure is caused by the inappropriate test case comparison time range.|
+| [I4EUOW](https://gitee.com/openharmony/ai_engine/issues/I4EUOW) | The number of case execution threads is inappropriate.|
+| [I4HTFS](https://gitee.com/openharmony/appexecfwk_appexecfwk_lite/issues/I4HTFS) | BMS adaptation for the mini system is not supported.|
+| [I4C3BE](https://gitee.com/openharmony/communication_dsoftbus/issues/I4C3BE) | During passive Bluetooth Low Energy (BLE) discovery, the Bluetooth advertisement is frequently updated and, when the Bluetooth resources are used up, automatically disabled.|
+| [I4I7QL](https://gitee.com/openharmony/developtools_packing_tool/issues/I4I7QL) | Packing fails when an ability has two widgets.|
+| [I4BW0G](https://gitee.com/openharmony/drivers_framework/issues/I4BW0G) | There is a possibility that the Wi-Fi **ResetDriver** interface fails to be called.|
+| [I4GBB6](https://gitee.com/openharmony/device_qemu/issues/I4GBB6) | The RISC-V QEMU emulator fails to run.|
+| [I4CE7E](https://gitee.com/openharmony/kernel_liteos_a/issues/I4CE7E) | **drivers/mtd/multi_partition/** in the LiteOS-A kernel is implemented by using the driver functions in **device/hisilicon**.|
+| [I4JBEH](https://gitee.com/openharmony/drivers_framework/issues/I4JBEH) | Memory leakage occurs when the DMA transmission interface of HDF is repeatedly used.|
+| [I4IGQ0](https://gitee.com/openharmony/drivers_framework/issues/I4IGQ0) | Resources are released after component detection fails.|
+| [I4JPCG](https://gitee.com/openharmony/drivers_framework/issues/I4JPCG) | The PWM backlight cannot be set to 0.|
+| [I4ERM4](https://gitee.com/openharmony/drivers_peripheral/issues/I4ERM4) | A test case fails to be displayed.|
+| [I4CMUY](https://gitee.com/openharmony/drivers_adapter_khdf_linux/issues/I4CMUY) | The hdf\_peripheral\_wlan\_test\_performance.bin test suite fails to run.|
+| [I4FIP2](https://gitee.com/openharmony/kernel_liteos_a/issues/I4FIP2) | The **ioctl** function of the LiteOS_A kernel does not support the **SIOCGIFBRDADDR** option.|
+| [I4GVF7](https://gitee.com/openharmony/kernel_liteos_a/issues/I4GVF7) | The permissions on the files and folders generated by the blackbox are inappropriate.|
+| [I4EV8U](https://gitee.com/openharmony/kernel_liteos_a/issues/I4EV8U) | Three test cases, including IO_TEST_PPOLL_001, fail in the liteos\_a\_io\_unittest.bin\#IoTest module.|
+| [I4EV3X](https://gitee.com/openharmony/kernel_liteos_a/issues/I4EV3X) | Seven test cases, including ItTestSys018, fail in the liteos\_a\_sys\_unittest.bin\#SysTest module.|
+| [I4EVG0](https://gitee.com/openharmony/kernel_liteos_a/issues/I4EVG0) | The test case ItTestMisc009 fails in the liteos\_a\_misc\_unittest.bin\#MiscTest module.|
+| [I4JYAX](https://gitee.com/openharmony/kernel_liteos_a/issues/I4JYAX) | The jffs2 adaptation layer incorrectly releases the lock.|
+| [I4FIQW](https://gitee.com/openharmony/kernel_liteos_m/issues/I4FIQW) | The **ioctl** function of the LiteOS_M kernel does not support the **SIOCGIFBRDADDR** option.|
+| [I4ELVA](https://gitee.com/openharmony/kernel_liteos_m/issues/I4ELVA) | The **read** interface at the VFS layer of the file system incorrectly determines whether **g_fs** is null.|
+| [I4C6P2](https://gitee.com/openharmony/kernel_liteos_m/issues/I4C6P2) | The **LOS_QueueInfoGet** function incorrectly counts the tasks waiting to be read and written.|
+| [I4C5RW](https://gitee.com/openharmony/kernel_liteos_m/issues/I4C5RW) | The error indicating that the **OS_TASK_STACK_PROTECT_SIZE** macro is not defined occurs when the MPU is enabled to protect the task stack.|
+| [I4G4VK](https://gitee.com/openharmony/kernel_liteos_m/issues/I4G4VK) | Some macros are inappropriate. If they (for example, **inet_addr**) are changed to functions, the lwIP header file is not required for external calling.|
+| [I4FVGV](https://gitee.com/openharmony/kernel_liteos_m/issues/I4FVGV) | The default lwIP configuration of the LiteOS_M kernel is inappropriate.|
+| [I4CE7D](https://gitee.com/openharmony/miscservices_inputmethod/issues/I4CE7D) | There is no necessary to start the input method after a 3-second delay.|
+| [I4CFOO](https://gitee.com/openharmony/multimedia_media_lite/issues/I4CFOO) | After an application running on the Linux system records videos for multiple times, the size of the last recording file is 0 when the system is restarted without exiting the application.|
+| [I4CLGW](https://gitee.com/openharmony/kernel_liteos_a/issues/I4CLGW) | The page cache is inappropriate.|
+| [I4HKQ2](https://gitee.com/openharmony/vendor_hisilicon/issues/I4HKQ2) | The mechanism for the LiteOS running on a mini-system board to obtain the UDID is inappropriate.|
+| [I4FVJN](https://gitee.com/openharmony/startup_syspara_lite/issues/I4FVJN) | Mini system compilation fails because the dependency to mbedTLS is not added.|
+| [I4CE7E](https://gitee.com/openharmony/kernel_liteos_a/issues/I4CE7E) | **drivers/mtd/multi_partition/** in the LiteOS-A kernel is implemented by using the driver functions in **device/hisilicon**.|
+
+**Table 4** Issues resolved for the standard system
+
+| Issue No.| Description|
+| -------- | -------- |
+| [I4BX4J](https://gitee.com/openharmony/hiviewdfx_hicollie/issues/I4BX4J?from=project-issue) | The Hi3516D V300 board fails to call the **hicollie** interface.|
+| [I4BX1X](https://gitee.com/openharmony/hiviewdfx_hitrace/issues/I4BX1X?from=project-issue) | The Hi3516D V300 board fails to call the **hitrace** interface.|
+| [I4BVUL](https://gitee.com/openharmony/communication_wifi/issues/I4BVUL?from=project-issue) | When access points (APs) are changed, the success rate for networking between standard-system devices and mobile phones is 91%, lower than the expected value (98%).|
+| [I4BW6E](https://gitee.com/openharmony/security_deviceauth/issues/I4BW6E) | During the test for networking between standard-system devices and mobile phones, when the mobile phone disables and enables the network access repeatedly for around 30 times, the networking fails.|
+| [I4BVVW](https://gitee.com/openharmony/communication_dsoftbus/issues/I4BVVW) | During the test for networking between standard-system devices and mobile phones, when the Wi-Fi switch is turned on and off repeatedly, the networking success rate is 97%, lower than the expected value.|
+| [I48YPH](https://gitee.com/openharmony/security_deviceauth/issues/I48YPH?from=project-issue) | During the test for discovery and networking performance, 3 out of 110 networking attempts fails.|
+| [I4492M](https://gitee.com/openharmony/communication_dsoftbus/issues/I4492M) | The offline device detection takes about 30s longer than the specifications.|
+| [I44W7U](https://gitee.com/openharmony/graphic_standard/issues/I44W7U?from=project-issue) | The child window does not support zooming. As a result, the progress bar is hidden during video playback.|
+| [I480Z1](https://gitee.com/openharmony/communication_dsoftbus/issues/I480Z1?from=project-issue) | Softbus_server crashes when executing **socketfuzz**.|
+| [I4BGLS](https://gitee.com/openharmony/security_deviceauth/issues/I4BGLS?from=project-issue) | The key imported by using `import_signed_auth_info_hilink` is used for identifying the HiChain connection. After the key is imported, it is encrypted and stored in the file and is not cleared from the heap after being returned.|
+| [I4A10Q](https://gitee.com/openharmony/startup_appspawn/issues/I4A10Q?from=project-issue) | The performance of Hi3516 3.0.0.6 static KPIs deteriorates severely.|
+| [I4BXYT](https://gitee.com/openharmony/developtools_hdc_standard/issues/I4BXYT) | After device restart, developers must run the **hdc_std kill** command to discover the device again.|
+| [I4KUTY](https://gitee.com/openharmony/ace_engine_lite/issues/I4KUTY) | There are invalid return values.|
+| [I4DMFV](https://gitee.com/openharmony/ark_js_runtime/issues/I4DMFV) | The conversion from UTF-16 to UTF-8 is inappropriate.|
+| [I4HGVM](https://gitee.com/openharmony/communication_dsoftbus/issues/I4HGVM) | The dependency on mbedTLS is missing for the standard system.|
+| [I4DLV2](https://gitee.com/openharmony/drivers_framework/issues/I4DLV2) | An invalid memory access error occurs due to the HidInfo\* type.|
+| [I4CIJJ](https://gitee.com/openharmony/third_party_flutter/issues/I4CIJJ) | ACE does not support GPU rendering.|
+| [I4G31Z](https://gitee.com/openharmony/third_party_freetype/issues/I4G31Z) | An update for the font engine version from 2.10.1 to 2.10.4 is unavailable.|
+| [I4H06M](https://gitee.com/openharmony/third_party_harfbuzz/issues/I4H06M) | An update for the OpenType text shaping engine from 2.6.1 to 2.8.1 is unavailable.|
+| [I4FS7V](https://gitee.com/openharmony/third_party_lwip/issues/I4FS7V) | The **LWIP\_NETCONN\_FULLDUPLEX** macro is not used to control the initialization of **conn->mbox\_threads\_waiting**.|
+| [I43KL7](https://gitee.com/openharmony/graphic_standard/issues/I43KL7) | The synthesizer does not support GPU synthesis.|
+
+
+## Known Issues
+
+**Table 5** Known issues
+
+| Issue No.| Description| Impact| To Be Resolved On|
+| -------- | -------- | -------- | -------- |
+| [I4NMXQ](https://gitee.com/openharmony/xts_acts/issues/I4NMXQ?from=project-issue) | The XTS test suites storagefileioperformancejstest and storagefilestabilityjstest cannot be automatically executed on a standard-system device.| This issue is caused by the XTS test suite framework. The test suites can only be manually executed. This issue does not affect functions.| 2022/01/30 |
+| [I4NU92](https://gitee.com/openharmony/communication_wifi/issues/I4NU92) | Mini-system Hi3516_Linux: The ActsLwipTest.bin test suite has a failed test item.| The automatic test case fails to invoke the kernel to read time_out. This issue does not affect the communication function.| 2022/01/15 |
+| [I4NTKG](https://gitee.com/openharmony/xts_acts/issues/I4NTKG) | Two failed items are displayed when the XTS test suite WeekPluralNumberTest is executed.| This is a test case issue and does not affect functions.| 2022/01/15 |
+| [I4OWWM](https://gitee.com/openharmony/xts_acts/issues/I4OWWM) | The JSON file corresponding to the WeekPluralNumbertest module is incorrectly configured. During case execution, the error message "required device does not exist" is displayed.| The JSON file configuration is incorrect. This issue does not affect functions.| 2022/01/15 |
+| [I4MSVV](https://gitee.com/openharmony/xts_acts/issues/I4MSVV?from=project-issue) | During the XTS test on the standard system, there are three failed items of the HiCollieCppTest cases in the ActsHiCollieCppTest module.| The test suite name is changed. As a result, the test case with the text verification function fails. This issue does not affect functions.| 2022/01/15 |
+| [I4MSWM](https://gitee.com/openharmony/xts_acts/issues/I4MSWM?from=project-issue) | During the XTS test on the standard system, there is one failed item for faultloggertest in the ActsFaultLoggerTest module.| The test suite name is changed. As a result, the test case with the text verification function fails. This issue does not affect functions.| 2022/01/15 |
+| [I4NODO](https://gitee.com/openharmony/device_manager/issues/I4NODO) | During the test for the Hi3516 board running on a standard-system device, the E2E test of the distributed service hopping fails.| The DM component fails to repeatedly create a group. This issue affects the services that use hopping in the same way as that described in the issue details. Other services are not affected.| 2022/01/30 |
diff --git a/en/release-notes/Readme.md b/en/release-notes/Readme.md
index bc2cf67f424665d1346bfd1e4955ed8f56bbb2ee..1182087f12c19aff9aa3772fe559feed1ba534ef 100644
--- a/en/release-notes/Readme.md
+++ b/en/release-notes/Readme.md
@@ -1,11 +1,12 @@
# OpenHarmony Release Notes
## OpenHarmony 3.x Releases
- [OpenHarmony v3.1 Beta (2021-12-31)](OpenHarmony-v3.1-beta.md)
+- [OpenHarmony v3.0.1 LTS (2022-01-12)](OpenHarmony-v3.0.1-LTS.md)
- [OpenHarmony v3.0 LTS (2021-09-30)](OpenHarmony-v3.0-LTS.md)
## OpenHarmony 2.x Releases
- [OpenHarmony v2.2 beta2 (2021-08-04)](OpenHarmony-v2.2-beta2.md)
-- [OpenHarmony 2.0 Canary (2021-06-02)](OpenHarmony-2-0-canary.md)
+- [OpenHarmony 2.0 Canary (2021-06-02)](OpenHarmony-2-0-Canary.md)
## OpenHarmony 1.x Releases
- [OpenHarmony v1.1.3 LTS (2021-09-30)](OpenHarmony-v1-1-3-LTS.md)
- [OpenHarmony v1.1.2 LTS (2021-08-04)](OpenHarmony-v1.1.2-LTS.md)
diff --git a/zh-cn/application-dev/Readme-CN.md b/zh-cn/application-dev/Readme-CN.md
index da4e7d1ccf044c6c683143eeaaa9385840bb0c11..46bc2b4a8691a43cbf65b5fa836580ed76e96204 100644
--- a/zh-cn/application-dev/Readme-CN.md
+++ b/zh-cn/application-dev/Readme-CN.md
@@ -8,10 +8,12 @@
- 方舟开发框架(ArkUI)
- [基于JS扩展的类Web开发范式](ui/ui-arkui-js.md)
- [基于TS扩展的声明式开发范式](ui/ui-arkui-ts.md)
+- [后台代理提醒](background-agent-scheduled-reminder/Readme-CN.md)
+- [后台任务管理](background-task-management/Readme-CN.md)
- [媒体](media/Readme-CN.md)
- [安全](security/Readme-CN.md)
- [IPC与RPC通信](connectivity/ipc-rpc.md)
-- [分布式数据服务](database/Readme-CN.md)
+- [数据管理](database/Readme-CN.md)
- [USB服务](usb/Readme-CN.md)
- [DFX](dfx/Readme-CN.md)
- [开发参考](reference/Readme-CN.md)
diff --git a/zh-cn/application-dev/background-task-management/Readme-CN.md b/zh-cn/application-dev/background-task-management/Readme-CN.md
new file mode 100644
index 0000000000000000000000000000000000000000..36178f390b77fbf8b4ed9abd5309c450f0fed3eb
--- /dev/null
+++ b/zh-cn/application-dev/background-task-management/Readme-CN.md
@@ -0,0 +1,5 @@
+# 后台任务管理
+
+- 后台任务
+ - [后台任务概述](background-task-overview.md)
+ - [后台任务开发指导](background-task-dev-guide.md)
\ No newline at end of file
diff --git a/zh-cn/application-dev/background-task-management/background-task-dev-guide.md b/zh-cn/application-dev/background-task-management/background-task-dev-guide.md
index 590eeaeb10e8fb8eef38659490aeaeb0f8badc0b..2047780916748df3d73dabb48f13df84c9960e32 100644
--- a/zh-cn/application-dev/background-task-management/background-task-dev-guide.md
+++ b/zh-cn/application-dev/background-task-management/background-task-dev-guide.md
@@ -7,10 +7,12 @@
## 接口说明
-```
+```js
import backgroundTaskManager from '@ohos.backgroundTaskManager';
```
+## 短时任务
+
**表1** backgroundTaskManager主要接口
| 接口名 | 描述 |
@@ -29,51 +31,221 @@ import backgroundTaskManager from '@ohos.backgroundTaskManager';
## 开发步骤
+
1. 申请延迟挂起
- ```
- import backgroundTaskManager from '@ohos.backgroundTaskManager';
- let myReason = 'test requestSuspendDelay';
- let delayInfo = backgroundTaskManager.requestSuspendDelay(myReason, () => {
- console.info("Request suspend delay will time out.");
- });
- var id = delayInfo.requestId;console.info("requestId is: " + id);
- ```
+
+ ```js
+ import backgroundTaskManager from '@ohos.backgroundTaskManager';
+
+ let myReason = 'test requestSuspendDelay';
+ let delayInfo = backgroundTaskManager.requestSuspendDelay(myReason, () => {
+ console.info("Request suspension delay will time out.");
+ });
+
+ var id = delayInfo.requestId;console.info("requestId is: " + id);
+ ```
+
2. 获取进入挂起前的剩余时间
- ```
- backgroundTaskManager.getRemainingDelayTime(id).then( res => {
- console.log('promise => Operation succeeded. Data: ' + JSON.stringify(res));
- }).catch( err => {
- console.log('promise => Operation failed. Cause: ' + err.data);
- });
- ```
+
+ ```js
+ backgroundTaskManager.getRemainingDelayTime(id).then( res => {
+ console.log('promise => Operation succeeded. Data: ' + JSON.stringify(res));
+ }).catch( err => {
+ console.log('promise => Operation failed. Cause: ' + err.data);
+ });
+ ```
+
3. 取消延迟挂起
- ```
- backgroundTaskManager.cancelSuspendDelay(id);
- ```
+
+ ```js
+ backgroundTaskManager.cancelSuspendDelay(id);
+ ```
## 开发实例
-```
+```js
import backgroundTaskManager from '@ohos.backgroundTaskManager';
let myReason = 'test requestSuspendDelay';
+
// 申请延迟挂起
let delayInfo = backgroundTaskManager.requestSuspendDelay(myReason, () => {
- console.info("Request suspend delay will time out.");
+ console.info("Request suspension delay will time out.");
});
+
// 打印延迟挂起信息
var id = delayInfo.requestId;
var time = delayInfo.actualDelayTime;
console.info("The requestId is: " + id);
console.info("The actualDelayTime is: " + time);
+
// 获取应用程序进入挂起状态前的剩余时间
backgroundTaskManager.getRemainingDelayTime(id).then( res => {
console.log('promise => Operation succeeded. Data: ' + JSON.stringify(res));
}).catch( err => {
console.log('promise => Operation failed. Cause: ' + err.data);
});
+
// 取消延迟挂起
backgroundTaskManager.cancelSuspendDelay(id);
```
+
+## 长时任务
+
+### 权限
+
+ohos.permission.KEEP_BACKGROUND_RUNNING
+
+**表3** 长时任务主要接口
+
+| 接口名 | 描述 |
+| -------- | -------- |
+| function startBackgroundRunning(context: Context, bgMode: BackgroundMode, wantAgent: WantAgent, callback: AsyncCallback<void>): void; function startBackgroundRunning(context: Context, bgMode: BackgroundMode, wantAgent: WantAgent): Promise<void>; | 服务启动后,向系统申请长时任务,使服务一直保持后台运行 |
+| function stopBackgroundRunning(context: Context, callback: AsyncCallback<void>): void; function stopBackgroundRunning(context: Context): Promise<void>; | 停止后台长时任务的运行 |
+
+
+其中,wantAgent的信息详见([WantAgent](#zh-cn/application-dev/reference/apis/js-apis-notification.md#WantAgent接口))
+
+
+**表4** 后台模式类型
+| 参数名 | id值 | 描述 |
+| -------- | -------- | -------- |
+| DATA_TRANSFER | 1 | 数据传输 |
+| AUDIO_PLAYBACK | 2 | 音频播放 |
+| AUDIO_RECORDING | 3 | 录音 |
+| LOCATION | 4 | 定位导航 |
+| BLUETOOTH_INTERACTION | 5 | 蓝牙相关 |
+| MULTI_DEVICE_CONNECTION | 6 | 多设备互联 |
+| WIFI_INTERACTION | 7 | WLAN相关(系统保留) |
+| VOIP | 8 | 音视频通话(系统保留) |
+| TASK_KEEPING | 9 | 计算任务(仅供PC使用) |
+
+
+## 开发步骤
+
+1. 在config.json文件中配置长时任务权限
+
+ ```json
+ "module": {
+ "package": "com.example.myapplication",
+ ...,
+ "reqPermissions": [
+ {
+ "name": "ohos.permission.KEEP_BACKGROUND_RUNNING"
+ }
+ ]
+ }
+ ```
+
+2. 申请长时任务
+
+ ```js
+ import backgroundTaskManager from '@ohos.backgroundTaskManager';
+ import featureAbility from '@ohos.ability.featureAbility';
+ import wantAgent from '@ohos.wantAgent';
+
+ let wantAgentInfo = {
+ wants: [
+ {
+ bundleName: "com.example.myapplication",
+ abilityName: "com.example.myapplication.MainAbility"
+ }
+ ],
+ operationType: wantAgent.OperationType.START_ABILITY,
+ requestCode: 0,
+ wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESET_FLAG]
+ };
+
+ // 通过wantAgent模块的getWantAgent方法获取WantAgent对象
+ wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => {
+ backgroundTaskManager.startBackgroundRunning(featureAbility.getContext(),
+ backgroundTaskManager.BackgroundMode.DATA_TRANSFER, wantAgentObj).then(() => {
+ console.info("Operation succeeded");
+ }).catch((err) => {
+ console.error("Operation failed Cause: " + err);
+ });
+ });
+ ```
+
+3. 停止长时任务
+
+ ```js
+ import backgroundTaskManager from '@ohos.backgroundTaskManager';
+ import featureAbility from '@ohos.ability.featureAbility';
+
+ backgroundTaskManager.stopBackgroundRunning(featureAbility.getContext()).then(() => {
+ console.info("Operation succeeded");
+ }).catch((err) => {
+ console.error("Operation failed Cause: " + err);
+ });
+
+ ```
+
+## 开发实例
+
+当服务启动后,在serviceAbility的onStart回调方法中,调用长时任务的申请接口,声明此服务需要在后台长时运行。在onStop回调方法里,调用长时任务取消接口,声明取消长时任务。
+在service.js文件中:
+
+```js
+import backgroundTaskManager from '@ohos.backgroundTaskManager';
+import featureAbility from '@ohos.ability.featureAbility';
+import wantAgent from '@ohos.wantAgent';
+
+function startBackgroundRunning() {
+ let wantAgentInfo = {
+ wants: [
+ {
+ bundleName: "com.example.myapplication",
+ abilityName: "com.example.myapplication.MainAbility"
+ }
+ ],
+ operationType: wantAgent.OperationType.START_ABILITY,
+ requestCode: 0,
+ wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESET_FLAG]
+ };
+
+ // 通过wantAgent模块的getWantAgent方法获取WantAgent对象
+ wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => {
+ backgroundTaskManager.startBackgroundRunning(featureAbility.getContext(),
+ backgroundTaskManager.BackgroundMode.DATA_TRANSFER, wantAgentObj).then(() => {
+ console.info("Operation succeeded");
+ }).catch((err) => {
+ console.error("Operation failed Cause: " + err);
+ });
+ });
+}
+
+function stopBackgroundRunning() {
+ backgroundTaskManager.stopBackgroundRunning(featureAbility.getContext()).then(() => {
+ console.info("Operation succeeded");
+ }).catch((err) => {
+ console.error("Operation failed Cause: " + err);
+ });
+}
+
+export default {
+ onStart(want) {
+ console.info('ServiceAbility onStart');
+ startBackgroundRunning();
+ },
+ onStop() {
+ console.info('ServiceAbility onStop');
+ stopBackgroundRunning();
+ },
+ onConnect(want) {
+ console.info('ServiceAbility onConnect');
+ return {};
+ },
+ onReconnect(want) {
+ console.info('ServiceAbility onReconnect');
+ },
+ onDisconnect() {
+ console.info('ServiceAbility onDisconnect');
+ },
+ onCommand(want, restart, startId) {
+ console.info('ServiceAbility onCommand');
+ }
+};
+```
\ No newline at end of file
diff --git a/zh-cn/application-dev/background-task-management/background-task-overview.md b/zh-cn/application-dev/background-task-management/background-task-overview.md
index f3cec92c4187b4a63b4ca35f787b37e37c0a71d5..fa4c7330628333de635df896851dbb1c04b5cf6f 100644
--- a/zh-cn/application-dev/background-task-management/background-task-overview.md
+++ b/zh-cn/application-dev/background-task-management/background-task-overview.md
@@ -1,4 +1,4 @@
-# 概述
+# 后台任务概述
对于有用户交互的OS来说,资源优先分配给与用户交互的业务进程,换句话说,在支撑OS运行的进程以外,用户能感知到的业务进程优先级最高,所以后台任务管理的范围是用户感知不到的业务进程。
@@ -33,3 +33,30 @@
- **取消时机**:任务完成后申请方应用主动取消延时申请,不要等到超时后被系统取消,否则会影响该应用的后台允许运行时长配额。
- **配额机制**:为了防止应用滥用保活,或者申请后不取消,每个应用每天都会有一定配额(会根据用户的使用习惯动态调整),配额消耗完就不再允许申请短时任务,所以应用完成短时任务后立刻取消延时申请,避免消耗配额。(注,这个配额指的是申请的时长,系统默认应用在后台运行的时间不计算在内)。
+
+## 长时任务
+长时任务给用户能够直观感受到的且需要一直在后台运行的业务提供后台运行生命周期的保障。比如:业务需要在后台播放声音、需要在后台持续导航定位等。此类用户可以直观感知到的后台业务行为,可以通过使用长时任务对应的后台模式保障业务在后台的运行,支撑应用完成在后台的业务。
+
+### 后台模式分类
+OpenHarmony提供了九种后台模式,供需要在后台做长时任务的业务使用,具体的后台模式类型如下:
+
+**表1** 长时任务种类
+
+| BackgroundMode | 说明 | 通知栏显示提示 | 备注 |
+| -------- | -------- | -------- | -------- |
+| dataTransfer | 通过网络/对端设备进行数据下载、备份、分享、传输等 | 正在运行数据传输任务 | |
+| audioPlayback | 音频输出 | 正在运行音频播放任务 | |
+| audioRecording | 音频输入 | 正在运行录音任务 | |
+| location | 定位、导航 | 正在运行定位任务 | |
+| bluetoothInteraction | 蓝牙传输 | 正在运行蓝牙相关任务 | |
+| multiDeviceConnection | 分布式互联任务 | 正在运行分布式任务 | |
+| wifiInteraction | WLAN传输 | 正在运行WLAN相关任务 | SystemApi,仅对System权限应用开放 |
+| voip | 音视频电话、VOIP | 正在运行通话相关任务 | SystemApi,仅对System权限应用开放 |
+| taskKeeping | 计算任务 | 正在运行计算任务 | PC特有,仅在PC申请生效 |
+
+### 长时任务使用约束
+- 如果用户选择可感知业务(如播音、导航、上传下载等),触发对应后台模式,在任务启动时,系统会强制弹出通知提醒用户。
+- 如果任务结束,应用应主动退出后台模式。若在后台运行期间,系统检测到应用并未使用对应后台模式的资源,则会被挂起(Suspend)。
+- 避免不合理地申请后台长时任务,长时任务类型要与应用的业务类型匹配。如表1所示。如果执行的任务和申请的类型不匹配,也会被系统检测到并被挂起(Suspend)。
+- 长时任务是为了真正在后台长时间执行某个任务,如果一个应用申请了长时任务,但在实际运行过程中,并未真正运行或执行此类任务时,也会被系统检测到并被挂起(Suspend)。
+- 每个Ability同一时刻只能申请运行一个长时任务。
\ No newline at end of file
diff --git a/zh-cn/application-dev/database/Readme-CN.md b/zh-cn/application-dev/database/Readme-CN.md
index f6341aa680d95dc524fb2e1820f7b08b53ecc69d..c96d684813ae4d444503601e566f5e42061f552e 100644
--- a/zh-cn/application-dev/database/Readme-CN.md
+++ b/zh-cn/application-dev/database/Readme-CN.md
@@ -1,4 +1,11 @@
-# 分布式数据服务
+# 数据管理
-- [分布式数据服务概述](database-mdds-overview.md)
-- [分布式数据服务开发指导](database-mdds-guidelines.md)
+- 分布式数据服务
+ - [分布式数据服务概述](database-mdds-overview.md)
+ - [分布式数据服务开发指导](database-mdds-guidelines.md)
+- 关系型数据库
+ - [关系型数据库概述](database-relational-overview.md)
+ - [分布式数据服务开发指导](database-relational-guidelines.md)
+- 轻量级数据存储
+ - [轻量级数据存储概述](database-preference-overview.md)
+ - [轻量级数据存储开发指导](database-preference-guidelines.md)
diff --git a/zh-cn/application-dev/database/database-preference-guidelines.md b/zh-cn/application-dev/database/database-preference-guidelines.md
new file mode 100644
index 0000000000000000000000000000000000000000..93ae0313272e6599e0f12ce48cea14e4a47b042f
--- /dev/null
+++ b/zh-cn/application-dev/database/database-preference-guidelines.md
@@ -0,0 +1,161 @@
+# 轻量级数据存储开发指导
+
+## 场景介绍
+
+轻量级数据存储功能通常用于保存应用的一些常用配置信息,并不适合需要存储大量数据和频繁改变数据的场景。应用的数据保存在文件中,这些文件可以持久化地存储在设备上。需要注意的是,应用访问的实例包含文件所有数据,这些数据会一直加载在设备的内存中,直到应用主动从内存中将其移除前,应用可以通过Storage的API进行数据操作。
+
+## 接口说明
+
+轻量级存储为应用提供key-value键值型的文件数据处理能力,支持应用对数据进行轻量级存储及查询。数据存储形式为键值对,键的类型为字符串型,值的存储数据类型包括数字型、字符型、布尔型。
+
+**创建存储实例**
+
+读取指定文件,将数据加载到Storage实例,即可创建一个存储实例,用于数据操作。
+
+**表1** 轻量级数据存储实例创建接口
+
+| 包名 | 接口名 | 描述 |
+| ----------------- | ------------------------------------------- | ------------------------------------------- |
+| ohos.data.storage | getStorage(path: string): Promise\ | 获取文件对应的Storage单实例,用于数据操作。 |
+
+**存入数据**
+
+通过put系列方法,可以增加或修改Storage实例中的数据。
+
+**表2** 轻量级数据存入接口
+
+| 类名 | 接口名 | 描述 |
+| ------- | -------------------------------------------------- | ----------------------------------------------- |
+| Storage | put(key: string, value: ValueType): Promise\ | 支持值为number、string、boolean类型的数据存入。 |
+
+**读取数据**
+
+通过调用get系列方法,可以读取Storage中的数据。
+
+**表3** 轻量级数据读取接口
+
+| 类名 | 接口名 | 描述 |
+| ------- | ---------------------------------------------------------- | ----------------------------------------------- |
+| Storage | get(key: string, defValue: ValueType): Promise\ | 支持获取值为number、string、boolean类型的数据。 |
+
+**数据持久化**
+
+通过执行flush方法,应用可以将缓存的数据再次写回文本文件中进行持久化存储。
+
+**表4** 轻量级数据持久化接口
+
+| 类名 | 接口名 | 描述 |
+| ------- | ----------------------- | --------------------------------------- |
+| Storage | flush(): Promise\ | 将Storage实例通过异步线程回写入文件中。 |
+
+**订阅数据变化**
+
+订阅数据变化需要指定StorageObserver作为回调方法。订阅的key的值发生变更后,当执行flush方法时,StorageObserver被回调。
+
+**表5** 轻量级数据变化订阅接口
+
+| 类名 | 接口名 | 描述 |
+| ------- | ------------------------------------------------------------ | -------------- |
+| Storage | on(type: 'change', callback: Callback\): void | 订阅数据变化。 |
+| Storage | off(type: 'change', callback: Callback\): void | 注销订阅。 |
+
+**删除数据文件**
+
+通过调用以下两种接口,可以删除数据实例或对应的文件。
+
+**表6** 轻量级数据存储删除接口
+
+| 包名 | 接口名 | 描述 |
+| ----------------- | ---------------------------------------------------- | ------------------------------------------------------------ |
+| ohos.data.storage | deleteStorage(path: string): Promise\ | 从缓存中移除已加载的Storage对象,同时从设备上删除对应的文件。 |
+| ohos.data.storage | removeStorageFromCache(path: string): Promise\ | 仅从缓存中移除已加载的Storage对象,主要用于释放内存。 |
+
+## 开发步骤
+
+1. 准备工作,导入@ohos.data.storage以及相关的模块到开发环境。
+
+ ```
+ import dataStorage from '@ohos.data.storage'
+ import featureAbility from '@ohos.ability.featureAbility' // 用于获取文件存储路径
+ ```
+
+2. 获取Storage实例。
+
+ 读取指定文件,将数据加载到Storage实例,用于数据操作。
+ ```
+ var context = featureAbility.getContext()
+ var path = await context.getFilesDir()
+ let promise = dataStorage.getStorage(path + '/mystore')
+ ```
+
+3. 存入数据。
+
+ 使用Storage put方法保存数据到缓存的实例中。
+
+ ```
+ promise.then((storage) => {
+ let getPromise = storage.put('startup', 'auto') // 保存数据到缓存的storage示例中。
+ getPromise.then(() => {
+ console.info("Put the value of startup successfully.")
+ }).catch((err) => {
+ console.info("Put the value of startup failed with err: " + err)
+ })
+ }).catch((err) => {
+ console.info("Get the storage failed")
+ })
+ ```
+
+4. 读取数据。
+
+ 使用Storage get方法读取数据。
+
+ ```
+ promise.then((storage) => {
+ let getPromise = storage.get('startup', 'default')
+ getPromise.then((value) => {
+ console.info("The value of startup is " + value)
+ }).catch((err) => {
+ console.info("Get the value of startup failed with err: " + err)
+ })
+ }).catch((err) => {
+ console.info("Get the storage failed")})
+ ```
+
+5. 数据持久化。
+
+ 应用存入数据到Storage实例后,可以通过flush或者flushSync方法将Storage实例回写到文件中。
+
+ ```
+ storage.flush();
+ ```
+
+6. 订阅数据变化。
+
+ 应用订阅数据变化需要指定StorageObserver作为回调方法。订阅的key的值发生变更后,当执行flush方法时,StorageObserver被触发回调。不再需要StorageObserver时请注销。
+
+ ```
+ promise.then((storage) => {
+ var observer = function (key) {
+ console.info("The key of " + key + " changed.")
+ }
+ storage.on('change', observer)
+ storage.putSync('startup', 'auto') // 修改storage存储数据
+ storage.flushSync() // 触发订阅者回调方法
+
+ storage.off('change', observer) // 注销数据变化订阅
+ }).catch((err) => {
+ console.info("Get the storage failed")
+ })
+ ```
+
+7. 删除指定文件。
+
+ 使用deleteStorage方法从内存中移除指定文件对应的Storage单实例,并删除指定文件及其备份文件、损坏文件。删除指定文件时,应用不允许再使用该实例进行数据操作,否则会出现数据一致性问题。删除后,数据及文件将不可恢复。
+
+ ```
+ let promise = dataStorage.deleteStorage(path + '/mystore')
+ promise.then(() => {
+ console.info("Deleted successfully.")
+ }).catch((err) => {
+ console.info("Deleted failed with err: " + err)})
+ ```
\ No newline at end of file
diff --git a/zh-cn/application-dev/database/database-preference-overview.md b/zh-cn/application-dev/database/database-preference-overview.md
new file mode 100644
index 0000000000000000000000000000000000000000..b906e9423d4b4f988a0d12d66167f0ec6f855047
--- /dev/null
+++ b/zh-cn/application-dev/database/database-preference-overview.md
@@ -0,0 +1,28 @@
+# 轻量级数据存储概述
+
+轻量级数据存储适用于对Key-Value结构的数据进行存取和持久化操作。应用获取某个轻量级存储对象后,该存储对象中的数据将会被缓存在内存中,以便应用获得更快的数据存取速度。应用也可以将缓存的数据再次写回文本文件中进行持久化存储,由于文件读写将产生不可避免的系统资源开销,建议应用减少对持久化文件的读写频率。
+
+## 基本概念
+
+- **Key-Value数据结构**
+
+ 一种键值结构数据类型。Key是不重复的关键字,Value是数据值。
+
+- **非关系型数据库**
+
+ 区别于关系数据库,不保证遵循ACID(Atomic、Consistency、Isolation及Durability)特性,不采用关系模型来组织数据,数据之间无关系。
+
+## 运作机制
+
+1. 应用通过指定Storage文件将其中的数据加载到Storage实例,系统会通过静态容器将该实例存储在内存中,同一应用或进程中每个文件仅存在一个Storage实例,直到应用主动从内存中移除该实例或者删除该Storage文件。
+2. 应用获取到Storage文件对应的实例后,可以从Storage实例中读取数据,或者将数据存入Storage实例中。通过调用flush或者flushSync方法可以将Storage实例中的数据回写到文件里。
+
+**图1** 轻量级数据存储运作机制
+
+
+
+## 约束与限制
+
+- 因Storage实例会加载到内存中,建议存储的数据不超过一万条,并及时清理不再使用的实例,以便减少非内存开销。
+- 数据中的key为string类型,要求非空且字符长度不超过80个。
+- 当数据中的value为string类型时,允许为空,字符长度不超过8192个。
\ No newline at end of file
diff --git a/zh-cn/application-dev/database/database-relational-guidelines.md b/zh-cn/application-dev/database/database-relational-guidelines.md
new file mode 100644
index 0000000000000000000000000000000000000000..127fa0bae8e4a437f27d02262d388d22ff7a1ba5
--- /dev/null
+++ b/zh-cn/application-dev/database/database-relational-guidelines.md
@@ -0,0 +1,200 @@
+# 关系型数据库开发指导
+
+## 场景介绍
+
+关系型数据库是在SQLite基础上实现的本地数据操作机制,提供给用户无需编写原生SQL语句就能进行数据增删改查的方法,同时也支持原生SQL语句操作。
+
+
+## 接口说明
+
+**数据库的创建和删除**
+
+关系型数据库提供了数据库创建方式,以及对应的删除接口,涉及的API如下所示。
+
+**表1** 数据库创建和删除API
+
+| 类名 | 接口名 | 描述 |
+| -------- | -------- | -------- |
+| dataRdb | getRdbStore(config: StoreConfig, version: number, callback: AsyncCallback<RdbStore>): void | 获得一个相关的RdbStore,操作关系型数据库,用户可以根据自己的需求配置RdbStore的参数,然后通过RdbStore调用相关接口可以执行相关的数据操作,结果以callback形式返回。 - config:与此RDB存储相关的数据库配置。 - version:数据库版本。 - callback:指定callback回调函数。返回一个RdbStore。 |
+| dataRdb | getRdbStore(config: StoreConfig, version: number): Promise<RdbStore> | 获得一个相关的RdbStore,操作关系型数据库,用户可以根据自己的需求配置RdbStore的参数,然后通过RdbStore调用相关接口可以执行相关的数据操作,结果以Promise形式返回。 - config:与此RDB存储相关的数据库配置。 - version:数据库版本。 |
+| dataRdb | deleteRdbStore(name: string, callback: AsyncCallback<void>): void | 删除数据库,结果以callback形式返回。 - name:数据库名称。 - callback:指定callback回调函数。如果数据库已删除,则为true;否则返回false。 |
+| dataRdb | deleteRdbStore(name: string): Promise<void> | 使用指定的数据库文件配置删除数据库,结果以Promise形式返回。 - name:数据库名称。 |
+
+**数据库的增删改查**
+
+关系型数据库提供对本地数据增删改查操作的能力,相关API如下所示。
+
+- **新增**
+ 关系型数据库提供了插入数据的接口,通过ValuesBucket输入要存储的数据,通过返回值判断是否插入成功,插入成功时返回最新插入数据所在的行号,失败时则返回-1。
+ **表2** 数据库插入API
+
+ | 类名 | 接口名 | 描述 |
+ | -------- | -------- | -------- |
+ | RdbStore | insert(name: string, values: ValuesBucket, callback: AsyncCallback<number>):void | 向目标表中插入一行数据,结果以callback形式返回。 - name:指定的目标表名。 - values:表示要插入到表中的数据行。 - callback:指定callback回调函数。如果操作成功,返回行ID;否则返回-1。 |
+ | RdbStore | insert(name: string, values: ValuesBucket): Promise<number> | 向目标表中插入一行数据,结果以Promise形式返回。 - name:指定的目标表名。 - values:表示要插入到表中的数据行。 |
+
+- **更新**
+ 调用更新接口,传入要更新的数据,并通过RdbPredicates指定更新条件。该接口的返回值表示更新操作影响的行数。如果更新失败,则返回0。
+
+ **表3** 数据库更新API
+
+ | 类名 | 接口名 | 描述 |
+ | -------- | -------- | -------- |
+ | RdbStore | update(values: ValuesBucket, rdbPredicates: RdbPredicates, callback: AsyncCallback<number>):void | 根据RdbPredicates的指定实例对象更新数据库中的数据,结果以callback形式返回。 - values:以ValuesBucket存储的要更新的数据。 - rdbPredicates:表示RdbPredicates的实例对象指定的更新条件。 - callback:指定的callback回调方法。返回受影响的行数。 |
+ | RdbStore | update(values: ValuesBucket, rdbPredicates: RdbPredicates): Promise | 根据RdbPredicates的指定实例对象更新数据库中的数据,结果以Promise形式返回。 - values:以ValuesBucket存储的要更新的数据。 - rdbPredicates:表示RdbPredicates的实例对象指定的更新条件。 |
+
+- **删除**
+ 调用删除接口,通过RdbPredicates指定删除条件。该接口的返回值表示删除的数据行数,可根据此值判断是否删除成功。如果删除失败,则返回0。
+
+ **表4** 数据库删除API
+
+ | 类名 | 接口名 | 描述 |
+ | -------- | -------- | -------- |
+ | RdbStore | delete(rdbPredicates: RdbPredicates, callback: AsyncCallback<number>):void | 根据rdbPredicates的指定实例对象从数据库中删除数据,结果以callback形式返回。 - rdbPredicates:RdbPredicates的实例对象指定的删除条件。 - callback:指定callback回调函数。返回受影响的行数。 |
+ | RdbStore | delete(rdbPredicates: RdbPredicates): Promise | 根据rdbPredicates的指定实例对象从数据库中删除数据,结果以Promise形式返回。 - rdbPredicates:RdbPredicates的实例对象指定的删除条件。 |
+
+- **查询**
+ 关系型数据库提供了两种查询数据的方式:
+
+ - 直接调用查询接口。使用该接口,会将包含查询条件的谓词自动拼接成完整的SQL语句进行查询操作,无需用户传入原生的SQL语句。
+ - 执行原生的SQL语句进行查询操作。
+
+ **表5** 数据库查询API
+
+ | 类名 | 接口名 | 描述 |
+ | -------- | -------- | -------- |
+ | RdbStore | query(rdbPredicates: RdbPredicates, columns: Array, callback: AsyncCallback<ResultSet>): void | 根据指定条件查询数据库中的数据,结果以callback形式返回。 - rdbPredicates:表示RdbPredicates的实例对象指定的查询条件。 - columns:表示要查询的列。如果值为空,则查询应用于所有列。 - callback:指定callback回调函数。如果操作成功,则返回ResultSet对象。 |
+ | RdbStore | query(rdbPredicates: RdbPredicates, columns: Array): Promise<ResultSet> | 根据指定条件查询数据库中的数据,结果以Promise形式返回。 - rdbPredicates:表示RdbPredicates的实例对象指定的查询条件。 - columns:表示要查询的列。如果值为空,则查询应用于所有列。 |
+ | RdbStore | querySql(sql: string, bindArgs: Array<ValueType>, callback: AsyncCallback<ResultSet>):void | 根据指定SQL语句查询数据库中的数据,结果以callback形式返回。 - sql:指定要查询的SQL语句。 - bindArgs:SQL语句中参数的值。 - callback:指定callback回调函数。如果操作成功,则返回ResultSet对象。 |
+ | RdbStore | querySql(sql: string, bindArgs?: Array<ValueType>):Promise<ResultSet> | 根据指定SQL语句查询数据库中的数据,结果以Promise形式返回。 - sql:指定要查询的SQL语句。 - bindArgs:SQL语句中参数的值。 |
+
+**数据库谓词的使用**
+
+关系型数据库提供了用于设置数据库操作条件的谓词RdbPredicates,该类确定RDB中条件表达式的值是true还是false。
+
+**表6** 数据库谓词API
+
+| 类名 | 接口名 | 描述 |
+| -------- | -------- | -------- |
+| RdbPredicates | equalTo(field: string, value: ValueType): RdbPredicates | 配置谓词以匹配数据字段为ValueType且值等于指定值的字段。 - field:数据库表中的列名。 - value:指示要与谓词匹配的值。 - RdbPredicates:返回与指定字段匹配的谓词。 |
+| RdbPredicates | notEqualTo(field: string, value: ValueType): RdbPredicates | 配置谓词以匹配数据字段为ValueType且值不等于指定值的字段。 - field:数据库表中的列名。 - value:指示要与谓词匹配的值。 - RdbPredicates:返回与指定字段匹配的谓词。 |
+| RdbPredicates | beginWrap(): RdbPredicates | 向谓词添加左括号。 - RdbPredicates:返回带有左括号的谓词。 |
+| RdbPredicates | endWrap(): RdbPredicates | 向谓词添加右括号。 - RdbPredicates:返回带有右括号的谓词。 |
+| RdbPredicates | or(): RdbPredicates | 将或条件添加到谓词中。 - RdbPredicates:返回带有或条件的谓词。 |
+| RdbPredicates | and(): RdbPredicates | 向谓词添加和条件。 - RdbPredicates:返回带有和条件的谓词。 |
+| RdbPredicates | contains(field: string, value: string): RdbPredicats | 配置谓词以匹配数据字段为String且value包含指定值的字段。 - field:数据库表中的列名。 - value:指示要与谓词匹配的值。 - RdbPredicates:返回带有包含条件的谓词。 |
+| RdbPredicates | beginsWith(field: string, value: string): RdbPredicates | 配置谓词以匹配数据字段为String且值以指定字符串开头的字段。 - field:数据库表中的列名。 - value:指示要与谓词匹配的值。 - RdbPredicates:返回与指定字段匹配的谓词。 |
+| RdbPredicates | endsWith(field: string, value: string): RdbPredicates | 配置谓词以匹配数据字段为String且值以指定字符串结尾的字段。 - field:数据库表中的列名。 - value:指示要与谓词匹配的值。 - RdbPredicates:返回与指定字段匹配的谓词。 |
+| RdbPredicates | isNull(field: string): RdbPredicates | 配置谓词以匹配值为null的字段。 - field:数据库表中的列名。 - RdbPredicates:返回与指定字段匹配的谓词。 |
+| RdbPredicates | isNotNull(field: string): RdbPredicates | 配置谓词以匹配值不为null的指定字段。 - field:数据库表中的列名。 - RdbPredicates:返回与指定字段匹配的谓词。 |
+| RdbPredicates | like(field: string, value: string): RdbPredicates | 配置谓词以匹配数据字段为String且值类似于指定字符串的字段。 - field:数据库表中的列名。 - value:指示要与谓词匹配的值。 - RdbPredicates:返回与指定字段匹配的谓词。 |
+| RdbPredicates | glob(field: string, value: string): RdbPredicates | 配置RdbPredicates匹配数据字段为String的指定字段。 - field:数据库表中的列名。 - value:指示要与谓词匹配的值。 - RdbPredicates:返回与指定字段匹配的谓词。 |
+| RdbPredicates | between(field: string, low: ValueType, high: ValueType): RdbPredicates | 将谓词配置为匹配数据字段为ValueType且value在给定范围内的指定字段。 - field:数据库表中的列名。 - low:指示与谓词匹配的最小值。 - high:指示与谓词匹配的最大值。 - RdbPredicates:返回与指定字段匹配的谓词。 |
+| RdbPredicates | notBetween(field: string, low: ValueType, high: ValueType): RdbPredicates | 配置RdbPredicates以匹配数据字段为ValueType且value超出给定范围的指定字段。 - field:数据库表中的列名。 - low:指示与谓词匹配的最小值。 - high:指示与谓词匹配的最大值。 - RdbPredicates:返回与指定字段匹配的谓词。 |
+| RdbPredicates | greaterThan(field: string, value: ValueType): RdbPredicatesgr | 配置谓词以匹配数据字段为ValueType且值大于指定值的字段。 - field:数据库表中的列名。 - value:指示要与谓词匹配的值。 - RdbPredicates:返回与指定字段匹配的谓词。 |
+| RdbPredicates | lessThan(field: string, value: ValueType): RdbPredicates | 配置谓词以匹配数据字段为valueType且value小于指定值的字段。 - field:数据库表中的列名。 - value:指示要与谓词匹配的值。 - RdbPredicates:返回与指定字段匹配的谓词。 |
+| RdbPredicates | greaterThanOrEqualTo(field: string, value: ValueType): RdbPredicates | 配置谓词以匹配数据字段为ValueType且value大于或等于指定值的字段。 - field:数据库表中的列名。 - value:指示要与谓词匹配的值。 - RdbPredicates:返回与指定字段匹配的谓词。 |
+| RdbPredicates | lessThanOrEqualTo(field: string, value: ValueType): RdbPredicates | 配置谓词以匹配数据字段为ValueType且value小于或等于指定值的字段。 - field:数据库表中的列名。 - value:指示要与谓词匹配的值。 - RdbPredicates:返回与指定字段匹配的谓词。 |
+| RdbPredicates | orderByAsc(field: string): RdbPredicates | 配置谓词以匹配其值按升序排序的列。 - field:数据库表中的列名。 - RdbPredicates:返回与指定字段匹配的谓词。 |
+| RdbPredicates | orderByDesc(field: string): RdbPredicates | 配置谓词以匹配其值按降序排序的列。 - field:数据库表中的列名。 - RdbPredicates:返回与指定字段匹配的谓词。 |
+| RdbPredicates | distinct(): RdbPredicates | 配置谓词以过滤重复记录并仅保留其中一个。 - RdbPredicates:返回可用于过滤重复记录的谓词。 |
+| RdbPredicates | limitAs(value: number): RdbPredicates | 设置最大数据记录数的谓词。 - value:最大数据记录数。 - RdbPredicates:返回可用于设置最大数据记录数的谓词。 |
+| RdbPredicates | offsetAs(rowOffset: number): RdbPredicates | 配置RdbPredicates以指定返回结果的起始位置。 - rowOffset:返回结果的起始位置,取值为正整数。 - RdbPredicates:返回具有指定返回结果起始位置的谓词。 |
+| RdbPredicates | groupBy(fields: Array<string>): RdbPredicates | 配置RdbPredicates按指定列分组查询结果。 - fields:指定分组依赖的列名。 - RdbPredicates:返回分组查询列的谓词。 |
+| RdbPredicates | indexedBy(indexName: string): RdbPredicates | 配置RdbPredicates以指定索引列。 - indexName:索引列的名称。 - RdbPredicates:返回具有指定索引列的RdbPredicates。 |
+| RdbPredicates | in(field: string, value: Array<ValueType>): RdbPredicates | 配置RdbPredicates以匹配数据字段为ValueType数组且值在给定范围内的指定字段。 - field:数据库表中的列名。 - value:以ValueType型数组形式指定的要匹配的值。 - RdbPredicates:返回与指定字段匹配的谓词。 |
+| RdbPredicates | notIn(field: string, value: Array<ValueType>): RdbPredicates | 将RdbPredicates配置为匹配数据字段为ValueType且值超出给定范围的指定字段。 - field:数据库表中的列名。 - value:以ValueType型数组形式指定的要匹配的值。 - RdbPredicates:返回与指定字段匹配的谓词。 |
+
+**查询结果集的使用**
+
+关系型数据库提供了查询返回的结果集ResultSet,其指向查询结果中的一行数据,供用户对查询结果进行遍历和访问。ResultSet对外API如下所示。
+
+>  **须知:**
+> **注:结果集使用完后,请一定要调用close方法显式关闭。**
+
+**表7** 结果集API
+
+| 类名 | 接口名 | 描述 |
+| -------- | -------- | -------- |
+| ResultSet | goTo(offset:number): boolean | 从结果集当前位置移动指定偏移量。 |
+| ResultSet | goToRow(position: number): boolean | 将结果集移动到指定位置。 |
+| ResultSet | goToNextRow(): boolean | 将结果集向后移动一行。 |
+| ResultSet | goToPreviousRow(): boolean | 将结果集向前移动一行。 |
+| ResultSet | getColumnIndex(columnName: string): number | 根据指定的列名获取列索引。 |
+| ResultSet | getColumnName(columnIndex: number): string | 根据指定的列索引获取列名。 |
+| ResultSet | goToFirstRow(): boolean | 判断结果集当前位置是否在第一行。 |
+| ResultSet | goToLastRow(): boolean | 判断结果集当前位置是否在最后一行。 |
+| ResultSet | getString(columnIndex: number): string | 获取当前行指定列的值,以String类型返回。 |
+| ResultSet | getBlob(columnIndex: number): Uint8Array | 获取当前行指定列的值,以字节数组形式返回。 |
+| ResultSet | getDouble(columnIndex: number): number | 获取当前行指定列的值,以double型返回。 |
+| ResultSet | isColumnNull(columnIndex: number): boolean | 检查当前行中指定列的值是否为null。 |
+| ResultSet | close(): void | 关闭结果集。 |
+
+**数据库更改秘钥**
+
+用户可以对当前数据库进行加密。
+
+数据库的加密仅限于初始使用一个数据库时就进行加密,使用过程中进行秘钥的变更,但不支持取消秘钥。
+
+数据库初始时为加密库,则一直为加密库;初始时为未加密库,则一直为未加密库。
+
+**表8** 数据库更改秘钥
+
+| 类名 | 接口名 | 描述 |
+| -------- | -------- | -------- |
+| RdbStore | changeEncryptKey(newEncryptKey:Uint8Array, callback: AsyncCallback<number>):void; | 数据库更改秘钥接口,通过callback 可以异步处理返回结果。返回结果0成功,非0失败。 |
+| RdbStore | changeEncryptKey(newEncryptKey:Uint8Array): Promise<number>; | 数据库更改秘钥接口,通过await 可以同步处理返回结果。返回结果0成功,非0失败。 |
+
+
+## 开发步骤
+
+1. 创建数据库。
+ 1. 配置数据库相关信息,包括数据库的名称、存储模式、是否为只读模式等。
+ 2. 初始化数据库表结构和相关数据。
+ 3. 创建数据库。
+
+ 示例代码如下:
+
+ ```
+ import dataRdb from '@ohos.data.rdb';
+
+ const CREATE_TABLE_TEST = "CREATE TABLE IF NOT EXISTS test (" + "id INTEGER PRIMARY KEY AUTOINCREMENT, " + "name TEXT NOT NULL, " + "age INTEGER, " + "salary REAL, " + "blobType BLOB)";
+ const STORE_CONFIG = {name: "rdbstore.db",}
+
+ let rdbStore = await dataRdb.getRdbStore(STORE_CONFIG, 1);
+ await rdbStore.executeSql(CREATE_TABLE_TEST);
+ ```
+
+2. 插入数据。
+ 1. 构造要插入的数据,以ValuesBucket形式存储。
+ 2. 调用关系型数据库提供的插入接口。
+
+ 示例代码如下:
+
+ ```
+ var u8 = new Uint8Array([1, 2, 3])
+ const valueBucket = {"name": "Tom", "age": 18, "salary": 100.5, "blobType": u8,}
+ let insertPromise = rdbStore.insert("test", valueBucket)
+ ```
+
+3. 查询数据。
+ 1. 构造用于查询的谓词对象,设置查询条件。
+ 2. 调用查询接口查询数据。
+ 3. 调用结果集接口,返回查询结果。
+
+ 示例代码如下:
+
+ ```
+ let predicates = new dataRdb.RdbPredicates("test");
+ predicates.equalTo("name", "Tom")
+ let resultSet = await rdbStore.query(predicates)
+
+ resultSet.goToFirstRow()
+ const id = await resultSet.getLong(resultSet.getColumnIndex("id"))
+ const name = await resultSet.getString(resultSet.getColumnIndex("name"))
+ const age = await resultSet.getLong(resultSet.getColumnIndex("age"))
+ const salary = await resultSet.getDouble(resultSet.getColumnIndex("salary"))
+ const blobType = await resultSet.getBlob(resultSet.getColumnIndex("blobType"))
+
+ resultSet.close()
+ ```
diff --git a/zh-cn/application-dev/database/database-relational-overview.md b/zh-cn/application-dev/database/database-relational-overview.md
new file mode 100644
index 0000000000000000000000000000000000000000..f9a84f85a03efcda86bac16424ecb82bfbe108de
--- /dev/null
+++ b/zh-cn/application-dev/database/database-relational-overview.md
@@ -0,0 +1,41 @@
+# 关系型数据库概述
+
+关系型数据库(Relational Database,RDB)是一种基于关系模型来管理数据的数据库。关系型数据库基于SQLite组件提供了一套完整的对本地数据库进行管理的机制,对外提供了一系列的增、删、改、查等接口,也可以直接运行用户输入的SQL语句来满足复杂的场景需要。
+
+## 基本概念
+
+- **关系型数据库**
+
+ 基于关系模型来管理数据的数据库,以行和列的形式存储数据。
+
+- **谓词**
+
+ 数据库中用来代表数据实体的性质、特征或者数据实体之间关系的词项,主要用来定义数据库的操作条件。
+
+- **结果集**
+
+ 指用户查询之后的结果集合,可以对数据进行访问。结果集提供了灵活的数据访问方式,可以更方便的拿到用户想要的数据。
+
+- **SQLite数据库**
+
+ 一款遵守ACID的轻型开源关系型数据库管理系统。
+
+## 运作机制
+
+关系型数据库对外提供通用的操作接口,底层使用SQLite作为持久化存储引擎,支持SQLite具有的所有数据库特性,包括但不限于事务、索引、视图、触发器、外键、参数化查询和预编译SQL语句。
+
+**图1** 关系型数据库运作机制
+
+
+
+## 默认配置
+
+- 如果不指定数据库的日志模式,那么系统默认日志方式是WAL(Write Ahead Log)模式。
+- 如果不指定数据库的落盘模式,那么系统默认落盘方式是FULL模式。
+- OpenHarmony数据库使用的共享内存默认大小是2MB。
+
+## 约束与限制
+
+- 数据库中连接池的最大数量是4个,用以管理用户的读操作。
+
+- 为保证数据的准确性,数据库同一时间只能支持一个写操作。
\ No newline at end of file
diff --git a/zh-cn/application-dev/database/figures/how-rdb-works.png b/zh-cn/application-dev/database/figures/how-rdb-works.png
new file mode 100644
index 0000000000000000000000000000000000000000..e85411eef39281e3213d6b4697a8d32d2cecd9a2
Binary files /dev/null and b/zh-cn/application-dev/database/figures/how-rdb-works.png differ
diff --git a/zh-cn/application-dev/database/figures/zh-cn_image_0000001199139454.png b/zh-cn/application-dev/database/figures/zh-cn_image_0000001199139454.png
new file mode 100644
index 0000000000000000000000000000000000000000..5a6f6879944d0fda3cc24d7e726c842c74476728
Binary files /dev/null and b/zh-cn/application-dev/database/figures/zh-cn_image_0000001199139454.png differ
diff --git a/zh-cn/application-dev/media/figures/zh-ch_image_20220117.jpg b/zh-cn/application-dev/media/figures/zh-ch_image_20220117.jpg
index bc56b9d8395873193bbad2b3faf7340c6728af60..8fba3a7beeb4efc7599dde3f32b228135ed92fce 100644
Binary files a/zh-cn/application-dev/media/figures/zh-ch_image_20220117.jpg and b/zh-cn/application-dev/media/figures/zh-ch_image_20220117.jpg differ
diff --git a/zh-cn/application-dev/reference/apis/Readme-CN.md b/zh-cn/application-dev/reference/apis/Readme-CN.md
index 5557c9c32d412e58e064db9b9592e65f7e15019c..16286defa11112818f3dac92860a7e2004849493 100644
--- a/zh-cn/application-dev/reference/apis/Readme-CN.md
+++ b/zh-cn/application-dev/reference/apis/Readme-CN.md
@@ -32,6 +32,9 @@
- [文件管理](js-apis-fileio.md)
- [Statfs](js-apis-statfs.md)
- [目录环境](js-apis-environment.md)
+ - [公共文件访问与管理](js-apis-filemanager.md)
+ - [应用空间统计](js-apis-storage-statistics.md)
+ - [卷管理](js-apis-volumemanager.md)
- 账号管理
- [分布式帐号管理](js-apis-distributed-account.md)
- [应用帐号管理](js-apis-appAccount.md)
@@ -69,6 +72,7 @@
- [性能打点](js-apis-hitracemeter.md)
- [故障日志获取](js-apis-faultLogger.md)
- [分布式跟踪](js-apis-hitracechain.md)
+ - [日志打印](js-apis-hilog.md)
- 语言基础类库
- [获取进程相关的信息](js-apis-process.md)
- [URL字符串解析](js-apis-url.md)
@@ -77,4 +81,18 @@
- [xml解析与生成](js-apis-xml.md)
- [xml转换JavaScript](js-apis-convertxml.md)
- [启动一个worker](js-apis-worker.md)
+ - [线性容器ArrayList](js-apis-arraylist.md)
+ - [线性容器Deque](js-apis-deque.md)
+ - [线性容器List](js-apis-list.md)
+ - [线性容器LinkedList](js-apis-linkedlist.md)
+ - [线性容器Queue](js-apis-queue.md)
+ - [线性容器Stack](js-apis-stack.md)
+ - [线性容器Vector](js-apis-vector.md)
+ - [非线性容器HashSet](js-apis-hashset.md)
+ - [非线性容器HashMap](js-apis-hashmap.md)
+ - [非线性容器PlainArray](js-apis-plainarray.md)
+ - [非线性容器TreeMap](js-apis-treemap.md)
+ - [非线性容器TreeSet](js-apis-treeset.md)
+ - [非线性容器LightWeightMap](js-apis-lightweightmap.md)
+ - [非线性容器LightWeightSet](js-apis-lightweightset.md)
diff --git a/zh-cn/application-dev/reference/apis/js-apis-appAccount.md b/zh-cn/application-dev/reference/apis/js-apis-appAccount.md
index 537dc263d18ec8b7359b849a063d4f133774a305..38e22506315711bdc156e56523ad76a3998d0ac8 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-appAccount.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-appAccount.md
@@ -11,6 +11,11 @@ import account_appAccount from '@ohos.account.appAccount';
```
+## 系统能力
+
+SystemCapability.Account.AppAccount
+
+
## account_appAccount.createAppAccountManager
createAppAccountManager(): AppAccountManager;
@@ -114,6 +119,47 @@ addAccount(name: string, extraInfo?: string): Promise<void>;
});
```
+### addAccountImplicitly8+
+
+addAccountImplicitly(owner: string, authType: string, options: {[key: string]: any}, callback: AuthenticatorCallback): void;
+
+根据指定的帐号所有者、鉴权类型和可选项,隐式地添加应用帐号,并使用callback回调异步返回结果。
+
+需要权限:无。
+
+- 参数:
+
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | --------------------- | --- | -------------------------- |
+ | owner | string | 是 | 要添加的应用帐户的所有者包名。 |
+ | authType | string | 是 | 要添加的应用帐户的鉴权类型。 |
+ | options | {[key: string]: any} | 是 | 鉴权所需要的可选项。 |
+ | callback | AuthenticatorCallback | 是 | 认证器回调,用于返回鉴权结果。 |
+
+- 示例:
+
+ ```
+ import featureAbility from '@ohos.ability.featureAbility';
+
+ function onResultCallback(code, result) {
+ console.log("resultCode: " + code);
+ console.log("result: " + JSON.stringify(result));
+ }
+
+ function onRequestRedirectedCallback(request) {
+ let abilityStartSetting = {want: request};
+ featureAbility.startAbility(abilityStartSetting, (err)=>{
+ console.log("startAbility err: " + JSON.stringify(err));
+ });
+ }
+
+ const appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager.addAccountImplicitly("LiSi", "readAge", {}, {
+ onResult: onResultCallback,
+ onRequestRedirected: onRequestRedirectedCallback
+ });
+ ```
+
### deleteAccount
deleteAccount(name: string, callback: AsyncCallback<void>): void;
@@ -872,12 +918,739 @@ off(type: 'change', callback?: Callback<void>): void;
}
```
+### authenticate8+
+
+authenticate(name: string, owner: string, authType: string, options: {[key: string]: any}, callback: AuthenticatorCallback): void;
+
+鉴权应用帐户以获取OAuth令牌,使用callback回调异步返回结果。
+
+- 参数:
+
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | --------------------- | ---- | --------------------------- |
+ | name | string | 是 | 要鉴权的应用帐户的名称。 |
+ | owner | string | 是 | 要鉴权的应用帐户的所有者包名。 |
+ | authType | string | 是 | 鉴权类型。 |
+ | options | {[key: string]: any} | 是 | 鉴权所需的可选项。 |
+ | callback | AuthenticatorCallback | 是 | 认证器回调,用于返回鉴权结果。 |
+
+- 示例:
+
+ ```
+ import featureAbility from '@ohos.ability.featureAbility';
+
+ function onResultCallback(code, result) {
+ console.log("resultCode: " + code);
+ console.log("result: " + JSON.stringify(result));
+ }
+
+ function onRequestRedirectedCallback(request) {
+ let abilityStartSetting = {want: request};
+ featureAbility.startAbility(abilityStartSetting, (err)=>{
+ console.log("startAbility err: " + JSON.stringify(err));
+ });
+ }
+
+ const appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager.authenticate("LiSi", "com.example.ohos.accountjsdemo", "readAge", {}, {
+ onResult: onResultCallback,
+ onRequestRedirected: onRequestRedirectedCallback
+ });
+ ```
+
+### getOAuthToken8+
+
+getOAuthToken(name: string, owner: string, authType: string, callback: AsyncCallback<string>): void;
+
+获取指定应用帐户和鉴权类型的OAuth令牌,使用callback回调异步返回结果。
+
+- 参数:
+
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | --------------------------- | ---- | -------------------- |
+ | name | string | 是 | 应用帐户的名称。 |
+ | owner | string | 是 | 应用帐户的所有者包名。 |
+ | authType | string | 是 | 鉴权类型。 |
+ | callback | AsyncCallback<string> | 是 | 查询结果的回调。 |
+
+- 示例:
+
+ ```
+ const appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager.getOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "readAge", (err, data) => {
+ console.log('getOAuthToken err: ' + JSON.stringify(err));
+ console.log('getOAuthToken token: ' + data);
+ });
+ ```
+
+### getOAuthToken8+
+
+getOAuthToken(name: string, owner: string, authType: string): Promise<string>;
+
+获取指定应用帐户和鉴权类型的OAuth令牌,使用Promise方式异步返回结果。
+
+- 参数:
+
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | ------ | ---- | -------------------- |
+ | name | string | 是 | 应用帐户的名称。 |
+ | owner | string | 是 | 应用帐户的所有者包名。 |
+ | authType | string | 是 | 鉴权类型。 |
+
+- 参数:
+
+ | 类型 | 说明 |
+ | --------------------- | -------------------------------- |
+ | Promise<string> | Promise实例,用于获取异步返回结果。 |
+
+- 示例:
+
+ ```
+ const appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager.getOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "readAge").then((data) => {
+ console.log('getOAuthToken token: ' + data);
+ }).catch((err) => {
+ console.log("getOAuthToken err: " + JSON.stringify(err));
+ });
+ ```
+
+### setOAuthToken8+
+
+setOAuthToken(name: string, authType: string, token: string, callback: AsyncCallback<void>): void;
+
+设置指定应用帐户和鉴权类型的OAuth令牌,使用callback回调异步返回结果。
+
+- 参数:
+
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | ------------------------- | ---- | ------------- |
+ | name | string | 是 | 应用帐户的名称。 |
+ | authType | string | 是 | 鉴权类型。 |
+ | token | string | 是 | OAuth令牌。 |
+ | callback | AsyncCallback<void> | 是 | 设置结果的回调。 |
+
+- 示例:
+
+ ```
+ const appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager.setOAuthToken("LiSi", "readAge", "xxxx", (err) => {
+ console.log('setOAuthToken err: ' + JSON.stringify(err));
+ });
+ ```
+
+### setOAuthToken8+
+
+setOAuthToken(name: string, authType: string, token: string): Promise<void>;
+
+设置指定应用帐户和鉴权类型的OAuth令牌,使用Promise方式异步返回结果。
+
+- 参数:
+
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | ------ | ---- | ------------- |
+ | name | string | 是 | 应用帐户的名称。 |
+ | authType | string | 是 | 鉴权类型。 |
+ | token | string | 是 | OAuth令牌。 |
+
+- 参数:
+
+ | 类型 | 说明 |
+ | ------------------- | -------------------------------- |
+ | Promise<void> | Promise实例,用于获取异步返回结果。 |
+
+- 示例:
+
+ ```
+ const appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager.setOAuthToken("LiSi", "readAge", "xxxx").then(() => {
+ console.log('setOAuthToken successfully');
+ }).catch((err) => {
+ console.log('setOAuthToken err: ' + JSON.stringify(err));
+ });
+ ```
+
+### deleteOAuthToken8+
+
+deleteOAuthToken(name: string, owner: string, authType: string, token: string, callback: AsyncCallback<void>): void;
+
+删除指定应用帐户和鉴权类型的OAuth令牌,使用callback回调异步返回结果。
+
+- 参数:
+
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | ------------------------- | ---- | ------------------ |
+ | name | string | 是 | 应用帐户的名称。 |
+ | owner | string | 是 | 应用帐户的所有者包名。 |
+ | authType | string | 是 | 鉴权类型。 |
+ | token | string | 是 | 要删除的OAuth令牌。 |
+ | callback | AsyncCallback<void> | 是 | 删除结果的回调。 |
+
+- 示例:
+
+ ```
+ const appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager.deleteOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "readAge", "xxxxx", (err) => {
+ console.log('deleteOAuthToken err: ' + JSON.stringify(err));
+ });
+ ```
+
+### deleteOAuthToken8+
+
+deleteOAuthToken(name: string, owner: string, authType: string, token: string): Promise<void>;
+
+删除指定应用帐户和鉴权类型的OAuth令牌,使用Promise方式异步返回结果。
+
+- 参数:
+
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | ------ | ---- | ------------------ |
+ | name | string | 是 | 应用帐户的名称。 |
+ | owner | string | 是 | 应用帐户的所有者包名。 |
+ | authType | string | 是 | 鉴权类型。 |
+ | token | string | 是 | 要删除的OAuth令牌。 |
+
+- 参数:
+
+ | 类型 | 说明 |
+ | ------------------------------ | --------------------- |
+ | Promise<void> | Promise实例,用于获取异步返回结果。 |
+
+- 示例:
+
+ ```
+ const appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager.deleteOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "readAge", "xxxxx").then(() => {
+ console.log('deleteOAuthToken successfully');
+ }).catch((err) => {
+ console.log("deleteOAuthToken err: " + JSON.stringify(err));
+ });
+ ```
+
+### setOAuthTokenVisibility8+
+
+setOAuthTokenVisibility(name: string, authType: string, bundleName: string, isVisible: boolean, callback: AsyncCallback<void>): void;
+
+设置指定鉴权类型的OAuth令牌对特定应用的可见性,使用callback回调异步返回结果。
+
+- 参数:
+
+ | 参数名 | 类型 | 必填 | 说明 |
+ | ---------- | ------------------------- | ---- | ------------------- |
+ | name | string | 是 | 应用帐户的名称。 |
+ | authType | string | 是 | 鉴权类型。 |
+ | bundleName | string | 是 | 被设置可见性的应用包名。|
+ | isVisible | boolean | 是 | 是否可见。 |
+ | callback | AsyncCallback<void> | 是 | 设置结果的回调。 |
+
+- 示例:
+
+ ```
+ const appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager.setOAuthTokenVisibility("LiSi", "readAge", "com.example.ohos.accountjsdemo", true, (err) => {
+ console.log('setOAuthTokenVisibility err: ' + JSON.stringify(err));
+ });
+ ```
+
+### setOAuthTokenVisibility8+
+
+setOAuthTokenVisibility(name: string, authType: string, bundleName: string, isVisible: boolean): Promise<void>;
+
+设置指定鉴权类型的OAuth令牌对特定应用的可见性,使用Promise方式异步返回结果。
+
+- 参数:
+
+ | 参数名 | 类型 | 必填 | 说明 |
+ | ---------- | ------------------------- | ---- | ------------------- |
+ | name | string | 是 | 应用帐户的名称。 |
+ | authType | string | 是 | 鉴权类型。 |
+ | bundleName | string | 是 | 被设置可见性的应用包名。|
+ | isVisible | boolean | 是 | 是否可见。 |
+
+- 参数:
+
+ | 类型 | 说明 |
+ | ------------------------------ | --------------------- |
+ | Promise<void> | Promise实例,用于获取异步返回结果。 |
+
+- 示例:
+
+ ```
+ const appAccountManager = account_appAccount.createAppAccountManager();
+ const appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager.setOAuthTokenVisibility("LiSi", "readAge", "com.example.ohos.accountjsdemo", true).then(() => {
+ console.log('setOAuthTokenVisibility successfully');
+ }).catch((err) => {
+ console.log('setOAuthTokenVisibility err: ' + JSON.stringify(err));
+ });
+ ```
+
+### checkOAuthTokenVisibility8+
+
+checkOAuthTokenVisibility(name: string, authType: string, bundleName: string, callback: AsyncCallback<boolean>): void;
+
+检查指定鉴权类型的OAuth令牌对特定应用的可见性,使用callback回调异步返回结果。
+
+- 参数:
+
+ | 参数名 | 类型 | 必填 | 说明 |
+ | ---------- | ---------------------------- | ---- | ---------------------- |
+ | name | string | 是 | 应用帐户的名称。 |
+ | authType | string | 是 | 鉴权类型。 |
+ | bundleName | string | 是 | 用于检查可见性的应用包名。 |
+ | callback | AsyncCallback<boolean> | 是 | 检查结果的回调。 |
+
+- 示例:
+
+ ```
+ const appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager.checkOAuthTokenVisibility("LiSi", "readAge", "com.example.ohos.accountjsdemo", true, (err, data) => {
+ console.log('checkOAuthTokenVisibility err: ' + JSON.stringify(err));
+ console.log('checkOAuthTokenVisibility isVisible: ' + data);
+ });
+ ```
+
+### checkOAuthTokenVisibility8+
+
+checkOAuthTokenVisibility(name: string, authType: string, bundleName: string): Promise<boolean>;
+
+检查指定鉴权类型的OAuth令牌对特定应用的可见性,使用Promise方式异步返回结果。
+
+- 参数:
+
+ | 参数名 | 类型 | 必填 | 说明 |
+ | ---------- | ------------------------- | ---- | ---------------------- |
+ | name | string | 是 | 应用帐户的名称。 |
+ | authType | string | 是 | 鉴权类型。 |
+ | bundleName | string | 是 | 用于检查可见性的应用包名。 |
+
+- 参数:
+
+ | 类型 | 说明 |
+ | ------------------------------ | ------------------------ |
+ | Promise<boolean> | Promise实例,用于获取异步返回结果。 |
+
+- 示例:
+
+ ```
+ const appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager.checkOAuthTokenVisibility("LiSi", "readAge", "com.example.ohos.accountjsdemo", true).then((data) => {
+ console.log('checkOAuthTokenVisibility isVisible: ' + data);
+ }).catch((err) => {
+ console.log('checkOAuthTokenVisibility err: ' + JSON.stringify(err));
+ });
+ ```
+
+### getAllOAuthTokens8+
+
+getAllOAuthTokens(name: string, owner: string, callback: AsyncCallback<Array<OAuthTokenInfo>>): void;
+
+获取指定应用对调用方全部可见的OAuth令牌,使用callback回调异步返回结果。
+
+- 参数:
+
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | ------------------------------------------------ | ---- | ------------------- |
+ | name | string | 是 | 应用帐户的名称。 |
+ | owner | string | 是 | 应用帐户的所有者包名。 |
+ | callback | AsyncCallback<Array<OAuthTokenInfo>> | 是 | 查询结果的回调。 |
+
+- 示例:
+
+ ```
+ const appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager.getAllOAuthTokens("LiSi", "com.example.ohos.accountjsdemo", (err, data) => {
+ console.log("getAllOAuthTokens err: " + JSON.stringify(err));
+ console.log('getAllOAuthTokens data: ' + JSON.stringify(data));
+ });
+ ```
+
+### getAllOAuthTokens8+
+
+getAllOAuthTokens(name: string, owner: string): Promise<Array<OAuthTokenInfo>>;
+
+获取指定应用帐户对调用方可见的全部OAuth令牌,使用Promise方式异步返回结果。
+
+- 参数:
+
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | ------ | ---- | ------------------- |
+ | name | string | 是 | 应用帐户的名称。 |
+ | owner | string | 是 | 应用帐户的所有者包名。 |
+
+- 参数:
+
+ | 类型 | 说明 |
+ | ------------------------------ | ----------------------------------- |
+ | Promise<Array<OAuthTokenInfo>> | Promise实例,用于获取异步返回结果。 |
+
+- 示例:
+
+ ```
+ const appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager.getAllOAuthTokens("LiSi", "com.example.ohos.accountjsdemo").then((data) => {
+ console.log('getAllOAuthTokens data: ' + JSON.stringify(data));
+ }).catch((err) => {
+ console.log("getAllOAuthTokens err: " + JSON.stringify(err));
+ });
+ ```
+
+### getOAuthList8+
+
+getOAuthList(name: string, authType: string, callback: AsyncCallback<Array<string>>): void;
+
+获取指定应用帐户和鉴权类型的OAuth令牌的授权列表,使用callback回调异步返回结果。
+
+- 参数:
+
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | ---------------------------------------- | ---- | ------------------ |
+ | name | string | 是 | 应用帐户的名称。 |
+ | owner | string | 是 | 应用帐户的所有者包名。 |
+ | callback | AsyncCallback<Array<string>> | 是 | 查询结果的回调。 |
+
+- 示例:
+
+ ```
+ const appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager.getOAuthList("com.example.ohos.accountjsdemo", "readAge", (err, data) => {
+ console.log('getOAuthList err: ' + JSON.stringify(err));
+ console.log('getOAuthList data: ' + JSON.stringify(data));
+ });
+ ```
+
+### getOAuthList8+
+
+getOAuthList(name: string, authType: string): Promise<Array<string>>;
+
+获取指定应用帐户和鉴权类型的OAuth令牌的授权列表,使用Promise方式异步返回结果。
+
+- 参数:
+
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | ------ | ---- | ------------------- |
+ | name | string | 是 | 应用帐户的名称。 |
+ | owner | string | 是 | 应用帐户的所有者包名。 |
+
+- 参数:
+
+ | 类型 | 说明 |
+ | ------------------------------ | ------------------------------------ |
+ | Promise<Array<string>> | Promise实例,用于获取异步返回结果。 |
+
+- 示例:
+
+ ```
+ const appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager.getOAuthList("com.example.ohos.accountjsdemo", "readAge").then((data) => {
+ console.log('getOAuthList data: ' + JSON.stringify(data));
+ }).catch((err) => {
+ console.log("getOAuthList err: " + JSON.stringify(err));
+ });
+ ```
+
+### getAuthenticatorCallback8+
+
+getAuthenticatorCallback(sessionId: string, callback: AsyncCallback<AuthenticatorCallback>): void;
+
+获取鉴权会话的认证器回调,使用callback回调异步返回结果。
+
+- 参数:
+
+ | 参数名 | 类型 | 必填 | 说明 |
+ | --------- | ------------------------------------------ | ---- | -------------- |
+ | sessionId | string | 是 | 鉴权会话的标识。 |
+ | callback | AsyncCallback<AuthenticatorCallback> | 是 | 查询结果的回调。 |
+
+- 示例:
+
+ ```
+ const appAccountManager = account_appAccount.createAppAccountManager();
+ featureAbility.getWant((err, want) => {
+ var sessionId = want.parameters[Constants.KEY_SESSION_ID];
+ appAccountManager.getAuthenticatorCallback(sessionId, (err, callback) => {
+ if (err.code != ResultCode.SUCCESS) {
+ console.log("getAuthenticatorCallback err: " + JSON.stringify(err));
+ return;
+ }
+ var result = {Constants.KEY_NAME: "LiSi", Constants.KEY_OWNER: "com.example.ohos.accountjsdemo",
+ Constants.KEY_AUTH_TYPE: "readAge", Constants.KEY_TOKEN: "xxxxxx"};
+ callback.OnResult(ResultCode.SUCCESS, result);
+ });
+ });
+ ```
+
+### getAuthenticatorCallback8+
+
+getAuthenticatorCallback(sessionId: string): Promise<AuthenticatorCallback>;
+
+获取鉴权会话的认证器回调,使用Promise方式异步返回结果。
+
+- 参数:
+
+ | 参数名 | 类型 | 必填 | 说明 |
+ | ---------- | ------ | ---- | -------------- |
+ | sessionId | string | 是 | 鉴权会话的标识。 |
+
+- 参数:
+
+ | 类型 | 说明 |
+ | ------------------------------------ | -------------------------------- |
+ | Promise<AuthenticatorCallback> | Promise实例,用于获取异步返回结果。 |
+
+- 示例:
+
+ ```
+ const appAccountManager = account_appAccount.createAppAccountManager();
+ featureAbility.getWant().then((want) => {
+ var sessionId = want.parameters[Constants.KEY_SESSION_ID];
+ appAccountManager.getAuthenticatorCallback(sessionId).then((callback) => {
+ var result = {Constants.KEY_NAME: "LiSi", Constants.KEY_OWNER: "com.example.ohos.accountjsdemo",
+ Constants.KEY_AUTH_TYPE: "readAge", Constants.KEY_TOKEN: "xxxxxx"};
+ callback.OnResult(ResultCode.SUCCESS, result);
+ }).catch((err) => {
+ console.log("getAuthenticatorCallback err: " + JSON.stringify(err));
+ });
+ }).catch((err) => {
+ console.log("getWant err: " + JSON.stringify(err));
+ });
+ ```
+
+### getAuthenticatorInfo8+
+
+getAuthenticatorInfo(owner: string, callback: AsyncCallback<AuthenticatorInfo>): void;
+
+获取指定应用帐户的认证器信息,使用callback回调异步返回结果。
+
+- 参数:
+
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------------------------------------- | ---- | ------------------- |
+ | owner | string | 是 | 应用帐户的所有者包名。 |
+ | callback | AsyncCallback<AuthenticatorInfo> | 是 | 查询结果的回调。 |
+
+- 示例:
+
+ ```
+ const appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager.getAuthenticatorInfo("com.example.ohos.accountjsdemo", (err, data) => {
+ console.log("getAuthenticatorInfo err: " + JSON.stringify(err));
+ console.log('getAuthenticatorInfo data: ' + JSON.stringify(data));
+ });
+ ```
+
+### getAuthenticatorInfo8+
+
+getAuthenticatorInfo(owner: string): Promise<AuthenticatorInfo>;
+
+获取指定应用帐户的认证器信息,使用Promise方式异步返回结果。
+
+- 参数:
+
+ | 参数名 | 类型 | 必填 | 说明 |
+ | ----- | ------ | ---- | -------------------- |
+ | owner | string | 是 | 应用帐户的所有者包名。 |
+
+- 参数:
+
+ | 类型 | 说明 |
+ | ------------------------------ | ----------------------------------- |
+ | Promise<AuthenticatorInfo> | Promise实例,用于获取异步返回结果。 |
+
+- 示例:
+
+ ```
+ const appAccountManager = account_appAccount.createAppAccountManager();
+ appAccountManager.getAuthenticatorInfo("com.example.ohos.accountjsdemo").then((data) => {
+ console.log('getAuthenticatorInfo: ' + JSON.stringify(data));
+ }).catch((err) => {
+ console.log("getAuthenticatorInfo err: " + JSON.stringify(err));
+ });
+ ```
+
## AppAccountInfo
+表示应用帐号信息。
+
+| 参数名 | 类型 | 必填 | 说明 |
+| ----- | ------ | ---- | ---------------- |
+| owner | string | 是 | 应用帐户的所有者包名。 |
+| name | string | 是 | 应用帐户的名称。 |
+
+## OAuthTokenInfo8+
+
+表示OAuth令牌信息。
+
+| 参数名 | 类型 | 必填 | 说明 |
+| -------- | ------ | ---- | -------------- |
+| authType | string | 是 | 令牌的鉴权类型。 |
+| token | string | 是 | 令牌的取值。 |
+
+## AuthenticatorInfo8+
+
+表示OAuth认证器信息。
+
+| 参数名 | 类型 | 必填 | 说明 |
+| ------- | ------ | ---- | ------------------ |
+| owner | string | 是 | 认证器的所有者包名。 |
+| iconId | string | 是 | 认证器的图标标识。 |
+| labelId | string | 是 | 认证器的标签标识。 |
+
+## Constants8+
+
+表示常量的枚举。
+
+| 名称 | 默认值 | 描述 |
+| ----------------------------- | ---------------------- | ----------------------- |
+| ACTION_ADD_ACCOUNT_IMPLICITLY | "addAccountImplicitly" | 表示操作_隐式添加帐号。 |
+| ACTION_AUTHENTICATE | "authenticate" | 表示操作_鉴权。 |
+| KEY_NAME | "name" | 表示键名_应用帐户名称。 |
+| KEY_OWNER | "owner" | 表示键名_应用帐户所有者。 |
+| KEY_TOKEN | "token" | 表示键名_令牌。 |
+| KEY_ACTION | "action" | 表示键名_操作。 |
+| KEY_AUTH_TYPE | "authType" | 表示键名_鉴权类型。 |
+| KEY_SESSION_ID | "sessionId" | 表示键名_会话标识。 |
+| KEY_CALLER_PID | "callerPid" | 表示键名_调用方PID。 |
+| KEY_CALLER_UID | "callerUid" | 表示键名_调用方UID。 |
+| KEY_CALLER_BUNDLE_NAME | "callerBundleName" | 表示键名_调用方包名。 |
+
+## ResultCode8+
+表示返回码的枚举。
-| 参数名 | 类型 | 必填 | 说明 |
-| ------ | ------ | ---- | ------------------ |
-| owner | string | 是 | 所有者是应用帐户。 |
-| name | string | 是 | 应用帐户的名称。 |
+| 名称 | 默认值 | 描述 |
+| ----------------------------------- | ----- | ---------------------- |
+| SUCCESS | 0 | 表示操作成功。 |
+| ERROR_ACCOUNT_NOT_EXIST | 10001 | 表示应用帐户不存在。 |
+| ERROR_APP_ACCOUNT_SERVICE_EXCEPTION | 10002 | 表示应用帐户服务异常。 |
+| ERROR_INVALID_PASSWORD | 10003 | 表示密码无效。 |
+| ERROR_INVALID_REQUEST | 10004 | 表示请求无效。 |
+| ERROR_INVALID_RESPONSE | 10005 | 表示响应无效。 |
+| ERROR_NETWORK_EXCEPTION | 10006 | 表示网络异常。 |
+| ERROR_OAUTH_AUTHENTICATOR_NOT_EXIST | 10007 | 表示认证器不存在。 |
+| ERROR_OAUTH_CANCELED | 10008 | 表示鉴权取消。 |
+| ERROR_OAUTH_LIST_TOO_LARGE | 10009 | 表示开放授权列表过大。 |
+| ERROR_OAUTH_SERVICE_BUSY | 10010 | 表示开放授权服务忙碌。 |
+| ERROR_OAUTH_SERVICE_EXCEPTION | 10011 | 表示开放授权服务异常。 |
+| ERROR_OAUTH_SESSION_NOT_EXIST | 10012 | 表示鉴权会话不存在。 |
+| ERROR_OAUTH_TIMEOUT | 10013 | 表示鉴权超时。 |
+| ERROR_OAUTH_TOKEN_NOT_EXIST | 10014 | 表示开放授权令牌不存在。 |
+| ERROR_OAUTH_TOKEN_TOO_MANY | 10015 | 表示开放授权令牌过多。 |
+| ERROR_OAUTH_UNSUPPORT_ACTION | 10016 | 表示不支持的鉴权操作。 |
+| ERROR_OAUTH_UNSUPPORT_AUTH_TYPE | 10017 | 表示不支持的鉴权类型。 |
+| ERROR_PERMISSION_DENIED | 10018 | 表示权限不足。 |
+## AuthenticatorCallback8+
+
+OAuth认证器回调接口。
+
+### onResult8+
+
+onResult: (code: number, result: {[key: string]: any}) => void;
+
+通知鉴权结果。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | ------ | -------------------- | ---- | ----------- |
+ | code | number | 是 | 鉴权结果码。 |
+ | result | {[key: string]: any} | 是 | 鉴权结果。 |
+
+- 示例:
+
+ ```
+ const appAccountManager = account_appAccount.createAppAccountManager();
+ var sessionId = "1234";
+ appAccountManager.getAuthenticatorCallback(sessionId).then((callback) => {
+ var result = {Constants.KEY_NAME: "LiSi", Constants.KEY_OWNER: "com.example.ohos.accountjsdemo",
+ Constants.KEY_AUTH_TYPE: "readAge", Constants.KEY_TOKEN: "xxxxxx"};
+ callback.OnResult(ResultCode.SUCCESS, result);
+ }).catch((err) => {
+ console.log("getAuthenticatorCallback err: " + JSON.stringify(err));
+ });
+ ```
+
+### onRequestRedirected8+
+
+onRequestRedirected: (request: Want) => void;
+
+通知鉴权请求被跳转。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | ------- | ---- | ---- | ------------------ |
+ | request | Want | 是 | 用于跳转的请求信息。 |
+
+- 示例:
+
+ ```
+ class MyAuthenticator extends account_appAccount.Authenticator {
+ addAccountImplicitly(authType, callerBundleName, options, callback) {
+ callback.onRequestRedirected({
+ bundleName: "com.example.ohos.accountjsdemo",
+ abilityName: "com.example.ohos.accountjsdemo.LoginAbility",
+ });
+ }
+
+ authenticate(name, authType, callerBundleName, options, callback) {
+ var result = {Constants.KEY_NAME: name, Constants.KEY_AUTH_TYPE: authType, Constants.KEY_TOKEN: "xxxxxx"};
+ callback.onResult(ResultCode.SUCCESS, result);
+ }
+ }
+ ```
+
+## Authenticator8+
+
+OAuth认证器基类。
+
+### addAccountImplicitly8+
+
+addAccountImplicitly(authType: string, callerBundleName: string, options: {[key: string]: any}, callback: AuthenticatorCallback): void;
+
+根据指定的鉴权类型和可选项,隐式地添加应用帐户,并使用callback回调异步返回结果。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | ---------------- | --------------------- | --- | -------------------------- |
+ | authType | string | 是 | 应用帐户的鉴权类型。 |
+ | callerBundleName | string | 是 | 鉴权请求方的包名。 |
+ | options | {[key: string]: any} | 是 | 鉴权所需要的可选项。 |
+ | callback | AuthenticatorCallback | 是 | 认证器回调,用于返回鉴权结果。 |
+
+### authenticate8+
+
+authenticate(name: string, authType: string, callerBundleName: string, options: {[key: string]: any}, callback: AuthenticatorCallback): void;
+
+对应用帐户进行鉴权,获取OAuth令牌,并使用callback回调异步返回结果。
+
+- 参数:
+ | 接口名 | 类型 | 必填 | 说明 |
+ | ---------------- | --------------------- | ---- | -------------------------- |
+ | name | string | 是 | 应用帐户的名称。 |
+ | authType | string | 是 | 应用帐户的鉴权类型。 |
+ | callerBundleName | string | 是 | 鉴权请求方的包名。 |
+ | options | {[key: string]: any} | 是 | 鉴权所需要的可选项。 |
+ | callback | AuthenticatorCallback | 是 | 认证器回调,用于返回鉴权结果。 |
+
+- 示例:
+
+ ```
+ class MyAuthenticator extends account_appAccount.Authenticator {
+ addAccountImplicitly(authType, callerBundleName, options, callback) {
+ callback.onRequestRedirected({
+ bundleName: "com.example.ohos.accountjsdemo",
+ abilityName: "com.example.ohos.accountjsdemo.LoginAbility",
+ });
+ }
+
+ authenticate(name, authType, callerBundleName, options, callback) {
+ var result = {Constants.KEY_NAME: name, Constants.KEY_AUTH_TYPE: authType, Constants.KEY_TOKEN: "xxxxxx"};
+ callback.onResult(ResultCode.SUCCESS, result);
+ }
+ }
+
+ export default {
+ onConnect(want) {
+ return new MyAuthenticator();
+ }
+ }
+ ```
diff --git a/zh-cn/application-dev/reference/apis/js-apis-arraylist.md b/zh-cn/application-dev/reference/apis/js-apis-arraylist.md
new file mode 100644
index 0000000000000000000000000000000000000000..059e706a5eda43e0590af517bfd71fea862efb07
--- /dev/null
+++ b/zh-cn/application-dev/reference/apis/js-apis-arraylist.md
@@ -0,0 +1,518 @@
+# 线性容器ArrayList
+
+>  **说明:**
+> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
+
+## 导入模块
+
+```
+import ArrayList from '@ohos.util.ArrayList'
+```
+
+## 权限
+
+无
+
+## ArrayList
+
+### 属性
+
+| 名称 | 参数类型 | 可读 | 可写 | 说明 |
+| -------- | -------- | -------- | -------- | -------- |
+| length | number | 是 | 否 | ArrayList的元素个数 |
+
+
+### constructor
+
+constructor();
+
+ArrayList的构造函数。
+
+- 示例:
+ ```
+ let arrayList = new ArrayList();
+ ```
+
+
+### add
+
+add(element: T): boolean;
+
+在ArrayList尾部插入元素。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | element | T | 是 | 添加进去的元素 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | boolean | 插入成功返回true,失败返回false |
+
+- 示例:
+ ```
+ let arrayList = new ArrayList();
+ arrayList.add("a");
+ arrayList.add(1);
+ let b = [1, 2, 3];
+ arrayList.add(b);
+ let c = {name: "lala", age: "13"};
+ arrayList.add(false);
+ ```
+
+### insert
+
+insert(element: T, index: number): void;
+
+在长度范围内任意位置插入指定元素。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | element | T | 是 | 被插入的元素 |
+ | index | number | 是 | 被插入的位置索引 |
+
+- 示例:
+ ```
+ let arrayList = new ArrayList();
+ arrayList.insert("A", 0);
+ arrayList.insert(0, 1);
+ arrayList.insert(true, 2);
+ ```
+
+### has
+
+has(element: T): boolean;
+
+判断此ArrayList中是否含有该指定元素。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | element | T | 是 | 指定元素 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | boolean | 是否包含指定元素 |
+
+- 示例:
+ ```
+ let arrayList = new ArrayList();
+ arrayList.has("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
+ arrayList.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
+ arrayList.has("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
+ ```
+
+### getIndexOf
+
+getIndexOf(element: T): number;
+
+返回指定元素第一次出现时的下标值,查找失败返回-1。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | element | T | 是 | 指定元素 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | number | 返回指定元素第一次出现时的下标值,查找失败返回-1 |
+
+- 示例:
+ ```
+ let arrayList = new ArrayList();
+ arrayList.add(2);
+ arrayList.add(4);
+ arrayList.add(5);
+ arrayList.add(2);
+ arrayList.add(1);
+ arrayList.add(2);
+ arrayList.add(4);
+ arrayList.getIndexOf(2);
+ ```
+### getLastIndexOf
+
+getLastIndexOf(element: T): number;
+
+返回指定元素最后一次出现时的下标值,查找失败返回-1。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | element | T | 是 | 指定元素 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | number | 返回指定元素最后一次出现时的下标值,查找失败返回-1 |
+
+- 示例:
+ ```
+ let arrayList = new ArrayList();
+ arrayList.add(2);
+ arrayList.add(4);
+ arrayList.add(5);
+ arrayList.add(2);
+ arrayList.add(1);
+ arrayList.add(2);
+ arrayList.add(4);
+ arrayList.getLastIndexOf(2);
+ ```
+### removeByIndex
+
+removeByIndex(index: number): T;
+
+根据元素的下标值查找元素,返回元素后将其删除。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | index | number | 是 | 指定元素的下标值 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | T | 返回删除的元素 |
+
+- 示例:
+ ```
+ let arrayList = new ArrayList();
+ arrayList.add(2);
+ arrayList.add(4);
+ arrayList.add(5);
+ arrayList.add(2);
+ arrayList.add(4);
+ arrayList.removeByIndex(2);
+ ```
+
+### remove
+
+remove(element: T): boolean;
+
+删除查找到的第一个指定的元素。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | element | T | 是 | 指定元素 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | boolean | 删除成功返回true,失败返回false |
+
+- 示例:
+ ```
+ let arrayList = new ArrayList();
+ arrayList.add(2);
+ arrayList.add(4);
+ arrayList.add(5);
+ arrayList.add(4);
+ arrayList.remove(2);
+ ```
+
+### removeByRange
+
+removeByRange(fromIndex: number, toIndex: number): void;
+
+从一段范围内删除元素,包括起始值但不包括终止值。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | fromIndex | number | 是 | 起始下标 |
+ | toIndex | number | 是 | 终止下标 |
+
+- 示例:
+ ```
+ let arrayList = new ArrayList();
+ arrayList.add(2);
+ arrayList.add(4);
+ arrayList.add(5);
+ arrayList.add(4);
+ arrayList.removeByRange(2, 4);
+ arrayList.removeByRange(4, 3);
+ arrayList.removeByRange(2, 6);
+ ```
+### replaceAllElements
+replaceAllElements(callbackfn: (value: T, index?: number, arraylist?: ArrayList<T>) => T,
+thisArg?: Object): void;
+
+用户操作ArrayList中的元素,用操作后的元素替换原元素并返回操作后的元素。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | callbackfn | function | 是 | 回调函数 |
+ | thisArg | Object | 否 | callbackfn被调用时用作this值 |
+
+- callbackfn的参数说明
+
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | value | T | 是 | 当前遍历到的元素 |
+ | index | number | 否 | 当前遍历到的下标值 |
+ | arraylist | ArrayList<T> | 否 | 当前调用replaceAllElements方法的实例对象 |
+
+- 示例:
+ ```
+ let arrayList = new ArrayList();
+ arrayList.add(2);
+ arrayList.add(4);
+ arrayList.add(5);
+ arrayList.add(4);
+ arrayList.replaceAllElements((value, index) => {
+ return value = 2 * value;
+ });
+ arrayList.replaceAllElements((value, index) => {
+ return value = value - 2;
+ });
+ ```
+### forEach
+forEach(callbackfn: (value: T, index?: number, arraylist?: ArrayList<T>) => void,
+thisArg?: Object): void;
+
+通过回调函数来遍历ArrayList实例对象上的元素以及元素对应的下标。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | callbackfn | function | 是 | 回调函数。 |
+ | thisArg | Object | 否 | callbackfn被调用时用作this值 |
+
+- callbackfn的参数说明
+
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | value | T | 是 | 当前遍历到的元素。 |
+ | index | number | 否 | 当前遍历到的下标值。 |
+ | arraylist | ArrayList<T> | 否 | 当前调用forEach方法的实例对象。 |
+
+
+- 示例:
+ ```
+ let arrayList = new ArrayList();
+ arrayList.add(2);
+ arrayList.add(4);
+ arrayList.add(5);
+ arrayList.add(4);
+ arrayList.forEach((value, index) => {
+ console.log(value, index);
+ });
+ ```
+### sort
+sort(comparator?: (firstValue: T, secondValue: T) => number): void;
+
+对ArrayList中的元素进行一个排序操作
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | comparator | function | 否 | 回调函数 |
+
+- comparator的参数说明
+
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | firstValue | T | 是 | 前一项元素 |
+ | secondValue | T | 是 | 后一项元素 |
+
+
+- 示例:
+ ```
+ let arrayList = new ArrayList();
+ arrayList.add(2);
+ arrayList.add(4);
+ arrayList.add(5);
+ arrayList.add(4);
+ arrayList.sort(a, (b => a - b));
+ arrayList.sort(a, (b => b - a));
+ arrayList.sort();
+ ```
+### subArrayList
+subArrayList(fromIndex: number, toIndex: number): ArrayList<T>;
+
+根据下标截取ArrayList中的一段元素,并返回这一段ArrayList实例, 包括起始值但不包括终止值
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | fromIndex | number | 是 | 起始下标 |
+ | toIndex | number | 是 | 终止下标 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | ArrayList<T> | 返回ArrayList对象实例 |
+
+- 示例:
+ ```
+ let arrayList = new ArrayList();
+ arrayList.add(2);
+ arrayList.add(4);
+ arrayList.add(5);
+ arrayList.add(4);
+ arrayList.subArrayList(2, 4);
+ arrayList.subArrayList(4, 3);
+ arrayList.subArrayList(2, 6);
+ ```
+
+### clear
+clear(): void;
+
+清除ArrayList中的所有元素,并把length置为0。
+
+- 示例:
+ ```
+ let arrayList = new ArrayList();
+ arrayList.add(2);
+ arrayList.add(4);
+ arrayList.add(5);
+ arrayList.add(4);
+ arrayList.clear();
+ ```
+### clone
+clone(): ArrayList<T> ;
+
+克隆一个与ArrayList一模一样的实例,并返回克隆后的实例,修改克隆后的实例并不会影响原实例。
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | ArrayList<T> | 返回ArrayList对象实例 |
+
+- 示例:
+ ```
+ let arrayList = new ArrayList();
+ arrayList.add(2);
+ arrayList.add(4);
+ arrayList.add(5);
+ arrayList.add(4);
+ arrayList.clone();
+ ```
+### getCapacity
+getCapacity(): number;
+
+获取当前实例的容量大小。
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | number | 返回arraylist的容量大小 |
+
+- 示例:
+ ```
+ let arrayList = new ArrayList();
+ arrayList.add(2);
+ arrayList.add(4);
+ arrayList.add(5);
+ arrayList.add(4);
+ arrayList.getCapacity();
+ ```
+### convertToArray
+convertToArray(): Array<T>;
+
+把当前ArrayList实例转换成数组,并返回转换后的数组。
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | Array<T> | 返回数组类型 |
+
+- 示例:
+ ```
+ let arrayList = new ArrayList();
+ arrayList.add(2);
+ arrayList.add(4);
+ arrayList.add(5);
+ arrayList.add(4);
+ arrayList.convertToArray();
+ ```
+### isEmpty
+isEmpty(): boolean;
+
+判断该ArrayList是否为空。
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | boolean | 为空返回true, 不为空返回false |
+
+- 示例:
+ ```
+ let arrayList = new ArrayList();
+ arrayList.add(2);
+ arrayList.add(4);
+ arrayList.add(5);
+ arrayList.add(4);
+ arrayList.isEmpty();
+ ```
+### increaseCapacityTo
+increaseCapacityTo(newCapacity: number): void;
+
+如果传入的新容量大于或等于ArrayList中的元素个数,将容量变更为新容量。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | newCapacity | number | 是 | 新容量 |
+
+
+- 示例:
+ ```
+ let arrayList = new ArrayList();
+ arrayList.add(2);
+ arrayList.add(4);
+ arrayList.add(5);
+ arrayList.add(4);
+ arrayList.increaseCapacityTo(2);
+ arrayList.increaseCapacityTo(8);
+ ```
+### trimToCurrentLength
+trimToCurrentLength(): void;
+
+把容量限制为当前的length大小。
+
+- 示例:
+ ```
+ let arrayList = new ArrayList();
+ arrayList.add(2);
+ arrayList.add(4);
+ arrayList.add(5);
+ arrayList.add(4);
+ arrayList.trimToCurrentLength(2);
+ ```
+### [Symbol.iterator]
+
+[Symbol.iterator]\(): IterableIterator<T>;
+
+返回一个迭代器,迭代器的每一项都是一个 JavaScript 对象,并返回该对象。
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | IterableIterator<T> | 返回一个迭代器 |
+
+- 示例:
+ ```
+ let arrayList = new ArrayList();
+ arrayList.add(2);
+ arrayList.add(4);
+ arrayList.add(5);
+ arrayList.add(4);
+
+ // 使用方法一:
+ for (let item of arrayList) {
+ console.log(item);
+ }
+
+ // 使用方法二:
+ let iter = arrayList[Symbol.iterator]();
+ let temp = iter.next().value;
+ while(temp != undefined) {
+ console.log(temp);
+ temp = iter.next().value;
+ }
+ ```
\ No newline at end of file
diff --git a/zh-cn/application-dev/reference/apis/js-apis-audio.md b/zh-cn/application-dev/reference/apis/js-apis-audio.md
index 636afc455eb984765269155842edec14c2cfbda5..4369e06d5710ff9b4fcefec08576015c83ebba7b 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-audio.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-audio.md
@@ -7,11 +7,6 @@ import audio from '@ohos.multimedia.audio';
```
-## 权限
-
-无
-
-
## getAudioManager
getAudioManager(): AudioManager
@@ -115,6 +110,7 @@ setVolume(volumeType: AudioVolumeType, volume: number, callback: AsyncCallback&l
**示例:**
```
+var audioManager = audio.getAudioManager();
audioManager.setVolume(audio.AudioVolumeType.MEDIA, 10, (err)=>{
if (err) {
console.error('Failed to set the volume. ${err.message}');
@@ -146,6 +142,7 @@ setVolume(volumeType: AudioVolumeType, volume: number): Promise<void>
**示例:**
```
+var audioManager = audio.getAudioManager();
audioManager.setVolume(audio.AudioVolumeType.MEDIA, 10).then(()=>
console.log('Promise returned to indicate a successful volume setting.');
)
@@ -167,6 +164,7 @@ getVolume(volumeType: AudioVolumeType, callback: AsyncCallback<number>): v
**示例:**
```
+var audioManager = audio.getAudioManager();
audioManager.getVolume(audio.AudioVolumeType.MEDIA, (err, value) => {
if (err) {
console.error('Failed to obtain the volume. ${err.message}');
@@ -197,6 +195,7 @@ getVolume(volumeType: AudioVolumeType): Promise<number>
**示例:**
```
+var audioManager = audio.getAudioManager();
audioManager.getVolume(audio.AudioVolumeType.MEDIA).then((value) =>
console.log('Promise returned to indicate that the volume is obtained.' + value);
)
@@ -218,6 +217,7 @@ getMinVolume(volumeType: AudioVolumeType, callback: AsyncCallback<number>)
**示例:**
```
+var audioManager = audio.getAudioManager();
audioManager.getMinVolume(audio.AudioVolumeType.MEDIA, (err, value) => {
if (err) {
console.error('Failed to obtain the minimum volume. ${err.message}');
@@ -248,6 +248,7 @@ getMinVolume(volumeType: AudioVolumeType): Promise<number>
**示例:**
```
+var audioManager = audio.getAudioManager();
audioManager.getMinVolume(audio.AudioVolumeType.MEDIA).then((value) =>
console.log('Promised returned to indicate that the minimum volume is obtained.' + value);
)
@@ -269,6 +270,7 @@ getMaxVolume(volumeType: AudioVolumeType, callback: AsyncCallback<number>)
**示例:**
```
+var audioManager = audio.getAudioManager();
audioManager.getMaxVolume(audio.AudioVolumeType.MEDIA, (err, value) => {
if (err) {
console.error('Failed to obtain the maximum volume. ${err.message}');
@@ -299,6 +301,7 @@ getMaxVolume(volumeType: AudioVolumeType): Promise<number>
**示例:**
```
+var audioManager = audio.getAudioManager();
audioManager.getMaxVolume(audio.AudioVolumeType.MEDIA).then((data)=>
console.log('Promised returned to indicate that the maximum volume is obtained.');
)
@@ -321,6 +324,7 @@ mute(volumeType: AudioVolumeType, mute: boolean, callback: AsyncCallback<void
**示例:**
```
+var audioManager = audio.getAudioManager();
audioManager.mute(audio.AudioVolumeType.MEDIA, true, (err) => {
if (err) {
console.error('Failed to mute the stream. ${err.message}');
@@ -353,6 +357,7 @@ mute(volumeType: AudioVolumeType, mute: boolean): Promise<void>
```
+var audioManager = audio.getAudioManager();
audioManager.mute(audio.AudioVolumeType.MEDIA, true).then(() =>
console.log('Promise returned to indicate that the stream is muted.');
)
@@ -375,6 +380,7 @@ isMute(volumeType: AudioVolumeType, callback: AsyncCallback<boolean>): voi
**示例:**
```
+var audioManager = audio.getAudioManager();
audioManager.isMute(audio.AudioVolumeType.MEDIA, (err, value) => {
if (err) {
console.error('Failed to obtain the mute status. ${err.message}');
@@ -406,6 +412,7 @@ isMute(volumeType: AudioVolumeType): Promise<boolean>
**示例:**
```
+var audioManager = audio.getAudioManager();
audioManager.isMute(audio.AudioVolumeType.MEDIA).then((value) =>
console.log('Promise returned to indicate that the mute status of the stream is obtained.' + value);
)
@@ -427,6 +434,7 @@ isActive(volumeType: AudioVolumeType, callback: AsyncCallback<boolean>): v
**示例:**
```
+var audioManager = audio.getAudioManager();
audioManager.isActive(audio.AudioVolumeType.MEDIA, (err, value) => {
if (err) {
console.error('Failed to obtain the active status of the stream. ${err.message}');
@@ -457,6 +465,7 @@ isActive(volumeType: AudioVolumeType): Promise<boolean>
**示例:**
```
+var audioManager = audio.getAudioManager();
audioManager.isActive(audio.AudioVolumeType.MEDIA).then((value) =>
console.log('Promise returned to indicate that the active status of the stream is obtained.' + value);
)
@@ -478,6 +487,7 @@ setRingerMode(mode: AudioRingMode, callback: AsyncCallback<void>): void
**示例:**
```
+var audioManager = audio.getAudioManager();
audioManager.setRingerMode(audio.AudioRingMode.RINGER_MODE_NORMAL, (err) => {
if (err) {
console.error('Failed to set the ringer mode. ${err.message}');
@@ -508,6 +518,7 @@ setRingerMode(mode: AudioRingMode): Promise<void>
**示例:**
```
+var audioManager = audio.getAudioManager();
audioManager.setRingerMode(audio.AudioRingMode.RINGER_MODE_NORMAL).then(() =>
console.log('Promise returned to indicate a successful setting of the ringer mode.');
)
@@ -529,6 +540,7 @@ getRingerMode(callback: AsyncCallback<AudioRingMode>): void
**示例:**
```
+var audioManager = audio.getAudioManager();
audioManager.getRingerMode((err, value) => {
if (err) {
console.error('Failed to obtain the ringer mode. ${err.message}');
@@ -554,6 +566,7 @@ getRingerMode(): Promise<AudioRingMode>
**示例:**
```
+var audioManager = audio.getAudioManager();
audioManager.getRingerMode().then((value) =>
console.log('Promise returned to indicate that the ringer mode is obtained.' + value);
)
@@ -576,6 +589,7 @@ setAudioParameter(key: string, value: string, callback: AsyncCallback<void>
**示例:**
```
+var audioManager = audio.getAudioManager();
audioManager.setAudioParameter('PBits per sample', '8 bit', (err) => {
if (err) {
console.error('Failed to set the audio parameter. ${err.message}');
@@ -607,6 +621,7 @@ setAudioParameter(key: string, value: string): Promise<void>
**示例:**
```
+var audioManager = audio.getAudioManager();
audioManager.setAudioParameter('PBits per sample', '8 bit').then(() =>
console.log('Promise returned to indicate a successful setting of the audio parameter.');
)
@@ -628,6 +643,7 @@ getAudioParameter(key: string, callback: AsyncCallback<string>): void
**示例:**
```
+var audioManager = audio.getAudioManager();
audioManager.getAudioParameter('PBits per sample', (err, value) => {
if (err) {
console.error('Failed to obtain the value of the audio parameter. ${err.message}');
@@ -658,6 +674,7 @@ getAudioParameter(key: string): Promise<string>
**示例:**
```
+var audioManager = audio.getAudioManager();
audioManager.getAudioParameter('PBits per sample').then((value) =>
console.log('Promise returned to indicate that the value of the audio parameter is obtained.' + value);
)
@@ -678,6 +695,7 @@ getDevices(deviceFlag: DeviceFlag, callback: AsyncCallback<AudioDeviceDescrip
**示例:**
```
+var audioManager = audio.getAudioManager();
audioManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG, (err, value)=>{
if (err) {
console.error('Failed to obtain the device list. ${err.message}');
@@ -708,6 +726,7 @@ audioManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG, (err, value)=>{
**示例:**
```
+var audioManager = audio.getAudioManager();
audioManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG).then((data)=>
console.log('Promise returned to indicate that the device list is obtained.');
)
@@ -730,6 +749,7 @@ setDeviceActive(deviceType: DeviceType, active: boolean, callback: AsyncCallback
**示例:**
```
+var audioManager = audio.getAudioManager();
audioManager.setDeviceActive(audio.DeviceType.SPEAKER, true, (err)=> {
if (err) {
console.error('Failed to set the active status of the device. ${err.message}');
@@ -762,6 +782,7 @@ setDeviceActive(deviceType: DeviceType, active: boolean): Promise<void>
```
+var audioManager = audio.getAudioManager();
audioManager.setDeviceActive(audio.DeviceType.SPEAKER, true).then(()=>
console.log('Promise returned to indicate that the device is set to the active status.');
)
@@ -783,6 +804,7 @@ isDeviceActive(deviceType: DeviceType, callback: AsyncCallback<boolean>):
**示例:**
```
+var audioManager = audio.getAudioManager();
audioManager.isDeviceActive(audio.DeviceType.SPEAKER, (err, value) => {
if (err) {
console.error('Failed to obtain the active status of the device. ${err.message}');
@@ -814,6 +836,7 @@ isDeviceActive(deviceType: DeviceType): Promise<boolean>
**示例:**
```
+var audioManager = audio.getAudioManager();
audioManager.isDeviceActive(audio.DeviceType.SPEAKER).then((value) =>
console.log('Promise returned to indicate that the active status of the device is obtained.' + value);
)
@@ -835,6 +858,7 @@ setMicrophoneMute(mute: boolean, callback: AsyncCallback<void>): void
**示例:**
```
+var audioManager = audio.getAudioManager();
audioManager.setMicrophoneMute(true, (err) => {
if (err) {
console.error('Failed to mute the microphone. ${err.message}');
@@ -865,6 +889,7 @@ setMicrophoneMute(mute: boolean): Promise<void>
**示例:**
```
+var audioManager = audio.getAudioManager();
audioManager.setMicrophoneMute(true).then(() =>
console.log('Promise returned to indicate that the microphone is muted.');
)
@@ -885,6 +910,7 @@ isMicrophoneMute(callback: AsyncCallback<boolean>): void
**示例:**
```
+var audioManager = audio.getAudioManager();
audioManager.isMicrophoneMute((err, value) => {
if (err) {
console.error('Failed to obtain the mute status of the microphone. ${err.message}');
@@ -910,6 +936,7 @@ isMicrophoneMute(): Promise<boolean>
```
+var audioManager = audio.getAudioManager();
audioManager.isMicrophoneMute().then((value) =>
console.log('Promise returned to indicate that the mute status of the microphone is obtained.', + value);
)
diff --git a/zh-cn/application-dev/reference/apis/js-apis-backgroundTaskManager.md b/zh-cn/application-dev/reference/apis/js-apis-backgroundTaskManager.md
index 6054f6d62100b455a5abc2092bae1ac30dd957a5..fb4a41f4bbd0ba63a5088ad0a75c2c6677a1ee81 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-backgroundTaskManager.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-backgroundTaskManager.md
@@ -10,10 +10,15 @@
import backgroundTaskManager from '@ohos.backgroundTaskManager';
```
+## 系统能力
+SystemCapability.ResourceSchedule.BackgroundTaskManager.ContinuousTask
+SystemCapability.ResourceSchedule.BackgroundTaskManager.TransientTask
-## 权限
+## 权限列表
-无
+长时任务需要申请如下权限:
+
+ohos.permission.KEEP_BACKGROUND_RUNNING
## backgroundTaskManager.requestSuspendDelay
@@ -39,7 +44,7 @@ requestSuspendDelay(reason: string, callback: Callback<void>): DelaySuspen
```
let myReason = 'test requestSuspendDelay';
let delayInfo = backgroundTaskManager.requestSuspendDelay(myReason, () => {
- console.info("Request suspend delay will time out.");
+ console.info("Request suspension delay will time out.");
})
```
@@ -122,3 +127,168 @@ cancelSuspendDelay(requestId: number): void
| requestId | number | 是 | 延迟挂起的请求ID。 |
| actualDelayTime | number | 是 | 应用的实际挂起延迟时间,以毫秒为单位。 一般情况下默认值为180000,低电量(依据系统低电量广播)时默认值为60000。 |
+## backgroundTaskManager.startBackgroundRunning
+
+[8] startBackgroundRunning(context: Context, bgMode: BackgroundMode, wantAgent: WantAgent, callback: AsyncCallback<void>): void;
+
+向系统申请长时任务,使用callback形式返回结果。
+
+- **参数**:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | context | Context | 是 | 应用运行的上下文 |
+ | bgMode | BackgroundMode | 是 | 向系统申请的后台模式 |
+ | wantAgent | WantAgent | 是 | 通知参数,用于指定长时任务通知点击跳转的界面。使用方式参考:[8] |
+ | callback | AsyncCallback<void> | 是 | callback形式返回启动长时任务的结果 |
+
+- **示例**:
+```js
+import backgroundTaskManager from '@ohos.backgroundTaskManager';
+import featureAbility from '@ohos.ability.featureAbility';
+import wantAgent from '@ohos.wantAgent';
+
+function callback(err, data) {
+ if (err) {
+ console.error("Operation failed Cause: " + err);
+ } else {
+ console.info("Operation succeeded");
+ }
+}
+
+let wantAgentInfo = {
+ wants: [
+ {
+ bundleName: "com.example.myapplication",
+ abilityName: "com.example.myapplication.MainAbility"
+ }
+ ],
+ operationType: wantAgent.OperationType.START_ABILITY,
+ requestCode: 0,
+ wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESET_FLAG]
+};
+
+wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => {
+ backgroundTaskManager.startBackgroundRunning(featureAbility.getContext(),
+ backgroundTaskManager.BackgroundMode.DATA_TRANSFER, wantAgentObj, callback)
+});
+
+```
+
+## backgroundTaskManager.startBackgroundRunning
+
+[8] startBackgroundRunning(context: Context, bgMode: BackgroundMode, wantAgent: WantAgent): Promise<void>
+
+向系统申请长时任务,使用promise形式返回结果。
+
+- **参数**:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | context | Context | 是 | 应用运行的上下文 |
+ | bgMode | BackgroundMode | 是 | 向系统申请的后台模式 |
+ | wantAgent | WantAgent | 是 | 通知参数,用于指定长时任务通知点击跳转的界面 |
+
+- **返回值**
+ | 类型 | 说明 |
+ | -------------- | ------------------------- |
+ | Promise\ | 使用Promise形式返回结果。 |
+
+- **示例**:
+```js
+import backgroundTaskManager from '@ohos.backgroundTaskManager';
+import featureAbility from '@ohos.ability.featureAbility';
+import wantAgent from '@ohos.wantAgent';
+
+let wantAgentInfo = {
+ wants: [
+ {
+ bundleName: "com.example.myapplication",
+ abilityName: "com.example.myapplication.MainAbility"
+ }
+ ],
+ operationType: wantAgent.OperationType.START_ABILITY,
+ requestCode: 0,
+ wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESET_FLAG]
+};
+
+wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => {
+ backgroundTaskManager.startBackgroundRunning(featureAbility.getContext(),
+ backgroundTaskManager.BackgroundMode.DATA_TRANSFER, wantAgentObj).then(() => {
+ console.info("Operation succeeded");
+ }).catch((err) => {
+ console.error("Operation failed Cause: " + err);
+ });
+});
+
+```
+
+## backgroundTaskManager.stopBackgroundRunning
+
+[8] stopBackgroundRunning(context: Context, callback: AsyncCallback<void>): void;
+
+向系统申请取消长时任务,使用callback形式返回结果。
+
+- **参数**:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | context | Context | 是 | 应用运行的上下文 |
+ | callback | AsyncCallback<void> | 是 | callback形式返回启动长时任务的结果 |
+
+- **示例**:
+```js
+import backgroundTaskManager from '@ohos.backgroundTaskManager';
+import featureAbility from '@ohos.ability.featureAbility';
+
+function callback(err, data) {
+ if (err) {
+ console.error("Operation failed Cause: " + err);
+ } else {
+ console.info("Operation succeeded");
+ }
+}
+
+backgroundTaskManager.stopBackgroundRunning(featureAbility.getContext(), callback);
+
+```
+
+## backgroundTaskManager.stopBackgroundRunning
+
+[8] stopBackgroundRunning(context: Context): Promise<void>;
+
+向系统申请取消长时任务,使用promise形式返回结果。
+
+- **参数**:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | context | Context | 是 | 应用运行的上下文 |
+
+- **返回值**
+ | 类型 | 说明 |
+ | -------------- | ------------------------- |
+ | Promise\ | 使用Promise形式返回结果。 |
+
+- **示例**:
+```js
+import backgroundTaskManager from '@ohos.backgroundTaskManager';
+import featureAbility from '@ohos.ability.featureAbility';
+
+backgroundTaskManager.stopBackgroundRunning(featureAbility.getContext()).then(() => {
+ console.info("Operation succeeded");
+}).catch((err) => {
+ console.error("Operation failed Cause: " + err);
+});
+
+```
+
+## [8] BackgroundMode
+
+| 参数名 | 参数 | 描述 |
+| ----------------------- | -------- | -------- |
+| DATA_TRANSFER | 1 | 数据传输 |
+| AUDIO_PLAYBACK | 2 | 音频播放 |
+| AUDIO_RECORDING | 3 | 录音 |
+| LOCATION | 4 | 定位导航 |
+| BLUETOOTH_INTERACTION | 5 | 蓝牙相关 |
+| MULTI_DEVICE_CONNECTION | 6 | 多设备互联 |
+| WIFI_INTERACTION | 7 | WLAN相关(系统保留) |
+| VOIP | 8 | 音视频通话(系统保留) |
+| TASK_KEEPING | 9 | 计算任务(仅供PC使用) |
\ No newline at end of file
diff --git a/zh-cn/application-dev/reference/apis/js-apis-battery-info.md b/zh-cn/application-dev/reference/apis/js-apis-battery-info.md
index 57a8070f4f4d702331a2c2fbb1868f0f44e30fdd..c9a4b11914a4240013c0475d85a6aaa5acab39b3 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-battery-info.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-battery-info.md
@@ -10,6 +10,9 @@
import batteryInfo from '@ohos.batteryInfo';
```
+## 系统能力
+
+SystemCapability.PowerManager.BatteryManager
## 属性
diff --git a/zh-cn/application-dev/reference/apis/js-apis-brightness.md b/zh-cn/application-dev/reference/apis/js-apis-brightness.md
index 1825ff78c9b0b02223f4aecd41ddafe9575fde44..9692cb136f5ac05ef9fe2152f8ce73297994a074 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-brightness.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-brightness.md
@@ -10,6 +10,9 @@
import brightness from '@ohos.brightness';
```
+## 系统能力
+
+SystemCapability.PowerManager.DisplayPowerManager
## brightness.setValue
diff --git a/zh-cn/application-dev/reference/apis/js-apis-commonEvent.md b/zh-cn/application-dev/reference/apis/js-apis-commonEvent.md
index 80f4570493b387bd947dfcd5ffdd7d7a7319600a..31d716c34984355e71aa62bc1fb41c3fd453c390 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-commonEvent.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-commonEvent.md
@@ -116,7 +116,11 @@
import CommonEvent from '@ohos.commonevent';
```
+## 系统能力
+```js
+SystemCapability.Notification.CommonEvent
+```
## CommonEvent.publish
diff --git a/zh-cn/application-dev/reference/apis/js-apis-convertxml.md b/zh-cn/application-dev/reference/apis/js-apis-convertxml.md
index 6b5edb199d7c4f174d49dadf620a640afff7bf60..1520b77763fb5d845d153beb3b12acd0a9d2c276 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-convertxml.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-convertxml.md
@@ -7,14 +7,9 @@
## 导入模块
```
-import convertxml from '@ohos.convertxml'
+import convertxml from '@ohos.convertxml';
```
-
-## 权限
-
-无
-
## ConvertXML
@@ -48,7 +43,7 @@ convert(xml: string, options?: ConvertOptions) : Object
' Work' +
' Play' +
'';
- var conv= new convertxml.ConvertXML();
+ var conv = new convertxml.ConvertXML();
var result1 = conv.convert(xml, {trim: false, ignoreDeclaration: false});
console.log(result1)
```
@@ -63,7 +58,7 @@ convert(xml: string, options?: ConvertOptions) : Object
| ignoreInstruction | boolean | 否 | 是否忽略xml的写入处理指令,默认false。 |
| ignoreAttributes | boolean | 否 | 是否跨多行打印属性并缩进属性,默认false。 |
| ignoreComment | boolean | 否 | 是否忽略元素的注释信息,默认false。 |
-| ignoreCdata | boolean | 否 | 是否忽略元素的CData信息,默认false。 |
+| ignoreCDATA | boolean | 否 | 是否忽略元素的CDATA信息,默认false。 |
| ignoreDoctype | boolean | 否 | 是否忽略元素的Doctype信息,默认false。 |
| ignoreText | boolean | 否 | 是否忽略元素的文本信息,默认false。 |
| declarationKey | string | 否 | 用于输出对象中declaration的属性键的名称,默认_declaration。 |
diff --git a/zh-cn/application-dev/reference/apis/js-apis-data-ability.md b/zh-cn/application-dev/reference/apis/js-apis-data-ability.md
index 7b82a0b98d1008b2badae7cdbdf58305cdad6481..20029605f35b85f37dfa652abef620d20836aceb 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-data-ability.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-data-ability.md
@@ -622,7 +622,7 @@ distinct(): DataAbilityPredicates
```
let predicates = new dataAbility.DataAbilityPredicates("EMPLOYEE")
predicates.equalTo("NAME", "Rose").distinct("NAME")
- let resultSet = await rdbStore.query(predicates, ["NAME"])
+ rdbStore.query(predicates, ["NAME"])
```
diff --git a/zh-cn/application-dev/reference/apis/js-apis-data-rdb.md b/zh-cn/application-dev/reference/apis/js-apis-data-rdb.md
index 44c6e7089da9a60bd84c70afd3d4278222343a43..0bfbca177757860cc989587e2bdf7386e30d0a69 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-data-rdb.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-data-rdb.md
@@ -7,7 +7,7 @@
## 导入模块
```
-import dataRdb from '@ohos.data.rdb'
+import data_rdb from '@ohos.data.rdb'
```
@@ -16,40 +16,44 @@ import dataRdb from '@ohos.data.rdb'
无
-## dataRdb.getRdbStore
+## data_rdb.getRdbStore
-getRdbStore(config: StoreConfig, version: number, callback: AsyncCallback<RdbStore>): void
+getRdbStore(context: Context, config: StoreConfig, version: number, callback: AsyncCallback<RdbStore>): void
获得一个相关的RdbStore,操作关系型数据库,用户可以根据自己的需求配置RdbStore的参数,然后通过RdbStore调用相关接口可以执行相关的数据操作,结果以callback形式返回。
- 参数:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
+ | context | Context | 是 | 应用程序或功能的上下文 |
| config | [StoreConfig](#storeconfig) | 是 | 与此RDB存储相关的数据库配置。 |
| version | number | 是 | 数据库版本。 |
| callback | AsyncCallback<[RdbStore](#rdbstore)> | 是 | 指定callback回调函数。返回一个RdbStore。 |
- 示例:
```
- import dataRdb from '@ohos.data.rdb'
- const STORE_CONFIG = { name: "RdbTest.db"}
- const SQL_CREATE_TABLE = "CREATE TABLE IF NOT EXISTS EMPLOYEE (ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT NOT NULL, AGE INTEGER, SALARY REAL, CODES BLOB)"
- dataRdb.getRdbStore(STORE_CONFIG, 1, function (err, rdbStore) {
- rdbStore.executeSql(SQL_CREATE_TABLE)
- console.info(TAG + 'create table done.')
- })
+ import Ability from '@ohos.application.Ability'
+ import data_rdb from '@ohos.data.rdb'
+ export default class MainAbility extends Ability {
+ const STORE_CONFIG = { name: "RdbTest.db"}
+ const SQL_CREATE_TABLE = "CREATE TABLE IF NOT EXISTS EMPLOYEE (ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT NOT NULL, AGE INTEGER, SALARY REAL, CODES BLOB)"
+ data_rdb.getRdbStore(this.context, STORE_CONFIG, 1, function (err, rdbStore) {
+ rdbStore.executeSql(SQL_CREATE_TABLE)
+ console.info(TAG + 'create table done.')
+ })
+ }
```
+## data_rdb.getRdbStore
-## dataRdb.getRdbStore
-
-getRdbStore(config: StoreConfig, version: number): Promise<RdbStore>
+getRdbStore(context: Context, config: StoreConfig, version: number): Promise<RdbStore>
获得一个相关的RdbStore,操作关系型数据库,用户可以根据自己的需求配置RdbStore的参数,然后通过RdbStore调用相关接口可以执行相关的数据操作,结果以Promise形式返回。
- 参数:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
+ | context | Context | 是 | 应用程序或功能的上下文 |
| config | [StoreConfig](#storeconfig) | 是 | 与此RDB存储相关的数据库配置。 |
| version | number | 是 | 数据库版本。 |
@@ -60,47 +64,53 @@ getRdbStore(config: StoreConfig, version: number): Promise<RdbStore>
- 示例:
```
- import dataRdb from '@ohos.data.rdb'
- const STORE_CONFIG = { name: "RdbTest.db" }
- const SQL_CREATE_TABLE = "CREATE TABLE IF NOT EXISTS EMPLOYEE (ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT NOT NULL, AGE INTEGER, SALARY REAL, CODES BLOB)"
- let promise = dataRdb.getRdbStore(STORE_CONFIG, 1);
- promise.then(async (rdbStore) => {
- await rdbStore.executeSql(SQL_CREATE_TABLE, null)
- }).catch((err) => {
- expect(null).assertFail();
- })
+ import Ability from '@ohos.application.Ability'
+ import data_rdb from '@ohos.data.rdb'
+ export default class MainAbility extends Ability {
+ const STORE_CONFIG = { name: "RdbTest.db" }
+ const SQL_CREATE_TABLE = "CREATE TABLE IF NOT EXISTS EMPLOYEE (ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT NOT NULL, AGE INTEGER, SALARY REAL, CODES BLOB)"
+ let promise = data_rdb.getRdbStore(this.context, STORE_CONFIG, 1);
+ promise.then(async (rdbStore) => {
+ await rdbStore.executeSql(SQL_CREATE_TABLE, null)
+ }).catch((err) => {
+ expect(null).assertFail();
+ })
+ }
```
+## data_rdb.deleteRdbStore
-## dataRdb.deleteRdbStore
-
-deleteRdbStore(name: string, callback: AsyncCallback<void>): void
+deleteRdbStore(context: Context, name: string, callback: AsyncCallback<void>): void
删除数据库,结果以callback形式返回。
- 参数:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
+ | context | Context | 是 | 应用程序或功能的上下文 |
| name | string | 是 | 数据库名称。 |
| callback | AsyncCallback<void> | 是 | 指定callback回调函数。如果数据库已删除,则为true;否则返回false。 |
- 示例:
```
- import dataRdb from '@ohos.data.rdb'
- dataRdb.deleteRdbStore("RdbTest.db", function (err, rdbStore) {
- console.info(TAG + 'delete store done.')})
+ import Ability from '@ohos.application.Ability'
+ import data_rdb from '@ohos.data.rdb'
+ export default class MainAbility extends Ability {
+ data_rdb.deleteRdbStore(this.context, "RdbTest.db", function (err, rdbStore) {
+ console.info(TAG + 'delete store done.')})
+ }
```
+## data_rdb.deleteRdbStore
-## dataRdb.deleteRdbStore
-
-deleteRdbStore(name: string): Promise<void>
+deleteRdbStore(context: Context, name: string): Promise<void>
使用指定的数据库文件配置删除数据库,结果以Promise形式返回。
- 参数:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
+ | context | Context | 是 | 应用程序或功能的上下文 |
| name | string | 是 | 数据库名称。 |
- 返回值:
@@ -110,14 +120,16 @@ deleteRdbStore(name: string): Promise<void>
- 示例:
```
- import dataRdb from '@ohos.data.rdb'
- let promise = dataRdb.deleteRdbStore("RdbTest.db")
- promise.then(()=>{
- console.info(TAG + 'delete store done.')
- })
+ import Ability from '@ohos.application.Ability'
+ import data_rdb from '@ohos.data.rdb'
+ export default class MainAbility extends Ability {
+ let promise = data_rdb.deleteRdbStore(this.context, "RdbTest.db")
+ promise.then(()=>{
+ console.info(TAG + 'delete store done.')
+ })
+ }
```
-
## RdbPredicates
表示关系型数据库(RDB)的谓词。该类确定RDB中条件表达式的值是true还是false。
@@ -138,8 +150,7 @@ constructor(name: string)
- 示例:
```
- import dataRdb from '@ohos.data.rdb'
- let predicates = new dataRdb.RdbPredicates("EMPLOYEE")
+ let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
```
@@ -164,7 +175,7 @@ equalTo(field: string, value: ValueType): RdbPredicates
- 示例:
```
- let predicates = new dataRdb.RdbPredicates("EMPLOYEE")
+ let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.equalTo("NAME", "lisi")
```
@@ -190,7 +201,7 @@ notEqualTo(field: string, value: ValueType): RdbPredicates
- 示例:
```
- let predicates = new dataRdb.RdbPredicates("EMPLOYEE")
+ let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.notEqualTo("NAME", "lisi")
```
@@ -210,7 +221,7 @@ beginWrap(): RdbPredicates
- 示例:
```
- let predicates = new dataRdb.RdbPredicates("EMPLOYEE")
+ let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.equalTo("NAME", "lisi")
.beginWrap()
.equalTo("AGE", 18)
@@ -235,7 +246,7 @@ endWrap(): RdbPredicates
- 示例:
```
- let predicates = new dataRdb.RdbPredicates("EMPLOYEE")
+ let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.equalTo("NAME", "lisi")
.beginWrap()
.equalTo("AGE", 18)
@@ -260,7 +271,7 @@ or(): RdbPredicates
- 示例:
```
- let predicates = new dataRdb.RdbPredicates("EMPLOYEE")
+ let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.equalTo("NAME", "Lisa")
.or()
.equalTo("NAME", "Rose")
@@ -282,7 +293,7 @@ and(): RdbPredicates
- 示例:
```
- let predicates = new dataRdb.RdbPredicates("EMPLOYEE")
+ let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.equalTo("NAME", "Lisa")
.and()
.equalTo("SALARY", 200.5)
@@ -310,7 +321,7 @@ contains(field: string, value: string): RdbPredicat
- 示例:
```
- let predicates = new dataRdb.RdbPredicates("EMPLOYEE")
+ let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.contains("NAME", "os")
```
@@ -336,7 +347,7 @@ beginsWith(field: string, value: string): RdbPredicates
- 示例:
```
- let predicates = new dataRdb.RdbPredicates("EMPLOYEE")
+ let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.beginsWith("NAME", "os")
```
@@ -362,7 +373,7 @@ endsWith(field: string, value: string): RdbPredicates
- 示例:
```
- let predicates = new dataRdb.RdbPredicates("EMPLOYEE")
+ let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.endsWith("NAME", "se")
```
@@ -387,7 +398,7 @@ isNull(field: string): RdbPredicates
- 示例
```
- let predicates = new dataRdb.RdbPredicates("EMPLOYEE")
+ let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.isNull("NAME")
```
@@ -412,7 +423,7 @@ isNotNull(field: string): RdbPredicates
- 示例:
```
- let predicates = new dataRdb.RdbPredicates("EMPLOYEE")
+ let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.isNotNull("NAME")
```
@@ -438,7 +449,7 @@ like(field: string, value: string): RdbPredicates
- 示例:
```
- let predicates = new dataRdb.RdbPredicates("EMPLOYEE")
+ let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.like("NAME", "%os%")
```
@@ -464,7 +475,7 @@ glob(field: string, value: string): RdbPredicates
- 示例:
```
- let predicates = new dataRdb.RdbPredicates("EMPLOYEE")
+ let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.glob("NAME", "?h*g")
```
@@ -491,7 +502,7 @@ between(field: string, low: ValueType, high: ValueType): RdbPredicates
- 示例:
```
- let predicates = new dataRdb.RdbPredicates("EMPLOYEE")
+ let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.between("AGE", 10, 50)
```
@@ -518,7 +529,7 @@ notBetween(field: string, low: ValueType, high: ValueType): RdbPredicates
- 示例:
```
- let predicates = new dataRdb.RdbPredicates("EMPLOYEE")
+ let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.notBetween("AGE", 10, 50)
```
@@ -544,7 +555,7 @@ greaterThan(field: string, value: ValueType): RdbPredicatesgr
- 示例:
```
- let predicates = new dataRdb.RdbPredicates("EMPLOYEE")
+ let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.greaterThan("AGE", 18)
```
@@ -570,7 +581,7 @@ lessThan(field: string, value: ValueType): RdbPredicates
- 示例:
```
- let predicates = new dataRdb.RdbPredicates("EMPLOYEE")
+ let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.lessThan("AGE", 20)
```
@@ -597,7 +608,7 @@ greaterThanOrEqualTo(field: string, value: ValueType): RdbPredicates
- 示例:
```
- let predicates = new dataRdb.RdbPredicates("EMPLOYEE")
+ let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.greaterThanOrEqualTo("AGE", 18)
```
@@ -624,7 +635,7 @@ lessThanOrEqualTo(field: string, value: ValueType): RdbPredicates
- 示例:
```
- let predicates = new dataRdb.RdbPredicates("EMPLOYEE")
+ let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.lessThanOrEqualTo("AGE", 20)
```
@@ -650,7 +661,7 @@ orderByAsc(field: string): RdbPredicates
- 示例:
```
- let predicates = new dataRdb.RdbPredicates("EMPLOYEE")
+ let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.orderByAsc("NAME")
```
@@ -676,7 +687,7 @@ orderByDesc(field: string): RdbPredicates
- 示例:
```
- let predicates = new dataRdb.RdbPredicates("EMPLOYEE")
+ let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.orderByDesc("AGE")
```
@@ -696,9 +707,9 @@ distinct(): RdbPredicates
- 示例:
```
- let predicates = new dataRdb.RdbPredicates("EMPLOYEE")
+ let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.equalTo("NAME", "Rose").distinct("NAME")
- let resultSet = await rdbStore.query(predicates, ["NAME"])
+ rdbStore.query(predicates, ["NAME"])
```
@@ -722,7 +733,7 @@ limitAs(value: number): RdbPredicates
- 示例:
```
- let predicates = new dataRdb.RdbPredicates("EMPLOYEE")
+ let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.equalTo("NAME", "Rose").limitAs(3)
```
@@ -747,7 +758,7 @@ offsetAs(rowOffset: number): RdbPredicates
- 示例:
```
- let predicates = new dataRdb.RdbPredicates("EMPLOYEE")
+ let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.equalTo("NAME", "Rose").offsetAs(3)
```
@@ -772,7 +783,7 @@ groupBy(fields: Array<string>): RdbPredicates
- 示例:
```
- let predicates = new dataRdb.RdbPredicates("EMPLOYEE")
+ let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.groupBy(["AGE", "NAME"])
```
@@ -797,7 +808,7 @@ indexedBy(indexName: string): RdbPredicates
- 示例:
```
- let predicates = new dataRdb.RdbPredicates("EMPLOYEE")
+ let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.indexedBy("SALARY_INDEX")
```
@@ -824,7 +835,7 @@ in(field: string, value: Array<ValueType>): RdbPredicates
- 示例:
```
- let predicates = new dataRdb.RdbPredicates("EMPLOYEE")
+ let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.in("AGE", [18, 20])
```
@@ -851,7 +862,7 @@ notIn(field: string, value: Array<ValueType>): RdbPredicates
- 示例:
```
- let predicates = new dataRdb.RdbPredicates("EMPLOYEE")
+ let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.notIn("NAME", ["Lisa", "Rose"])
```
@@ -941,7 +952,7 @@ update(values: ValuesBucket, rdbPredicates: RdbPredicates, callback: AsyncCallba
"SALARY": 200.5,
"CODES": new Uint8Array([1, 2, 3, 4, 5]),
}
- let predicates = new dataRdb.RdbPredicates("EMPLOYEE")
+ let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.equalTo("NAME", "Lisa")
rdbStore.update(valueBucket, predicates, function (err, ret) {
console.log(TAG + "updated row count: " + changedRows)})
@@ -973,7 +984,7 @@ update(values: ValuesBucket, rdbPredicates: RdbPredicates):Promise<number>
"SALARY": 200.5,
"CODES": new Uint8Array([1, 2, 3, 4, 5]),
}
- let predicates = new dataRdb.RdbPredicates("EMPLOYEE")
+ let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.equalTo("NAME", "Lisa")
let promise = rdbStore.update(valueBucket, predicates)
promise.then(async (ret) => {
@@ -998,7 +1009,7 @@ delete(rdbPredicates: RdbPredicates, callback: AsyncCallback<number>):void
- 示例:
```
- let predicates = new dataRdb.RdbPredicates("EMPLOYEE")
+ let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.equalTo("NAME", "Lisa")
rdbStore.delete(predicates, function (err, rows) {
console.log(TAG + "delete rows: " + rows)})
@@ -1023,7 +1034,7 @@ delete(rdbPredicates: RdbPredicates):Promise<number>
- 示例:
```
- let predicates = new dataRdb.RdbPredicates("EMPLOYEE")
+ let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.equalTo("NAME", "Lisa")
let promise = rdbStore.delete(predicates)
promise.then((rows) => {
@@ -1047,7 +1058,7 @@ query(rdbPredicates: RdbPredicates, columns: Array<string>, callback: Asyn
- 示例:
```
- let predicates = new dataRdb.RdbPredicates("EMPLOYEE")
+ let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.equalTo("NAME", "Rose")
rdbStore.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"], function (err, resultSet) {
console.log(TAG + "resultSet column names:" + resultSet.columnNames)
@@ -1074,7 +1085,7 @@ query(rdbPredicates: RdbPredicates, columns?: Array<string>):Promise<Re
- 示例:
```
- let predicates = new dataRdb.RdbPredicates("EMPLOYEE")
+ let predicates = new data_rdb.RdbPredicates("EMPLOYEE")
predicates.equalTo("NAME", "Rose")
let promise = rdbStore.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"])
promise.then((resultSet) => {
diff --git a/zh-cn/application-dev/reference/apis/js-apis-data-resultset.md b/zh-cn/application-dev/reference/apis/js-apis-data-resultset.md
index b2bd32db35fd9af1347a6abd2f1539e5b82d8fb2..88409ad69ff346cf0bfb97df2cdf9f1ab00be16c 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-data-resultset.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-data-resultset.md
@@ -14,8 +14,9 @@ let predicates = new dataRdb.RdbPredicates("EMPLOYEE")
predicates.equalTo("AGE", 18)
let promise = rdbStore.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"])
promise.then((resultSet) => {
- await console.log(TAG + "resultSet columnNames:" + resultSet.columnNames);
- await console.log(TAG + "resultSet columnCount:" + resultSet.columnCount);})
+ console.log("resultSet columnNames:" + resultSet.columnNames);
+ console.log("resultSet columnCount:" + resultSet.columnCount);
+})
```
@@ -114,10 +115,11 @@ goTo(offset:number): boolean
- 示例:
```
let predicates = new dataRdb.RdbPredicates("EMPLOYEE")
- let resultSet = await rdbStore.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"])
- resultSet.goTo(1)
- resultSet.close()
- resultSet = null
+ rdbStore.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]).then((resultSet) => {
+ resultSet.goTo(1);
+ resultSet.close();
+ resultSet = null;
+ })
```
@@ -140,10 +142,11 @@ goToRow(position: number): boolean
- 示例:
```
let predicates = new dataRdb.RdbPredicates("EMPLOYEE")
- let resultSet = await rdbStore.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"])
- resultSet.goToRow(1)
- resultSet.close()
- resultSet = null
+ rdbStore.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]).then((resultSet) => {
+ resultSet.goToRow(1);
+ resultSet.close();
+ resultSet = null
+ })
```
@@ -163,10 +166,11 @@ goToFirstRow(): boolean
- 示例:
```
let predicates = new dataRdb.RdbPredicates("EMPLOYEE")
- let resultSet = await rdbStore.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"])
- resultSet.goToFirstRow()
- resultSet.close()
- resultSet = null;
+ rdbStore.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]).then((resultSet) => {
+ resultSet.goToFirstRow();
+ resultSet.close();
+ resultSet = null;
+ })
```
@@ -184,10 +188,11 @@ goToLastRow(): boolean
- 示例:
```
let predicates = new dataRdb.RdbPredicates("EMPLOYEE")
- let resultSet = await rdbStore.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"])
- resultSet.goToLastRow()
- resultSet.close()
- resultSet = null;
+ rdbStore.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]).then((resultSet) => {
+ resultSet.goToLastRow();
+ resultSet.close();
+ resultSet = null;
+ })
```
@@ -205,10 +210,11 @@ goToNextRow(): boolean
- 示例:
```
let predicates = new dataRdb.RdbPredicates("EMPLOYEE")
- let resultSet = await rdbStore.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"])
- resultSet.goToNextRow()
- resultSet.close()
- resultSet = null;
+ rdbStore.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]).then((resultSet) => {
+ resultSet.goToNextRow()
+ resultSet.close()
+ resultSet = null;
+ })
```
@@ -226,10 +232,11 @@ goToPreviousRow(): boolean
- 示例:
```
let predicates = new dataRdb.RdbPredicates("EMPLOYEE")
- let resultSet = await rdbStore.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"])
- resultSet.goToPreviousRow()
- resultSet.close()
- resultSet = null
+ rdbStore.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]).then((resultSet) => {
+ resultSet.goToPreviousRow();
+ resultSet.close();
+ resultSet = null
+ })
```
@@ -353,7 +360,8 @@ close(): void
- 示例:
```
let predicates = new dataRdb.RdbPredicates("EMPLOYEE")
- let resultSet = await rdbStore.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"])
- resultSet.close()
- resultSet = null
+ rdbStore.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"]).then((resultSet) => {
+ resultSet.close();
+ resultSet = null
+ })
```
diff --git a/zh-cn/application-dev/reference/apis/js-apis-data-storage.md b/zh-cn/application-dev/reference/apis/js-apis-data-storage.md
index 37f09d0cbf171c0ec304b5934d8be0c23ac3a91f..ffe1f1bf2719bc6e8e0fc9628725a653e5cb71a6 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-data-storage.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-data-storage.md
@@ -48,11 +48,13 @@ getStorageSync(path: string): Storage
import dataStorage from '@ohos.data.storage'
import featureAbility from '@ohos.ability.featureAbility'
- var context = featureAbility.getContext()
- var path = await context.getFilesDir()
- let storage = dataStorage.getStorageSync(path + '/mystore')
- storage.putSync('startup', 'auto')
- storage.flushSync()
+ (async () => {
+ var context = featureAbility.getContext()
+ var path = await context.getFilesDir()
+ let storage = dataStorage.getStorageSync(path + '/mystore')
+ storage.putSync('startup', 'auto')
+ storage.flushSync()
+ })()
```
@@ -73,16 +75,18 @@ getStorage(path: string, callback: AsyncCallback<Storage>): void
import dataStorage from '@ohos.data.storage'
import featureAbility from '@ohos.ability.featureAbility'
- var context = featureAbility.getContext()
- var path = await context.getFilesDir()
- dataStorage.getStorage(path + '/mystore', function (err, storage) {
- if (err) {
- console.info("Get the storage failed, path: " + path + '/mystore')
- return;
- }
- storage.putSync('startup', 'auto')
- storage.flushSync()
- })
+ (async () => {
+ var context = featureAbility.getContext()
+ var path = await context.getFilesDir()
+ dataStorage.getStorage(path + '/mystore', function (err, storage) {
+ if (err) {
+ console.info("Get the storage failed, path: " + path + '/mystore')
+ return;
+ }
+ storage.putSync('startup', 'auto')
+ storage.flushSync()
+ })
+ })()
```
@@ -107,15 +111,17 @@ getStorage(path: string): Promise<Storage>
import dataStorage from '@ohos.data.storage'
import featureAbility from '@ohos.ability.featureAbility'
- var context = featureAbility.getContext()
- var path = await context.getFilesDir()
- let promise = dataStorage.getStorage(path + '/mystore')
- promise.then((storage) => {
- storage.putSync('startup', 'auto')
- storage.flushSync()
- }).catch((err) => {
- console.info("Get the storage failed, path: " + path + '/mystore')
- })
+ (async () => {
+ var context = featureAbility.getContext()
+ var path = await context.getFilesDir()
+ let promise = dataStorage.getStorage(path + '/mystore')
+ promise.then((storage) => {
+ storage.putSync('startup', 'auto')
+ storage.flushSync()
+ }).catch((err) => {
+ console.info("Get the storage failed, path: " + path + '/mystore')
+ })
+ }()
```
diff --git a/zh-cn/application-dev/reference/apis/js-apis-deque.md b/zh-cn/application-dev/reference/apis/js-apis-deque.md
new file mode 100644
index 0000000000000000000000000000000000000000..6ef3ab95b545c41765e72178de06a080fbc82c08
--- /dev/null
+++ b/zh-cn/application-dev/reference/apis/js-apis-deque.md
@@ -0,0 +1,251 @@
+# 线性容器Deque
+
+>  **说明:**
+> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
+
+
+## 导入模块
+
+```
+import Deque from '@ohos.util.Deque'
+```
+
+## 权限
+
+无
+
+## Deque
+
+### 属性
+
+| 名称 | 参数类型 | 可读 | 可写 | 说明 |
+| -------- | -------- | -------- | -------- | -------- |
+| length | number | 是 | 否 | Deque的元素个数 |
+
+### constructor
+
+constructor();
+
+Deque的构造函数。
+
+- 示例:
+ ```
+ let deque = new Deque();
+ ```
+
+### insertFront
+
+insertFront(element: T): void;
+
+在deque头部插入元素。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | element | T | 是 | 添加进去的元素 |
+
+- 示例:
+ ```
+ let deque = new Deque;
+ deque.insertFront("a");
+ deque.insertFront(1);
+ let b = [1, 2, 3];
+ deque.insertFront(b);
+ let c = {name : "lala", age : "13"};
+ deque.insertFront(false);
+ ```
+### insertEnd
+
+insertEnd(element: T): void;
+
+在deque尾部插入元素。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | element | T | 是 | 添加进去的元素 |
+
+- 示例:
+ ```
+ let deque = new Deque;
+ deque.insertEnd("a");
+ deque.insertEnd(1);
+ let b = [1, 2, 3];
+ deque.insertEnd(b);
+ let c = {name : "lala", age : "13"};
+ deque.insertEnd(false);
+ ```
+### has
+
+has(element: T): boolean;
+
+判断此Deque中是否含有该指定元素。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | element | T | 是 | 指定的元素 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | boolean | 是否包含指定元素 |
+
+- 示例:
+ ```
+ let deque = new Deque();
+ deque.has("Ahfbrgrbgnutfodgorrogorg");
+ deque.insertFront("Ahfbrgrbgnutfodgorrogorg");
+ deque.has("Ahfbrgrbgnutfodgorrogorg");
+ ```
+### popFirst
+
+popFirst(): T;
+
+删除并返回双端队列的首元素。
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | T | 返回删除的元素 |
+
+- 示例:
+ ```
+ let deque = new Deque();
+ deque.insertFront(2);
+ deque.insertFront(4);
+ deque.insertEnd(5);
+ deque.insertFront(2);
+ deque.insertFront(4);
+ deque.popFirst();
+ ```
+### popLast
+
+popLast(): T;
+
+删除并返回双端队列的尾元素。
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | T | 返回删除的元素 |
+
+- 示例:
+ ```
+ let deque = new Deque();
+ deque.insertFront(2);
+ deque.insertEnd(4);
+ deque.insertFront(5);
+ deque.insertFront(2);
+ deque.insertFront(4);
+ deque.popLast();
+ ```
+
+### forEach
+forEach(callbackfn: (value: T, index?: number, deque?: Deque<T>) => void,
+thisArg?: Object): void;
+
+通过回调函数来遍历Deque实例对象上的元素以及元素对应的下标。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | callbackfn | function | 是 | 回调函数 |
+ | thisArg | Object | 否 | callbackfn被调用时用作this值 |
+
+- callbackfn的参数说明
+
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | value | T | 是 | 当前遍历到的元素 |
+ | index | number | 否 | 当前遍历到的下标值 |
+ | deque | Deque<T> | 否 | 当前调用forEach方法的实例对象 |
+
+- 示例:
+ ```
+ let deque = new Deque();
+ deque.insertFront(2);
+ deque.insertEnd(4);
+ deque.insertFront(5);
+ deque.insertEnd(4);
+ deque.forEach((value, index) => {
+ console.log(value, index);
+ });
+ ```
+
+### getFirst
+
+getFirst(): T;
+获取Deque实例中的头元素。
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | T | 返回T型 |
+
+
+- 示例:
+ ```
+ let deque = new Deque();
+ deque.insertEnd(2);
+ deque.insertEnd(4);
+ deque.insertFront(5);
+ deque.insertFront(4);
+ deque.getFirst();
+ ```
+### getLast
+
+getLast(): T;
+获取Deque实例中的尾元素。
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | T | 返回T型 |
+
+
+- 示例:
+ ```
+ let deque = new Deque();
+ deque.insertFront(2);
+ deque.insertFront(4);
+ deque.insertFront(5);
+ deque.insertFront(4);
+ deque.getLast();
+ ```
+
+### [Symbol.iterator]
+
+[Symbol.iterator]\(): IterableIterator<T>;
+
+
+返回一个迭代器,迭代器的每一项都是一个 JavaScript 对象,并返回该对象。
+
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | IterableIterator<T> | 返回一个迭代器。 |
+
+
+- 示例:
+ ```
+ let deque = new Deque();
+ deque.insertFront(2);
+ deque.insertFront(4);
+ deque.insertFront(5);
+ deque.insertFront(4);
+
+ // 使用方法一:
+ for (let item of deque) {
+ console.log(item);
+ }
+
+ // 使用方法二:
+ let iter = deque[Symbol.iterator]();
+ let temp = iter.next().value;
+ while(temp != undefined) {
+ console.log(temp);
+ temp = iter.next().value;
+ }
+ ```
\ No newline at end of file
diff --git a/zh-cn/application-dev/reference/apis/js-apis-distributed-account.md b/zh-cn/application-dev/reference/apis/js-apis-distributed-account.md
index e61397cf8b0820b160081327b319b3ca18ea93a5..33ba4d7b94fc998cd072365f1045cc351ca1670a 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-distributed-account.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-distributed-account.md
@@ -11,6 +11,11 @@ import account_distributedAccount from '@ohos.account.distributedAccount';
```
+## 系统能力
+
+SystemCapability.Account.OsAccount
+
+
## account_distributedAccount.getDistributedAccountAbility
getDistributedAccountAbility(): DistributedAccountAbility
diff --git a/zh-cn/application-dev/reference/apis/js-apis-emitter.md b/zh-cn/application-dev/reference/apis/js-apis-emitter.md
index afed141714bfb8aa6a9868998b94a59b3236d8ee..dfaab6b7681fd39ac27cb3607b52078f02f1320d 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-emitter.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-emitter.md
@@ -8,6 +8,12 @@
import emitter from '@ohos.events.emitter'
```
+## 系统能力
+
+```javascript
+SystemCapability.Notification.Emitter
+```
+
## 权限列表
无
diff --git a/zh-cn/application-dev/reference/apis/js-apis-environment.md b/zh-cn/application-dev/reference/apis/js-apis-environment.md
index 2d38edd1d107c7713d9ef9e6815710e403650ecc..21898fc226a0b375069d5a3d6776d2e2d75acc12 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-environment.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-environment.md
@@ -1,18 +1,17 @@
# 目录环境能力
-
+>  **说明:**
+> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块
-```
+```js
import environment from '@ohos.environment';
```
+## 系统能力
-
-## 权限列表
-
-无
+SystemCapability.FileManagement.File.Environment
## environment.getStorageDataDir
@@ -28,11 +27,11 @@ getStorageDataDir():Promise<string>
- 示例:
- ```
+ ```js
environment.getStorageDataDir().then(function(path){
- // do something
+ console.info("getStorageDataDir successfully:"+ path);
}).catch(function(error){
-
+ console.info("getStorageDataDir failed with error:"+ error);
});
```
@@ -50,7 +49,7 @@ getStorageDataDir(callback:AsyncCallback<string>):void
- 示例:
- ```
+ ```js
environment.getStorageDataDir(function(error, path){
// do something
});
@@ -70,11 +69,11 @@ getUserDataDir():Promise<string>
- 示例:
- ```
+ ```js
environment.getUserDataDir().then(function(path){
- // do something
+ console.info("getUserDataDir successfully:"+ path);
}).catch(function(error){
-
+ console.info("getUserDataDir failed with error:"+ error);
});
```
@@ -92,7 +91,7 @@ getUserDataDir(callback:AsyncCallback<string>): void
- 示例:
- ```
+ ```js
environment.getUserDataDir(function(error, path){
// do something
});
diff --git a/zh-cn/application-dev/reference/apis/js-apis-fileio.md b/zh-cn/application-dev/reference/apis/js-apis-fileio.md
index f868fc0ef78fb7bc0034a9e49a0f73b864603e8b..00845ba0ef6afa8ff0fa3df97f9b74f51fe28814 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-fileio.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-fileio.md
@@ -5,7 +5,7 @@
## 导入模块
-```
+```js
import fileio from '@ohos.fileio';
```
@@ -23,7 +23,7 @@ import fileio from '@ohos.fileio';
通过上述接口获取到应用目录路径dir,文件名为“xxx.txt”,文件所在绝对路径为:
-```
+```js
let path = dir + "/xxx.txt";
```
@@ -31,7 +31,7 @@ let path = dir + "/xxx.txt";
文件描述符fd:
-```
+```js
let fd = fileio.openSync(path);
```
@@ -53,9 +53,12 @@ stat(path: string): Promise<Stat>
| Promise<[Stat](#stat)> | 表示文件的具体信息。 |
- 示例:
- ```
- let stat = await fileio.stat(path);
- // example code in Stat
+ ```js
+ fileio.stat(path).then(function(stat){
+ console.info("getFileInfo successfully:"+ JSON.stringify(stat));
+ }).catch(function(err){
+ console.info("getFileInfo failed with error:"+ err);
+ });
```
@@ -72,9 +75,9 @@ stat(path:string, callback:AsyncCallback<Stat>): void
| callback | AsyncCallback<[Stat](#stat)> | 是 | 异步获取文件的信息之后的回调。 |
- 示例:
- ```
+ ```js
fileio.stat(path, function (err, stat) {
- // example code in Stat
+ // example code in Stat
});
```
@@ -97,7 +100,7 @@ statSync(path:string): Stat
| [Stat](#stat) | 表示文件的具体信息。 |
- 示例:
- ```
+ ```js
let stat = fileio.statSync(path);
// example code in Stat
```
@@ -120,9 +123,12 @@ opendir(path: string): Promise<Dir>
| Promise<[Dir](#dir)> | 返回Dir对象。 |
- 示例:
- ```
- let dir = fileio.opendir(path);
- // example code in Dir
+ ```js
+ fileio.opendir(path).then(function(dir){
+ console.info("opendir successfully:"+ JSON.stringify(dir));
+ }).catch(function(err){
+ console.info("opendir failed with error:"+ err);
+ });
```
@@ -139,10 +145,10 @@ opendir(path: string, callback: AsyncCallback<Dir>): void
| callback | AsyncCallback<[Dir](#dir)> | 是 | 异步打开文件目录之后的回调。 |
- 示例:
- ```
+ ```js
fileio.opendir(path, function (err, dir) {
- // example code in Dir struct
- // use read/readSync/close
+ // example code in Dir struct
+ // use read/readSync/close
});
```
@@ -165,7 +171,7 @@ opendirSync(path: string): Dir
| [Dir](#dir) | 返回Dir对象。 |
- 示例:
- ```
+ ```js
let dir = fileio.opendirSync(path);
// example code in Dir struct
// use read/readSync/close
@@ -190,12 +196,11 @@ access(path: string, mode?: number): Promise<void>
| Promise<void> | Promise实例,用于异步获取结果。本调用将返回空值。 |
- 示例:
- ```
- fileio.access(path)
- .then(function(err) {
- // 文件存在,do something
- }).catch(function(e) {
- //若不符合条件则进入
+ ```js
+ fileio.access(path).then(function() {
+ console.info("access successfully");
+ }).catch(function(err){
+ console.info("access failed with error:"+ err);
});
```
@@ -214,8 +219,9 @@ access(path: String, mode?: number, callback: AsyncCallback<void>): void
| callback | AsyncCallback<void> | 是 | 异步检查当前进程是否可访问某文件之后的回调。 |
- 示例:
- ```
+ ```js
fileio.access(path, function (err) {
+ // do something
});
```
@@ -234,11 +240,11 @@ accessSync(path: string, mode?: number): void
| mode | number | 否 | 访问文件时的选项,可给定如下选项,以按位或的方式使用多个选项,默认给定0。 确认当前进程是否具有对应权限: - 0:确认文件是否存在。 - 1:确认当前进程是否具有可执行权限。 - 2:确认当前进程是否具有写权限。 - 4:确认当前进程是否具有读权限。 |
- 示例:
- ```
+ ```js
try {
fileio.accessSync(path);
- } catch(e) {
- //不符合条件则进入
+ } catch(err) {
+ console.info("accessSync failed with error:"+ err);
}
```
@@ -260,9 +266,13 @@ close(fd: number):Promise<void>
| Promise<void> | Promise实例,用于异步获取结果。本调用将返回空值。 |
- 示例:
- ```
+ ```js
let fd = fileio.openSync(path);
- await fileio.close(fd);
+ fileio.close(fd).then(function(){
+ console.info("close file successfully");
+ }).catch(function(err){
+ console.info("close file failed with error:"+ err);
+ });
```
@@ -279,9 +289,10 @@ close(fd: number, callback:AsyncCallback<void>): void
| callback | AsyncCallback<void> | 是 | 异步关闭文件之后的回调。 |
- 示例:
- ```
+ ```js
let fd = fileio.openSync(path);
- await fileio.close(fd, function (err) {
+ fileio.close(fd, function (err) {
+ // do something
});
```
@@ -298,7 +309,7 @@ closeSync(fd: number): void
| fd | number | 是 | 待关闭文件的文件描述符。 |
- 示例:
- ```
+ ```js
fileio.closeSync(fd);
```
@@ -315,8 +326,12 @@ close(): Promise<void>
| Promise<void> | Promise实例,用于异步获取结果。本调用将返回空值。 |
- 示例:
- ```
- fileio.close();
+ ```js
+ fileio.close().then(function(){
+ console.info("close file stream successfully");
+ }).catch(function(err){
+ console.info("close file stream failed with error:"+ err);
+ });
```
@@ -332,8 +347,9 @@ close(callback: AsyncCallback<void>): void
| callback | AsyncCallback<void> | 是 | 异步关闭文件流之后的回调。 |
- 示例:
- ```
- await fileio.close(function(err){
+ ```js
+ fileio.close(function(err){
+ // do something
});
```
@@ -357,8 +373,12 @@ copyFile(src:string | number, dest:string | number, mode?:number):Promise<voi
| Promise<void> | Promise实例,用于异步获取结果。本调用将返回空值。 |
- 示例:
- ```
- await fileio.copyFile(src, dest);
+ ```js
+ fileio.copyFile(src, dest).then(function(){
+ console.info("copyFile successfully");
+ }).catch(function(err){
+ console.info("copyFile failed with error:"+ err);
+ });
```
@@ -377,8 +397,9 @@ copyFile(src:string | number, dest:string | number, mode?: number, callback: Asy
| callback | AsyncCallback<void> | 是 | 异步复制文件之后的回调。 |
- 示例:
- ```
- await fileio.copyFile(src, dest, function (err) {
+ ```js
+ fileio.copyFile(src, dest, function (err) {
+ // do something
});
```
@@ -397,7 +418,7 @@ fileio.copyFileSync(src:string | number, dest:string | number, mode?:number): vo
| mode | number | 否 | mode提供覆盖文件的选项,当前仅支持0,且默认为0。 0:完全覆盖目标文件,未覆盖部分将被裁切掉。 |
- 示例:
- ```
+ ```js
fileio.copyFileSync(src, dest);
```
@@ -421,12 +442,12 @@ mkdir(path:string, mode?: number): Promise<void>
| Promise<void> | Promise实例,用于异步获取结果。本调用将返回空值。 |
- 示例:
- ```
- await fileio.mkdir(path)
- .then(function(err) {
- // 目录创建成功,do something
- }).catch(function (e){
- });
+ ```js
+ fileio.mkdir(path).then(function() {
+ console.info("mkdir successfully");
+ }).catch(function (error){
+ console.info("mkdir failed with error:"+ error);
+ });
```
@@ -444,8 +465,8 @@ mkdir(path:string, mode?:number, callback:AsyncCallbak<void>): void
| callback | AsyncCallback<void> | 是 | 异步创建目录操作完成之后的回调。 |
- 示例:
- ```
- await fileio.mkdir(path, function(err) {
+ ```js
+ fileio.mkdir(path, function(err) {
if (!err) {
// do something
}
@@ -466,7 +487,7 @@ fileio.mkdirSync(path: string, mode?: number): void
| mode | number | 否 | 创建目录的权限,可给定如下权限,以按位或的方式追加权限,默认给定0o775。 - 0o775:所有者具有读、写及可执行权限,其余用户具有读及可执行权限。 - 0o700:所有者具有读、写及可执行权限。 - 0o400:所有者具有读权限。 - 0o200:所有者具有写权限。 - 0o100:所有者具有可执行权限。 - 0o070:所有用户组具有读、写及可执行权限。 - 0o040:所有用户组具有读权限。 - 0o020:所有用户组具有写权限。 - 0o010:所有用户组具有可执行权限。 - 0o007:其余用户具有读、写及可执行权限。 - 0o004:其余用户具有读权限。 - 0o002:其余用户具有写权限。 - 0o001:其余用户具有可执行权限。 |
- 示例:
- ```
+ ```js
fileio.mkdirSync(path);
```
@@ -490,8 +511,12 @@ open(path: string, flags?: number, mode?: number): Promise<number>
| Promise<number> | 打开文件的文件描述符。 |
- 示例:
- ```
- let fd = await fileio.open(path, 0o1, 0o0200);
+ ```js
+ fileio.open(path, 0o1, 0o0200).then(function(number){
+ console.info("open file successfully");
+ }).catch(function(error){
+ console.info("open file failed with error:"+ err);
+ });
```
@@ -510,8 +535,9 @@ open(path: string, flags: number, mode: number, callback: AsyncCallback<numbe
| callback | AsyncCallback <void> | 是 | 异步打开文件之后的回调。 |
- 示例:
- ```
- await fileio.open(path, 0, function(err, fd) {
+ ```js
+ fileio.open(path, 0, function(err, fd) {
+ // do something
});
```
@@ -535,7 +561,7 @@ openSync(path:string, flags?:number, mode?:number): number
| number | 打开文件的文件描述符。 |
- 示例:
- ```
+ ```js
let fd = fileio.openSync(path);
```
@@ -559,10 +585,14 @@ read(fd: number, buffer: ArrayBuffer, options?: Object): Promise<Readout>
| Promise<[Readout](#readout)> | 读取的结果。 |
- 示例:
- ```
+ ```js
let fd = fileio.openSync(path, 0o2);
let buf = new ArrayBuffer(4096);
- let res = await fileio.read(fd, buf);
+ fileio.read(fd, buf).then(function(readout){
+ console.info("read file data successfully:"+ JSON.stringify(readout));
+ }).catch(function(error){
+ console.info("read file data failed with error:"+ error);
+ });
```
@@ -581,10 +611,10 @@ read(fd: number, buffer: ArrayBuffer, options?: Object, callback: AsyncCallback&
| callback | AsyncCallback<[Readout](#readout)> | 是 | 异步读取数据之后的回调。 |
- 示例:
- ```
+ ```js
let fd = fileio.openSync(path, 0o2);
let buf = new ArrayBuffer(4096);
- await fileio.read(fd, buf, function (err, readOut) {
+ fileio.read(fd, buf, function (err, readOut) {
if (!err) {
console.log(String.fromCharCode.apply(null, new Uint8Array(readOut.buffer)))
}
@@ -611,7 +641,7 @@ readSync(fd: number, buffer: ArrayBuffer, options?: Object): number
| number | 实际读取的长度。 |
- 示例:
- ```
+ ```js
let fd = fileio.openSync(path, 0o2);
let buf = new ArrayBuffer(4096);
let num = fileio.readSync(fd, buf);
@@ -635,11 +665,11 @@ rmdir(path: string): Promise<void>
| Promise<void> | Promise实例,用于异步获取结果。本调用将返回空值。 |
- 示例:
- ```
- fileio.rmdir(path)
- .then(function(err) {
- // 删除目录成功,do something
- }).catch(function(e){
+ ```js
+ fileio.rmdir(path).then(function() {
+ console.info("rmdir successfully");
+ }).catch(function(err){
+ console.info("rmdir failed with error:"+ err);
});
```
@@ -657,8 +687,9 @@ rmdir(path: string, callback:AsyncCallback<void>): void
| callback | AsyncCallback<void> | 是 | 异步删除目录之后的回调。 |
- 示例:
- ```
- fileio.rmdir(path, function(err){
+ ```js
+ fileio.rmdir(path, function(err){
+ // do something
});
```
@@ -675,7 +706,7 @@ rmdirSync(path:string)
| path | string | 是 | 待删除目录的绝对路径。 |
- 示例:
- ```
+ ```js
fileio.rmdirSync(path);
```
@@ -697,8 +728,12 @@ unlink(path:string): Promise<void>
| Promise<void> | Promise实例,用于异步获取结果。本调用将返回空值。 |
- 示例:
- ```
- await fileio.unlink(path);
+ ```js
+ fileio.unlink(path).then(function(){
+ console.info("remove file successfully");
+ }).catch(function(error){
+ console.info("remove file failed with error:"+ error);
+ });
```
@@ -715,8 +750,8 @@ unlink(path:string, callback:AsyncCallback<void>): void
| callback | AsyncCallback<void> | 是 | 异步删除文件之后的回调。 |
- 示例:
- ```
- await fileio.unlink(path, function(err) {
+ ```js
+ fileio.unlink(path, function(err) {
if (!err) {
// do something
}
@@ -736,7 +771,7 @@ unlinkSync(path: string): void
| path | string | 是 | 待删除文件的绝对路径。 |
- 示例:
- ```
+ ```js
fileio.unlinkSync(path);
```
@@ -760,9 +795,13 @@ write(fd: number, buffer: ArrayBuffer | string, options?: Object): Promise<nu
| Promise<number> | 实际写入的长度。 |
- 示例:
- ```
+ ```js
let fd = fileio.openSync(fpath, 0o100 | 0o2, 0o666);
- let num = await fileio.write(fd, "hello, world");
+ fileio.write(fd, "hello, world").then(function(number){
+ console.info("write data to file successfully:"+ number);
+ }).catch(function(err){
+ console.info("write data to file failed with error:"+ err);
+ });
```
@@ -781,7 +820,7 @@ write(fd:number, buffer:ArrayBuffer | string,options?:Object, callback:AsyncCall
| callback | AsyncCallback<number> | 是 | 异步将数据写入完成后执行的回调函数。 |
- 示例:
- ```
+ ```js
let fd = fileio.openSync(path, 0o100 | 0o2, 0o666);
fileio.write(fd, "hello, world", function (err, bytesWritten) {
if (!err) {
@@ -810,7 +849,7 @@ writeSync(fd: number, buffer: ArrayBuffer | string, options?:Object): number
| number | 实际写入的长度。 |
- 示例:
- ```
+ ```js
let fd = fileio.openSync(path, 0o100 | 0o2, 0o666);
let num = fileio.writeSync(fd, "hello, world");
```
@@ -834,8 +873,12 @@ hash(path: string, algorithm: string): Promise<string>
| Promise<string> | 文件的哈希值。表示为十六进制数字串,所有字母均大写。 |
- 示例:
- ```
- let hashStr = await fileio.hash(path, "sha256");
+ ```js
+ fileio.hash(path, "sha256").then(function(str){
+ console.info("calculate file hash successfully:"+ str);
+ }).catch(function(error){
+ console.info("calculate file hash failed with error:"+ err);
+ });
```
@@ -853,7 +896,7 @@ hash(psth:string, algorithm:string, callback:AsyncCallback<string>): void
| callback | AsyncCallback<string> | 是 | 异步计算文件哈希操之后的回调函数(其中给定文件哈希值表示为十六进制数字串,所有字母均大写)。 |
- 示例:
- ```
+ ```js
fileio.hash(fpath, "sha256", function(err, hashStr) {
if (!err) {
console.log(hashStr)
@@ -880,11 +923,11 @@ chmod(path: string, mode: number):Promise<void>
| Promise<void> | Promise实例,用于异步获取结果。本调用将返回空值。 |
- 示例:
- ```
- fileio.chmod(path, mode)
- .then(function(err) {
- // 改变文件权限成功,do something
- }).catch(function(e){
+ ```js
+ fileio.chmod(path, mode).then(function() {
+ console.info("chmod successfully");
+ }).catch(function(err){
+ console.info("chmod failed with error:"+ err);
});
```
@@ -903,8 +946,9 @@ chmod(path: string, mode: number, callback: AsyncCallback<void>): void
| callback | AsyncCallback<void> | 是 | 异步改变文件权限之后的回调。 |
- 示例:
- ```
- fileio.chmod(path, mode, function (err) {
+ ```js
+ fileio.chmod(path, mode, function (err) {
+ // do something
});
```
@@ -922,7 +966,7 @@ chmodSync(path: string, mode: number): void
| mode | number | 是 | 改变文件权限,可给定如下权限,以按位或的方式追加权限。 - 0o700:所有者具有读、写及可执行权限。 - 0o400:所有者具有读权限。 - 0o200:所有者具有写权限。 - 0o100:所有者具有可执行权限。 - 0o070:所有用户组具有读、写及可执行权限。 - 0o040:所有用户组具有读权限。 - 0o020:所有用户组具有写权限。 - 0o010:所有用户组具有可执行权限。 - 0o007:其余用户具有读、写及可执行权限。 - 0o004:其余用户具有读权限。 - 0o002:其余用户具有写权限。 - 0o001:其余用户具有可执行权限。 |
- 示例:
- ```
+ ```js
fileio.chmodSync(fpath, mode);
```
@@ -944,8 +988,12 @@ fstat(fd: number): Promise<Stat>
| Promise<[Stat](#stat)> | 表示文件的具体信息。 |
- 示例:
- ```
- let stat = await fileio.fstat(fd);
+ ```js
+ fileio.fstat(fd).then(function(stat){
+ console.info("fstat successfully:"+ JSON.stringify(stat));
+ }).catch(function(err){
+ console.info("fstat failed with error:"+ err);
+ });
```
@@ -962,9 +1010,10 @@ fstat(fd: number, callback: AsyncCallback<Stat>): void
| callback | AsyncCallback<[Stat](#stat)> | 是 | 异步获取文件状态信息之后的回调。 |
- 示例:
- ```
+ ```js
let fd = fileio.openSync(path);
- fileio.fstat(fd, function (err) {
+ fileio.fstat(fd, function (err) {
+ // do something
});
```
@@ -986,7 +1035,7 @@ fstatSync(fd: number): Stat
| [Stat](#stat) | 表示文件的具体信息。 |
- 示例:
- ```
+ ```js
let fd = fileio.openSync(path);
let stat = fileio.fstatSync(fd);
```
@@ -1010,12 +1059,12 @@ ftruncate(fd: number, len: number): Promise<void>
| Promise<void> | Promise实例,用于异步获取结果。本调用将返回空值。 |
- 示例:
- ```
+ ```js
let fd = fileio.openSync(path);
- fileio.ftruncate(fd, 5)
- .then(function(err) {
- // 截断文件成功, do something
- }).catch(function(e){
+ fileio.ftruncate(fd, 5).then(function(err) {
+ console.info("truncate file successfully");
+ }).catch(function(err){
+ console.info("truncate file failed with error:"+ err);
});
```
@@ -1034,8 +1083,9 @@ ftruncate(fd: number, len: number, callback:AsyncCallback<void>): void
| callback | AsyncCallback<void> | 是 | 异步截断文件的信息之后的回调。 |
- 示例:
- ```
- fileio.ftruncate(fd, len, function(err){
+ ```js
+ fileio.ftruncate(fd, len, function(err){
+ // do something
});
```
@@ -1053,8 +1103,8 @@ ftruncateSync(fd: number, len?: number): void
| len | number | 否 | 文件截断后的长度,以字节为单位。 |
- 示例:
- ```
- fileio.ftruncate(fd, len);
+ ```js
+ fileio.ftruncate(fd, len);
```
@@ -1076,11 +1126,11 @@ truncate(path: string, len: number): Promise<void>
| Promise<void> | Promise实例,用于异步获取结果。本调用将返回空值。 |
- 示例:
- ```
- fileio.truncate(path, len)
- .then(function(err) {
- // 截断文件成功,do something
- }).catch(function(e){
+ ```js
+ fileio.truncate(path, len).then(function(){
+ console.info("truncate file successfully");
+ }).catch(function(err){
+ console.info("truncate file failed with error:"+ err);
});
```
@@ -1099,8 +1149,9 @@ truncate(path: string, len: number, callback:AsyncCallback<void>): void
| callback | AsyncCallback<void> | 是 | 异步截断文件的信息之后的回调。 |
- 示例:
- ```
- fileio.truncate(path, len, function(err){
+ ```js
+ fileio.truncate(path, len, function(err){
+ // do something
});
```
@@ -1118,7 +1169,7 @@ truncateSync(fpath: string, len?: number): void
| len | number | 否 | 文件截断后的长度,以字节为单位。 |
- 示例:
- ```
+ ```js
fileio.ftruncate(path, len);
```
@@ -1141,11 +1192,11 @@ readText(filePath: string, options?:Object): Promise<string>
| Promise<string> | 返回读取文件的内容。 |
- 示例:
- ```
- fileio.readText(path)
- .then(function(str) {
- // 读取文件成功,do something
- }).catch(function(e){
+ ```js
+ fileio.readText(path).then(function(str) {
+ console.info("readText successfully:"+ str);
+ }).catch(function(err){
+ console.info("readText failed with error:"+ err);
});
```
@@ -1164,8 +1215,9 @@ readText(filePath: string, options?:Object, callback:AsyncCallback<string>
| callback | AsyncCallback<string> | 是 | 异步通过文本方式读取文件之后的回调。 |
- 示例:
- ```
+ ```js
fileio.readText(path, function(err, str){
+ // do something
});
```
@@ -1188,8 +1240,8 @@ readTextSync(filePath: string, options?:Object): string
| Promise<string> | 返回读取文件的内容。 |
- 示例:
- ```
- let str = fileio.readTextSync(path, {position: pos, length: len});
+ ```js
+ let str = fileio.readTextSync(path, {position: 1, length: 3});
```
@@ -1210,8 +1262,12 @@ lstat(path: string): Promise<Stat>
| Promise<[Stat](#stat)> | 表示文件的具体信息。 |
- 示例:
- ```
- let stat = await fileio.lstat(path);
+ ```js
+ fileio.lstat(path).then(function(stat){
+ console.info("get link status successfully:"+ number);
+ }).catch(function(err){
+ console.info("get link status failed with error:"+ err);
+ });
```
@@ -1228,8 +1284,9 @@ lstat(path:string, callback:AsyncCallback<Stat>): void
| callback | AsyncCallback<[Stat](#stat)> | 是 | 异步获取链接状态信息之后的回调。 |
- 示例:
- ```
- fileio.lstat(path, function (err, stat) {
+ ```js
+ fileio.lstat(path, function (err, stat) {
+ // do something
));
```
@@ -1251,7 +1308,7 @@ lstatSync(path:string): Stat
| [Stat](#stat) | 表示文件的具体信息。 |
- 示例:
- ```
+ ```js
let stat = fileio.lstatSync(path);
```
@@ -1274,8 +1331,12 @@ read(buffer: ArrayBuffer, options?: Object): Promise<Readout>
| Promise<[Readout](#readout)> | 读取的结果。 |
- 示例:
- ```
- let readout = await fileio.read(new ArrayBuffer(4096));
+ ```js
+ fileio.read(new ArrayBuffer(4096)).then(function(readout){
+ console.info("read file data successfully:"+ String.fromCharCode.apply(null, new Uint8Array(readout.buffer)));
+ }).catch(function(err){
+ console.info("read file data failed with error:"+ err);
+ });
```
@@ -1293,7 +1354,7 @@ read(buffer: ArrayBuffer, options?: Object, callback: AsyncCallback<Readout&g
| callback | AsyncCallback<[Readout](#readout)> | 是 | 异步从文件读取数据之后的回调。 |
- 示例
- ```
+ ```js
let buf = new ArrayBuffer(4096);
fileio.read(buf, function (err, readOut) {
if (!err) {
@@ -1321,12 +1382,11 @@ rename(oldPath: string, newPath: string): Promise<void>
| Promise<void> | Promise实例,用于异步获取结果。本调用将返回空值。 |
- 示例:
- ```
- fileio.rename(oldPath, Newpath)
- .then(function(err) {
- // 重命名文件成功,do something
- }).catch(function(e){
-
+ ```js
+ fileio.rename(oldPath, Newpath).then(function() {
+ console.info("rename successfully");
+ }).catch(function(err){
+ console.info("rename failed with error:"+ err);
});
```
@@ -1345,7 +1405,7 @@ rename(oldPath: string, newPath: string, callback: AsyncCallback<void>): v
| Callback | AsyncCallback<void> | 是 | 异步重命名文件之后的回调。 |
- 示例:
- ```
+ ```js
fileio.rename(oldpath, Newpath, function(err){
});
```
@@ -1364,7 +1424,7 @@ renameSync(oldPath: string, newPath: string): void
| Newpath | String | 是 | 目标文件的新绝对路径。 |
- 示例:
- ```
+ ```js
fileio.renameSync(oldpath, newpath);
```
@@ -1386,8 +1446,12 @@ fsync(fd: number): Promise<void>
| Promise<void> | Promise实例,用于异步获取结果。本调用将返回空值。 |
- 示例:
- ```
- await fileio.fsync(fd);
+ ```js
+ fileio.fsync(fd).then(function(){
+ console.info("sync data successfully");
+ }).catch(function(err){
+ console.info("sync data failed with error:"+ err);
+ });
```
@@ -1404,8 +1468,9 @@ fsync(fd: number, callback: AsyncCallback<void>): void
| Callback | AsyncCallback<void> | 是 | 异步将文件数据同步之后的回调。 |
- 示例:
- ```
+ ```js
fileio.fsync(fd, function(err){
+ // do something
});
```
@@ -1422,7 +1487,7 @@ fsyncSync(fd: number): void
| fd | number | 是 | 待同步文件的文件描述符。 |
- 示例:
- ```
+ ```js
fileio.fyncsSync(fd);
```
@@ -1444,11 +1509,11 @@ fdatasync(fd: number): Promise<void>
| Promise<void> | Promise实例,用于异步获取结果,本调用将返回空值。 |
- 示例:
- ```
- fileio.fdatasync(fd)
- .then(function(err) {
- // 数据同步成功,do something
- }).catch(function(e){
+ ```js
+ fileio.fdatasync(fd).then(function(err) {
+ console.info("sync data successfully");
+ }).catch(function(err){
+ console.info("sync data failed with error:"+ err);
});
```
@@ -1466,8 +1531,9 @@ fdatasync(fd: number, callback:AsyncCallback<void>): void
| callback | AsyncCallback <void> | 是 | 异步将文件内容数据同步之后的回调。 |
- 示例:
- ```
+ ```js
fileio.fdatasync (fd, function (err) {
+ // do something
});
```
@@ -1484,7 +1550,7 @@ fdatasyncSync(fd: number): void
| fd | number | 是 | 待同步文件的文件描述符。 |
- 示例:
- ```
+ ```js
let stat = fileio.fdatasyncSync(fd);
```
@@ -1507,12 +1573,11 @@ symlink(target: string, srcPath: string): Promise<void>
| Promise<void> | Promise实例,用于异步获取结果,本调用将返回空值。 |
- 示例:
- ```
- fileio.symlink(target, srcPath)
- .then(function(err) {
- // 创建符号链接成功,do something
- }).catch(function(e){
-
+ ```js
+ fileio.symlink(target, srcPath).then(function() {
+ console.info("symlink successfully");
+ }).catch(function(err){
+ console.info("symlink failed with error:"+ err);
});
```
@@ -1531,8 +1596,9 @@ symlink(target: string, srcPath: string, callback: AsyncCallback<void>): v
| callback | AsyncCallback<void> | 是 | 异步创建符号链接信息之后的回调。 |
- 示例:
- ```
- fileio.symlink(target, srcPath, function (err) {
+ ```js
+ fileio.symlink(target, srcPath, function (err) {
+ // do something
});
```
@@ -1550,7 +1616,7 @@ symlinkSync(target: string, srcPath: string): void
| srcPath | string | 是 | 符号链接文件的绝对路径。 |
- 示例:
- ```
+ ```js
fileio.symlinkSync(target, srcPath);
```
@@ -1574,9 +1640,13 @@ chown(path: string, uid: number, gid: number): Promise<void>
| Promise<void> | Promise实例,用于异步获取结果,本调用将返回空值。 |
- 示例:
- ```
+ ```js
let stat = fileio.statSync(path);
- await fileio.chown(path, stat.uid, stat.gid));
+ fileio.chown(path, stat.uid, stat.gid)).then(function(){
+ console.info("chown successfully");
+ }).catch(function(err){
+ console.info("chown failed with error:"+ err);
+ });
```
@@ -1595,9 +1665,10 @@ chown(path: string, uid: number, gid: number, callback: AsyncCallback<void>
| callback | AsyncCallback<void> | 是 | 异步改变文件所有者之后的回调。 |
- 示例:
- ```
+ ```js
let stat = fileio.statSync(fpath)
fileio.chown(path, stat.uid, stat.gid, function (err){
+ // do something
});
```
@@ -1616,7 +1687,7 @@ chownSync(path: string, uid: number, gid: number): void
| gid | number | 是 | 新的GID。 |
- 示例:
- ```
+ ```js
let stat = fileio.statSync(fpath)
fileio.chownSync(path, stat.uid, stat.gid);
```
@@ -1639,8 +1710,12 @@ mkdtemp(prefix: string): Promise<string>
| Promise<string> | 生成的唯一目录路径。 |
- 示例:
- ```
- let res = await fileio.mkdtempSync(path + "XXXX");
+ ```js
+ fileio.mkdtemp(path + "XXXX").then(function(path){
+ console.info("mkdtemp successfully:"+ path);
+ }).catch(function(err){
+ console.info("mkdtemp failed with error:"+ err);
+ });
```
@@ -1657,8 +1732,9 @@ mkdtemp(prefix: string, callback: AsyncCallback<string>): void
| callback | AsyncCallback<string> | 是 | 异步创建临时目录之后的回调。 |
- 示例:
- ```
+ ```js
fileio.mkdtemp(path + "XXXX", function (err, res) {
+ // do something
});
```
@@ -1680,7 +1756,7 @@ mkdtempSync(prefix: string): string
| string | 产生的唯一目录路径。 |
- 示例:
- ```
+ ```js
let res = fileio.mkdtempSync(path + "XXXX");
```
@@ -1703,12 +1779,11 @@ fchmod(fd: number, mode: number): Promise<void>
| Promise<void> | Promise实例,用于异步获取结果,本调用将返回空值。 |
- 示例:
- ```
- fileio.fchmod(fd, mode)
- .then(function(err) {
- // 改变文件权限成功,do something
- }).catch(function(e){
-
+ ```js
+ fileio.fchmod(fd, mode).then(function() {
+ console.info("chmod successfully");
+ }).catch(function(err){
+ console.info("chmod failed with error:"+ err);
});
```
@@ -1727,8 +1802,9 @@ fchmod(fd: number, mode: number, callback: AsyncCallback<void>): void
| callback | AsyncCallback <void> | 是 | 异步改变文件权限之后的回调。 |
- 示例:
- ```
+ ```js
fileio.fchmod(fd, mode, function (err) {
+ // do something
});
```
@@ -1746,7 +1822,7 @@ fchmodSync(existingPath: string, newPath: string): void
| mode | number | 是 | 若创建文件,则指定文件的权限,可给定如下权限,以按位或的方式追加权限。 - 0o700:所有者具有读、写及可执行权限。 - 0o400:所有者具有读权限。 - 0o200:所有者具有写权限。 - 0o100:所有者具有可执行权限。 - 0o070:所有用户组具有读、写及可执行权限。 - 0o040:所有用户组具有读权限。 - 0o020:所有用户组具有写权限。 - 0o010:所有用户组具有可执行权限。 - 0o007:其余用户具有读、写及可执行权限。 - 0o004:其余用户具有读权限。 - 0o002:其余用户具有写权限。 - 0o001:其余用户具有可执行权限。 |
- 示例:
- ```
+ ```js
fileio.fchmodSync(fd, mode);
```
@@ -1769,8 +1845,12 @@ createStream(path: string, mode: string): Promise<Stream>
| Promise<[Stream](#stream7)> | 返回文件流的结果。 |
- 示例:
- ```
- let ss = filrio.createStream(path, "r+");
+ ```js
+ fileio.createStream(path, "r+").then(function(stream){
+ console.info("createStream successfully");
+ }).catch(function(err){
+ console.info("createStream failed with error:"+ err);
+ });
```
@@ -1788,8 +1868,9 @@ createStream(path: string, mode: string, callback: AsyncCallback<Stream>):
| callback | AsyncCallback<[Stream](#stream7)> | 是 | 异步打开文件流之后的回调。 |
- 示例:
- ```
- fileio.createStream(path, mode, function(err, stream){
+ ```js
+ fileio.createStream(path, mode, function(err, stream){
+ // do something
});
```
@@ -1812,7 +1893,7 @@ createStreamSync(path: string, mode: string): Stream
| [Stream](#stream7) | 返回文件流的结果。 |
- 示例:
- ```
+ ```js
let ss = fileio.createStreamSync(path, "r+");
```
@@ -1835,8 +1916,12 @@ fdopenStream(fd: number, mode: string): Promise<Stream>
| Promise<[Stream](#stream7)> | 返回文件流的结果。 |
- 示例:
- ```
- let fp = await fileio.fdopenStream(fd, mode);
+ ```js
+ fileio.fdopenStream(fd, mode).then(function(stream){
+ console.info("openStream successfully"+);
+ }).catch(function(err){
+ console.info("openStream failed with error:"+ err);
+ });
```
@@ -1854,8 +1939,9 @@ fdopenStream(fd: number, mode: string, callback: AsyncCallback<Stream>): v
| callback | AsyncCallback <[Stream](#stream7)> | 是 | 异步打开文件流之后的回调。 |
- 示例:
- ```
- fileio.fdopenStream(fd, mode, function (err, fp) {
+ ```js
+ fileio.fdopenStream(fd, mode, function (err, stream) {
+ // do something
});
```
@@ -1878,7 +1964,7 @@ fdopenStreamSync(fd: number, mode: string): Stream
| [Stream](#stream7) | 返回文件流的结果。 |
- 示例:
- ```
+ ```js
let ss = fileio.fdopenStreamSync(fd, "r+");
```
@@ -1902,13 +1988,12 @@ fchown(fd: number, uid: number, gid: number): Promise<void>
| Promise<void> | Promise实例,用于异步获取结果。本调用将返回空值。 |
- 示例:
- ```
+ ```js
let stat = fileio.statSync(path);
- fileio.fchown(fd, stat.uid, stat.gid)
- .then(function(err) {
- // 改变文件所有者成功,do something
- }).catch(function(e){
-
+ fileio.fchown(fd, stat.uid, stat.gid).then(function() {
+ console.info("chown successfully");
+ }).catch(function(err){
+ console.info("chown failed with error:"+ err);
});
```
@@ -1928,9 +2013,10 @@ fchown(fd: number, uid: number, gid: number, callback: AsyncCallback<void>
| callback | AsyncCallback<void> | 是 | 异步改变文件所有者之后的回调。 |
- 示例:
- ```
+ ```js
let stat = fileio.statSync(fpath);
fileio.fchown(fd, stat.uid, stat.gid, function (err){
+ // do something
});
```
@@ -1949,7 +2035,7 @@ fchownSync(fd: number, uid: number, gid: number): void
| gid | number | 是 | 文件所有组的GID。 |
- 示例:
- ```
+ ```js
let stat = fileio.statSync(fpath);
fileio.fchownSync(fd, stat.uid, stat.gid);
```
@@ -1974,14 +2060,13 @@ lchown(path: string, uid: number, gid: number): Promise<void>
| Promise<void> | Promise实例,用于异步获取结果。本调用将返回空值。 |
- 示例:
- ```
+ ```js
let stat = fileio.statSync(path);
- fileio.lchown(path, stat.uid, stat.gid)
- .then(function(err) {
- // 改变文件所有者,do something
- }).catch(function(e){
-
- });
+ fileio.lchown(path, stat.uid, stat.gid).then(function() {
+ console.info("chown successfully");
+ }).catch(function(err){
+ console.info("chown failed with error:"+ err);
+ });
```
@@ -2000,9 +2085,10 @@ lchown(path: string, uid: number, gid: number, callback: AsyncCallback<void&g
| callback | AsyncCallback<void> | 是 | 异步改变文件所有者之后的回调。 |
- 示例:
- ```
+ ```js
let stat = fileio.statSync(path);
fileio.lchown(path, stat.uid, stat.gid, function (err){
+ // do something
});
```
@@ -2021,7 +2107,7 @@ lchownSync(path: string, uid: number, gid: number): void
| gid | number | 是 | 新的GID。 |
- 示例:
- ```
+ ```js
let stat = fileio.statSync(path);
fileio.lchownSync(path, stat.uid, stat.gid);
```
@@ -2046,8 +2132,9 @@ createWatcher(filename: string, events: number, callback: AsyncCallback<numbe
| [Watcher](#watcher7) | 文件变化监听的实例。 |
- 示例:
- ```
- let ob = await fileio.createWatcher(filename, events, function(event){
+ ```js
+ fileio.createWatcher(filename, events, function(watcher){
+ // do something
});
```
@@ -2098,7 +2185,7 @@ isBlockDevice(): boolean
| boolean | 表示当前目录项是否是块特殊设备。 |
- 示例:
- ```
+ ```js
let isBLockDevice = fileio.statSync(path).isBlockDevice();
```
@@ -2115,7 +2202,7 @@ isCharacterDevice(): boolean
| boolean | 表示当前目录项是否是字符特殊设备。 |
- 示例:
- ```
+ ```js
let isCharacterDevice = fileio.statSync(path).isCharacterDevice();
```
@@ -2132,7 +2219,7 @@ isDirectory(): boolean
| boolean | 表示当前目录项是否是目录。 |
- 示例:
- ```
+ ```js
let isDirectory = fileio.statSync(path).isDirectory();
```
@@ -2149,7 +2236,7 @@ isFIFO(): boolean
| boolean | 表示当前目录项是否是 FIFO。 |
- 示例:
- ```
+ ```js
let isFIFO = fileio.statSync(path).isFIFO();
```
@@ -2166,7 +2253,7 @@ isFile(): boolean
| boolean | 表示当前目录项是否是普通文件。 |
- 示例:
- ```
+ ```js
let isFile = fileio.statSync(fpath).isFile();
```
@@ -2183,7 +2270,7 @@ isSocket(): boolean
| boolean | 表示当前目录项是否是套接字。 |
- 示例:
- ```
+ ```js
let isSocket = fileio.statSync(path).isSocket();
```
@@ -2200,7 +2287,7 @@ isSymbolicLink(): boolean
| boolean | 表示当前目录项是否是符号链接。 |
- 示例:
- ```
+ ```js
let isSymbolicLink = fileio.statSync(path).isSymbolicLink();
```
@@ -2217,7 +2304,7 @@ stop(): void
以异步方法关闭watcher监听,使用promise形式返回结果。
- 示例:
- ```
+ ```js
fileio.stop();
```
@@ -2234,8 +2321,9 @@ stop(callback: AsyncCallback): void
| callback | AsyncCallback<void> | 是 | 以异步方法关闭watcher监听之后的回调。 |
- 示例:
- ```
+ ```js
fileio.stop(function(err){
+ // do something
});
```
@@ -2257,9 +2345,13 @@ close(): Promise<void>
| Promise<void> | 表示异步关闭文件流的结果。 |
- 示例:
- ```
+ ```js
let ss= fileio.createStreamSync(path);
- await ss.close();
+ ss.close().then(function(){
+ console.info("close fileStream successfully");
+ }).catch(function(err){
+ console.info("close fileStream failed with error:"+ err);
+ });
```
@@ -2275,9 +2367,10 @@ close(callback: AsyncCallback<void>): void
| callback | AsyncCallback<void> | 是 | 异步关闭文件流之后的回调。 |
- 示例:
- ```
+ ```js
let ss= fileio.createStreamSync(path);
ss.close(function (err) {
+ // do something
});
```
@@ -2289,7 +2382,7 @@ closeSync(): void
同步关闭文件流。
- 示例:
- ```
+ ```js
let ss= fileio.createStreamSync(path);
ss.closeSync();
```
@@ -2307,9 +2400,13 @@ flush(): Promise<void>
| Promise<void> | 表示异步刷新文件流的结果。 |
- 示例:
- ```
+ ```js
let ss= fileio.createStreamSync(path);
- await ss.flush();
+ ss.flush().then(function (){
+ console.info("flush successfully");
+ }).catch(function(err){
+ console.info("flush failed with error:"+ err);
+ });
```
@@ -2325,10 +2422,10 @@ flush(callback: AsyncCallback<void>): void
| callback | AsyncCallback<void> | 是 | 异步刷新文件流后的回调函数。 |
- 示例:
- ```
+ ```js
let ss= fileio.createStreamSync(path);
ss.flush(function (err) {
- expect(fileio.unlinkSync(fpath)).assertNull();
+ // do something
});
```
@@ -2340,7 +2437,7 @@ flushSync(): void
同步刷新文件流。
- 示例:
- ```
+ ```js
let ss= fileio.createStreamSync(path);
ss.flushSync();
```
@@ -2364,9 +2461,13 @@ write(buffer: ArrayBuffer | string, options?: Object): Promise<number>
| Promise<number> | 实际写入的长度。 |
- 示例:
- ```
+ ```js
let ss= fileio.createStreamSync(fpath, "r+");
- let num = await ss.write("hello, world",{offset: 1,length: 5,position: 5,encoding :'utf-8'});
+ ss.write("hello, world",{offset: 1,length: 5,position: 5,encoding :'utf-8'}).then(function (number){
+ console.info("write successfully:"+ number);
+ }).catch(function(err){
+ console.info("write failed with error:"+ err);
+ });
```
@@ -2384,11 +2485,12 @@ write(buffer:ArrayBuffer | string,options?:Object, callback:AsyncCallback<num
| callback | AsyncCallback<number> | 是 | 异步写入完成后执行的回调函数。 |
- 示例:
- ```
+ ```js
let ss= fileio.createStreamSync(fpath, "r+");
ss.write("hello, world", {offset: 1, length: 5, position: 5, encoding :'utf-8'}, function (err, bytesWritten) {
if (!err) {
- console.log(bytesWritten)
+ // do something
+ console.log(bytesWritten);
}
});
```
@@ -2412,7 +2514,7 @@ writeSync(buffer: ArrayBuffer | string, options?:Object): number
| number | 实际写入的长度。 |
- 示例:
- ```
+ ```js
let ss= fileio.createStreamSync(fpath,"r+");
let num = ss.writeSync("hello, world", {offset: 1, length: 5, position: 5, encoding :'utf-8'});
```
@@ -2436,9 +2538,13 @@ read(buffer: ArrayBuffer, options?: Object): Promise<Readout>
| Promise<[Readout](#readout)> | 读取的结果。 |
- 示例:
- ```
+ ```js
let ss = fileio.createStreamSync(fpath, "r+");
- let readOut = await ss.read(new ArrayBuffer(4096), {offset: 1, length: 5, position: 5});
+ ss.read(new ArrayBuffer(4096), {offset: 1, length: 5, position: 5}).then(function (readout){
+ console.info("read data successfully");
+ }).catch(function(err){
+ console.info("read data failed with error:"+ err);
+ });
```
@@ -2456,11 +2562,11 @@ read(buffer: ArrayBuffer, options?: Object, callback: AsyncCallback<Readout&g
| callback | AsyncCallback<[Readout](#readout)> | 是 | 异步从流文件读取数据之后的回调。 |
- 示例:
- ```
+ ```js
let ss = fileio.createStreamSync(fpath, "r+");
ss.read(new ArrayBuffer(4096),{offset: 1, length: 5, position: 5},function (err, readOut) {
if (!err) {
- console.log(readOut)
+ // do something
}
});
```
@@ -2484,7 +2590,7 @@ readSync(buffer: ArrayBuffer, options?: Object): number
| number | 实际读取的长度。 |
- 示例:
- ```
+ ```js
let ss = fileio.createStreamSync(fpath, "r+");
let num = ss.readSync(new ArrayBuffer(4096), {offset: 1, length: 5, position: 5});
```
@@ -2507,9 +2613,13 @@ read(): Promise<Dirent>
| Promise<[Dirent](#dirent)> | 表示异步读取目录项的结果。 |
- 示例:
- ```
+ ```js
let dir = fileio.opendirSync(dpath);
- let dirent = await dir.read();
+ dir.read().then(function (dirent){
+ console.info("read successfully:"+ dirent.name);
+ }).catch(function(err){
+ console.info("read failed with error:"+ err);
+ });
```
@@ -2525,10 +2635,11 @@ read(callback: AsyncCallback<Dirent>): void
| callback | AsyncCallback<[Dirent](#dirent)> | 是 | 异步读取下一个目录项之后的回调。 |
- 示例:
- ```
+ ```js
let dir = fileio.opendirSync(dpath);
dir.read(function (err, dirent) {
if (!err) {
+ // do something
console.log(dirent.name)
}
});
@@ -2547,7 +2658,7 @@ readSync(): Dirent
| [Dirent](#dirent) | 表示一个目录项。 |
- 示例:
- ```
+ ```js
let dir = fileio.opendirSync(dpath);
let dirent = dir.readSync();
```
@@ -2560,7 +2671,7 @@ closeSync(): void
用于关闭目录。目录被关闭后,Dir中持有的文件描述将被释放,后续将无法从Dir中读取目录项。
- 示例:
- ```
+ ```js
let dir = fileio.opendirSync(dpath);
dir.closeSync();
```
@@ -2590,7 +2701,7 @@ isBlockDevice(): boolean
| boolean | 表示当前目录项是否是块特殊设备。 |
- 示例:
- ```
+ ```js
let dir = fileio.opendirSync(dpath);
let isBLockDevice = dir.readSync().isBlockDevice();
```
@@ -2608,7 +2719,7 @@ isCharacterDevice(): boolean
| boolean | 表示当前目录项是否是字符特殊设备。 |
- 示例:
- ```
+ ```js
let dir = fileio.opendirSync(dpath);
let isCharacterDevice = dir.readSync().isCharacterDevice();
```
@@ -2626,7 +2737,7 @@ isDirectory(): boolean
| boolean | 表示当前目录项是否是目录。 |
- 示例:
- ```
+ ```js
let dir = fileio.opendirSync(dpath);
let isDirectory = dir.readSync().isDirectory();
```
@@ -2644,7 +2755,7 @@ isFIFO(): boolean
| boolean | 表示当前目录项是否是FIFO。 |
- 示例:
- ```
+ ```js
let dir = fileio.opendirSync(dpath);
let isFIFO = dir.readSync().isFIFO();
```
@@ -2662,7 +2773,7 @@ isFile(): boolean
| boolean | 表示当前目录项是否是普通文件。 |
- 示例:
- ```
+ ```js
let dir = fileio.opendirSync(dpath);
let isFile = dir.readSync().isFile();
```
@@ -2680,7 +2791,7 @@ isSocket(): boolean
| boolean | 表示当前目录项是否是套接字。 |
- 示例:
- ```
+ ```js
let dir = fileio.opendirSync(dpath);
let isSocket = dir.readSync().isSocket();
```
@@ -2698,7 +2809,7 @@ isSymbolicLink(): boolean
| boolean | 表示当前目录项是否是符号链接。 |
- 示例:
- ```
+ ```js
let dir = fileio.opendirSync(dpath);
let isSymbolicLink = dir.readSync().isSymbolicLink();
```
diff --git a/zh-cn/application-dev/reference/apis/js-apis-filemanager.md b/zh-cn/application-dev/reference/apis/js-apis-filemanager.md
index 897f1063eadeedf1ce2acfbb392f85139d4e959a..5c520aef02ef740eb995f5deaaf250815dd969c6 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-filemanager.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-filemanager.md
@@ -1,16 +1,18 @@
# 公共文件访问与管理
-
+> **说明:**
+>本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块
-```
-import filemanager from 'ohos.filemanager'
+```js
+import filemanager from 'ohos.filemanager';
```
-## 权限
+## 系统能力
-应用需要拥有SystemCapability.FileManagement.FileManagerService权限
+SystemCapability.FileManagement.FileManagerService
## filemanager.getRoot
+
getRoot(options? : {dev? : DevInfo}) : Promise<FileInfo[]>
以异步方法获取第一层相册,目录信息。使用promise形式返回结果。
@@ -18,28 +20,26 @@ getRoot(options? : {dev? : DevInfo}) : Promise<FileInfo[]>
- 参数
| 参数名 | 类型 | 必填 | 说明 |
| --- | --- | --- | -- |
- | dev | DevInfo | 否 | 设备名, 当前仅支持设备'local' |
+ | dev | [DevInfo](#devinfo) | 否 | 设备名, 不填为默认值dev = {name: "local"}, 当前仅支持设备'local' |
- 返回值
| 类型 | 说明 |
| --- | -- |
- | Promise<FileInfo[]> | 第一层目录相册信息 |
+ | Promise<[FileInfo](#fileinfo)[]> | 第一层目录相册信息 |
- 示例
```js
-filemanager.getRoot()
-.then((fileInfo) => {
+filemanager.getRoot().then((fileInfo) => {
if(Array.isArray(fileInfo)) {
for (var i = 0; i < fileInfo.length; i++) {
console.log(JSON.Stringify(fileInfo))
}
}
-})
-.catch((err) => {
+}).catch((err) => {
console.log(err)
-})
+});
```
## filemanager.getRoot
@@ -52,8 +52,8 @@ getRoot(options? : {dev? : DevInfo}, callback : AsyncCallback<FileInfo[]>)
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | ----------------------------- |
- | dev | DevInfo | 否 | 设备名, 当前仅支持设备'local' |
- | callback | AsyncCallback<FileInfo[]> | 是 | 异步获取文件的信息之后的回调 |
+ | dev | [DevInfo](#devinfo) | 否 | 设备名, 不填为默认值dev = {name: "local"}, 当前仅支持设备'local' |
+ | callback | AsyncCallback<[FileInfo](#fileinfo)[]> | 是 | 异步获取文件的信息之后的回调 |
- 示例
@@ -78,10 +78,10 @@ listFile(path : string, type : string, options? : {dev? : DevInfo, offset? : num
| --- | --- | --- | -- |
| type | string | 是 | 待查询文件类型, 支持以下类型 "file", "image", "audio", "video" |
| path | string | 是 | 待查询目录uri |
- | dev | DevInfo | 是 | 设备名, 当前仅支持设备'local' |
+ | dev | [DevInfo](#devinfo) | 是 | 设备名, 不填为默认值dev = {name: "local"}, 当前仅支持设备'local' |
| offset | number | 否 | 待查询文件偏移 |
| count | number | 否 | 待查询文件个数 |
-
+
- 返回值
| 类型 | 说明 |
@@ -123,10 +123,10 @@ listFile(path : string, type : string, options? : {dev? : DevInfo, offset? : num
| -------- | ------------------------- | ---- | ------------------------------------------------------------ |
| type | string | 是 | 待查询文件类型, 支持以下类型 "file", "image", "audio", "video" |
| path | string | 是 | 待查询目录uri |
- | dev | DevInfo | 否 | 设备名, 当前仅支持设备'local' |
+ | dev | [DevInfo](#devinfo) | 否 | 设备名, 不填为默认值dev = {name: "local"}, 当前仅支持设备'local' |
| offset | number | 否 | 待查询文件偏移 |
| count | number | 否 | 待查询文件个数 |
- | callback | AsyncCallback<FileInfo[]> | 是 | 异步获取文件的信息之后的回调 |
+ | callback | AsyncCallback<[FileInfo](#fileinfo)[]> | 是 | 异步获取文件的信息之后的回调 |
- 异常
| 错误名称 | 错误类型 | 错误码 | 说明 |
@@ -158,7 +158,7 @@ filemanager.createFile(path : string, filename : string, options? : {dev? : DevI
| --- | --- | --- | -- |
| filename | string | 是 | 待创建的文件名 |
| path | string | 是 | 待保存目的相册uri |
- | dev | DevInfo | 否 | 设备名, 当前仅支持设备'local' |
+ | dev | [DevInfo](#devinfo) | 否 | 设备名, 不填为默认值dev = {name: "local"}, 当前仅支持设备'local' |
- 返回值
@@ -199,8 +199,8 @@ createFile(path : string, filename: string, options? : {dev? : DevInfo}, callbac
| -------- | ------------------------- | ---- | ----------------------------- |
| filename | string | 是 | 待创建的文件名 |
| path | string | 是 | 待保存目的相册uri |
- | dev | DevInfo | 否 | 设备名, 当前仅支持设备'local' |
- | callback | AsyncCallback<FileInfo[]> | 是 | 异步获取文件的信息之后的回调 |
+ | dev | [DevInfo](#devinfo) | 否 | 设备名, 不填为默认值dev = {name: "local"}, 当前仅支持设备'local' |
+ | callback | AsyncCallback<[FileInfo](#fileinfo)[]> | 是 | 异步获取文件的信息之后的回调 |
- 异常
@@ -225,6 +225,8 @@ filemanager.createFile(media_path, name, (err, uri) => {
## FileInfo
文件信息类型,通过getRoot, listFile等接口返回的类型。
+### 属性
+
| 参数名 | 类型 | 可读 | 可写 | 说明 |
| --- | -- | -- | -- | -- |
| name | string | 是 | 否 | 文件名称 |
@@ -237,6 +239,8 @@ filemanager.createFile(media_path, name, (err, uri) => {
## DevInfo
设备类型,配置接口访问的设备类型。
+### 属性
+
| 参数名 | 类型 | 可读 | 可写 | 说明 |
| --- | -- | -- | -- | -- |
| name | string | 是 | 是 | 设备名称 |
\ No newline at end of file
diff --git a/zh-cn/application-dev/reference/apis/js-apis-hashmap.md b/zh-cn/application-dev/reference/apis/js-apis-hashmap.md
new file mode 100644
index 0000000000000000000000000000000000000000..751642a8acf530c77a123ecedf14d96d947e14a1
--- /dev/null
+++ b/zh-cn/application-dev/reference/apis/js-apis-hashmap.md
@@ -0,0 +1,380 @@
+# 非线性容器HashMap
+
+>  **说明:**
+> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
+
+
+## 导入模块
+
+```
+import HashMap from '@ohos.util.HashMap'
+```
+
+
+## 权限
+
+无
+
+## HashMap
+
+
+### 属性
+
+| 名称 | 参数类型 | 可读 | 可写 | 说明 |
+| -------- | -------- | -------- | -------- | -------- |
+| length | number | 是 | 否 | HashMap的元素个数 |
+
+
+### constructor
+
+constructor();
+
+HashMap的构造函数。
+
+- 示例:
+ ```
+ let hashMap = new HashMap();
+ ```
+
+
+### isEmpty
+
+isEmpty(): boolean;
+
+判断该HashMap是否为空。
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | boolean | 为空返回true, 不为空返回false |
+
+- 示例:
+ ```
+ const hashMap = new HashMap();
+ hashMap.isEmpty();
+ ```
+
+
+### hasKey
+
+hasKey(key: K): boolean;
+
+判断此HashMap中是否含有该指定key。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | key | K | 是 | 指定元素 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | boolean | 是否包含指定元素 |
+
+- 示例:
+ ```
+ let hashMap = new HashMap();
+ hashMap.hasKey("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
+ hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
+ hashMap.hasKey("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
+ ```
+
+
+### hasValue
+
+hasValue(value: V): boolean;
+
+判断此HashMap中是否含有该指定value。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | value | V | 是 | 指定元素 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | boolean | 是否包含指定元素 |
+
+- 示例:
+ ```
+ let hashMap = new HashMap();
+ hashMap.hasValue(123);
+ hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
+ hashMap.hasValue(123);
+ ```
+
+
+### get
+
+get(key: K): V;
+
+获取指定key所对应的value。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | key | K | 是 | 查找的指定key |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | V | 返回key映射的value值 |
+
+- 示例:
+ ```
+ let hashMap = new HashMap();
+ hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
+ hashMap.set("sdfs", 356);
+ hashMap.get("sdfs");
+ ```
+
+
+### setAll
+
+setAll(map: HashMap): void;
+
+将一个HashMap中的所有元素组添加到另一个hashmap中。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | map | HashMap | 是 | 被添加元素的hashmap |
+
+- 示例:
+ ```
+ let hashMap = new HashMap();
+ hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
+ hashMap.set("sdfs", 356);
+ let newHashMap = new HashMap();
+ hashMap.setAll(newHashMap);
+ ```
+
+
+### set
+
+set(key: K, value: V): Object;
+
+向HashMap中添加一组数据。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | key | K | 是 | 添加成员数据的键名 |
+ | value | V | 是 | 添加成员数据的值 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | Object | 返回添加后的hashmap |
+
+- 示例:
+ ```
+ let hashMap = new HashMap();
+ hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
+ ```
+
+
+### remove
+
+remove(key: K): V;
+
+删除指定的元素。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | key | K | 是 | 依据key指定删除的元素 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | V | 返回删除元素的值 |
+
+- 示例:
+ ```
+ let hashMap = new HashMap();
+ hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
+ hashMap.set("sdfs", 356);
+ hashMap.remove("sdfs");
+ ```
+
+
+### clear
+
+clear(): void;
+
+清除HashMap中的所有元素,并把length置为0。
+
+- 示例:
+ ```
+ let hashMap = new HashMap();
+ hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
+ hashMap.set("sdfs", 356);
+ hashMap.clear();
+ ```
+
+
+### keys
+
+keys(): IterableIterator<K>;
+
+返回包含此映射中包含的键的新迭代器对象。
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | IterableIterator<K> | 返回一个迭代器 |
+
+- 示例:
+ ```
+ let hashMap = new HashMap();
+ hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
+ hashMap.set("sdfs", 356);
+ let iter = hashMap.keys();
+ let temp = iter.next().value;
+ while(temp != undefined) {
+ console.log(temp);
+ temp = iter.next().value;
+ }
+ ```
+
+
+### values
+
+values(): IterableIterator<V>;
+
+返回包含此映射中包含的键的新迭代器对象。
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | IterableIterator<V> | 返回一个迭代器 |
+
+- 示例:
+ ```
+ let hashMap = new HashMap();
+ hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
+ hashMap.set("sdfs", 356);
+ let iter = hashMap.values();
+ let temp = iter.next().value;
+ while(temp != undefined) {
+ console.log(temp);
+ temp = iter.next().value;
+ }
+ ```
+
+
+### replace
+
+replace(key: K, value: V): boolean;
+
+对HashMap中一组数据进行更新(替换)。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | key | K | 是 | 依据key指定替换的元素 |
+ | value | V | 是 | 添加成员数据的值 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | boolean | 是否成功对已有数据进行替换 |
+
+- 示例:
+ ```
+ let hashMap = new HashMap();
+ hashMap.set("sdfs", 123);
+ hashMap.replace("sdfs", 357);
+ ```
+
+
+### forEach
+
+forEach(callbackfn: (value: V, key?: K, hashMap?: HashMap) => void, thisArg?: Object): void;
+
+通过回调函数来遍历HashMap实例对象上的元素以及元素对应的下标。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | callbackfn | function | 是 | 回调函数 |
+ | thisArg | Object | 否 | callbackfn被调用时用作this值 |
+
+- callbackfn的参数说明
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | value | V | 是 | 当前遍历到的元素键值对的值 |
+ | key | K | 是 | 当前遍历到的元素键值对的键 |
+ | hashMap | HashMap | 否 | 当前调用forEach方法的实例对象 |
+
+- 示例:
+ ```
+ let hashMap = new HashMap();
+ hashMap.set("sdfs", 123);
+ hashMap.set("dfsghsf", 357);
+ hashMap.forEach((value, key) => {
+ console.log(value, key);
+ });
+ ```
+
+
+### entries
+
+entries(): IterableIterator<[K, V]>;
+
+返回包含此映射中包含的键的新迭代器对象。
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | IterableIterator<[K, V]> | 返回一个迭代器 |
+
+- 示例:
+ ```
+ let hashMap = new HashMap();
+ hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
+ hashMap.set("sdfs", 356);
+ let iter = hashMap.entries();
+ let temp = iter.next().value;
+ while(temp != undefined) {
+ console.log(temp[0]);
+ console.log(temp[1]);
+ temp = iter.next().value;
+ }
+ ```
+
+
+### [Symbol.iterator]
+
+[Symbol.iterator]\(): IterableIterator<[K, V]>;
+
+返回一个迭代器,迭代器的每一项都是一个 JavaScript 对象,并返回该对象。
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | IterableIterator<[K, V]> | 返回一个迭代器 |
+
+- 示例:
+ ```
+ let hashMap = new HashMap();
+ hashMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
+ hashMap.set("sdfs", 356);
+
+ // 使用方法一:
+ for (let item of hashMap) {
+ console.log("key: " + item[0]);
+ console.log("value: " + item[1]);
+ }
+
+ // 使用方法二:
+ let iter = hashMap[Symbol.iterator]();
+ let temp = iter.next().value;
+ while(temp != undefined) {
+ console.log(temp[0]);
+ console.log(temp[1]);
+ temp = iter.next().value;
+ }
+ ```
\ No newline at end of file
diff --git a/zh-cn/application-dev/reference/apis/js-apis-hashset.md b/zh-cn/application-dev/reference/apis/js-apis-hashset.md
new file mode 100644
index 0000000000000000000000000000000000000000..3589c8fdb1e8607152ee2e57e0a070b594ca3345
--- /dev/null
+++ b/zh-cn/application-dev/reference/apis/js-apis-hashset.md
@@ -0,0 +1,255 @@
+# 非线性容器HashSet
+
+>  **说明:**
+> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
+
+
+## 导入模块
+
+```
+import HashSet from '@ohos.util.HashSet';
+```
+
+## 权限
+
+无
+
+## HashSet
+
+
+### 属性
+
+| 名称 | 参数类型 | 可读 | 可写 | 说明 |
+| -------- | -------- | -------- | -------- | -------- |
+| length | number | 是 | 否 | HashSet的元素个数 |
+
+
+### constructor
+
+constructor();
+
+HashSet的构造函数。
+
+- 示例:
+ ```
+ let hashSet = new HashSet();
+ ```
+
+
+### isEmpty
+
+isEmpty(): boolean;
+
+判断该HashSet是否为空。
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | boolean | 为空返回true, 不为空返回false |
+
+- 示例:
+ ```
+ const hashSet = new HashSet();
+ hashSet.isEmpty();
+ ```
+
+
+### has
+
+has(value: T): boolean;
+
+判断此HashSet中是否含有该指定key。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | value | T | 是 | 指定元素 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | boolean | 是否包含指定元素 |
+
+- 示例:
+ ```
+ let hashSet = new HashSet();
+ hashSet.has("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
+ hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
+ hashSet.has("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
+ ```
+
+
+### add
+
+add(value: T): boolean;
+
+向HashSet中添加数据。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | value | T | 是 | 添加成员数据 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | boolean | 返回是否有成功增加元素 |
+
+- 示例:
+ ```
+ let hashSet = new HashSet();
+ hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
+ ```
+
+
+### remove
+
+remove(value: T): boolean;
+
+删除指定的元素。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | value | T | 是 | 指定删除的元素 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | boolean | 返回是否成功删除指定元素 |
+
+- 示例:
+ ```
+ let hashSet = new HashSet();
+ hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
+ hashSet.add("sdfs");
+ hashSet.remove("sdfs");
+ ```
+
+
+### clear
+
+clear(): void;
+
+清除HashSet中的所有元素,并把length置为0。
+
+- 示例:
+ ```
+ let hashSet = new HashSet();
+ hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
+ hashSet.add("sdfs");
+ hashSet.clear();
+ ```
+
+
+### values
+
+values(): IterableIterator<T>;
+
+返回包含此映射中包含的键的新迭代器对象。
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | IterableIterator<T> | 返回一个迭代器 |
+
+- 示例:
+ ```
+ let hashSet = new HashSet();
+ hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
+ hashSet.add("sdfs");
+ let iter = hashSet.values();
+ let temp = iter.next().value;
+ while(temp != undefined) {
+ console.log(temp);
+ temp = iter.next().value;
+ }
+ ```
+
+
+### forEach
+
+forEach(callbackfn: (value: T, key?: T, hashSet?: HashSet<T>) => void, thisArg?: Object): void;
+
+通过回调函数来遍历实例对象上的元素以及元素对应的下标。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | callbackfn | function | 是 | 回调函数 |
+ | thisArg | Object | 否 | callbackfn被调用时用作this值 |
+
+- callbackfn的参数说明
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | value | T | 是 | 当前遍历到的元素键值对的值 |
+ | key | T | 否 | 当前遍历到的元素键值对的值(和value相同) |
+ | hashSet | HashSet<T> | 否 | 当前调用forEach方法的实例对象 |
+
+
+- 示例:
+ ```
+ let hashSet = new HashSet();
+ hashSet.add("sdfs");
+ hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
+ hashSet.forEach((value, key) => {
+ console.log(value, key);
+ });
+ ```
+
+
+### entries
+entries(): IterableIterator<[T, T]>;
+
+返回包含此映射中包含的键的新迭代器对象。
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | IterableIterator<[T, T]> | 返回一个迭代器 |
+
+- 示例:
+ ```
+ let hashSet = new HashSet();
+ hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
+ hashSet.add("sdfs");
+ let iter = hashSet.entries();
+ let temp = iter.next().value;
+ while(temp != undefined) {
+ console.log(temp[0]);
+ console.log(temp[1]);
+ temp = iter.next().value;
+ }
+ ```
+
+
+### [Symbol.iterator]
+
+[Symbol.iterator]\(): IterableIterator<T>;
+
+返回一个迭代器,迭代器的每一项都是一个 JavaScript 对象,并返回该对象。
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | IterableIterator<T> | 返回一个迭代器 |
+
+- 示例:
+ ```
+ let hashSet = new HashSet();
+ hashSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
+ hashSet.add("sdfs");
+
+ // 使用方法一:
+ for (let item of hashSet) {
+ console.log("value: " + item);
+ }
+
+ // 使用方法二:
+ let iter = hashSet[Symbol.iterator]();
+ let temp = iter.next().value;
+ while(temp != undefined) {
+ console.log(temp);
+ temp = iter.next().value;
+ }
+ ```
\ No newline at end of file
diff --git a/zh-cn/application-dev/reference/apis/js-apis-hiappevent.md b/zh-cn/application-dev/reference/apis/js-apis-hiappevent.md
index e0d5f8e146e5df63023b67a078e0c7d5edcb34a3..aec3024d35bcb5205f7d72e7a8bbb35de7b1453c 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-hiappevent.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-hiappevent.md
@@ -11,9 +11,9 @@ import hiAppEvent from '@ohos.hiAppEvent';
```
-## 权限
+## 系统能力
-无
+SystemCapability.HiviewDFX.HiAppEvent
## hiAppEvent.write
diff --git a/zh-cn/application-dev/reference/apis/js-apis-hilog.md b/zh-cn/application-dev/reference/apis/js-apis-hilog.md
new file mode 100644
index 0000000000000000000000000000000000000000..10809a70e6554b60481195dc90894f9adea1f896
--- /dev/null
+++ b/zh-cn/application-dev/reference/apis/js-apis-hilog.md
@@ -0,0 +1,182 @@
+# 日志打印
+
+> **说明:**
+>
+> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
+
+## 导入模块
+
+```
+import hilog from '@ohos.hilog';
+```
+
+## 系统能力
+
+SystemCapability.HiviewDFX.HiLog
+
+## hilog.debug
+
+debug(domain: number, tag: string, format: string, ...args: any[]) : void
+
+debug日志输出,打印debug级别日志。
+
+**参数:**
+
+| 参数名 | 类型 | 必填 | 说明 |
+| ------ | -------------- | ---- | ------------------------------------------------------------ |
+| domain | number | 是 | 业务领域。范围0x0~0xFFFFF。 |
+| tag | string | 是 | 字符串常量,标识调用所在的类或者业务行为。 |
+| format | string | 是 | 格式字符串,包含参数类型、隐私标识。未加隐私标识的缺省为隐私参数。 |
+| args | any[] | 是 | 与格式字符串里参数类型对应的可变长度参数列表。参数数目、参数类型必须与格式字符串中的标识一一对应。 |
+
+**示例:**
+
+```
+hilog.debug(0xFF00, "testTag", "%d: %{private}s World %{public}f", 1, "hello", 3.0);
+```
+
+**输出:**
+
+```
+09-08 12:49:35.941 1547 2452 D FF00/testTag: 1: hello World 3.0
+```
+
+## **hilog.info**
+
+info(domain: number, tag: string, format: string, ...args: any[]) : void
+
+info日志输出,打印info级别日志。
+
+**参数:**
+
+| 参数名 | 类型 | 必填 | 说明 |
+| ------ | -------------- | ---- | ------------------------------------------------------------ |
+| domain | number | 是 | 业务领域。范围0x0~0xFFFFF。 |
+| tag | string | 是 | 字符串常量,标识调用所在的类或者业务行为。 |
+| format | string | 是 | 格式字符串,包含参数类型、隐私标识。未加隐私标识的缺省为隐私参数。 |
+| args | any[] | 是 | 与格式字符串里参数类型对应的可变长度参数列表。参数数目、参数类型必须与格式字符串中的标识一一对应。 |
+
+**示例:**
+
+```
+hilog.info(0xFF00, "testTag", "%d: %{private}s World %{public}f", 1, "hello", 3.0);
+```
+
+**输出:**
+
+```
+09-08 12:49:35.941 1547 2452 I FF00/testTag: 1: hello World 3.0
+```
+
+## hilog.warn
+
+warn(domain: number, tag: string, format: string, ...args: any[]) : void
+
+warn日志输出,打印warn级别日志。
+
+**参数:**
+
+| 参数名 | 类型 | 必填 | 说明 |
+| ------ | -------------- | ---- | ------------------------------------------------------------ |
+| domain | number | 是 | 业务领域。范围0x0~0xFFFFF。 |
+| tag | string | 是 | 字符串常量,标识调用所在的类或者业务行为。 |
+| format | string | 是 | 格式字符串,包含参数类型、隐私标识。未加隐私标识的缺省为隐私参数。 |
+| args | any[] | 是 | 与格式字符串里参数类型对应的可变长度参数列表。参数数目、参数类型必须与格式字符串中的标识一一对应。 |
+
+**示例:**
+
+```
+hilog.warn(0xFF00, "testTag", "%d: %{private}s World %{public}f", 1, "hello", 3.0);
+```
+
+**输出:**
+
+```
+09-08 12:49:35.941 1547 2452 W FF00/testTag: 1: hello World 3.0
+```
+
+## hilog.error
+
+error(domain: number, tag: string, format: string, ...args: any[]) : void
+
+error日志输出,打印error级别日志。
+
+**参数:**
+
+| 参数名 | 类型 | 必填 | 说明 |
+| ------ | -------------- | ---- | ------------------------------------------------------------ |
+| domain | number | 是 | 业务领域。范围0x0~0xFFFFF。 |
+| tag | string | 是 | 字符串常量,标识调用所在的类或者业务行为。 |
+| format | string | 是 | 格式字符串,包含参数类型、隐私标识。未加隐私标识的缺省为隐私参数。 |
+| args | any[] | 是 | 与格式字符串里参数类型对应的可变长度参数列表。参数数目、参数类型必须与格式字符串中的标识一一对应。 |
+
+**示例:**
+
+```
+hilog.error(0xFF00, "testTag", "%d: %{private}s World %{public}f", 1, "hello", 3.0);
+```
+
+**输出:**
+
+```
+09-08 12:49:35.941 1547 2452 E FF00/testTag: 1: hello World 3.0
+```
+
+## hilog.fatal
+
+fatal(domain: number, tag: string, format: string, ...args: any[]) : void
+
+fatal日志输出,打印fatal级别日志。
+
+**参数:**
+
+| 参数名 | 类型 | 必填 | 说明 |
+| ------ | -------------- | ---- | ------------------------------------------------------------ |
+| domain | number | 是 | 业务领域。范围0x0~0xFFFFF。 |
+| tag | string | 是 | 字符串常量,标识调用所在的类或者业务行为。 |
+| format | string | 是 | 格式字符串,包含参数类型、隐私标识。未加隐私标识的缺省为隐私参数。 |
+| args | any[] | 是 | 与格式字符串里参数类型对应的可变长度参数列表。参数数目、参数类型必须与格式字符串中的标识一一对应。 |
+
+**示例:**
+
+```
+hilog.fatal(0xFF00, "testTag", "%d: %{private}s World %{public}f", 1, "hello", 3.0);
+```
+
+**输出:**
+
+```
+09-08 12:49:35.941 1547 2452 F FF00/testTag: 1: hello World 3.0
+```
+
+## hilog.isLoggable
+
+isLoggable(domain: number, tag: string, level: LogLevel) : boolean
+
+检查一个domain、tag和日志级别是否被禁止打印日志。
+
+**参数:**
+
+| 参数名 | 类型 | 必填 | 说明 |
+| ------ | --------------------- | ---- | ------------------------------------------ |
+| domain | number | 是 | 业务领域。范围0x0~0xFFFFF。 |
+| tag | string | 是 | 字符串常量,标识调用所在的类或者业务行为。 |
+| level | [LogLevel](#loglevel) | 是 | 日志级别。 |
+
+**示例:**
+
+```
+hilog.isLoggable(0xFF00, "testTag", hilog.DEBUG);
+```
+
+## LogLevel
+
+用于表示事件类型。
+
+| 名称 | 默认值 | 说明 |
+| ----- | ------ | ----------- |
+| DEBUG | 3 | DEBUG级别。 |
+| INFO | 4 | INFO级别。 |
+| WARN | 5 | WARN级别。 |
+| ERROR | 6 | ERROR级别。 |
+| FATAL | 7 | FATAL级别。 |
\ No newline at end of file
diff --git a/zh-cn/application-dev/reference/apis/js-apis-lightweightmap.md b/zh-cn/application-dev/reference/apis/js-apis-lightweightmap.md
new file mode 100644
index 0000000000000000000000000000000000000000..b05217f58a56e2bb69fff3753dcceb88d1f2619a
--- /dev/null
+++ b/zh-cn/application-dev/reference/apis/js-apis-lightweightmap.md
@@ -0,0 +1,551 @@
+# 非线性容器LightWeightMap
+
+>  **说明:**
+> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
+
+
+## 导入模块
+
+```
+import LightWeightMap from '@ohos.util.LightWeightMap'
+```
+
+
+## 权限
+
+无
+
+## LightWeightMap
+
+
+### 属性
+
+| 名称 | 参数类型 | 可读 | 可写 | 说明 |
+| -------- | -------- | -------- | -------- | -------- |
+| length | number | 是 | 否 | LightWeightMap的元素个数 |
+
+
+### constructor
+
+constructor();
+
+LightWeightMap的构造函数。
+
+- 示例:
+ ```
+ let lightWeightMap = new LightWeightMap();
+ ```
+
+
+### isEmpty
+
+isEmpty(): boolean;
+
+判断该LightWeightMap是否为空。
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | boolean | 为空返回true, 不为空返回false |
+
+- 示例:
+ ```
+ const lightWeightMap = new LightWeightMap();
+ lightWeightMap.isEmpty();
+ ```
+
+
+### hasAll
+
+hasAll(map: LightWeightMap): boolean;
+
+判断此LightWeightMap中是否含有该指定map中的所有元素。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | map | LightWeightMap | 是 | 比较对象 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | boolean | 是否包含所有元素 |
+
+- 示例:
+ ```
+ let lightWeightMap = new LightWeightMap();
+ lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
+ lightWeightMap.set("sdfs", 356);
+ let map = new LightWeightMap();
+ map.set("sdfs", 356);
+ let result = lightWeightMap.hasAll(map);
+ ```
+
+
+### hasKey
+
+hasKey(key: K): boolean;
+
+判断此LightWeightMap中是否含有该指定key。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | key | K | 是 | 指定元素 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | boolean | 是否包含指定元素 |
+
+- 示例:
+ ```
+ let lightWeightMap = new LightWeightMap();
+ lightWeightMap.hasKey("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
+ lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
+ lightWeightMap.hasKey("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
+ ```
+
+
+### hasValue
+
+hasValue(value: V): boolean;
+
+判断此LightWeightMap中是否含有该指定value。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | value | V | 是 | 指定元素 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | boolean | 是否包含指定元素 |
+
+- 示例:
+ ```
+ let lightWeightMap = new LightWeightMap();
+ lightWeightMap.hasValue(123);
+ lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
+ lightWeightMap.hasValue(123);
+ ```
+
+
+### increaseCapacityTo
+
+increaseCapacityTo(minimumCapacity: number): void;
+
+将当前LightWeightMap扩容至可以容纳指定数量元素。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | minimumCapacity | number | 是 | 需要容纳数量 |
+
+
+- 示例:
+ ```
+ let lightWeightMap = new LightWeightMap();
+ lightWeightMap.increaseCapacityTo(10);
+ ```
+
+
+### get
+
+get(key: K): V;
+
+获取指定key所对应的value。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | key | K | 是 | 查找的指定key |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | V | 返回key映射的value值 |
+
+- 示例:
+ ```
+ let lightWeightMap = new LightWeightMap();
+ lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
+ lightWeightMap.set("sdfs", 356);
+ lightWeightMap.get("sdfs");
+ ```
+
+
+### getIndexOfKey
+
+getIndexOfKey(key: K): number;
+
+查找指定元素第一次出现的下标值,如果没有找到该元素返回-1。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | key | K | 是 | 被查找的元素 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | number | 返回指定元素第一次出现时的下标值,查找失败返回-1 |
+
+- 示例:
+ ```
+ let lightWeightMap = new LightWeightMap();
+ lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
+ lightWeightMap.set("sdfs", 356);
+ lightWeightMap.getIndexOfKey("sdfs");
+ ```
+
+
+### getIndexOfValue
+
+getIndexOfValue(value: V): number;
+
+查找指定元素第一次出现的下标值,如果没有找到该元素返回-1。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | value | V | 是 | 被查找的元素 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | number | 返回指定元素第一次出现时的下标值,查找失败返回-1 |
+
+- 示例:
+ ```
+ let lightWeightMap = new LightWeightMap();
+ lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
+ lightWeightMap.set("sdfs", 356);
+ lightWeightMap.getIndexOfValue(123);
+ ```
+
+
+### getKeyAt
+
+getKeyAt(index: number): K;
+
+查找指定下标的元素键值对中key值,否则返回undefined。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | index | number | 是 | 所查找的下标 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | K | 返回该下标对应的元素键值对中key值 |
+
+- 示例:
+ ```
+ let lightWeightMap = new LightWeightMap();
+ lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
+ lightWeightMap.set("sdfs", 356);
+ lightWeightMap.getKeyAt(1);
+ ```
+
+
+### setAll
+
+setAll(map: LightWeightMap): void;
+
+将一个LightWeightMap中的所有元素组添加到另一个lightweightmap中。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | map | LightWeightMap | 是 | 被添加元素的lightweightmap |
+
+- 示例:
+ ```
+ let lightWeightMap = new LightWeightMap();
+ lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
+ lightWeightMap.set("sdfs", 356);
+ let map = new LightWeightMap();
+ lightWeightMap.setAll(map);
+ ```
+
+
+### set
+set(key: K, value: V): Object;
+
+向LightWeightMap中添加一组数据。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | key | K | 是 | 添加成员数据的键名 |
+ | value | V | 是 | 添加成员数据的值 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | Object | 返回添加后的hashmap |
+
+- 示例:
+ ```
+ let lightWeightMap = new LightWeightMap();
+ lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
+ ```
+
+
+### remove
+
+remove(key: K): V;
+
+删除指定的元素。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | key | K | 是 | 依据key指定删除的元素 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | V | 返回删除元素的值 |
+
+- 示例:
+ ```
+ let lightWeightMap = new LightWeightMap();
+ lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
+ lightWeightMap.set("sdfs", 356);
+ lightWeightMap.remove("sdfs");
+ ```
+
+
+### removeAt
+
+removeAt(index: number): boolean;
+
+删除指定下标的元素。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | index | number | 是 | 指定想要删除元素下标 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | boolean | 确认是否成功删除元素 |
+
+- 示例:
+ ```
+ let lightWeightMap = new LightWeightMap();
+ lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
+ lightWeightMap.set("sdfs", 356);
+ lightWeightMap.removeAt(1);
+ ```
+
+
+### setValueAt
+
+setValueAt(index: number, newValue: V): boolean;
+
+向LightWeightMap中具体位置替换键值对中的值。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | index | number | 是 | 指定替换数据下标 |
+ | newValue | V | 是 | 替换键值对中的值 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | boolean | 是否成功替换指定位置数据 |
+
+- 示例:
+ ```
+ let lightWeightMap = new LightWeightMap();
+ lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
+ lightWeightMap.set("sdfs", 356);
+ lightWeightMap.setValueAt(1, 3546);
+ ```
+
+
+### getValueAt
+
+getValueAt(index: number): V;
+
+获取LightWeightMap中具体位置键值对中的值。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | index | number | 是 | 指定查询数据下标 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | V | 返回指定位置中键值对的值 |
+
+- 示例:
+ ```
+ let lightWeightMap = new LightWeightMap();
+ lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
+ lightWeightMap.set("sdfs", 356);
+ lightWeightMap.getValueAt(1);
+ ```
+
+
+### clear
+
+clear(): void;
+
+清除LightWeightMap中的所有元素,并把length置为0。
+
+- 示例:
+ ```
+ let lightWeightMap = new LightWeightMap();
+ lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
+ lightWeightMap.set("sdfs", 356);
+ lightWeightMap.clear();
+ ```
+
+
+### keys
+
+keys(): IterableIterator<K>;
+
+返回包含此映射中包含的键的新迭代器对象。
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | IterableIterator<K> | 返回一个迭代器 |
+
+- 示例:
+ ```
+ let lightWeightMap = new LightWeightMap();
+ lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
+ lightWeightMap.set("sdfs", 356);
+ let iter = lightWeightMap.keys();
+ let temp = iter.next().value;
+ while(temp != undefined) {
+ console.log(temp);
+ temp = iter.next().value;
+ }
+ ```
+
+
+### values
+
+values(): IterableIterator<V>;
+
+返回包含此映射中包含的键的新迭代器对象。
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | IterableIterator<V> | 返回一个迭代器 |
+
+- 示例:
+ ```
+ let lightWeightMap = new LightWeightMap();
+ lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
+ lightWeightMap.set("sdfs", 356);
+ let iter = lightWeightMap.values();
+ let temp = iter.next().value;
+ while(temp != undefined) {
+ console.log(temp);
+ temp = iter.next().value;
+ }
+ ```
+
+
+### forEach
+
+forEach(callbackfn: (value: V, key?: K, lightWeightMap?: LightWeightMap) => void, thisArg?: Object): void;
+
+通过回调函数来遍历实例对象上的元素以及元素对应的下标。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | callbackfn | function | 是 | 回调函数 |
+ | thisArg | Object | 否 | callbackfn被调用时用作this值 |
+
+- callbackfn的参数说明
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | value | V | 是 | 当前遍历到的元素键值对的值 |
+ | key | K | 是 | 当前遍历到的元素键值对的键 |
+ | lightWeightMap | LightWeightMap | 否 | 当前调用forEach方法的实例对象 |
+
+- 示例:
+ ```
+ let lightWeightMap = new LightWeightMap();
+ lightWeightMap.set("sdfs", 123);
+ lightWeightMap.set("dfsghsf", 357);
+ lightWeightMap.forEach((value, key) => {
+ console.log(value, key);
+ });
+ ```
+
+
+### entries
+
+entries(): IterableIterator<[K, V]>;
+
+返回包含此映射中包含的键的新迭代器对象。
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | IterableIterator<[K, V]> | 返回一个迭代器 |
+
+- 示例:
+ ```
+ let lightWeightMap = new LightWeightMap();
+ lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
+ lightWeightMap.set("sdfs", 356);
+ let iter = lightWeightMap.entries();
+ let temp = iter.next().value;
+ while(temp != undefined) {
+ console.log(temp[0]);
+ console.log(temp[1]);
+ temp = iter.next().value;
+ }
+ ```
+
+
+### [Symbol.iterator]
+
+[Symbol.iterator]\(): IterableIterator<[K, V]>;
+
+返回一个迭代器,迭代器的每一项都是一个 JavaScript 对象,并返回该对象。
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | IterableIterator<[K, V]> | 返回一个迭代器 |
+
+- 示例:
+ ```
+ let lightWeightMap = new LightWeightMap();
+ lightWeightMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
+ lightWeightMap.set("sdfs", 356);
+
+ // 使用方法一:
+ for (let item of lightWeightMap) {
+ console.log("key: " + item[0]);
+ console.log("value: " + item[1]);
+ }
+
+ // 使用方法二:
+ let iter = lightWeightMap[Symbol.iterator]();
+ let temp = iter.next().value;
+ while(temp != undefined) {
+ console.log(temp[0]);
+ console.log(temp[1]);
+ temp = iter.next().value;
+ }
+ ```
\ No newline at end of file
diff --git a/zh-cn/application-dev/reference/apis/js-apis-lightweightset.md b/zh-cn/application-dev/reference/apis/js-apis-lightweightset.md
new file mode 100644
index 0000000000000000000000000000000000000000..353250ebdcb353a0ed9843b09c70869dba7a7b69
--- /dev/null
+++ b/zh-cn/application-dev/reference/apis/js-apis-lightweightset.md
@@ -0,0 +1,463 @@
+# 非线性容器LightWeightSet
+
+>  **说明:**
+> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
+
+
+## 导入模块
+
+```
+import LightWeightSet from '@ohos.util.LightWeightSet'
+```
+
+
+## 权限
+
+无
+
+## LightWeightSet
+
+
+### 属性
+
+| 名称 | 参数类型 | 可读 | 可写 | 说明 |
+| -------- | -------- | -------- | -------- | -------- |
+| length | number | 是 | 否 | LightWeightSet的元素个数 |
+
+
+### constructor
+
+constructor();
+
+LightWeightSet的构造函数。
+
+- 示例:
+ ```
+ let lightWeightSet = new LightWeightSet();
+ ```
+
+
+### isEmpty
+
+isEmpty(): boolean;
+
+判断该容器是否为空。
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | boolean | 为空返回true, 不为空返回false |
+
+- 示例:
+ ```
+ const lightWeightSet = new LightWeightSet();
+ lightWeightSet.isEmpty();
+ ```
+
+### add
+
+add(value: T): boolean;
+
+向此容器中添加数据。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | value | T | 是 | 添加的成员数据 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | boolean | 是否成功添加元素 |
+
+- 示例:
+ ```
+ let lightWeightSet = new LightWeightSet();
+ lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
+ ```
+
+
+### addAll
+
+addAll(set: LightWeightSet<T>): boolean;
+
+将另一个容器中的所有元素组添加到当前容器中。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | set | LightWeightSet<T> | 是 | 提供添加元素的lightweightmap |
+
+- 示例:
+ ```
+ let lightWeightSet = new LightWeightSet();
+ lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
+ lightWeightSet.add("sdfs");
+ let set = new LightWeightSet();
+ set.add("sfage");
+ lightWeightSet.addAll(set);
+ ```
+
+
+### hasAll
+
+hasAll(set: LightWeightSet<T>): boolean;
+
+判断此容器中是否含有该指定set中的所有元素。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | set | LightWeightSet<T> | 是 | 比较对象 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | boolean | 是否包含所有元素 |
+
+- 示例:
+ ```
+ let lightWeightSet = new LightWeightSet();
+ lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
+ lightWeightSet.add("sdfs");
+ let set = new LightWeightSet();
+ set.add("sdfs");
+ let result = lightWeightSet.hasAll(set);
+ ```
+
+
+### has
+
+has(value: T): boolean;
+
+判断此容器中是否含有该指定value。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | value | T | 是 | 指定元素 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | boolean | 是否包含指定元素 |
+
+- 示例:
+ ```
+ let lightWeightSet = new LightWeightSet();
+ lightWeightSet.has(123);
+ lightWeightSet.add(123);
+ lightWeightSet.has(123);
+ ```
+
+
+### equal
+
+equal(obj: Object): boolean;
+
+判断此容器中是否含有该指定obj同类型。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | obj | Object | 是 | 比较对象 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | boolean | 是否构成类型相同 |
+
+- 示例:
+ ```
+ let lightWeightSet = new LightWeightSet();
+ lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
+ lightWeightSet.add("sdfs");
+ let obj = {"Ahfbrgrbgnutfodgorrogorgrogofdfdf", "sdfs"};
+ let result = lightWeightSet.equal(obj);
+ ```
+
+
+### ensureCapacityTo
+
+ensureCapacityTo(minimumCapacity: number): void;
+
+将当前容器扩容至可以容纳指定数量元素。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | minimumCapacity | number | 是 | 需要容纳数量 |
+
+
+- 示例:
+ ```
+ let lightWeightSet = new LightWeightSet();
+ lightWeightSet.ensureCapacityTo(10);
+ ```
+
+
+### getIndexOf
+
+getIndexOf(key: T): number;
+
+获取指定key所对应的下标。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | key | T | 是 | 查找的指定key |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | number | 在lightweightset中指定数据的下标 |
+
+- 示例:
+ ```
+ let lightWeightSet = new LightWeightSet();
+ lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
+ lightWeightSet.add("sdfs");
+ lightWeightSet.getIndexOf("sdfs");
+ ```
+
+
+### remove
+
+remove(key: T): T;
+
+删除指定的元素。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | key | T | 是 | 依据key指定删除的元素 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | T | 返回删除元素的值 |
+
+- 示例:
+ ```
+ let lightWeightSet = new LightWeightSet();
+ lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
+ lightWeightSet.add("sdfs");
+ lightWeightSet.remove("sdfs");
+ ```
+
+
+### removeAt
+
+removeAt(index: number): boolean;
+
+删除指定下标的元素。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | index | number | 是 | 指定想要删除元素下标 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | boolean | 确认是否成功删除元素 |
+
+- 示例:
+ ```
+ let lightWeightSet = new LightWeightSet();
+ lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
+ lightWeightSet.add("sdfs");
+ lightWeightSet.removeAt(1);
+ ```
+
+
+### getValueAt
+
+getValueAt(index: number): T;
+
+获取此容器中具体位置的元素
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | index | number | 是 | 指定查询数据下标 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | T | 返回指定位置中元素 |
+
+- 示例:
+ ```
+ let lightWeightSet = new LightWeightSet();
+ lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
+ lightWeightSet.add("sdfs");
+ lightWeightSet.getValueAt(1);
+ ```
+
+
+### clear
+
+clear(): void;
+
+清除容器中的所有元素,并把length置为0。
+
+- 示例:
+ ```
+ let lightWeightSet = new LightWeightSet();
+ lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
+ lightWeightSet.add("sdfs");
+ lightWeightSet.clear();
+ ```
+
+
+### toString
+
+toString(): String;
+
+获取包含容器中所有键和值的字符串。
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | String | 返回一个字符串 |
+
+- 示例:
+ ```
+ let lightWeightSet = new LightWeightSet();
+ lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
+ lightWeightSet.add("sdfs");
+ lightWeightSet.toString();
+ ```
+
+
+### toArray
+
+toArray(): Array<T>;
+
+获取包含此容器中所有对象的数组。
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | Array<T> | 返回一个数组 |
+
+- 示例:
+ ```
+ let lightWeightSet = new LightWeightSet();
+ lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
+ lightWeightSet.add("sdfs");
+ lightWeightSet.toString();
+ ```
+
+
+### values
+
+values(): IterableIterator<T>;
+
+返回包含此映射中包含的键的新迭代器对象。
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | IterableIterator<T> | 返回一个迭代器 |
+
+- 示例:
+ ```
+ let lightWeightSet = new LightWeightSet();
+ lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
+ lightWeightSet.add("sdfs");
+ let iter = lightWeightSet.values();
+ let index = 0;
+ while(index < lightWeightSet.length) {
+ console.log(JSON.stringify(iter.next().value));
+ index++;
+ }
+ ```
+
+
+### forEach
+
+forEach(callbackfn: (value: T, key?: T, lightWeightSet?: LightWeightSet<T>) => void, thisArg?: Object): void;
+
+通过回调函数来遍历LightWeightSet实例对象上的元素以及元素对应的下标。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | callbackfn | function | 是 | 回调函数 |
+ | thisArg | Object | 否 | callbackfn被调用时用作this值 |
+
+- callbackfn的参数说明
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | value | T | 是 | 当前遍历到的元素 |
+ | key | T | 否 | 当前遍历到的元素(和value相同) |
+ | lightWeightSet | LightWeightSet<T> | 否 | 当前调用forEach方法的实例对象 |
+
+- 示例:
+ ```
+ let lightWeightSet = new LightWeightSet();
+ lightWeightSet.add("sdfs");
+ lightWeightSet.add("dfsghsf");
+ lightWeightSet.forEach((value, key) => {
+ console.log(value, key);
+ });
+ ```
+
+
+### entries
+
+entries(): IterableIterator<[T, T]>;
+
+返回包含此映射中包含的键的新迭代器对象。
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | IterableIterator<[T, T]> | 返回一个迭代器 |
+
+- 示例:
+ ```
+ let lightWeightSet = new LightWeightSet();
+ lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
+ lightWeightSet.add("sdfs");
+ let iter = lightWeightSet.entries();
+ let index = 0;
+ while(index < lightWeightSet.length) {
+ console.log(JSON.stringify(iter.next().value));
+ index++;
+ }
+ ```
+
+
+### [Symbol.iterator]
+
+[Symbol.iterator]\(): IterableIterator<T>;
+
+返回一个迭代器,迭代器的每一项都是一个 JavaScript 对象,并返回该对象。
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | IterableIterator<T> | 返回一个迭代器 |
+
+- 示例:
+ ```
+ let lightWeightSet = new LightWeightSet();
+ lightWeightSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
+ lightWeightSet.add("sdfs");
+
+ // 使用方法一:
+ for (let item of lightWeightSet) {
+ console.log("value: " + item);
+ }
+
+ // 使用方法二:
+ let iter = lightWeightSet[Symbol.iterator]();
+ let temp = iter.next().value;
+ while(temp != undefined) {
+ console.log(temp);
+ temp = iter.next().value;
+ }
+ ```
\ No newline at end of file
diff --git a/zh-cn/application-dev/reference/apis/js-apis-linkedlist.md b/zh-cn/application-dev/reference/apis/js-apis-linkedlist.md
new file mode 100644
index 0000000000000000000000000000000000000000..385391288e46dd506618e3c19f0b2074af407abe
--- /dev/null
+++ b/zh-cn/application-dev/reference/apis/js-apis-linkedlist.md
@@ -0,0 +1,551 @@
+# 线性容器LinkedList
+
+>  **说明:**
+> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
+
+
+## 导入模块
+
+```
+import LinkedList from '@ohos.util.LinkedList'
+```
+
+
+## 权限
+
+无
+
+
+## LinkedList
+
+
+### 属性
+
+| 名称 | 参数类型 | 可读 | 可写 | 说明 |
+| -------- | -------- | -------- | -------- | -------- |
+| length | number | 是 | 否 | LinkedList的元素个数 |
+
+
+### constructor
+
+constructor(_head?: NodeObj<T>, _tail?: NodeObj<T>);
+
+LinkedList的构造函数。
+
+- 参数:
+ | 参数名 | 类型 | 可读 | 可写 | 说明 |
+ | -------- | -------- | -------- | -------- | -------- |
+ | _head | NodeObj<T> | 是 | 否 | 入参对象,节点对象,含有element,和next指向,和prev指向 |
+ | _tail | NodeObj<T> | 是 | 否 | 入参对象,节点对象,含有element,和next指向,和prev指向 |
+
+- 示例:
+ ```
+ let linkedList = new LinkedList();
+ ```
+
+
+### add
+
+add(element: T): boolean;
+
+在LinkedList尾部插入元素。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | element | T | 是 | 添加进去的元素 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | boolean | 插入成功返回true,失败返回false |
+
+- 示例:
+ ```
+ let linkedList = new LinkedList();
+ linkedList.add("a");
+ linkedList.add(1);
+ let b = [1, 2, 3];
+ linkedList.add(b);
+ let c = {name : "lala", age : "13"};
+ linkedList.add(false);
+ ```
+### addFirst
+
+addFirst(element: T): void;
+
+在LinkedList头部插入元素。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | element | T | 是 | 添加进去的元素 |
+
+- 示例:
+ ```
+ let linkedList = new LinkedList();
+ linkedList.addFirst("a");
+ linkedList.addFirst(1);
+ let b = [1, 2, 3];
+ linkedList.addFirst(b);
+ let c = {name : "lala", age : "13"};
+ linkedList.addFirst(false);
+ ```
+
+### insert
+
+insert(element: T, index: number): void;
+
+在长度范围内任意插入指定元素。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | element | T | 是 | 被插入的元素 |
+ | index | number | 是 | 被插入的位置索引 |
+
+- 示例:
+ ```
+ let linkedList = new LinkedList();
+ linkedList.insert("A", 0);
+ linkedList.insert(0, 1);
+ linkedList.insert(true, 2);
+ ```
+
+### has
+
+has(element: T): boolean;
+
+判断此LinkedList中是否含有该指定元素。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | element | T | 是 | 指定元素 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | boolean | 是否包含指定元素 |
+
+- 示例:
+ ```
+ let linkedList = new LinkedList();
+ linkedList.has("Ahfbrgrbgnutfodgorrogorg");
+ linkedList.add("Ahfbrgrbgnutfodgorrogorg");
+ linkedList.has("Ahfbrgrbgnutfodgorrogorg");
+ ```
+
+### get
+
+get(index: number): T;
+
+根据下标获取LinkedList中的元素。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | index | number | 是 | 指定的下标值 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | T | 根据下标查找到的元素 |
+
+- 示例:
+ ```
+ let linkedList = new LinkedList();
+ linkedList.add(2);
+ linkedList.add(4);
+ linkedList.add(5);
+ linkedList.add(2);
+ linkedList.add(1);
+ linkedList.add(2);
+ linkedList.add(4);
+ linkedList.get(2);
+ ```
+### getLastIndexOf
+
+getLastIndexOf(element: T): number;
+
+返回指定元素最后一次出现时的下标值,查找失败返回-1。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | element | T | 是 | 指定元素 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | number | 返回指定元素最后一次出现时的下标值,查找失败返回-1 |
+
+- 示例:
+ ```
+ let linkedList = new LinkedList();
+ linkedList.add(2);
+ linkedList.add(4);
+ linkedList.add(5);
+ linkedList.add(2);
+ linkedList.add(1);
+ linkedList.add(2);
+ linkedList.add(4);
+ linkedList.getLastIndexOf(2);
+ ```
+
+### getIndexOf
+
+getIndexOf(element: T): number;
+
+返回指定元素第一次出现时的下标值,查找失败返回-1。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | element | T | 是 | 指定元素 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | number | 返回指定元素第一次出现时的下标值,查找失败返回-1 |
+
+- 示例:
+ ```
+ let linkedList = new LinkedList();
+ linkedList.add(2);
+ linkedList.add(4);
+ linkedList.add(5);
+ linkedList.add(2);
+ linkedList.add(1);
+ linkedList.add(2);
+ linkedList.add(4);
+ linkedList.getIndexOf(2);
+ ```
+### removeByIndex
+
+removeByIndex(index: number): T;
+
+根据元素的下标值查找元素,返回元素后将其删除。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | index | number | 是 | 指定元素的下标值 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | T | 返回删除的元素 |
+
+- 示例:
+ ```
+ let linkedList = new LinkedList();
+ linkedList.add(2);
+ linkedList.add(4);
+ linkedList.add(5);
+ linkedList.add(2);
+ linkedList.add(4);
+ linkedList.removeByIndex(2);
+ ```
+### removeFirst
+
+removeFirst(): T;
+
+删除并返回LinkedList的第一个元素。
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | T | 返回删除的元素 |
+
+- 示例:
+ ```
+ let linkedList = new LinkedList();
+ linkedList.add(2);
+ linkedList.add(4);
+ linkedList.add(5);
+ linkedList.add(2);
+ linkedList.add(4);
+ linkedList.removeFirst();
+ ```
+### removeLast
+
+removeLst(): T;
+
+删除并返回LinkedList的最后一个元素。
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | T | 返回删除的元素 |
+
+- 示例:
+ ```
+ let linkedList = new LinkedList();
+ linkedList.add(2);
+ linkedList.add(4);
+ linkedList.add(5);
+ linkedList.add(2);
+ linkedList.add(4);
+ linkedList.removeLast();
+ ```
+
+### remove
+
+remove(element: T): boolean;
+
+删除查找到的第一个指定的元素。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | element | T | 是 | 指定元素 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | boolean | 删除成功返回true,失败返回false |
+
+- 示例:
+ ```
+ let linkedList = new LinkedList();
+ linkedList.add(2);
+ linkedList.add(4);
+ linkedList.add(5);
+ linkedList.add(4);
+ linkedList.remove(2);
+ ```
+### removeFirstFound
+
+removeFirstFound(element: T): boolean;
+
+删除第一次出现的指定元素。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | element | T | 是 | 指定元素 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | boolean | 删除成功返回true,失败返回false |
+
+- 示例:
+ ```
+ let linkedList = new LinkedList();
+ linkedList.add(2);
+ linkedList.add(4);
+ linkedList.add(5);
+ linkedList.add(4);
+ linkedList.removeFirstFound(4);
+ ```
+### removeLastFound
+
+removeLastFound(element: T): boolean;
+
+删除最后一次出现的指定元素。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | element | T | 是 | 指定元素 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | boolean | 删除成功返回true,失败返回false |
+
+- 示例:
+ ```
+ let linkedList = new LinkedList();
+ linkedList.add(2);
+ linkedList.add(4);
+ linkedList.add(5);
+ linkedList.add(4);
+ linkedList.removeLastFound(4);
+ ```
+### clone
+clone(): LinkedList<T>;
+
+克隆一个与LinkedList一模一样的实例,并返回克隆后的实例,修改克隆后的实例并不会影响原实例。
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | LinkedList<T> | 返回LinkedList对象实例 |
+
+- 示例:
+ ```
+ let linkedList = new LinkedList();
+ linkedList.add(2);
+ linkedList.add(4);
+ linkedList.add(5);
+ linkedList.add(4);
+ linkedList.clone();
+ ```
+### forEach
+forEach(callbackfn: (value: T, index?: number, linkedlist?: LinkedList<T>) => void,
+thisArg?: Object): void;
+
+通过回调函数来遍历LinkedList实例对象上的元素以及元素对应的下标。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | callbackfn | function | 是 | 回调函数 |
+ | thisArg | Object | 否 | callbackfn被调用时用作this值 |
+
+- callbackfn的参数说明
+
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | value | T | 是 | 当前遍历到的元素 |
+ | index | number | 否 | 当前遍历到的下标值 |
+ | linkedlist | LinkedList<T> | 否 | 当前调用forEach方法的实例对象 |
+
+- 示例:
+ ```
+ let linkedList = new LinkedList();
+ linkedList.add(2);
+ linkedList.add(4);
+ linkedList.add(5);
+ linkedList.add(4);
+ linkedList.forEach((value, index) => {
+ console.log(value, index);
+ });
+ ```
+### clear
+clear(): void;
+
+清除LinkedList中的所有元素,并把length置为0。
+
+- 示例:
+ ```
+ let linkedList = new LinkedList();
+ linkedList.add(2);
+ linkedList.add(4);
+ linkedList.add(5);
+ linkedList.add(4);
+ linkedList.clear();
+ ```
+### set
+set(index: number, element: T): T;
+将此 LinkedList 中指定位置的元素替换为指定元素。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | index | number | 是 | 查找的下标值 |
+ | element | T | 是 | 用来替换的元素 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | T | 返回T类型 |
+
+- 示例:
+ ```
+ let linkedList = new LinkedList();
+ linkedList.add(2);
+ linkedList.add(4);
+ linkedList.add(5);
+ linkedList.add(4);
+ linkedList.set(2, "b");
+ ```
+### convertToArray
+convertToArray(): Array<T>;
+
+把当前LinkedList实例转换成数组,并返回转换后的数组。
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | Array<T> | 返回数组类型 |
+
+- 示例:
+ ```
+ let linkedList = new LinkedList();
+ linkedList.add(2);
+ linkedList.add(4);
+ linkedList.add(5);
+ linkedList.add(4);
+ linkedList.convertToArray();
+ ```
+
+### getFirst
+
+getFirst(): T;
+获取LinkedList实例中的第一个元素。
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | T | 返回T型 |
+
+
+- 示例:
+ ```
+ let linkedList = new LinkedList();
+ linkedList.add(2);
+ linkedList.add(4);
+ linkedList.add(5);
+ linkedList.add(4);
+ linkedList.getFirst();
+ ```
+### getLast
+
+getLast(): T;
+获取LinkedList实例中的最后一个元素。
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | T | 返回T型 |
+
+
+- 示例:
+ ```
+ let linkedList = new LinkedList();
+ linkedList.add(2);
+ linkedList.add(4);
+ linkedList.add(5);
+ linkedList.add(4);
+ linkedList.getLast();
+ ```
+
+### [Symbol.iterator]
+
+[Symbol.iterator]\(): IterableIterator<T>;
+
+
+返回一个迭代器,迭代器的每一项都是一个 JavaScript 对象,并返回该对象。
+
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | IterableIterator<T> | 返回一个迭代器。 |
+
+
+- 示例:
+ ```
+ let linkedList = new LinkedList();
+ linkedList.add(2);
+ linkedList.add(4);
+ linkedList.add(5);
+ linkedList.add(4);
+
+ // 使用方法一:
+ for (let item of linkedList) {
+ console.log(item);
+ }
+
+ // 使用方法二:
+ let iter = linkedList[Symbol.iterator]();
+ let temp = iter.next().value;
+ while(temp != undefined) {
+ console.log(temp);
+ temp = iter.next().value;
+ }
+ ```
\ No newline at end of file
diff --git a/zh-cn/application-dev/reference/apis/js-apis-list.md b/zh-cn/application-dev/reference/apis/js-apis-list.md
new file mode 100644
index 0000000000000000000000000000000000000000..bef7e6b9b4346110aff2868d616dfc8afafebc1c
--- /dev/null
+++ b/zh-cn/application-dev/reference/apis/js-apis-list.md
@@ -0,0 +1,561 @@
+# 线性容器List
+
+>  **说明:**
+> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
+
+
+## 导入模块
+
+```
+import List from '@ohos.util.List'
+```
+
+
+## 权限
+
+无
+
+
+## List
+
+
+### 属性
+
+| 名称 | 参数类型 | 可读 | 可写 | 说明 |
+| -------- | -------- | -------- | -------- | -------- |
+| length | number | 是 | 否 | List的元素个数 |
+
+
+### constructor
+
+constructor(_head?: NodeObj<T>);
+
+List的构造函数。
+
+- 参数:
+ | 参数名 | 类型 | 可读 | 可写 | 说明 |
+ | -------- | -------- | -------- | -------- | -------- |
+ | _head | NodeObj<T> | 是 | 否 | 入参对象,节点对象,含有element,和next指向 |
+
+- 示例:
+ ```
+ let list = new List();
+ ```
+
+
+### add
+
+add(element: T): boolean;
+
+在List尾部插入元素。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | element | T | 是 | 添加进去的元素 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | boolean | 插入成功返回true,失败返回false |
+
+- 示例:
+ ```
+ let list = new List;
+ list.add("a");
+ list.add(1);
+ let b = [1, 2, 3];
+ list.add(b);
+ let c = {name : "lala", age : "13"};
+ list.add(false);
+ ```
+
+### insert
+
+insert(element: T, index: number): void;
+
+在长度范围内任意位置插入指定元素。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | element | T | 是 | 被插入的元素 |
+ | index | number | 是 | 被插入的位置索引 |
+
+- 示例:
+ ```
+ let list = new List();
+ list.insert("A", 0);
+ list.insert(0, 1);
+ list.insert(true, 2);
+ ```
+
+### has
+
+has(element: T): boolean;
+
+判断此List中是否含有该指定元素。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | element | T | 是 | 指定元素 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | boolean | 是否包含指定元素 |
+
+- 示例:
+ ```
+ let list = new List();
+ list.has("Ahfbrgrbgnutfodgorrogorg");
+ list.add("Ahfbrgrbgnutfodgorrogorg");
+ list.has("Ahfbrgrbgnutfodgorrogorg");
+ ```
+
+### get
+
+get(index: number): T;
+
+根据下标获取List中的元素。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | index | number | 是 | 要查找的下标 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | T | 根据下标查找到的元素 |
+
+- 示例:
+ ```
+ let list = new List();
+ list.add(2);
+ list.add(4);
+ list.add(5);
+ list.add(2);
+ list.add(1);
+ list.add(2);
+ list.add(4);
+ list.get(2);
+ ```
+### getLastIndexOf
+
+getLastIndexOf(element: T): number;
+
+查找指定元素最后一次出现的下标值,查找失败返回-1。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | element | T | 是 | 指定元素 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | number | 查找指定元素最后一次出现的下标值,查找失败返回-1 |
+
+- 示例:
+ ```
+ let list = new List();
+ list.add(2);
+ list.add(4);
+ list.add(5);
+ list.add(2);
+ list.add(1);
+ list.add(2);
+ list.add(4);
+ list.getLastIndexOf(2);
+ ```
+
+### getIndexOf
+
+getIndexOf(element: T): number;
+
+查找指定元素第一次出现的下标值,查找失败返回-1。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | element | T | 是 | 指定元素 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | number | 返回第一次找到指定元素的下标,没有找到返回-1 |
+
+- 示例:
+ ```
+ let list = new List();
+ list.add(2);
+ list.add(4);
+ list.add(5);
+ list.add(2);
+ list.add(1);
+ list.add(2);
+ list.add(4);
+ list.getIndexOf(2);
+ ```
+
+### equal
+
+equal(obj: Object): boolean;
+
+比较指定对象与此List是否相等。如果对象与此列表相同,返回true,否则返回false。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | obj | Object | 是 | 用来比较的对象 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | boolean | 返回boolean类型 |
+
+- 示例:
+ ```
+ let list = new List();
+ list.add(2);
+ list.add(4);
+ list.add(5);
+ list.add(2);
+ let obj1 = new List();
+ obj1.add(2);
+ obj1.add(4);
+ obj1.add(5);
+ list.equal(obj1);
+ let obj2 = {name : "lala", age : "13"};
+ list.equal(obj2);
+ ```
+### removeByIndex
+
+removeByIndex(index: number): T;
+
+根据元素的下标值查找元素,返回元素后将其删除。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | index | number | 是 | 指定元素的下标值 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | T | 返回删除的元素 |
+
+- 示例:
+ ```
+ let list = new List();
+ list.add(2);
+ list.add(4);
+ list.add(5);
+ list.add(2);
+ list.add(4);
+ list.removeByIndex(2);
+ ```
+
+### remove
+
+remove(element: T): boolean;
+
+删除查找到的第一个指定的元素。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | element | T | 是 | 指定元素 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | boolean | 删除成功返回true,失败返回false |
+
+- 示例:
+ ```
+ let list = new List();
+ list.add(2);
+ list.add(4);
+ list.add(5);
+ list.add(4);
+ list.remove(2);
+ ```
+
+### replaceAllElements
+replaceAllElements(callbackfn: (value: T, index?: number, list?: List<T>) => T,
+thisArg?: Object): void;
+
+用户操作List中的元素,用操作后的元素替换原元素并返回操作后的元素。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | callbackfn | function | 是 | 回调函数 |
+ | thisArg | Object | 否 | callbackfn被调用时用作this值 |
+
+- callbackfn的参数说明
+
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | value | T | 是 | 当前遍历到的元素 |
+ | index | number | 否 | 当前遍历到的下标值 |
+ | list | List<T> | 否 | 当前调用replaceAllElements方法的实例对象 |
+
+- 示例:
+ ```
+ let list = new List();
+ list.add(2);
+ list.add(4);
+ list.add(5);
+ list.add(4);
+ list.replaceAllElements((value, index) => {
+ return value = 2 * value;
+ });
+ list.replaceAllElements((value, index) => {
+ return value = value - 2;
+ });
+ ```
+### forEach
+forEach(callbackfn: (value: T, index?: number, list?: List<T>) => void,
+thisArg?: Object): void;
+
+通过回调函数来遍历List实例对象上的元素以及元素对应的下标。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | callbackfn | function | 是 | 回调函数 |
+ | thisArg | Object | 否 | callbackfn被调用时用作this值 |
+
+- callbackfn的参数说明
+
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | value | T | 是 | 当前遍历到的元素。 |
+ | index | number | 否 | 当前遍历到的下标值。 |
+ | list | List<T> | 否 | 当前调用forEach方法的实例对象 |
+
+
+- 示例:
+ ```
+ let list = new List();
+ list.add(2);
+ list.add(4);
+ list.add(5);
+ list.add(4);
+ list.forEach((value, index) => {
+ console.log(value, index);
+ });
+
+ ```
+### sort
+sort(comparator: (firstValue: T, secondValue: T) => number): void;
+
+对List中的元素进行一个排序操作。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | comparator | function | 是 | 回调函数。 |
+
+- comparator的参数说明
+
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | firstValue | T | 是 | 前一项元素 |
+ | secondValue | T | 是 | 后一项元素 |
+
+
+- 示例:
+ ```
+ let list = new List();
+ list.add(2);
+ list.add(4);
+ list.add(5);
+ list.add(4);
+ list.sort(a, (b => a - b));
+ list.sort(a, (b => b - a));
+ ```
+### getSubList
+getSubList(fromIndex: number, toIndex: number): List<T>;
+
+根据下标截取List中的一段元素,并返回这一段List实例,包括起始值但不包括终止值。
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | fromIndex | number | 是 | 起始下标 |
+ | toIndex | number | 是 | 终止下标 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | List<T> | 返回List对象实例 |
+
+- 示例:
+ ```
+ let list = new List();
+ list.add(2);
+ list.add(4);
+ list.add(5);
+ list.add(4);
+ list.subList(2, 4);
+ list.subList(4, 3);
+ list.subList(2, 6);
+ ```
+
+### clear
+clear(): void;
+
+清除List中的所有元素,并把length置为0。
+
+- 示例:
+ ```
+ let list = new List();
+ list.add(2);
+ list.add(4);
+ list.add(5);
+ list.add(4);
+ list.clear();
+ ```
+### set
+set(index: number, element: T): T;
+将此 List 中指定位置的元素替换为指定元素。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | index | number | 是 | 查找的下标值 |
+ | element | T | 是 | 用来替换的元素 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | T | 返回T类型 |
+
+- 示例:
+ ```
+ let list = new List();
+ list.add(2);
+ list.add(4);
+ list.add(5);
+ list.add(4);
+ list.set(2, "b");
+
+ ```
+### convertToArray
+convertToArray(): Array<T>;
+
+把当前List实例转换成数组,并返回转换后的数组。
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | Array<T> | 返回数组类型 |
+
+- 示例:
+ ```
+ let list = new List();
+ list.add(2);
+ list.add(4);
+ list.add(5);
+ list.add(4);
+ list.convertToArray();
+ ```
+### isEmpty
+isEmpty(): boolean;
+
+判断该List是否为空。
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | boolean | 为空返回true, 不为空返回false |
+
+- 示例:
+ ```
+ let list = new List();
+ list.add(2);
+ list.add(4);
+ list.add(5);
+ list.add(4);
+ list.isEmpty();
+ ```
+### getFirst
+
+getFirst(): T;
+获取List实例中的第一个元素。
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | T | 返回T型 |
+
+
+- 示例:
+ ```
+ let list = new Vector();
+ list.add(2);
+ list.add(4);
+ list.add(5);
+ list.add(4);
+ list.getFirst();
+ ```
+### getLast
+
+getLast(): T;
+获取List实例中的最后一个元素。
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | T | 返回T型 |
+
+
+- 示例:
+ ```
+ let list = new Vector();
+ list.add(2);
+ list.add(4);
+ list.add(5);
+ list.add(4);
+ list.getLast();
+ ```
+
+### [Symbol.iterator]
+
+[Symbol.iterator]\(): IterableIterator<T>;
+
+
+返回一个迭代器,迭代器的每一项都是一个 JavaScript 对象,并返回该对象。
+
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | IterableIterator<T> | 返回一个迭代器。 |
+
+
+- 示例:
+ ```
+ let list = new List();
+ list.add(2);
+ list.add(4);
+ list.add(5);
+ list.add(4);
+
+ // 使用方法一:
+ for (let item of list) {
+ console.log(item);
+ }
+
+ // 使用方法二:
+ let iter = list[Symbol.iterator]();
+ let temp = iter.next().value;
+ while(temp != undefined) {
+ console.log(temp);
+ temp = iter.next().value;
+ }
+ ```
\ No newline at end of file
diff --git a/zh-cn/application-dev/reference/apis/js-apis-media.md b/zh-cn/application-dev/reference/apis/js-apis-media.md
index 8855a83325232bff6fa06fdcf142f17f9100f307..21af291759b0e9c973a051ce31c2b5e660311e67 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-media.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-media.md
@@ -575,6 +575,7 @@ prepare(config: AudioRecorderConfig): void
**示例:**
```
+var audiorecorder = media.createAudioRecorder();
let audioRecorderConfig = {
audioEncoder : AAC_LC ,
audioEncodeBitRate : 22050,
@@ -596,6 +597,7 @@ start(): void
**示例:**
```
+var audiorecorder = media.createAudioRecorder();
audiorecorder.start();
```
@@ -608,6 +610,7 @@ stop(): void
**示例:**
```
+var audiorecorder = media.createAudioRecorder();
audiorecorder.stop();
```
@@ -620,6 +623,7 @@ release(): void
**示例:**
```
+var audiorecorder = media.createAudioRecorder();
audiorecorder.release();
```
@@ -634,6 +638,7 @@ reset(): void
**示例:**
```
+var audiorecorder = media.createAudioRecorder();
audiorecorder.reset();
```
@@ -653,6 +658,7 @@ on(type: 'prepare' | 'start' | 'stop' | 'release' | 'reset', callback: () => voi
**示例:**
```
+var audiorecorder = media.createAudioRecorder();
audiorecorder.on('prepare', () => {
console.log('Preparation succeeded.');
audiorecorder.start();
diff --git a/zh-cn/application-dev/reference/apis/js-apis-notification.md b/zh-cn/application-dev/reference/apis/js-apis-notification.md
index 02964d02cf598c71a0febb23db10d47b1ecacc69..881bf945bc79614c36f7b574dba1456945644992 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-notification.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-notification.md
@@ -6,6 +6,12 @@
import Notification from '@ohos.notification';
```
+## 系统能力
+
+```js
+SystemCapability.Notification.Notification
+```
+
## Notification.publish(request: NotificationRequest, callback: AsyncCallback\)
- 接口说明
diff --git a/zh-cn/application-dev/reference/apis/js-apis-particleAbility.md b/zh-cn/application-dev/reference/apis/js-apis-particleAbility.md
index 0e2cad1377516dab8e71878eea75c8938aaea29b..0730011d84859cb178d328a94fdbef118a6ac0a5 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-particleAbility.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-particleAbility.md
@@ -370,4 +370,171 @@ abilityStartSetting属性是一个定义为[key: string]: any的对象,key对
| WINDOW_MODE_FULLSCREEN | 1 | 全屏。 |
| WINDOW_MODE_SPLIT_PRIMARY | 100 | 分屏主屏。 |
| WINDOW_MODE_SPLIT_SECONDARY | 101 | 分屏次屏。 |
-| WINDOW_MODE_FLOATING | 102 | 悬浮窗。 |
\ No newline at end of file
+| WINDOW_MODE_FLOATING | 102 | 悬浮窗。 |
+
+
+## particleAbility.startBackgroundRunning
+
+startBackgroundRunning(id: number, request: NotificationRequest, callback: AsyncCallback<void>): void;
+
+向系统申请长时任务,使用callback形式返回结果。(此接口为api7接口,后续会被废弃,请使用新的api8接口)
+
+- **参数**:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | id | number | 是 | 长时任务通知id号 |
+ | request | NotificationRequest | 是 | 通知参数,用于显示通知栏的信息 |
+ | callback | AsyncCallback<void> | 是 | callback形式返回启动长时任务的结果 |
+
+- **示例**:
+```js
+import notification from '@ohos.notification';
+import particleAbility from '@ohos.ability.particleAbility';
+import wantAgent from '@ohos.wantAgent';
+
+function callback(err, data) {
+ if (err) {
+ console.error("Operation failed Cause: " + err);
+ } else {
+ console.info("Operation succeeded");
+ }
+}
+
+let wantAgentInfo = {
+ wants: [
+ {
+ bundleName: "com.example.myapplication",
+ abilityName: "com.example.myapplication.MainAbility"
+ }
+ ],
+ operationType: wantAgent.OperationType.START_ABILITY,
+ requestCode: 0,
+ wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESET_FLAG]
+};
+
+wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => {
+ let basicContent = {
+ title: "title",
+ text: "text"
+ };
+ let notificationContent = {
+ contentType: notification.ContentType.NOTIFICATION_CONTENT_TEXT,
+ normal: basicContent
+ };
+ let request = {
+ content: notificatonContent,
+ wantAgent: wantAgentObj
+ };
+ let id = 1;
+ particleAbility.startBackgroundRunning(id, request, callback);
+});
+
+```
+
+## particleAbility.startBackgroundRunning
+
+startBackgroundRunning(id: number, request: NotificationRequest): Promise<void>
+
+向系统申请长时任务,使用promise形式返回结果。(此接口为api7接口,后续会被废弃,请使用新的api8接口)
+
+**参数**:
+| 参数名 | 类型 | 必填 | 说明 |
+| -------- | -------- | -------- | -------- |
+| id | number | 是 | 长时任务通知id号 |
+| request | NotificationRequest | 是 | 通知参数,用于显示通知栏的信息 |
+
+**返回值**
+| 类型 | 说明 |
+| -------------- | ------------------------- |
+| Promise\ | 使用Promise形式返回结果。 |
+
+- **示例**:
+```js
+import notification from '@ohos.notification';
+import particleAbility from '@ohos.ability.particleAbility';
+import wantAgent from '@ohos.wantAgent';
+
+let wantAgentInfo = {
+ wants: [
+ {
+ bundleName: "com.example.myapplication",
+ abilityName: "com.example.myapplication.MainAbility"
+ }
+ ],
+ operationType: wantAgent.OperationType.START_ABILITY,
+ requestCode: 0,
+ wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESET_FLAG]
+};
+
+wantAgent.getWantAgent(wantAgentInfo).then((wantAgentObj) => {
+ let basicContent = {
+ title: "title",
+ text: "text"
+ };
+ let notificationContent = {
+ contentType: notification.ContentType.NOTIFICATION_CONTENT_TEXT,
+ normal: basicContent
+ };
+ let request = {
+ content: notificatonContent,
+ wantAgent: wantAgentObj
+ };
+ let id = 1;
+ particleAbility.startBackgroundRunning(id, request).then(() => {
+ console.info("Operation succeeded");
+ }).catch((err) => {
+ console.error("Operation failed Cause: " + err);
+ });
+});
+
+```
+
+## particleAbility.cancelBackgroundRunning
+
+cancelBackgroundRunning(callback: AsyncCallback<void>): void;
+
+向系统申请取消长时任务,使用callback形式返回结果。(此接口为api7接口,后续会被废弃,请使用新的api8接口)
+
+- **参数**:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | callback | AsyncCallback<void> | 是 | callback形式返回启动长时任务的结果 |
+
+- **示例**:
+```js
+import particleAbility from '@ohos.ability.particleAbility';
+
+function callback(err, data) {
+ if (err) {
+ console.error("Operation failed Cause: " + err);
+ } else {
+ console.info("Operation succeeded");
+ }
+}
+
+particleAbility.cancelBackgroundRunning(callback);
+
+```
+
+## particleAbility.cancelBackgroundRunning
+
+cancelBackgroundRunning(): Promise<void>;
+
+向系统申请取消长时任务,使用promise形式返回结果。(此接口为api7接口,后续会被废弃,请使用新的api8接口)
+
+**返回值**
+| 类型 | 说明 |
+| -------------- | ------------------------- |
+| Promise\ | 使用Promise形式返回结果。 |
+
+- **示例**:
+```js
+import particleAbility from '@ohos.ability.particleAbility';
+
+particleAbility.cancelBackgroundRunning().then(() => {
+ console.info("Operation succeeded");
+}).catch((err) => {
+ console.error("Operation failed Cause: " + err);
+});
+
+```
\ No newline at end of file
diff --git a/zh-cn/application-dev/reference/apis/js-apis-plainarray.md b/zh-cn/application-dev/reference/apis/js-apis-plainarray.md
new file mode 100644
index 0000000000000000000000000000000000000000..f8657b795f73c6238842c81b245cb7e52ad7f8ca
--- /dev/null
+++ b/zh-cn/application-dev/reference/apis/js-apis-plainarray.md
@@ -0,0 +1,421 @@
+# 非线性容器PlainArray
+
+>  **说明:**
+> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
+
+
+## 导入模块
+
+```
+import PlainArray from '@ohos.util.PlainArray'
+```
+
+
+## 权限
+
+无
+
+## PlainArray
+
+
+### 属性
+
+| 名称 | 参数类型 | 可读 | 可写 | 说明 |
+| -------- | -------- | -------- | -------- | -------- |
+| length | number | 是 | 否 | PlainArray的元素个数 |
+
+
+### constructor
+
+constructor();
+
+PlainArray的构造函数。
+
+- 示例:
+ ```
+ let plainArray = new PlainArray();
+ ```
+
+
+### isEmpty
+
+isEmpty(): boolean;
+
+判断该容器是否为空。
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | boolean | 为空返回true, 不为空返回false |
+
+- 示例:
+ ```
+ const plainArray = new PlainArray();
+ plainArray.isEmpty();
+ ```
+
+
+### has
+
+has(key: number): boolean;
+
+判断此容器中是否含有该指定key。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | key | number | 是 | 查询的元素 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | boolean | 是否包含指定元素 |
+
+- 示例:
+ ```
+ let plainArray = new PlainArray();
+ plainArray.has(1);
+ plainArray.add(1, "sddfhf");
+ plainArray.has(1);
+ ```
+
+
+### get
+
+get(key: number): T;
+
+获取指定key所对应的value。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | key | number | 是 | 查找的指定key |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | T | 返回key映射的value值 |
+
+- 示例:
+ ```
+ let plainArray = new PlainArray();
+ plainArray.add(1, "sddfhf");
+ plainArray.add(2, "sffdfhf");
+ plainArray.get(1);
+ ```
+
+
+### getIndexOfKey
+
+getIndexOfKey(key: number): number;
+
+查找指定元素第一次出现的下标值,如果没有找到该元素返回-1。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | key | number | 是 | 被查找的元素 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | number | 返回指定元素第一次出现时的下标值,查找失败返回-1 |
+
+- 示例:
+ ```
+ let plainArray = new PlainArray();
+ plainArray.add(1, "sddfhf");
+ plainArray.add(2, "sffdfhf");
+ plainArray.getIndexOfKey("sdfs");
+ ```
+
+
+### getIndexOfValue
+
+getIndexOfValue(value: T): number;
+
+查找指定元素第一次出现的下标值,如果没有找到该元素返回-1。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | value | T | 是 | 被查找的元素 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | number | 返回指定元素第一次出现时的下标值,查找失败返回-1 |
+
+- 示例:
+ ```
+ let plainArray = new PlainArray();
+ plainArray.add(1, "sddfhf");
+ plainArray.add(2, "sffdfhf");
+ plainArray.getIndexOfValue("sddfhf");
+ ```
+
+
+### getKeyAt
+
+getKeyAt(index: number): number;
+
+查找指定下标的元素键值对中key值,否则返回undefined。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | index | number | 是 | 所查找的下标 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | number | 返回该下标对应的元素键值对中key值 |
+
+- 示例:
+ ```
+ let plainArray = new PlainArray();
+ plainArray.add(1, "sddfhf");
+ plainArray.add(2, "sffdfhf");
+ plainArray.getKeyAt(1);
+ ```
+
+
+### clone
+
+clone(): PlainArray<T>;
+
+克隆一个一模一样的实例,并返回克隆后的实例,修改克隆后的实例并不会影响原实例。
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | PlainArray<T> | 返回新的对象实例 |
+
+- 示例:
+ ```
+ let plainArray = new ArrayList();
+ plainArray.add(1, "sddfhf");
+ plainArray.add(2, "sffdfhf");
+ let newPlainArray = plainArray.clone();
+ ```
+
+
+### add
+
+add(key: number, value: T): boolean;
+
+向容器中添加一组数据。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | key | number | 是 | 添加成员数据的键名 |
+ | value | T | 是 | 添加成员数据的值 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | boolean | 确认是否成功添加 |
+
+- 示例:
+ ```
+ let plainArray = new PlainArray();
+ plainArray.add(1, "sddfhf");
+ ```
+
+
+### remove
+
+remove(key: number): T;
+
+删除指定的元素。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | key | number | 是 | 依据key指定删除的元素 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | T | 返回删除元素的值 |
+
+- 示例:
+ ```
+ let plainArray = new PlainArray();
+ plainArray.add(1, "sddfhf");
+ plainArray.add(2, "sffdfhf");
+ plainArray.remove(2);
+ ```
+
+
+### removeAt
+
+removeAt(index: number): boolean;
+
+删除指定下标的元素。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | index | number | 是 | 指定想要删除元素下标 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | boolean | 确认是否成功删除元素 |
+
+- 示例:
+ ```
+ let plainArray = new PlainArray();
+ plainArray.add(1, "sddfhf");
+ plainArray.add(2, "sffdfhf");
+ plainArray.removeAt(1);
+ ```
+
+
+### removeRangeFrom
+
+removeRangeFrom(index: number, size: number): number;
+
+删除一定范围内的元素。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | index | number | 是 | 删除元素的起始下标 |
+ | size | number | 是 | 期望删除元素个数 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | number | 实际删除元素个数 |
+
+- 示例:
+ ```
+ let plainArray = new PlainArray();
+ plainArray.add(1, "sddfhf");
+ plainArray.add(2, "sffdfhf");
+ plainArray.removeAt(1, 3);
+ ```
+
+
+### setValueAt
+
+setValueAt(index: number, newValue: T): void;
+
+向容器中具体位置替换键值对中的值。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | index | number | 是 | 指定替换数据下标 |
+ | newValue | T | 是 | 替换键值对中的值 |
+
+
+- 示例:
+ ```
+ let plainArray = new PlainArray();
+ plainArray.add(1, "sddfhf");
+ plainArray.add(2, "sffdfhf");
+ plainArray.setValueAt(1, 3546);
+ ```
+
+
+### toString
+
+toString(): String;
+
+获取包含容器中所有键和值的字符串。
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | String | 返回一个字符串 |
+
+- 示例:
+ ```
+ let plainArray = new PlainArray();
+ plainArray.add(1, "sddfhf");
+ plainArray.add(2, "sffdfhf");
+ plainArray.toString();
+ ```
+
+
+### clear
+
+clear(): void;
+
+清除容器中的所有元素,并把length置为0。
+
+- 示例:
+ ```
+ let plainArray = new PlainArray();
+ plainArray.add(1, "sddfhf");
+ plainArray.add(2, "sffdfhf");
+ plainArray.clear();
+ ```
+
+
+### forEach
+
+forEach(callbackfn: (value: T, key?: number, plainArray?: PlainArray) => void, thisArg?: Object): void;
+
+通过回调函数来遍历实例对象上的元素以及元素对应的下标。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | callbackfn | function | 是 | 回调函数 |
+ | thisArg | Object | 否 | callbackfn被调用时用作this值 |
+
+- callbackfn的参数说明
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | value | T | 是 | 当前遍历到的元素键值对的值 |
+ | key | number | 是 | 当前遍历到的元素键值对的键 |
+ | plainArray | PlainArray | 否 | 当前调用forEach方法的实例对象 |
+
+- 示例:
+ ```
+ let plainArray = new PlainArray();
+ plainArray.add(1, "sddfhf");
+ plainArray.add(2, "sffdfhf");
+ plainArray.forEach((value, key) => {
+ console.log(value, key);
+ });
+ ```
+
+
+### [Symbol.iterator]
+
+[Symbol.iterator]\(): IterableIterator<[number, T]>;
+
+返回一个迭代器,迭代器的每一项都是一个 JavaScript对象,并返回该对象。
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | IterableIterator<[number, T]> | 返回一个迭代器 |
+
+- 示例:
+ ```
+ let plainArray = new PlainArray();
+ plainArray.add(1, "sddfhf");
+ plainArray.add(2, "sffdfhf");
+
+ // 使用方法一:
+ for (let item of plainArray) {
+ console.log("index: " + item[0]);
+ console.log("value: " + item[1]);
+ }
+
+ // 使用方法二:
+ let iter = plainArray[Symbol.iterator]();
+ let temp = iter.next().value;
+ while(temp != undefined) {
+ console.log(temp[0]);
+ console.log(temp[1]);
+ temp = iter.next().value;
+ }
+ ```
\ No newline at end of file
diff --git a/zh-cn/application-dev/reference/apis/js-apis-power.md b/zh-cn/application-dev/reference/apis/js-apis-power.md
index 8304b440be0a7fa40c3be3af046863b6cb2da3af..281e065072a9cbd418ab2755255613665be337b9 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-power.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-power.md
@@ -10,14 +10,9 @@
import power from '@ohos.power';
```
+## 系统能力
-## 权限
-
-关机权限: ohos.permission.SHUTDOWN
-
-重启权限: ohos.permission.REBOOT
-
-重启并进入recovery模式的权限:ohos.permission.REBOOT_RECOVERY
+SystemCapability.PowerManager.PowerManager
## power.shutdownDevice
@@ -26,6 +21,8 @@ shutdownDevice(reason: string): void
系统关机。
+需要权限:ohos.permission.SHUTDOWN
+
- 参数:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
@@ -44,6 +41,8 @@ rebootDevice(reason: string): void
重启设备。
+需要权限:ohos.permission.REBOOT(重启权限)、ohos.permission.REBOOT_RECOVERY(重启并进入recovery模式的权限)
+
- 参数:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
diff --git a/zh-cn/application-dev/reference/apis/js-apis-process.md b/zh-cn/application-dev/reference/apis/js-apis-process.md
index 5aa3245c385bfbaa6d6f190ec708844dbc5ec51f..d7a2671e56c1d12b6a54d0e73e0aaf8f45ffbe54 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-process.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-process.md
@@ -11,11 +11,6 @@ import process from '@ohos.process';
```
-## 权限
-
-无
-
-
## 属性
| 名称 | 类型 | 可读 | 可写 | 说明 |
@@ -143,12 +138,12 @@ kill函数用来发送信号给子进程,结束指定进程。
isIsolatedProcess(): boolean
-检查进程是否被隔离。
+判断进程是否被隔离。
- 返回值:
| 类型 | 说明 |
| -------- | -------- |
- | boolean | 进程是否隔离 |
+ | boolean | 返回判断结果,如果返回true表示进程被隔离。 |
- 示例:
```
@@ -160,17 +155,17 @@ isIsolatedProcess(): boolean
isAppUid(v:number): boolean
-判断是否特定程序的uid。
+判断uid是否属于应用程序。
- 参数:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
- | v | number | 是 | 进程的id。 |
+ | v | number | 是 | 应用程序的uid。 |
- 返回值:
| 类型 | 说明 |
| -------- | -------- |
- | boolean | 是否是当前app的uid |
+ | boolean | 返回判断结果,如果返回true表示为应用程序的uid。|
- 示例:
```
@@ -182,12 +177,12 @@ isAppUid(v:number): boolean
is64Bit(): boolean
-判断运行环境是不是64位。
+判断运行环境是否64位。
- 返回值:
| 类型 | 说明 |
| -------- | -------- |
- | boolean | 是不是64位环境 |
+ | boolean | 返回判断结果,如果返回true表示为64位环境。 |
- 示例:
```
@@ -204,12 +199,12 @@ getUidForName(v:string): number
- 参数:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
- | v | string | 是 | 进程name |
+ | v | string | 是 | 进程名。 |
- 返回值:
| 类型 | 说明 |
| -------- | -------- |
- | number | 进程的uid |
+ | number | 返回进程uid。|
- 示例:
```
@@ -221,17 +216,17 @@ getUidForName(v:string): number
getThreadPriority(v:number): number
-根据指定的 TID 获取线程优先级。
+根据指定的tid获取线程优先级。
- 参数:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
- | v | number | 是 | 进程的id |
+ | v | number | 是 | 指定的线程tid。 |
- 返回值:
| 类型 | 说明 |
| -------- | -------- |
- | number | 进程的优先级 |
+ | number | 返回线程的优先级。 |
- 示例:
```
@@ -249,31 +244,13 @@ getStartRealtime() :number
- 返回值:
| 类型 | 说明 |
| -------- | -------- |
- | number | 时间 |
+ | number | 返回经过的实时时间。|
- 示例:
```
var realtime = process.getStartRealtime();
```
-
-## process.getAvailableCores8+
-
-getAvailableCores() :number[]
-
-获取多核设备上当前进程可用的 CPU 内核。
-
-- 返回值:
- | 类型 | 说明 |
- | -------- | -------- |
- | number[] | 可用内核数 |
-
-- 示例:
- ```
- var result = getAvailableCores();
- ```
-
-
## process.getPastCputime8+
getPastCputime() :number
@@ -283,7 +260,7 @@ getPastCputime() :number
- 返回值:
| 类型 | 说明 |
| -------- | -------- |
- | number | 时间 |
+ | number | 返回经过的CPU时间。 |
- 示例:
```
@@ -295,17 +272,17 @@ getPastCputime() :number
getSystemConfig(name:number): number
-用该方法发送signal到指定的进程。
+获取系统配置信息。
- 参数:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
- | name | number | 是 | 系统配置参数名 |
+ | name | number | 是 | 指定系统配置参数名。 |
- 返回值:
| 类型 | 说明 |
| -------- | -------- |
- | number | 配置信息 |
+ | number | 返回系统配置信息。 |
- 示例:
```
@@ -323,12 +300,12 @@ getEnvironmentVar(name:string): string
- 参数:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
- | name | string | 是 | 环境名 |
+ | name | string | 是 | 环境变量名。 |
- 返回值:
| 类型 | 说明 |
| -------- | -------- |
- | string | 环境名对应的value |
+ | string | 返回环境变量名对应的value。 |
- 示例:
```
@@ -367,7 +344,7 @@ runCmd(command: string, options?: { timeout : number, killSignal :number | str
var result = child.wait();
child.getOutput.then(val=>{
console.log("child.getOutput = " + val);
- }
+ })
```
diff --git a/zh-cn/application-dev/reference/apis/js-apis-queue.md b/zh-cn/application-dev/reference/apis/js-apis-queue.md
new file mode 100644
index 0000000000000000000000000000000000000000..30eb24a15f2e4fe6d03b8fcae31c84ebb4a98d60
--- /dev/null
+++ b/zh-cn/application-dev/reference/apis/js-apis-queue.md
@@ -0,0 +1,180 @@
+# 线性容器Queue
+
+>  **说明:**
+> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
+
+
+## 导入模块
+
+```
+import Queue from '@ohos.util.Queue'
+```
+
+
+## 权限
+
+无
+
+
+## Queue
+
+
+### 属性
+
+| 名称 | 参数类型 | 可读 | 可写 | 说明 |
+| -------- | -------- | -------- | -------- | -------- |
+| length | number | 是 | 否 | Queue的元素个数 |
+
+
+### constructor
+
+constructor();
+
+Queue的构造函数。
+
+
+- 示例:
+ ```
+ let queue = new Queue();
+ ```
+
+
+### add
+
+add(element: T): boolean;
+
+在队列尾部插入元素。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | element | T | 是 | 添加进去的元素 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | boolean | 插入成功返回true,失败返回false |
+
+- 示例:
+ ```
+ let queue = new Queue();
+ queue.add("a");
+ queue.add(1);
+ let b = [1, 2, 3];
+ queue.add(b);
+ let c = {name : "lala", age : "13"};
+ queue.add(false);
+ ```
+
+### pop
+
+pop(): T
+
+删除头元素并返回该删除元素。
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | T | 返回删除的元素 |
+
+- 示例:
+ ```
+ let queue = new Queue();
+ queue.add(2);
+ queue.add(4);
+ queue.add(5);
+ queue.add(2);
+ queue.add(4);
+ queue.pop();
+ ```
+
+### getFirst
+
+getFirst(): T;
+
+获取队列的头元素。
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | T | 返回尾元素 |
+
+- 示例:
+ ```
+ let queue = new Queue();
+ queue.add(2);
+ queue.add(4);
+ queue.add(5);
+ queue.add(2);
+ queue.getFirst();
+ ```
+
+### forEach
+forEach(callbackfn: (value: T, index?: number, queue?: Queue<T>) => void,
+thisArg?: Object): void;
+
+通过回调函数来遍历Queue实例对象上的元素以及元素对应的下标。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | callbackfn | function | 是 | 回调函数。 |
+ | thisArg | Object | 否 | callbackfn被调用时用作this值 |
+
+- callbackfn的参数说明
+
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | value | T | 是 | 当前遍历到的元素 |
+ | index | number | 否 | 当前遍历到的下标值 |
+ | queue | Queue<T> | 否 | 当前调用forEach方法的实例对象 |
+
+
+- 示例:
+ ```
+ let queue = new Queue();
+ queue.add(2);
+ queue.add(4);
+ queue.add(5);
+ queue.add(4);
+ queue.forEach((value, index) => {
+ console.log(value, index);
+ });
+
+ ```
+
+### [Symbol.iterator]
+
+[Symbol.iterator]\(): IterableIterator<T>;
+
+
+返回一个迭代器,迭代器的每一项都是一个 JavaScript 对象,并返回该对象。
+
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | IterableIterator<T> | 返回一个迭代器 |
+
+
+- 示例:
+ ```
+ let queue = new Queue();
+ queue.add(2);
+ queue.add(4);
+ queue.add(5);
+ queue.add(4);
+
+ // 使用方法一:
+ for (let item of queue) {
+ console.log(item);
+ }
+
+ // 使用方法二:
+ let iter = queue[Symbol.iterator]();
+ let temp = iter.next().value;
+ while(temp != undefined) {
+ console.log(temp);
+ temp = iter.next().value;
+ }
+ ```
\ No newline at end of file
diff --git a/zh-cn/application-dev/reference/apis/js-apis-reminderAgent.md b/zh-cn/application-dev/reference/apis/js-apis-reminderAgent.md
index 302ec50fe59579adac4133cd9f5e41df1ce37536..5d634d453ea544c2eff9e67b164e41d6e4de6a1d 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-reminderAgent.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-reminderAgent.md
@@ -11,6 +11,11 @@ import reminderAgent from'@ohos.reminderAgent';
```
+## 系统能力
+
+SystemCapability.Notification.ReminderAgent
+
+
## 权限
ohos.permission.PUBLISH_AGENT_REMINDER
diff --git a/zh-cn/application-dev/reference/apis/js-apis-runninglock.md b/zh-cn/application-dev/reference/apis/js-apis-runninglock.md
index 887fa5eb22a99229226be3d13c70037e44d61318..c6f8ba213794bcd5398c20148c79624c45c3c698 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-runninglock.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-runninglock.md
@@ -11,9 +11,9 @@ import runninglock from '@ohos.runningLock';
```
-## 权限
+## 系统能力
-申请、使用锁的权限:ohos.permission.RUNNING_LOCK
+SystemCapability.PowerManager.PowerManager
## RunningLockType
@@ -84,6 +84,8 @@ createRunningLock(name: string, type: RunningLockType, callback: AsyncCallback&l
创建RunningLock锁。
+需要权限:ohos.permission.RUNNING_LOCK
+
- 参数:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
@@ -113,6 +115,8 @@ createRunningLock(name: string, type: RunningLockType): Promise<RunningLock&g
创建Runninglock锁。
+需要权限:ohos.permission.RUNNING_LOCK
+
- 参数:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
diff --git a/zh-cn/application-dev/reference/apis/js-apis-sensor.md b/zh-cn/application-dev/reference/apis/js-apis-sensor.md
index c672a9bfdf63115a0070c576bf939021735739e5..838641fb4ee7d5f08e671f789e9000f31f602164 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-sensor.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-sensor.md
@@ -10,6 +10,9 @@
import sensor from '@ohos.sensor';
```
+## 系统能力
+
+SystemCapability.Sensors.Sensor
## 权限列表
diff --git a/zh-cn/application-dev/reference/apis/js-apis-stack.md b/zh-cn/application-dev/reference/apis/js-apis-stack.md
new file mode 100644
index 0000000000000000000000000000000000000000..c20b9196cd20fe6b88b58bbeb192aa261abb24ee
--- /dev/null
+++ b/zh-cn/application-dev/reference/apis/js-apis-stack.md
@@ -0,0 +1,222 @@
+# 线性容器Stack
+
+>  **说明:**
+> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
+
+
+## 导入模块
+
+```
+import Stack from '@ohos.util.Stack'
+```
+
+
+## 权限
+
+无
+
+
+## Stack
+
+
+### 属性
+
+| 名称 | 参数类型 | 可读 | 可写 | 说明 |
+| -------- | -------- | -------- | -------- | -------- |
+| length | number | 是 | 否 | Stack的元素个数 |
+
+
+### constructor
+
+constructor();
+
+Stack的构造函数。
+
+
+- 示例:
+ ```
+ let stack = new Stack();
+ ```
+
+
+### push
+
+push(item: T): T;
+
+在栈顶插入元素,并返回该元素。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | item | T | 是 | 添加进去的元素 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | T | 返回被添加进去的元素 |
+
+- 示例:
+ ```
+ let stack = new Stack();
+ stack.push("a");
+ stack.push(1);
+ let b = [1, 2, 3];
+ stack.push(b);
+ let c = {name : "lala", age : "13"};
+ stack.push(false);
+ ```
+
+### pop
+
+pop(): T;
+
+删除栈顶元素并返回该删除元素。
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | T | 返回删除的元素 |
+
+- 示例:
+ ```
+ let stack = new Stack();
+ stack.push(2);
+ stack.push(4);
+ stack.push(5);
+ stack.push(2);
+ stack.push(4);
+ stack.pop();
+ ```
+
+### peek
+
+peek(): T;
+
+获取并返回栈顶元素。
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | T | 返回栈顶元素 |
+
+- 示例:
+ ```
+ let stack = new Stack();
+ stack.push(2);
+ stack.push(4);
+ stack.push(5);
+ stack.push(2);
+ stack.peek();
+ ```
+### locate
+
+locate(element: T): number;
+
+返回指定元素第一次出现时的下标值,查找失败返回-1。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | element | T | 是 | 指定元素 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | number | 找到就返回下标值,查找失败返回-1 |
+- 示例:
+ ```
+ let stack = new Stack();
+ stack.push(2);
+ stack.push(4);
+ stack.push(5);
+ stack.push(2);
+ stack.locate(2);
+ ```
+
+### forEach
+forEach(callbackfn: (value: T, index?: number, stack?: Stack<T>) => void,
+thisArg?: Object): void;
+
+通过回调函数来遍历Stack实例对象上的元素以及元素对应的下标。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | callbackfn | function | 是 | 回调函数 |
+ | thisArg | Object | 否 | callbackfn被调用时用作this值 |
+
+- callbackfn的参数说明
+
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | value | T | 是 | 当前遍历到的元素。 |
+ | index | number | 否 | 当前遍历到的下标值。 |
+ | stack | Stack<T> | 否 | 当前调用forEach方法的实例对象。 |
+
+
+- 示例:
+ ```
+ let stack = new Stack();
+ stack.push(2);
+ stack.push(4);
+ stack.push(5);
+ stack.push(4);
+ stack.forEach((value, index) => {
+ console.log(value, index);
+ });
+ ```
+### isEmpty
+isEmpty(): boolean;
+
+判断该栈是否为空。
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | boolean | 为空返回true, 不为空返回false |
+
+- 示例:
+ ```
+ let stack = new Stack();
+ stack.push(2);
+ stack.push(4);
+ stack.push(5);
+ stack.push(4);
+ stack.isEmpty();
+ ```
+
+### [Symbol.iterator]
+
+[Symbol.iterator]\(): IterableIterator<T>;
+
+
+返回一个迭代器,迭代器的每一项都是一个 JavaScript 对象,并返回该对象。
+
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | IterableIterator<T> | 返回一个迭代器 |
+
+
+- 示例:
+ ```
+ let stack = new Stack();
+ stack.push(2);
+ stack.push(4);
+ stack.push(5);
+ stack.push(4);
+
+ // 使用方法一:
+ for (let item of stack) {
+ console.log(item);
+ }
+
+ // 使用方法二:
+ let iter = stack[Symbol.iterator]();
+ let temp = iter.next().value;
+ while(temp != undefined) {
+ console.log(temp);
+ temp = iter.next().value;
+ }
+ ```
\ No newline at end of file
diff --git a/zh-cn/application-dev/reference/apis/js-apis-statfs.md b/zh-cn/application-dev/reference/apis/js-apis-statfs.md
index de83a64b5d31a3da69ec9c072ce0391d8f27f809..8c7b111f4effa7815c208b55c79f5ea1ab64de00 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-statfs.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-statfs.md
@@ -1,11 +1,12 @@
# statfs
-
+>  **说明:**
+> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块
-```
-import statfs from '@ohos.statfs'
+```js
+import statfs from '@ohos.statfs';
```
## 使用说明
@@ -16,13 +17,13 @@ import statfs from '@ohos.statfs'
通过上述接口获取到应用目录路径dir,文件名为“xxx.txt”,文件所在绝对路径为:
-```
-let path = dir + "xxx.txt"
+```js
+let path = dir + "xxx.txt";
```
-## 权限列表
+## 系统能力
-无
+SystemCapability.FileManagement.File.FileIO
## statfs.getFreeBytes
@@ -44,8 +45,13 @@ getFreeBytes(path:string):Promise<number>
- 示例:
- ```
- let num = await statfs.getFreeBytes(path);
+ ```js
+ let path = "/data";
+ statfs.getFreeBytes(path).then(function (number){
+ console.info("getFreeBytes successfully:"+ number);
+ }).catch(function(err){
+ console.info("getFreeBytes failed with error:"+ err);
+ });
```
## statfs.getFreeBytes
@@ -63,7 +69,7 @@ getFreeBytes(path:string, callback:AsyncCallback<number>): void
- 示例:
- ```
+ ```js
statfs.getFreeBytes(path, function(err, number){
//do something
});
@@ -89,8 +95,13 @@ getTotalBytes.(path:string):Promise<number>
- 示例:
- ```
- let num = await statfs.getTotalBytes(path);
+ ```js
+ let path = "/data";
+ statfs.getTotalBytes(path).then(function (number){
+ console.info("getTotalBytes successfully:"+ number);
+ }).catch(function(err){
+ console.info("getTotalBytes failed with error:"+ err);
+ });
```
## statfs.getTotalBytes
@@ -108,7 +119,7 @@ getTotalBytes(path:string, callback:AsyncCallback<number>): void
- 示例:
- ```
+ ```js
statfs.getTotalBytes(path, function(err, number){
//do something
});
diff --git a/zh-cn/application-dev/reference/apis/js-apis-storage-statistics.md b/zh-cn/application-dev/reference/apis/js-apis-storage-statistics.md
new file mode 100644
index 0000000000000000000000000000000000000000..1f6fd7240d544c637071afe99294fc1e46af5ae1
--- /dev/null
+++ b/zh-cn/application-dev/reference/apis/js-apis-storage-statistics.md
@@ -0,0 +1,183 @@
+# 应用空间统计
+
+>  **说明:**
+> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
+
+## 导入模块
+
+```js
+import storagestatistics from "@ohos.storagestatistics";
+```
+
+## 系统能力
+
+SystemCapability.FileManagement.StorageService.SpatialStatistics
+
+## storagestatistics.getTotalSizeOfVolume
+
+getTotalSizeOfVolume(volumeUuid: string): Promise<number>
+
+异步获取指定卷的总空间大小,以promise方式返回。
+
+- 参数
+
+ | 参数名 | 类型 | 必填 | 说明 |
+ | ---------- | ------ | ---- | ---- |
+ | volumeUuid | string | 是 | 卷id |
+
+- 返回值
+
+ | 类型 | 说明 |
+ | --------------------- | ---------------- |
+ | Promise<number> | 返回指定卷总空间 |
+
+- 示例
+
+ ```js
+ let uuid = "";
+ storagestatistics.getTotalSizeOfVolume(uuid).then(function(number){
+ console.info("getTotalSizeOfVolume successfully:"+ number);
+ }).catch(function(err){
+ console.info("getTotalSizeOfVolume failed with error:"+ err);
+ });
+ ```
+
+## storagestatistics.getTotalSizeOfVolume
+
+getTotalSizeOfVolume(volumeUuid: string, callback:AsyncCallback<number>):void
+
+异步获取指定卷的总空间大小,以callback方式返回。
+
+- 参数
+
+ | 参数名 | 类型 | 必填 | 说明 |
+ | ---------- | ------------------------------------ | ---- | -------------------------- |
+ | volumeUuid | string | 是 | 卷id |
+ | callback | callback:AsyncCallback<number> | 是 | 获取指定卷总空间之后的回调 |
+
+- 示例
+
+ ```js
+ let uuid = "";
+ storagestatistics.getTotalSizeOfVolume(uuid, function(error, number){
+ // do something
+ });
+ ```
+
+
+
+## storagestatistics.getFreeSizeOfVolume
+
+getFreeSizeOfVolume(volumeUuid: string): Promise<number>
+
+异步获取指定卷的可用空间大小,以promise方式返回。
+
+- 参数
+
+ | 参数名 | 类型 | 必填 | 说明 |
+ | ---------- | ------ | ---- | ---- |
+ | volumeUuid | string | 是 | 卷id |
+
+- 返回值
+
+ | 类型 | 说明 |
+ | --------------------- | ------------------ |
+ | Promise<number> | 返回指定卷可用空间 |
+
+- 示例
+
+ ```js
+ let uuid = "";
+ storagestatistics.getFreeSizeOfVolume(uuid).then(function(number){
+ console.info("getFreeSizeOfVolume successfully:"+ number);
+ }).catch(function(err){
+ console.info("getFreeSizeOfVolume failed with error:"+ err);
+ });
+
+ ```
+
+## storagestatistics.getFreeSizeOfVolume
+
+getFreeSizeOfVolume(volumeUuid: string, callback:AsyncCallback<number>):void
+
+异步获取指定卷的可用空间大小,以callback方式返回。
+
+- 参数
+
+ | 参数名 | 类型 | 必填 | 说明 |
+ | ---------- | ------------------------------------ | ---- | ---------------------------- |
+ | volumeUuid | string | 是 | 卷id |
+ | callback | callback:AsyncCallback<number> | 是 | 获取指定卷可用空间之后的回调 |
+
+- 示例
+
+ ```js
+ let uuid = "";
+ storagestatistics.getFreeSizeOfVolume(uuid, function(error, number){
+ // do something
+ });
+ ```
+
+## storagestatistics.getBundleStats
+
+getBundleStats(volumeUuid: string, packageName:String, ): Promise<BundleStats>
+
+异步获取指定卷上的应用存储状态,以promise方式返回。
+
+- 参数
+
+ | 参数名 | 类型 | 必填 | 说明 |
+ | ----------- | ------ | ---- | -------- |
+ | volumeUuid | string | 是 | 卷id |
+ | packageName | string | 是 | 应用包名 |
+
+- 返回值
+
+ | 类型 | 说明 |
+ | ------------------------------------------ | -------------------------- |
+ | Promise<[Bundlestats](#bundlestats)> | 返回指定卷上的应用存储状态 |
+
+- 示例
+
+ ```js
+ let uuid = "";
+ let packageName = "";
+ storagestatistics.getBundleStats(uuid, packageName).then(function(BundleStats){
+ console.info("getBundleStats successfully:"+ JSON.stringify(BundleStats));
+ }).catch(function(err){
+ console.info("getBundleStats failed with error:"+ err);
+ });
+ ```
+
+## storagestatistics.getBundleStats
+
+getBundleStats(volumeUuid: string, callback:AsyncCallback<BundleStats>):void
+
+异步获取指定卷上的应用存储状态,以callback方式返回。
+
+- 参数
+
+ | 参数名 | 类型 | 必填 | 说明 |
+ | ---------- | --------------------------------------------------------- | ---- | ------------------------------------ |
+ | volumeUuid | string | 是 | 卷id |
+ | callback | callback:AsyncCallback<[Bundlestats](#bundlestats)> | 是 | 获取指定卷上的应用存储状态之后的回调 |
+
+- 示例
+
+ ```js
+ let uuid = "";
+ let packageName = "";
+ storagestatistics.getBundleStats(uuid, packageName, function(error, BundleStats){
+ // do something
+ });
+ ```
+
+## BundleStats
+
+### 属性
+
+| 名称 | 类型 | 说明 |
+| --------- | ------ | -------------- |
+| appSize | number | app数据大小 |
+| cacheSize | number | 缓存数据大小 |
+| dataSize | number | 应用总数据大小 |
\ No newline at end of file
diff --git a/zh-cn/application-dev/reference/apis/js-apis-treemap.md b/zh-cn/application-dev/reference/apis/js-apis-treemap.md
new file mode 100644
index 0000000000000000000000000000000000000000..56fd01993c739aced2a480e6957c571580a6be39
--- /dev/null
+++ b/zh-cn/application-dev/reference/apis/js-apis-treemap.md
@@ -0,0 +1,476 @@
+# 非线性容器TreeMap
+
+>  **说明:**
+> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
+
+
+## 导入模块
+
+```
+import TreeMap from '@ohos.util.TreeMap'
+```
+
+
+## 权限
+
+无
+
+## TreeMap
+
+
+### 属性
+
+| 名称 | 参数类型 | 可读 | 可写 | 说明 |
+| -------- | -------- | -------- | -------- | -------- |
+| length | number | 是 | 否 | TreeMap的元素个数 |
+
+
+### constructor
+
+constructor(comparator?:(firstValue: K, secondValue: K) => boolean);
+
+TreeMap的构造函数。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | comparator | function | 否 | 用户自定义的比较函数 |
+
+- 示例:
+ ```
+ let treeMap = new TreeMap();
+ ```
+
+
+### isEmpty
+
+isEmpty(): boolean;
+
+判断该容器是否为空。
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | boolean | 为空返回true, 不为空返回false |
+
+- 示例:
+ ```
+ const treeMap = new TreeMap();
+ treeMap.isEmpty();
+ ```
+
+
+### hasKey
+
+hasKey(key: K): boolean;
+
+判断此容器中是否含有该指定key。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | key | K | 是 | 指定元素 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | boolean | 是否包含指定元素 |
+
+- 示例:
+ ```
+ let treeMap = new TreeMap();
+ treeMap.hasKey("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
+ treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
+ treeMap.hasKey("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
+ ```
+
+
+### hasValue
+
+hasValue(value: V): boolean;
+
+判断此容器中是否含有该指定value。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | value | V | 是 | 指定元素 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | boolean | 是否包含指定元素 |
+
+- 示例:
+ ```
+ let treeMap = new TreeMap();
+ treeMap.hasValue(123);
+ treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
+ treeMap.hasValue(123);
+ ```
+
+
+### get
+
+get(key: K): V;
+
+获取指定key所对应的value。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | key | K | 是 | 查找的指定key |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | V | 返回key映射的value值 |
+
+- 示例:
+ ```
+ let treeMap = new TreeMap();
+ treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
+ treeMap.set("sdfs", 356);
+ treeMap.get("sdfs");
+ ```
+
+
+### getFirstKey
+
+getFirstKey(): K;
+
+获取容器中排序第一的数据。
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | K | 返回排序第一的数据 |
+
+- 示例:
+ ```
+ let treeMap = new TreeMap();
+ treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
+ treeMap.set("sdfs", 356);
+ let result = treeMap.getFirstKey();
+ ```
+
+
+### getLastKey
+
+getLastKey(): K;
+
+获取容器中排序最后的数据。
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | K | 返回排序最后的数据 |
+
+- 示例:
+ ```
+ let treeMap = new TreeMap();
+ treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
+ treeMap.set("sdfs", 356);
+ let result = treeMap.getLastKey();
+ ```
+
+
+### setAll
+
+setAll(map: TreeMap): void;
+
+将一个treemap中的所有元素组添加到另一个treemap中。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | map | TreeMap | 是 | 被添加元素的treemap |
+
+- 示例:
+ ```
+ let treeMap = new TreeMap();
+ treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
+ treeMap.set("sdfs", 356);
+ let map = new TreeMap();
+ treeMap.setAll(map);
+ ```
+
+
+### set
+set(key: K, value: V): Object;
+
+向treemap中添加一组数据。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | key | K | 是 | 添加成员数据的键名 |
+ | value | V | 是 | 添加成员数据的值 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | Object | 返回添加后的hashmap |
+
+- 示例:
+ ```
+ let treeMap = new TreeMap();
+ treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
+ ```
+
+
+### remove
+
+remove(key: K): V;
+
+删除指定的元素。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | key | K | 是 | 依据key指定删除的元素 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | V | 返回删除元素的值 |
+
+- 示例:
+ ```
+ let treeMap = new TreeMap();
+ treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
+ treeMap.set("sdfs", 356);
+ treeMap.remove("sdfs");
+ ```
+
+
+### getLowerByKey
+
+getLowerByKey(key: K): K;
+
+获取容器中比传入key排序靠前一位的key。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | key | K | 是 | 对比的key值 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | K | 返回排序中key前一位的数据 |
+
+- 示例:
+ ```
+ let treeMap = new TreeMap();
+ treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
+ treeMap.set("sdfs", 356);
+ treeMap.set("zdfgsd", 356);
+ let result = treeMap.getLowerByKey("sdfs");
+ ```
+
+
+### getHigherByKey
+
+getHigherByKey(key: K): K;
+
+获取容器中比传入key排序靠后一位的key。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | key | K | 是 | 对比的key值 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | K | 返回排序中key后一位的数据 |
+
+- 示例:
+ ```
+ let treeMap = new TreeMap();
+ treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
+ treeMap.set("sdfs", 356);
+ treeMap.set("zdfgsd", 356);
+ let result = treeMap.getHigherByKey("sdfs");
+ ```
+
+
+### replace
+replace(key: K, value: V): boolean;
+
+对TreeMap中一组数据进行更新(替换)。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | key | K | 是 | 依据key指定替换的元素 |
+ | value | V | 是 | 添加成员数据的值 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | boolean | 是否成功对已有数据进行替换 |
+
+- 示例:
+ ```
+ let treeMap = new TreeMap();
+ treeMap.set("sdfs", 123);
+ treeMap.replace("sdfs", 357);
+ ```
+
+
+### clear
+
+clear(): void;
+
+清除TreeMap中的所有元素,并把length置为0。
+
+- 示例:
+ ```
+ let treeMap = new TreeMap();
+ treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
+ treeMap.set("sdfs", 356);
+ treeMap.clear();
+ ```
+
+
+### keys
+
+keys(): IterableIterator<K>;
+
+返回包含此映射中包含的键的新迭代器对象。
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | IterableIterator<K> | 返回一个迭代器 |
+
+- 示例:
+ ```
+ let treeMap = new TreeMap();
+ treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
+ treeMap.set("sdfs", 356);
+ let iter = treeMap.keys();
+ let temp = iter.next().value;
+ while(temp != undefined) {
+ console.log(temp);
+ temp = iter.next().value;
+ }
+ ```
+
+
+### values
+
+values(): IterableIterator<V>;
+
+返回包含此映射中包含的键的新迭代器对象。
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | IterableIterator<V> | 返回一个迭代器 |
+
+- 示例:
+ ```
+ let treeMap = new TreeMap();
+ treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
+ treeMap.set("sdfs", 356);
+ let iter = treeMap.values();
+ let temp = iter.next().value;
+ while(temp != undefined) {
+ console.log(temp);
+ temp = iter.next().value;
+ }
+ ```
+
+
+### forEach
+
+forEach(callbackfn: (value: V, key?: K, treeMap?: TreeMap) => void, thisArg?: Object): void;
+
+通过回调函数来遍历实例对象上的元素以及元素对应的下标。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | callbackfn | function | 是 | 回调函数 |
+ | thisArg | Object | 否 | callbackfn被调用时用作this值 |
+
+- callbackfn的参数说明
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | value | V | 是 | 当前遍历到的元素键值对的值 |
+ | key | K | 是 | 当前遍历到的元素键值对的键 |
+ | treeMap | TreeMap | 否 | 当前调用forEach方法的实例对象 |
+
+- 示例:
+ ```
+ let treeMap = new TreeMap();
+ treeMap.set("sdfs", 123);
+ treeMap.set("dfsghsf", 357);
+ treeMap.forEach((value, key) => {
+ console.log(value, key);
+ });
+ ```
+
+
+### entries
+
+entries(): IterableIterator<[K, V]>;
+
+返回包含此映射中包含的键的新迭代器对象。
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | IterableIterator<[K, V]> | 返回一个迭代器 |
+
+- 示例:
+ ```
+ let treeMap = new TreeMap();
+ treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
+ treeMap.set("sdfs", 356);
+ let iter = treeMap.entries();
+ let temp = iter.next().value;
+ while(temp != undefined) {
+ console.log(temp[0]);
+ console.log(temp[1]);
+ temp = iter.next().value;
+ }
+ ```
+
+
+### [Symbol.iterator]
+
+[Symbol.iterator]\(): IterableIterator<[K, V]>;
+
+
+返回一个迭代器,迭代器的每一项都是一个 JavaScript 对象,并返回该对象。
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | IterableIterator<[K, V]> | 返回一个迭代器 |
+
+- 示例:
+ ```
+ let treeMap = new TreeMap();
+ treeMap.set("Ahfbrgrbgnutfodgorrogorgrogofdfdf", 123);
+ treeMap.set("sdfs", 356);
+
+ // 使用方法一:
+ for (let item of treeMap) {
+ console.log("key: " + item[0]);
+ console.log("value: " + item[1]);
+ }
+
+ // 使用方法二:
+ let iter = treeMap[Symbol.iterator]();
+ let temp = iter.next().value;
+ while(temp != undefined) {
+ console.log(temp[0]);
+ console.log(temp[1]);
+ temp = iter.next().value;
+ }
+ ```
\ No newline at end of file
diff --git a/zh-cn/application-dev/reference/apis/js-apis-treeset.md b/zh-cn/application-dev/reference/apis/js-apis-treeset.md
new file mode 100644
index 0000000000000000000000000000000000000000..10cbd68738d777fd5c8788ec379f7562ca449f7f
--- /dev/null
+++ b/zh-cn/application-dev/reference/apis/js-apis-treeset.md
@@ -0,0 +1,393 @@
+# 非线性容器TreeSet
+
+>  **说明:**
+> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
+
+
+## 导入模块
+
+```
+import TreeSet from '@ohos.util.TreeSet'
+```
+
+
+## 权限
+
+无
+
+## TreeSet
+
+
+### 属性
+
+| 名称 | 参数类型 | 可读 | 可写 | 说明 |
+| -------- | -------- | -------- | -------- | -------- |
+| length | number | 是 | 否 | TreeSet的元素个数 |
+
+
+### constructor
+
+constructor(comparator?:(firstValue: T, secondValue: T) => boolean);
+
+TreeSet的构造函数。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | comparator | function | 否 | 用户自定义的比较函数 |
+
+- 示例:
+ ```
+ let treeSet = new TreeSet();
+ ```
+
+
+### isEmpty
+
+isEmpty(): boolean;
+
+判断该容器是否为空。
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | boolean | 为空返回true, 不为空返回false |
+
+- 示例:
+ ```
+ const treeSet = new TreeSet();
+ treeSet.isEmpty();
+ ```
+
+
+### has
+
+has(value: T): boolean;
+
+判断此容器中是否含有该指定value。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | value | T | 是 | 指定元素 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | boolean | 是否包含指定元素 |
+
+- 示例:
+ ```
+ let treeSet = new TreeSet();
+ treeSet.has(123);
+ treeSet.add(123);
+ treeSet.has(123);
+ ```
+
+
+### getFirstValue
+
+getFirstValue(): T;
+
+获取容器中排序第一的数据。
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | T | 返回排序第一的数据 |
+
+- 示例:
+ ```
+ let treeSet = new TreeSet();
+ treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
+ treeSet.add("sdfs");
+ let result = treeSet.getFirstValue();
+ ```
+
+
+### getLastValue
+
+getLastValue(): T;
+
+获取容器中排序最后的数据。
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | T | 返回排序最后的数据 |
+
+- 示例:
+ ```
+ let treeSet = new TreeSet();
+ treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
+ treeSet.add("sdfs");
+ let result = treeSet.getLastValue();
+ ```
+
+
+### add
+add(value: T): boolean;
+
+向TreeSet中添加一组数据。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | value | T | 是 | 添加的成员数据 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | boolean | 是否成功添加新数据至容器 |
+
+- 示例:
+ ```
+ let treeSet = new TreeSet();
+ treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
+ ```
+
+
+### remove
+
+remove(key: T): boolean;
+
+删除指定的元素。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | key | T | 是 | 指定的元素 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | boolean | 判断是否成功删除元素 |
+
+- 示例:
+ ```
+ let treeSet = new TreeSet();
+ treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
+ treeSet.add("sdfs");
+ treeSet.remove("sdfs");
+ ```
+
+
+### getLowerValue
+
+getLowerValue(key: T): T;
+
+获取容器中比传入元素排序靠前一位的元素。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | key | T | 是 | 对比的元素值 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | T | 返回排序中对比元素前一位的数据 |
+
+- 示例:
+ ```
+ let treeSet = new TreeSet();
+ treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
+ treeSet.add("sdfs");
+ treeSet.add("zdfgsd");
+ let result = treeSet.getLowerValue("sdfs");
+ ```
+
+
+### getHigherValue
+
+getHigherValue(key: T): T;
+
+获取容器中比传入元素排序靠后一位的元素。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | key | T | 是 | 对比的元素 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | T | 返回排序中传入元素后一位的数据 |
+
+- 示例:
+ ```
+ let treeSet = new TreeSet();
+ treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
+ treeSet.add("sdfs");
+ treeSet.add("zdfgsd");
+ let result = treeSet.getHigherValue("sdfs");
+ ```
+
+
+### popFirst
+
+popFirst(): T;
+
+删除容器中排序最前的数据。
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | T | 返回删除的数据 |
+
+- 示例:
+ ```
+ let treeSet = new TreeSet();
+ treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
+ treeSet.add("sdfs");
+ let result = treeSet.popFirst();
+ ```
+
+
+### popLast
+
+popLast(): T;
+
+删除容器中排序最后的数据。
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | T | 返回删除的数据 |
+
+- 示例:
+ ```
+ let treeSet = new TreeSet();
+ treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
+ treeSet.add("sdfs");
+ let result = treeSet.popLast();
+ ```
+
+
+### clear
+
+clear(): void;
+
+清除容器中的所有元素,并把length置为0。
+
+- 示例:
+ ```
+ let treeSet = new TreeSet();
+ treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
+ treeSet.add("sdfs");
+ treeSet.clear();
+ ```
+
+
+### values
+
+values(): IterableIterator<T>;
+
+返回包含此映射中包含的键的新迭代器对象。
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | IterableIterator<T> | 返回一个迭代器 |
+
+- 示例:
+ ```
+ let treeSet = new TreeSet();
+ treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
+ treeSet.add("sdfs");
+ let iter = treeSet.values();
+ let temp = iter.next().value;
+ while(temp != undefined) {
+ console.log(temp);
+ temp = iter.next().value;
+ }
+ ```
+
+
+### forEach
+
+forEach(callbackfn: (value: T, key?: T, treeSet?: TreeSet<T>) => void, thisArg?: Object): void;
+
+通过回调函数来遍历实例对象上的元素以及元素对应的下标。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | callbackfn | function | 是 | 回调函数 |
+ | thisArg | Object | 否 | callbackfn被调用时用作this值 |
+
+- callbackfn的参数说明
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | value | T | 是 | 当前遍历到的元素 |
+ | key | T | 否 | 当前遍历到的元素(和value相同). |
+ | treeSet | TreeSet<T> | 否 | 当前调用forEach方法的实例对象 |
+
+- 示例:
+ ```
+ let treeSet = new TreeSet();
+ treeSet.add("sdfs");
+ treeSet.add("dfsghsf");
+ treeSet.forEach((value, key) => {
+ console.log(value, key)
+ });
+ ```
+
+
+### entries
+
+entries(): IterableIterator<[T, T]>;
+
+返回包含此映射中包含的键的新迭代器对象。
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | IterableIterator<[T, T]> | 返回一个迭代器 |
+
+- 示例:
+ ```
+ let treeSet = new TreeSet();
+ treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
+ treeSet.add("sdfs");
+ let iter = treeSet.entries();
+ let temp = iter.next().value;
+ while(temp != undefined) {
+ console.log(temp[0]);
+ console.log(temp[1]);
+ temp = iter.next().value;
+ }
+ ```
+
+
+### [Symbol.iterator]
+
+[Symbol.iterator]\(): IterableIterator<T>;
+
+
+返回一个迭代器,迭代器的每一项都是一个 JavaScript 对象,并返回该对象。
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | IterableIterator<T> | 返回一个迭代器 |
+
+- 示例:
+ ```
+ let treeSet = new TreeSet();
+ treeSet.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
+ treeSet.add("sdfs");
+
+ // 使用方法一:
+ for (let item of treeSet) {
+ console.log("value: " + item);
+ }
+
+ // 使用方法二:
+ let iter = treeSet[Symbol.iterator]();
+ let temp = iter.next().value;
+ while(temp != undefined) {
+ console.log(temp);
+ temp = iter.next().value;
+ }
+ ```
\ No newline at end of file
diff --git a/zh-cn/application-dev/reference/apis/js-apis-uri.md b/zh-cn/application-dev/reference/apis/js-apis-uri.md
index 3d557c30957aba3b1b92df02452bb8a90a087847..ad0716494694700651adaa1e94df1beacb36ef0e 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-uri.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-uri.md
@@ -10,12 +10,6 @@
import uri from '@ohos.uri'
```
-
-## 权限
-
-无
-
-
## URI
@@ -24,7 +18,7 @@ import uri from '@ohos.uri'
| 名称 | 参数类型 | 可读 | 可写 | 说明 |
| -------- | -------- | -------- | -------- | -------- |
| scheme | string | 是 | 否 | 获取URI 的协议部分。 |
-| userinfo | string | 是 | 否 | 获取 URI 的用户信息部分。 |
+| userInfo | string | 是 | 否 | 获取 URI 的用户信息部分。 |
| host | string | 是 | 否 | 获取 URI 的主机名部分(不带端口)。 |
| port | string | 是 | 否 | 获取 URI 的端口部分。 |
| path | string | 是 | 否 | 获取 URI 的路径部分。 |
@@ -64,7 +58,7 @@ toString(): string
- 返回值:
| 类型 | 说明 |
| -------- | -------- |
- | string | 用于返回网址的字符串序列化。 |
+ | string | 返回网址的字符串序列化。 |
- 示例:
```
@@ -87,7 +81,7 @@ equals(other: URI): boolean
- 返回值:
| 类型 | 说明 |
| -------- | -------- |
- | boolean | 用于测试此URI是否与其他URI对象相等。 |
+ | boolean | 返回true表示相等,否则返回false。 |
- 示例:
```
@@ -96,15 +90,16 @@ equals(other: URI): boolean
uriInstance.equals(uriInstance1);
```
-
### checkIsAbsolute
-判断此URI是否为绝对URI。
+checkIsAbsolute(): boolean
+
+判断此URI是否为绝对URI(是否定义了scheme组件)。
- 返回值:
| 类型 | 说明 |
| -------- | -------- |
- | boolean | 用于说明此URI是否为绝对URI(是否定义了scheme组件)。 |
+ | boolean | 返回true表示该URI是否为绝对URI。 |
- 示例:
```
@@ -122,7 +117,7 @@ normalize(): URI
- 返回值:
| 类型 | 说明 |
| -------- | -------- |
- | URI | 用于规范化此URI的路径,并返回一个path被规范化后的URI对象。 |
+ | URI | 返回一个path被规范化后的URI对象。 |
- 示例:
```
diff --git a/zh-cn/application-dev/reference/apis/js-apis-url.md b/zh-cn/application-dev/reference/apis/js-apis-url.md
index bbe12540d1a55d2357a60ab06ac3fe49d04d84ce..e8b003482705ae144781b70d18953e481f045f7a 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-url.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-url.md
@@ -11,11 +11,6 @@ import Url from '@ohos.url'
```
-## 权限
-
-无
-
-
## URLSearchParams
diff --git a/zh-cn/application-dev/reference/apis/js-apis-util.md b/zh-cn/application-dev/reference/apis/js-apis-util.md
index 71707c4098ba3429ec091d68d343c151453bdf49..6b08fdcb79ee751afde0cebe83dd35bc1c72c7d0 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-util.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-util.md
@@ -15,11 +15,6 @@ import util from '@ohos.util';
```
-## 权限
-
-无
-
-
## util.printf
printf(format: string, ...args: Object[]): string
@@ -91,8 +86,8 @@ callbackWrapper(original: Function): (err: Object, value: Object )=>void
}
var cb = util.callbackWrapper(promiseFn);
cb((err, ret) => {
- expect(err).strictEqual('value');
- expect(ret).strictEqual(undefined);
+ console.log(err);
+ console.log(ret);
})
```
@@ -124,7 +119,7 @@ promiseWrapper(original: (err: Object, value: Object) => void): Object
}
let newPromiseObj = util.promiseWrapper(aysnFun)("Hello", 'World');
newPromiseObj.then(res => {
- expect(res).strictEqual('HelloWorld');
+ console.log(res);
})
```
@@ -296,7 +291,7 @@ RationalNumber的构造函数。
- 示例:
```
- var rationalNumber = new util.RationalNumber(1,2);
+ var rationalNumber = new util.RationalNumber(1,2);
```
@@ -551,7 +546,7 @@ constructor(capacity?:number)
- 示例:
```
- var lrubuffer= new util.LruBuffer();
+ var lrubuffer= new util.LruBuffer();
```
@@ -661,7 +656,7 @@ getMissCount():number
```
var pro = new util.LruBuffer();
pro.put(2,10);
- pro.get(2)
+ pro.get(2);
var result = pro.getMissCount();
```
@@ -896,7 +891,7 @@ afterRemoval(isEvict:boolean,key:K,value:V,newValue:V):void
}
}
}
- ChildLruBuffer.getInstance().afterRemoval(false,10,30,null);
+ ChildLruBuffer.getInstance().afterRemoval(false,10,30,null);
```
@@ -1115,7 +1110,7 @@ intersect(lowerObj:ScopeType,upperObj:ScopeType):Scope
var tempMiDF = new Temperature(35);
var tempMidS = new Temperature(39);
var range = new util.Scope(tempLower, tempUpper);
- var result = range.intersect(tempMiDF, tempMidS);
+ var result = range.intersect(tempMiDF, tempMidS);
```
@@ -1135,7 +1130,7 @@ getUpper():ScopeType
var tempLower = new Temperature(30);
var tempUpper = new Temperature(40);
var range = new util.Scope(tempLower, tempUpper);
- var result = range.getUpper();
+ var result = range.getUpper();
```
@@ -1155,7 +1150,7 @@ getLower():ScopeType
var tempLower = new Temperature(30);
var tempUpper = new Temperature(40);
var range = new util.Scope(tempLower, tempUpper);
- var result = range.getLower();
+ var result = range.getLower();
```
@@ -1183,7 +1178,7 @@ expand(lowerObj:ScopeType,upperObj:ScopeType):Scope
var tempMiDF = new Temperature(35);
var tempMidS = new Temperature(39);
var range = new util.Scope(tempLower, tempUpper);
- var result = range.expand(tempMiDF, tempMidS);
+ var result = range.expand(tempMiDF, tempMidS);
```
@@ -1211,7 +1206,7 @@ expand(range:Scope):Scope
var tempMidS = new Temperature(39);
var range = new util.Scope(tempLower, tempUpper);
var rangeFir = new util.Scope(tempMiDF, tempMidS);
- var result = range.expand(rangeFir);
+ var result = range.expand(rangeFir);
```
@@ -1237,7 +1232,7 @@ expand(value:ScopeType):Scope
var tempUpper = new Temperature(40);
var tempMiDF = new Temperature(35);
var range = new util.Scope(tempLower, tempUpper);
- var result = range.expand(tempMiDF);
+ var result = range.expand(tempMiDF);
```
@@ -1263,7 +1258,7 @@ contains(value:ScopeType):boolean
var tempUpper = new Temperature(40);
var tempMiDF = new Temperature(35);
var range = new util.Scope(tempLower, tempUpper);
- range.contains(tempMiDF);
+ range.contains(tempMiDF);
```
@@ -1291,7 +1286,7 @@ contains(range:Scope):boolean
var tempLess = new Temperature(20);
var tempMore = new Temperature(45);
var rangeSec = new util.Scope(tempLess, tempMore);
- var result = range.contains(rangeSec);
+ var result = range.contains(rangeSec);
```
@@ -1309,7 +1304,7 @@ clamp(value:ScopeType):ScopeType
- 返回值:
| 类型 | 说明 |
| -------- | -------- |
- | [ScopeType](#scopetype8) | 如果传入的value小于下限,则返回lowerObj;如果大于上限值则返回upperObj;如果在当前范围内,则返回value |
+ | [ScopeType](#scopetype8) | 如果传入的value小于下限,则返回lowerObj;如果大于上限值则返回upperObj;如果在当前范围内,则返回value。 |
- 示例:
```
@@ -1317,7 +1312,7 @@ clamp(value:ScopeType):ScopeType
var tempUpper = new Temperature(40);
var tempMiDF = new Temperature(35);
var range = new util.Scope(tempLower, tempUpper);
- var result = range.clamp(tempMiDF);
+ var result = range.clamp(tempMiDF);
```
@@ -1332,7 +1327,7 @@ Base64的构造函数。
- 示例:
```
- var base64 = new util.Base64();
+ var base64 = new util.Base64();
```
@@ -1429,12 +1424,11 @@ encode(src:Uint8Array):Promise<Uint8Array>
var that = new util.Base64();
var array = new Uint8Array([115,49,51]);
var rarray = new Uint8Array([99,122,69,122]);
- await that.encode(array).then(val=>{
+ that.encode(array).then(val=>{
for (var i = 0; i < rarray.length; i++) {
- expect(val[i]).assertEqual(rarray[i])
+ console.log(val[i])
}
})
- done();
```
@@ -1458,10 +1452,9 @@ encodeToString(src:Uint8Array):Promise<string>
```
var that = new util.Base64();
var array = new Uint8Array([115,49,51]);
- await that.encodeToString(array).then(val=>{
- expect(val).assertEqual('czEz')
+ that.encodeToString(array).then(val=>{
+ console.log(val)
})
- done();
```
@@ -1486,12 +1479,11 @@ decode(src:Uint8Array | string):Promise<Uint8Array>
var that = new util.Base64();
var array = new Uint8Array([99,122,69,122]);
var rarray = new Uint8Array([115,49,51]);
- await that.decode(array).then(val=>{
+ that.decode(array).then(val=>{
for (var i = 0; i < rarray.length; i++) {
- expect(val[i]).assertEqual(rarray[i])
+ console.log(val[i])
}
})
- done();
```
@@ -1588,7 +1580,7 @@ isArgumentsObject(value: Object):boolean
isArrayBuffer(value: Object):boolean
-检查输入的value是否是ArrayBuffer对象类型。
+检查输入的value是否是ArrayBuffer类型。
- 参数:
| 参数名 | 类型 | 必填 | 说明 |
diff --git a/zh-cn/application-dev/reference/apis/js-apis-vector.md b/zh-cn/application-dev/reference/apis/js-apis-vector.md
new file mode 100644
index 0000000000000000000000000000000000000000..e0548b7cd3d43907ae849068ce2595a199d4166e
--- /dev/null
+++ b/zh-cn/application-dev/reference/apis/js-apis-vector.md
@@ -0,0 +1,684 @@
+# 线性容器Vector
+
+>  **说明:**
+> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
+
+
+## 导入模块
+
+```
+import Vector from '@ohos.util.Vector'
+```
+
+
+## 权限
+
+无
+
+
+## Vector
+
+
+### 属性
+
+| 名称 | 参数类型 | 可读 | 可写 | 说明 |
+| -------- | -------- | -------- | -------- | -------- |
+| length | number | 是 | 否 | Vector的元素个数 |
+
+
+### constructor
+
+constructor();
+
+Vector的构造函数。
+
+- 示例:
+ ```
+ let vector = new Vector();
+ ```
+
+
+### add
+
+add(element: T): boolean;
+
+在Vector中尾部插入元素
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | element | T | 是 | 添加进去的元素 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | boolean | 插入成功返回true,失败返回false |
+
+- 示例:
+ ```
+ let vector = new Vector();
+ vector.add("a");
+ vector.add(1);
+ let b = [1, 2, 3];
+ vector.add(b);
+ let c = {name : "lala", age : "13"};
+ vector.add(false);
+ ```
+
+### insert
+
+insert(element: T, index: number): void;
+
+在长度范围内任意插入指定元素。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | element | T | 是 | 被插入的元素 |
+ | index | number | 是 | 被插入的位置索引 |
+
+- 示例:
+ ```
+ let vector = new Vector();
+ vector.insert("A", 0);
+ vector.insert(0, 1);
+ vector.insert(true, 2);
+ ```
+
+### has
+
+has(element: T): boolean;
+
+判断此Vector中是否含有该指定元素。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | element | T | 是 | 指定的元素 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | boolean | 是否包含指定元素 |
+
+- 示例:
+ ```
+ let vector = new Vector();
+ vector.has("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
+ vector.add("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
+ vector.has("Ahfbrgrbgnutfodgorrogorgrogofdfdf");
+ ```
+
+### getIndexOf
+
+getIndexOf(element: T): number;
+
+返回指定元素第一次出现时的下标值,查找失败返回-1。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | element | T | 是 | 指定的元素 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | number | 返回指定元素第一次出现时的下标值,查找失败返回-1 |
+
+- 示例:
+ ```
+ let vector = new Vector();
+ vector.add(2);
+ vector.add(4);
+ vector.add(5);
+ vector.add(2);
+ vector.add(1);
+ vector.add(2);
+ vector.add(4);
+ vector.getIndexOf(2);
+ ```
+### getLastIndexOf
+
+getLastIndexOf(element: T): number;
+
+返回指定元素最后一次出现时的下标值,查找失败返回-1。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | element | T | 是 | 指定元素 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | number | 返回指定元素最后一次出现时的下标值,查找失败返回-1 |
+
+- 示例:
+ ```
+ let vector = new Vector();
+ vector.add(2);
+ vector.add(4);
+ vector.add(5);
+ vector.add(2);
+ vector.add(1);
+ vector.add(2);
+ vector.add(4);
+ vector.getLastIndexOf(2);
+ ```
+### removeByIndex
+
+removeByIndex(index: number): T;
+
+根据元素的下标值查找元素,返回元素后将其删除。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | index | number | 是 | 指定元素的下标值 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | T | 返回删除的元素 |
+
+- 示例:
+ ```
+ let vector = new Vector();
+ vector.add(2);
+ vector.add(4);
+ vector.add(5);
+ vector.add(2);
+ vector.add(4);
+ vector.removeByIndex(2);
+ ```
+
+### remove
+
+remove(element: T): boolean;
+
+删除查找到的第一个指定的元素。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | element | T | 是 | 指定元素 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | boolean | 删除成功返回true,失败返回false |
+
+- 示例:
+ ```
+ let vector = new Vector();
+ vector.add(2);
+ vector.add(4);
+ vector.add(5);
+ vector.add(4);
+ vector.remove(2);
+ ```
+### removeByRange
+removeByRange(fromIndex: number, toIndex: number): void;
+
+从一段范围内删除元素,包括起始值但不包括终止值。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | fromIndex | number | 是 | 起始下标 |
+ | toIndex | number | 是 | 终止下标 |
+
+- 示例:
+ ```
+ let vector = new Vector();
+ vector.add(2);
+ vector.add(4);
+ vector.add(5);
+ vector.add(4);
+ vector.removeByRange(2,4);
+ vector.removeByRange(4,3);
+ vector.removeByRange(2,6);
+ ```
+
+### replaceAllElements
+replaceAllElements(callbackfn: (value: T, index?: number, vector?: Vector<T>) => T,
+thisArg?: Object): void;
+
+用户操作Vector中的元素,用操作后的元素替换原元素并返回操作后的元素。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | callbackfn | function | 是 | 回调函数 |
+ | thisArg | Object | 否 | callbackfn被调用时用作this值 |
+
+- callbackfn的参数说明
+
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | value | T | 是 | 当前遍历到的元素 |
+ | index | number | 否 | 当前遍历到的下标值 |
+ | vector | Vector<T> | 否 | 当前调用replaceAllElements方法的实例对象 |
+
+- 示例:
+ ```
+ let vector = new Vector();
+ vector.add(2);
+ vector.add(4);
+ vector.add(5);
+ vector.add(4);
+ vector.replaceAllElements((value, index) => {
+ return value = 2 * value;
+ });
+ vector.replaceAllElements((value, index) => {
+ return value = value - 2;
+ });
+ ```
+### forEach
+forEach(callbackfn: (value: T, index?: number, vector?: Vector<T>) => void,
+thisArg?: Object): void;
+
+通过回调函数来遍历Vector实例对象上的元素以及元素对应的下标。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | callbackfn | function | 是 | 回调函数。 |
+ | thisArg | Object | 否 | callbackfn被调用时用作this值 |
+
+- callbackfn的参数说明
+
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | value | T | 是 | 当前遍历到的元素。 |
+ | index | number | 否 | 当前遍历到的下标值。 |
+ | vector | Vector<T> | 否 | 当前调用forEach方法的实例对象。 |
+
+
+- 示例:
+ ```
+ let vector = new Vector();
+ vector.add(2);
+ vector.add(4);
+ vector.add(5);
+ vector.add(4);
+ vector.forEach((value, index) => {
+ console.log(value, index)
+ });
+
+ ```
+### sort
+sort(comparator?: (firstValue: T, secondValue: T) => number): void;
+
+对Vector中的元素进行一个排序操作。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | comparator | function | 否 | 回调函数。 |
+
+- comparator的参数说明
+
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | firstValue | T | 是 | 前一项元素 |
+ | secondValue | T | 是 | 后一项元素 |
+
+
+- 示例:
+ ```
+ let vector = new Vector();
+ vector.add(2);
+ vector.add(4);
+ vector.add(5);
+ vector.add(4);
+ vector.sort(a, (b => a - b));
+ vector.sort(a, (b => b - a));
+ vector.sort();
+ ```
+### subVector
+subVector(fromIndex: number, toIndex: number): Vector<T>;
+
+根据下标截取Vector中的一段元素,并返回这一段vector实例,包括起始值但不包括终止值。
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | fromIndex | number | 是 | 起始下标 |
+ | toIndex | number | 是 | 终止下标 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | Vector<T> | 返回Vector对象实例 |
+
+- 示例:
+ ```
+ let vector = new Vector();
+ vector.add(2);
+ vector.add(4);
+ vector.add(5);
+ vector.add(4);
+ vector.subVector(2,4);
+ vector.subVector(4,3);
+ vector.subVector(2,6);
+
+ ```
+
+### clear
+clear(): void;
+
+清除Vector中的所有元素,并把length置为0。
+
+- 示例:
+ ```
+ let vector = new Vector();
+ vector.add(2);
+ vector.add(4);
+ vector.add(5);
+ vector.add(4);
+ vector.clear();
+ ```
+### clone
+clone(): Vector<T>;
+
+克隆一个与Vector一模一样的实例,并返回克隆后的实例,修改克隆后的实例并不会影响原实例。
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | Vector<T> | 返回Vector对象实例 |
+
+- 示例:
+ ```
+ let vector = new Vector();
+ vector.add(2);
+ vector.add(4);
+ vector.add(5);
+ vector.add(4);
+ vector.clone();
+ ```
+### getCapacity
+getCapacity(): number;
+
+获取当前实例的容量大小。
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | number | 返回Vector的容量大小 |
+
+- 示例:
+ ```
+ let vector = new Vector();
+ vector.add(2);
+ vector.add(4);
+ vector.add(5);
+ vector.add(4);
+ vector.getCapacity();
+ ```
+### convertToArray
+convertToArray(): Array<T>;
+
+把当前Vector实例转换成数组,并返回转换后的数组。
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | Array<T> | 返回数组类型 |
+
+- 示例:
+ ```
+ let vector = new Vector();
+ vector.add(2);
+ vector.add(4);
+ vector.add(5);
+ vector.add(4);
+ vector.convertToArray();
+ ```
+### isEmpty
+isEmpty(): boolean;
+
+判断该Vector是否为空。
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | boolean | 为空返回true, 不为空返回false |
+
+- 示例:
+ ```
+ let vector = new Vector();
+ vector.add(2);
+ vector.add(4);
+ vector.add(5);
+ vector.add(4);
+ vector.isEmpty();
+ ```
+### increaseCapacityTo
+increaseCapacityTo(newCapacity: number): void;
+
+如果传入的新容量大于或等于Vector中的元素个数,将容量变更为新容量。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | newCapacity | number | 是 | 新容量 |
+
+
+- 示例:
+ ```
+ let vector = new Vector();
+ vector.add(2);
+ vector.add(4);
+ vector.add(5);
+ vector.add(4);
+ vector.increaseCapacityTo(2);
+ vector.increaseCapacityTo(8);
+ ```
+### trimToCurrentLength
+trimToCurrentLength(): void;
+
+把容量限制为当前的length大小。
+
+- 示例:
+ ```
+ let vector = new Vector();
+ vector.add(2);
+ vector.add(4);
+ vector.add(5);
+ vector.add(4);
+ vector.trimToCurrentLength(2);
+ ```
+### toString
+
+toString(): string;
+用","将Vector实例中的元素按顺序拼接成字符串。
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | string | 返回字符串类型 |
+
+
+- 示例:
+ ```
+ let vector = new Vector();
+ vector.add(2);
+ vector.add(4);
+ vector.add(5);
+ vector.add(4);
+ vector.toSting();
+ ```
+
+### copyToArray
+
+copyToArray(array: Array<T>): void;
+将Vector实例中的元素按照下标复制进array。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | array | Array<T> | 是 | 数组 |
+
+
+- 示例:
+ ```
+ let vector = new Vector();
+ vector.add(2);
+ vector.add(4);
+ vector.add(5);
+ vector.add(4);
+ let array = ["a", "b", "c", "d", "e", "f"];
+ vector.copyToArray(array);
+ ```
+### getFirstElement
+
+getFirstElement(): T;
+获取实例中的第一个元素。
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | T | 返回T型 |
+
+
+- 示例:
+ ```
+ let vector = new Vector();
+ vector.add(2);
+ vector.add(4);
+ vector.add(5);
+ vector.add(4);
+ vector.getFirstElement();
+ ```
+### getLastElement
+
+getLastElement(): T;
+获取Vector实例中的最后一个元素。
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | T | 返回T型 |
+
+
+- 示例:
+ ```
+ let vector = new Vector();
+ vector.add(2);
+ vector.add(4);
+ vector.add(5);
+ vector.add(4);
+ vector.getLastElement();
+ ```
+### getLastIndexFrom
+
+getLastIndexFrom(element: T, index: number): number;
+
+从指定索引向后搜索, 返回该元素的下标索引,如果查找失败,则返回-1。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | element | T | 是 | 要查找的元素 |
+ | index | number | 是 | 从指定索引开始搜索 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | number | 返回该元素的下标 |
+
+
+- 示例:
+ ```
+ let vector = new Vector();
+ vector.add(2);
+ vector.add(4);
+ vector.add(5);
+ vector.add(4);
+ vector.add("a");
+ vector.getLastIndexFrom(4,3);
+ ```
+### getIndexFrom
+
+getIndexFrom(element: T, index: number): number;
+
+从指定索引向前搜索, 返回该元素的下标索引,如果查找失败,则返回 -1
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | element | T | 是 | 要查找的元素 |
+ | index | number | 是 | 从指定索引开始搜索 |
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | number | 返回该元素的下标 |
+
+
+- 示例:
+ ```
+ let vector = new Vector();
+ vector.add(2);
+ vector.add(4);
+ vector.add(5);
+ vector.add(4);
+ vector.add("a");
+ vector.getIndexFrom(4, 3);
+ ```
+### setLength
+setLength(newSize: number): void;
+设置Vector实例的元素个数。
+
+- 参数:
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | -------- | -------- | -------- |
+ | newSize | number | 是 | 设置的新长度 |
+
+- 示例:
+ ```
+ let vector = new Vector();
+ vector.add(2);
+ vector.add(4);
+ vector.add(5);
+ vector.add(4);
+ vector.setLength(8);
+ vector.setLength(2);
+ ```
+
+### [Symbol.iterator]
+
+[Symbol.iterator]\(): IterableIterator<T>;
+
+
+返回一个迭代器,迭代器的每一项都是一个 JavaScript 对象,并返回该对象。
+
+
+- 返回值:
+ | 类型 | 说明 |
+ | -------- | -------- |
+ | IterableIterator<T> | 返回一个迭代器。 |
+
+
+- 示例:
+ ```
+ let vector = new Vector();
+ vector.add(2);
+ vector.add(4);
+ vector.add(5);
+ vector.add(4);
+
+ // 使用方法一:
+ for (let item of vector) {
+ console.log(item);
+ }
+
+ // 使用方法二:
+ let iter = vector[Symbol.iterator]();
+ let temp = iter.next().value;
+ while(temp != undefined) {
+ console.log(temp);
+ temp = iter.next().value;
+ }
+ ```
\ No newline at end of file
diff --git a/zh-cn/application-dev/reference/apis/js-apis-vibrator.md b/zh-cn/application-dev/reference/apis/js-apis-vibrator.md
index a31e5000d1cac98fb82212357b5bfa9117370fe7..7e4d658d1a434da4af2e0b54d058bc7da917300d 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-vibrator.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-vibrator.md
@@ -10,6 +10,9 @@
import vibrator from '@ohos.vibrator';
```
+## 系统能力
+
+SystemCapability.Sensors.MiscDevice
## 权限列表
diff --git a/zh-cn/application-dev/reference/apis/js-apis-volumemanager.md b/zh-cn/application-dev/reference/apis/js-apis-volumemanager.md
new file mode 100644
index 0000000000000000000000000000000000000000..dec4792a4ca340a5ec8fefb6e8ec5d27a739f71b
--- /dev/null
+++ b/zh-cn/application-dev/reference/apis/js-apis-volumemanager.md
@@ -0,0 +1,167 @@
+# 卷管理
+
+>  **说明:**
+> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
+
+## 导入模块
+
+```js
+import volumemanager from "@ohos.volumemanager";
+```
+
+## 系统能力
+
+SystemCapability.FileManagement.StorageService.Volume
+
+## volumemanager.getAllVolumes
+
+getAllVolumes(): Promise<Volume[]>
+
+异步获取当前所有可获得的卷信息,以promise方式返回。
+
+- 返回值
+
+ | 类型 | 说明 |
+ | ---------------------------------- | -------------------------- |
+ | Promise<[Volume](#volume)[]> | 返回当前所有可获得的卷信息 |
+
+- 示例
+
+ ```js
+ volumemanager.getAllVolumes().then(function(volumes){
+ // do something
+ });
+ ```
+
+## volumemanager.getAllVolumes
+
+getAllVolumes(callback:AsyncCallback<Volume[]>):void
+
+异步获取当前所有可获得的卷信息,以callback方式返回。
+
+- 参数
+
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | ------------------------------------------------- | ---- | ------------------------------------ |
+ | callback | callback:AsyncCallback<[Volume](#volume)[]> | 是 | 获取当前所有可获得的卷信息之后的回调 |
+
+- 示例
+
+ ```js
+ let uuid = "";
+ volumemanager.getAllVolumes(uuid, function(error, volumes){
+ // do something
+ });
+ ```
+
+
+## volumemanager.mount
+
+mount(volumeId: string): Promise<boolean>
+
+异步挂载指定卷,以promise方式返回。
+
+- 参数
+
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | ------ | ---- | ---- |
+ | volumeId | string | 是 | 卷id |
+
+- 返回值
+
+ | 类型 | 说明 |
+ | ---------------------- | ---------- |
+ | Promise<boolean> | 挂载指定卷 |
+
+- 示例
+
+ ```js
+ let volumeId = "";
+ volumemanager.mount(volumeId).then(function(flag){
+ // do something
+ });
+ ```
+
+## volumemanager.mount
+
+mount(volumeId: string, callback:AsyncCallback<boolean>):void
+
+异步获取指定卷的可用空间大小,以callback方式返回。
+
+- 参数
+
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | ------------------------------------- | ---- | -------------------- |
+ | volumeId | string | 是 | 卷id |
+ | callback | callback:AsyncCallback<boolean> | 是 | 挂载指定卷之后的回调 |
+
+- 示例
+
+ ```js
+ let volumeId = "";
+ volumemanager.mount(volumeId, function(error, flag){
+ // do something
+ });
+ ```
+
+## volumemanager.unmount
+
+unmount(volumeId: string): Promise<boolean>
+
+异步卸载指定卷,以promise方式返回。
+
+- 参数
+
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | ------ | ---- | ---- |
+ | volumeId | string | 是 | 卷id |
+
+- 返回值
+
+ | 类型 | 说明 |
+ | ---------------------- | ---------- |
+ | Promise<boolean> | 卸载指定卷 |
+
+- 示例
+
+ ```js
+ let volumeId = "";
+ volumemanager.unmount(volumeId).then(function(flag){
+ // do something
+ });
+ ```
+
+## volumemanager.unmount
+
+unmount(volumeId: string, callback:AsyncCallback<boolean>):void
+
+异步卸载指定卷,以callback方式返回。
+
+- 参数
+
+ | 参数名 | 类型 | 必填 | 说明 |
+ | -------- | ------------------------------------- | ---- | -------------------- |
+ | volumeId | string | 是 | 卷id |
+ | callback | callback:AsyncCallback<boolean> | 是 | 卸载指定卷之后的回调 |
+
+- 示例
+
+ ```js
+ let volumeId = "";
+ volumemanager.unmount(volumeId, function(error, flag){
+ // do something
+ });
+ ```
+
+## Volume
+
+### 属性
+
+| 名称 | 类型 | 说明 |
+| ----------- | ------- | -------------------- |
+| id | number | 卷id |
+| uuid | string | 卷uuid |
+| description | string | 卷相关描述 |
+| removeAble | boolean | 是否为可移动存储设备 |
+| state | int | 当前卷状态 |
+| path | string | 卷的挂载地址 |
\ No newline at end of file
diff --git a/zh-cn/application-dev/reference/apis/js-apis-window.md b/zh-cn/application-dev/reference/apis/js-apis-window.md
index ff45b896576008a906846753b579d928b04cbaf1..7ceb3a6c4b5c0ed422b81e41d329679df0464c73 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-window.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-window.md
@@ -11,6 +11,11 @@ import window from '@ohos.window';
```
+## 系统能力
+SystemCapability.WindowManager.WindowManager.Core
+
+
+
## 权限列表
ohos.permission.SYSTEM_FLOAT_WINDOW
@@ -189,7 +194,7 @@ getAbilityWindowMode(callback: AsyncCallback<WindowMode>): void
```
window.getAbilityWindowMode((err, data) => {
if (err) {
- console.error(''Failed to obtain the window mode. Cause:' + JSON.stringify(err));
+ console.error('Failed to obtain the window mode. Cause:' + JSON.stringify(err));
return;
}
console.info('Window mode obtained. Data:' + JSON.stringify(data))
diff --git a/zh-cn/application-dev/reference/apis/js-apis-worker.md b/zh-cn/application-dev/reference/apis/js-apis-worker.md
index 32c60ad58e313e0bae553022f4e6a742903c9341..57eaaf62badf4a17f228717065573bc2d9be67e4 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-worker.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-worker.md
@@ -11,11 +11,6 @@ import worker from '@ohos.worker';
```
-## 权限
-
-无
-
-
## 属性
| 名称 | 参数类型 | 可读 | 可写 | 说明 |
@@ -51,7 +46,7 @@ worker构造函数。
| options | [WorkerOptions](#workeroptions) | 否 | worker构造的选项。 |
- 返回值:
- | 参数名 | 说明 |
+ | 类型 | 说明 |
| -------- | -------- |
| worker | 执行Worker构造函数生成的Worker对象,失败则返回undefined。 |
@@ -294,7 +289,7 @@ dispatchEvent(event: Event): boolean
| event | [Event](#event) | 是 | 需要分发的事件。 |
- 返回值:
- | 参数名 | 说明 |
+ | 类型 | 说明 |
| -------- | -------- |
| boolean | 分发的结果,false表示分发失败。 |
@@ -347,7 +342,7 @@ worker向宿主线程发送消息。
```
```
// worker.js
- import worker from "@ohos.worker";
+ import worker from '@ohos.worker';
const parentPort = worker.parentPort;
parentPort.onmessage = function(e){
parentPort.postMessage("receive data from main.js")
@@ -369,7 +364,7 @@ close(): void
```
```
// worker.js
- import worker from "@ohos.worker";
+ import worker from '@ohos.worker';
const parentPort = worker.parentPort;
parentPort.onmessage = function(e) {
parentPort.close()
@@ -397,7 +392,7 @@ DedicatedWorkerGlobalScope的onmessage属性表示worker线程收到来自其宿
```
```
// worker.js
- import worker from "@ohos.worker";
+ import worker from '@ohos.worker';
const parentPort = worker.parentPort;
parentPort.onmessage = function(e) {
console.log("receive main.js message")
@@ -424,7 +419,7 @@ DedicatedWorkerGlobalScope的onmessageerror属性表示当 Worker 对象接收
```
```
// worker.js
- import worker from "@ohos.worker";
+ import worker from '@ohos.worker';
const parentPort = worker.parentPort;
parentPort.onmessageerror= function(e) {
console.log("worker.js onmessageerror")
@@ -466,7 +461,7 @@ DedicatedWorkerGlobalScope的onmessageerror属性表示当 Worker 对象接收
| evt | [Event](#event) | 是 | 回调的事件类。 |
- 返回值
- | 参数名 | 说明 |
+ | 类型 | 说明 |
| -------- | -------- |
| void \| Promise<void> | 无返回值或者以Promise形式返回。 |
@@ -533,7 +528,7 @@ WorkerGlobalScope的onerror属性表示worker在执行过程中发生异常被
```
```
// worker.js
- import worker from "@ohos.worker";
+ import worker from '@ohos.worker';
const parentPort = worker.parentPort
parentPort.onerror = function(e){
console.log("worker.js onerror")
diff --git a/zh-cn/application-dev/reference/apis/js-apis-xml.md b/zh-cn/application-dev/reference/apis/js-apis-xml.md
index fe319f9f62406f7282e42d1afa540525efb3555f..3765c3ff2c2b877bb4b7c16a2ff57b1669ff2933 100644
--- a/zh-cn/application-dev/reference/apis/js-apis-xml.md
+++ b/zh-cn/application-dev/reference/apis/js-apis-xml.md
@@ -11,11 +11,6 @@ import xml from '@ohos.xml';
```
-## 权限
-
-无
-
-
## XmlSerializer
@@ -28,7 +23,7 @@ XmlSerializer的构造函数。
- 参数:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
- | buffer | ArrayBuffer \| DataView | 是 | 用于接收写入xml信息的ArrayBuffer \| DataView内存。 |
+ | buffer | ArrayBuffer \| DataView | 是 | 用于接收写入xml信息的ArrayBuffer或DataView内存。 |
| encoding | string | 否 | 编码格式。 |
- 示例:
@@ -48,8 +43,8 @@ setAttributes(name: string, value: string):void
- 参数:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
- | name | string | 是 | 属性的key值 |
- | value | string | 是 | 属性的value值 |
+ | name | string | 是 | 属性的key值。 |
+ | value | string | 是 | 属性的value值。 |
- 示例:
```
@@ -67,7 +62,7 @@ addEmptyElement(name: string): void
- 参数:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
- | name | string | 是 | 该空元素的元素名 |
+ | name | string | 是 | 该空元素的元素名。 |
- 示例:
```
@@ -93,12 +88,12 @@ setDeclaration(): void
startElement(name: string): void
-XmlSerializer的构造函数。
+根据给定名称写入元素开始标记。
- 参数:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
- | name | string | 是 | 当前元素的元素名 |
+ | name | string | 是 | 当前元素的元素名。 |
- 示例:
```
@@ -113,7 +108,7 @@ XmlSerializer的构造函数。
endElement(): void
-设置结束元素方法。
+写入元素结束标记。
- 示例:
```
@@ -135,8 +130,8 @@ setNamespace(prefix: string, namespace: string): void
- 参数:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
- | prefix | string | 是 | 当前元素及其子元素的前缀 |
- | namespace | string | 是 | 当前元素及其子元素的命名空间 |
+ | prefix | string | 是 | 当前元素及其子元素的前缀。 |
+ | namespace | string | 是 | 当前元素及其子元素的命名空间。 |
- 示例:
```
@@ -148,43 +143,43 @@ setNamespace(prefix: string, namespace: string): void
thatSer.endElement();// = >'\r\n';
```
-### setCommnet
+### setComment
-setCommnet(text: string): void
+setComment(text: string): void
写入comment属性。
- 参数:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
- | text | string | 是 | 当前元素的注释内容 |
+ | text | string | 是 | 当前元素的注释内容。 |
- 示例:
```
var arrayBuffer = new ArrayBuffer(1024);
var thatSer = new xml.XmlSerializer(arrayBuffer);
thatSer.startElement("note");
- thatSer.setCommnet("Hi!");
+ thatSer.setComment("Hi!");
thatSer.endElement(); // => '\r\n \r\n';
```
-### setCData
+### setCDATA
-setCData(text: string): void
+setCDATA(text: string): void
-写入CData属性。
+写入CDATA属性。
- 参数:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
- | text | string | 是 | CDate属性的内容 |
+ | text | string | 是 | CDATA属性的内容。 |
- 示例:
```
var arrayBuffer = new ArrayBuffer(1028);
var thatSer = new xml.XmlSerializer(arrayBuffer);
- thatSer.setCData('root SYSTEM') // => '';
+ thatSer.setCDATA('root SYSTEM') // => '';
```
@@ -197,7 +192,7 @@ setText(text: string): void
- 参数:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
- | text | string | 是 | text属性的内容 |
+ | text | string | 是 | text属性的内容。 |
- 示例:
```
@@ -219,7 +214,7 @@ setDocType(text: string): void
- 参数:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
- | text | string | 是 | DocType属性的内容 |
+ | text | string | 是 | DocType属性的内容。 |
- 示例:
```
@@ -241,8 +236,8 @@ constructor(buffer: ArrayBuffer | DataView, encoding?: string)
- 参数:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
- | buffer | ArrayBuffer \| DataView | 是 | 含有xml文本信息的ArrayBuffer 或者DataView |
- | encoding | string | 否 | 编码格式(仅支持utf-8) |
+ | buffer | ArrayBuffer \| DataView | 是 | 含有xml文本信息的ArrayBuffer或者DataView。 |
+ | encoding | string | 否 | 编码格式(仅支持utf-8)。 |
- 示例:
```
@@ -325,12 +320,12 @@ xml解析选项。
getColumnNumber(): number
-获取当前行号,从1开始。
+获取当前列号,从1开始。
- 返回值:
| 类型 | 说明 |
| -------- | -------- |
- | number | 返回当前行号。 |
+ | number | 返回当前列号。 |
### getDepth
@@ -349,12 +344,12 @@ getDepth(): number
getLineNumber(): number
-获取当前列号,从1开始。
+获取当前行号,从1开始。
- 返回值:
| 类型 | 说明 |
| -------- | -------- |
- | number | 返回当前列号。 |
+ | number | 返回当前行号。 |
### getName
diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-canvasrenderingcontext2d.md b/zh-cn/application-dev/reference/arkui-ts/ts-canvasrenderingcontext2d.md
index 16c26fd80771ea1586cad5815a211e04c1e43785..c6efba1fd72e46de2323575f64cad167f788ac72 100644
--- a/zh-cn/application-dev/reference/arkui-ts/ts-canvasrenderingcontext2d.md
+++ b/zh-cn/application-dev/reference/arkui-ts/ts-canvasrenderingcontext2d.md
@@ -7,7 +7,7 @@
## 接口
-CanvasRenderingContext2D\(setting: RenderingContextSetting\)
+CanvasRenderingContext2D\(setting: RenderingContextSettings\)
- 参数
@@ -40,9 +40,9 @@ CanvasRenderingContext2D\(setting: RenderingContextSetting\)
### RenderingContextSettings
-RenderingContextSettings\(antialias?: bool, alpha?: bool\)
+RenderingContextSettings\(antialias?: bool)
-用来配置CanvasRenderingContext2D对象的参数,包括是否开启抗锯齿和是否包含一个alpha通道。
+用来配置CanvasRenderingContext2D对象的参数,包括是否开启抗锯齿。
- 参数
@@ -69,17 +69,6 @@ RenderingContextSettings\(antialias?: bool, alpha?: bool\)
表明canvas是否开启抗锯齿。
|
|
-