提交 cc11c5c6 编写于 作者: X xinking129

Merge remote-tracking branch 'upstream/master'

......@@ -24,6 +24,12 @@
- [Multi-HAP Usage Rules](quick-start/multi-hap-rules.md)
- [Multi-HAP Operation Mechanism and Data Communication Modes](quick-start/multi-hap-principles.md)
- [Application Installation and Uninstallation Process](quick-start/application-package-install-uninstall.md)
- Shared Package
- [Shared Package Overview](quick-start/shared-guide.md)
- [HAR](quick-start/har-package.md)
- HSP
- [In-Application HSP Development](quick-start/in-app-hsp.md)
- [Inter-Application HSP Development (for System Applications Only)](quick-start/cross-app-hsp.md)
- Application Configuration Files in Stage Model
- [Application Configuration File Overview (Stage Model)](quick-start/application-configuration-file-overview-stage.md)
- [app.json5 Configuration File](quick-start/app-configuration-file.md)
......@@ -36,18 +42,44 @@
- [Resource Categories and Access](quick-start/resource-categories-and-access.md)
- Learning ArkTS
- [Getting Started with ArkTS](quick-start/arkts-get-started.md)
- ArkTS Syntax (Declarative UI)
- [Basic UI Description](quick-start/arkts-basic-ui-description.md)
- State Management
- [Basic Concepts](quick-start/arkts-state-mgmt-concepts.md)
- [State Management with Page-level Variables](quick-start/arkts-state-mgmt-page-level.md)
- [State Management with Application-level Variables](quick-start/arkts-state-mgmt-application-level.md)
- [Dynamic UI Element Building](quick-start/arkts-dynamic-ui-elememt-building.md)
- [Rendering Control](quick-start/arkts-rendering-control.md)
- [Restrictions and Extensions](quick-start/arkts-restrictions-and-extensions.md)
- Basic Syntax
- [Basic Syntax Overview](quick-start/arkts-basic-syntax-overview.md)
- [Declarative UI Description](quick-start/arkts-declarative-ui-description.md)
- Custom Component
- [Creating a Custom Component](quick-start/arkts-create-custom-components.md)
- [Page and Custom Component Lifecycle](quick-start/arkts-page-custom-components-lifecycle.md)
- [\@Builder: Custom Builder Function](quick-start/arkts-builder.md)
- [\@BuilderParam: @Builder Function Reference](quick-start/arkts-builderparam.md)
- [\@Styles: Definition of Resusable Styles](quick-start/arkts-style.md)
- [\@Extend: Extension of Built-in Components](quick-start/arkts-extend.md)
- [stateStyles: Polymorphic Style](quick-start/arkts-statestyles.md)
- State Management
- [State Management Overview](quick-start/arkts-state-management-overview.md)
- Component State Management
- [\@State: State Owned by Component](quick-start/arkts-state.md)
- [\@Prop: One-Way Synchronization from Parent to Child Components](quick-start/arkts-prop.md)
- [\@Link: Two-Way Synchronization Between Parent and Child Components](quick-start/arkts-link.md)
- [\@Provide and \@Consume: Two-Way Synchronization with Descendant Components](quick-start/arkts-provide-and-consume.md)
- [\@Observed and \@ObjectLink: Observing Attribute Changes in Nested Class Objects](quick-start/arkts-observed-and-objectlink.md)
- Application State Management
- [Application State Management Overview](quick-start/arkts-application-state-management-overview.md)
- [LocalStorage: UI State Storage](quick-start/arkts-localstorage.md)
- [AppStorage: Application-wide UI State Storage](quick-start/arkts-appstorage.md)
- [PersistentStorage: Application State Persistence](quick-start/arkts-persiststorage.md)
- [Environment: Device Environment Query](quick-start/arkts-environment.md)
- Other State Management Features
- [Overview of Other State Management Features](quick-start/arkts-other-state-mgmt-functions-overview.md)
- [\@Watch: Getting Notified of State Variable Changes](quick-start/arkts-watch.md)
- [$$ Syntax: Two-Way Synchronization of Built-in Components](quick-start/arkts-two-way-sync.md)
- Rendering Control
- [Rendering Control Overview](quick-start/arkts-rendering-control-overview.md)
- [if/else: Conditional Rendering](quick-start/arkts-rendering-control-ifelse.md)
- [ForEach: Rendering of Repeated Content](quick-start/arkts-rendering-control-foreach.md)
- [LazyForEach: Lazy Data Loading](quick-start/arkts-rendering-control-lazyforeach.md)
- Development
- [Application Models](application-models/Readme-EN.md)
- [UI Development](ui/Readme-EN.md)
- [Web](web/Readme-EN.md)
- [Notification](notification/Readme-EN.md)
- [Window Manager](windowmanager/Readme-EN.md)
- [WebGL](webgl/Readme-EN.md)
......@@ -81,8 +113,10 @@
- [ArkTS and JS APIs](reference/apis/Readme-EN.md)
- [Error Codes](reference/errorcodes/Readme-EN.md)
- Native APIs
- [Native APIs](reference/native-apis/Readme-EN.md)
- [Standard Libraries](reference/native-lib/third_party_libc/musl.md)
- [Node_API](reference/native-lib/third_party_napi/napi.md)
- [FAQs](faqs/Readme-EN.md)
- Contribution
- [How to Contribute](../contribute/documentation-contribution.md)
<!--no_check-->
\ No newline at end of file
......@@ -5,7 +5,7 @@
- [Overview of Application Data Persistence](app-data-persistence-overview.md)
- [Persisting Preferences Data](data-persistence-by-preferences.md)
- [Persisting KV Store Data](data-persistence-by-kv-store.md)
- [Persisting RDB Store Data] (data-persistence-by-rdb-store.md)
- [Persisting RDB Store Data](data-persistence-by-rdb-store.md)
- Distributed Application Data Synchronization
- [Distributed Application Data Synchronization Overview](sync-app-data-across-devices-overview.md)
- [Cross-Device Synchronization of KV Stores](data-sync-of-kv-store.md)
......@@ -16,7 +16,7 @@
- [Database Backup and Restoration](data-backup-and-restore.md)
- [Database Encryption](data-encryption.md)
- [Access Control by Device and Data Level](access-control-by-device-and-data-level.md)
- Cross-Application Data Sharing (Available Only for System Applications)
- Cross-Application Data Sharing (for System Applications Only)
- [Cross-Application Data Sharing Overview](share-device-data-across-apps-overview.md)
- [Sharing Data Using DataShareExtensionAbility](share-data-by-datashareextensionability.md)
- [Sharing Data in Silent Access](share-data-by-silent-access.md)
......@@ -68,7 +68,7 @@ When data is added, deleted, or modified, a notification is sent to the subscrib
- The KV stores do not support custom conflict resolution policies for applications.
- A maximum of 16 distributed KV stores can be opened simultaneously for an application.
- A maximum of 16 KV stores can be opened simultaneously for an application.
- Each KV store supports a maximum of eight callbacks for subscription of data change notifications.
......
......@@ -23,7 +23,8 @@ When an asynchronous callback is used, the return value can be processed directl
| API | Description |
| ------------------------------ | ------------------------------------------------------------ |
| onUnhandledException(errMsg: string): void | Called when an application generates an uncaught exception after being registered.|
| onUnhandledException(errMsg: string): void | Called when an uncaught exception is reported after the application is registered.|
| onException?(errObject: Error): void | Called when an application exception is reported to the JavaScript layer after the application is registered.|
### Result Codes for Unregistering an Observer
......@@ -43,6 +44,13 @@ let registerId = -1;
let callback = {
onUnhandledException: function (errMsg) {
console.log(errMsg);
},
onException: function (errorObj) {
console.log('onException, name: ', errorObj.name);
console.log('onException, message: ', errorObj.message);
if (typeof(errorObj.stack) === 'string') {
console.log('onException, stack: ', errorObj.stack);
}
}
}
......
# File
# File Management
- [File Management Overview](file-management-overview.md)
- Application File
......@@ -20,4 +20,4 @@
- Distributed File System
- [Distributed File System Overview](distributed-fs-overview.md)
- [Setting the Security Level of a Distributed File](set-security-label.md)
- [Access Files Across Devices](file-access-across-devices.md)
- [Accessing Files Across Devices](file-access-across-devices.md)
......@@ -73,7 +73,7 @@ The following figure shows the application file directories. The path of a file
| distributedfiles | distributedFilesDir | Distributed file directory| Directory in **el2** for saving the application files that can be directly accessed across devices.<br>This directory is cleared when the application is uninstalled.|
| files | filesDir | Application file directory| Directory for saving the application's persistent files on the device.<br>This directory is cleared when the application is uninstalled.|
| cache | cacheDir | Application cache file directory| Directory for caching the downloaded files of the application or saving the cache files regenerated on the device.<br>This directory is automatically cleared when the size of the **cache** directory reaches the quota or the system storage space reaches a certain threshold. The user can also clear this directory by using a system space management application. <br>The application needs to check whether the file still exists and determine whether to cache the file again.|
| preferences | preferencesDir | Preferences file directory| Directory for saving common application configuration and user preference data managed by using database APIs.<br>This directory is cleared when the application is uninstalled. For details, see [Data Persistence by User Preferences](../database/data-persistence-by-preferences.md).|
| preferences | preferencesDir | Preferences file directory| Directory for saving common application configuration and user preference data managed by using database APIs.<br>This directory is cleared when the application is uninstalled. For details, see [Persisting Preferences Data](../database/data-persistence-by-preferences.md).|
| temp | tempDir | Temporary file directory| Directory for saving the files generated and required during the application's runtime on the device. <br>This directory is cleared when the application exits.|
The application file paths are used in the following scenarios:
......@@ -92,5 +92,3 @@ The following figure shows the application file directories. The path of a file
Used to store application preferences data, including preference files and configuration files. This directory applied to storing only a small amount of data.
- Temporary file directory<br>
Used to store temporarily generated data of an application, including cached database data and images, temporary log files, downloaded application installation package files. The data stored in this directory is deleted after being used.
<!--no_check-->
\ No newline at end of file
# Access Files Across Devices
# Accessing Files Across Devices
The distributed file system provides cross-device file access capabilities for applications. For the same application installed on multiple devices, you can implement read and write of the files in the application's distributed directory (**/data/storage/el2/distributedfiles/**) across devices by using [ohos.file.fs](app-file-access.md). For example, device A and device B are installed with the same application. After device A and device B are connected to form a Virtual Device, the application on device A can access the files of the same application on Device B. What you need to do is place the files to the distributed directory.
......
......@@ -23,6 +23,3 @@ The file systems can be classified into the following types based on the file st
**Figure 1** Files in an OS
![File classification model](figures/file-classification-model.png)
<!--no_check-->
\ No newline at end of file
# Setting the Security Level of a Distributed File
The security capabilities vary with devices. For example, small embedded devices provide fewer security capabilities than tablets. The security requirements also vary with data. For example, personal health information and bank card information are not expected to be accessed by devices of lower security levels. OpenHarmony provides a complete set of standards for data and device classification and custom data transfer policies for different devices. For details, see [Data and Device Security Classification](../database/access-control-by-device-and-data-level.md).
The security capabilities vary with devices. For example, small embedded devices provide fewer security capabilities than tablets. The security requirements also vary with data. For example, personal health information and bank card information are not expected to be accessed by devices of lower security levels. OpenHarmony provides a complete set of standards for data and device classification and custom data transfer policies for different devices. For details, see [Data Security Labels and Device Security Levels](../database/access-control-by-device-and-data-level.md).
## Available APIs
......@@ -39,4 +39,3 @@ securityLabel.setSecurityLabel(filePath, 's0').then(() => {
console.error(`Failed to setSecurityLabel. Code: ${err.code}, message: ${err.message}`);
});
```
<!--no_check-->
\ No newline at end of file
......@@ -45,11 +45,11 @@
- [Session Management](camera-session-management.md)
- [Camera Preview](camera-preview.md)
- [Camera Photographing](camera-shooting.md)
- [Video Recording](camera-recording.md)
- [Camera Recording](camera-recording.md)
- [Camera Metadata](camera-metadata.md)
- Best Practices
- [Camera Photographing Sample](camera-shooting-case.md)
- [Video Recording Sample](camera-recording-case.md)
- [Camera Recording Sample](camera-recording-case.md)
- Image
- [Image Overview](image-overview.md)
- [Image Decoding](image-decoding.md)
......
# Video Recording Sample
# Camera Recording Sample
## Development Process
......
# Video Recording
# Camera Recording
Video recording is also an important function of the camera application. Video recording is the process of cyclic capturing of frames. To smooth videos, you can follow step 4 in [Camera Photographing](camera-shooting.md) to set the resolution, flash, focal length, photo quality, and rotation angle.
......
......@@ -237,7 +237,7 @@
- [@ohos.file.environment (Directory Environment Capability)](js-apis-file-environment.md)
- [@ohos.file.fileAccess (User File Access and Management)](js-apis-fileAccess.md)
- [@ohos.file.fileExtensionInfo (User File Extension Information)](js-apis-fileExtensionInfo.md)
- [@ohos.file.fileUri (File URI)](js-apis-file-fileUri.md)
- [@ohos.file.fileuri (File URI)](js-apis-file-fileuri.md)
- [@ohos.file.fs (File Management)](js-apis-file-fs.md)
- [@ohos.file.hash (File Hash Processing)](js-apis-file-hash.md)
- [@ohos.file.picker (File Picker)](js-apis-file-picker.md)
......
......@@ -23,7 +23,7 @@ import distributedKVStore from '@ohos.data.distributedKVStore';
## KVManagerConfig
Defines the **KVManager** instance configuration, including the bundle name of the invoker and the application context.
Provides the **KVManager** instance configuration, including the bundle name of the invoker and the application context.
**System capability**: SystemCapability.DistributedDataManager.KVStore.Core
......@@ -127,7 +127,7 @@ Enumerates the distributed KV store types.
| Name | Description |
| -------------------- | ------------------------------------------------------------ |
| DEVICE_COLLABORATION | Device KV store.<br>The device KV store manages data by device, which eliminates conflicts. Data can be queried by device.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore |
| DEVICE_COLLABORATION | Device KV store.<br>The device KV store manages data by device, which eliminates conflicts. Data can be queried by device.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.DistributedKVStore|
| SINGLE_VERSION | Single KV store.<br>The single KV store does not differentiate data by device. If entries with the same key are modified on different devices, the value will be overwritten.<br>**System capability**: SystemCapability.DistributedDataManager.KVStore.Core |
## SecurityLevel
......@@ -136,7 +136,7 @@ Enumerates the KV store security levels.
**System capability**: SystemCapability.DistributedDataManager.KVStore.Core
| Name | Description |
| Name | Description |
| ---: | ------------------------------------------------------------ |
| S1 | Low security level. Disclosure, tampering, corruption, or loss of the data may cause minor impact on an individual or group.<br>Examples: gender and nationality information, and user application records |
| S2 | Medium security level. Disclosure, tampering, corruption, or loss of the data may cause major impact on an individual or group.<br>Examples: mailing addresses and nicknames of individuals |
......@@ -2028,7 +2028,7 @@ try {
deviceId(deviceId:string):Query
Creates a **Query** object with the device ID as the key prefix.
> **NOTE**<br/>
> **NOTE**
>
> **deviceId** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications.
> For details about how to obtain **deviceId**, see [sync()](#sync).
......@@ -2817,7 +2817,7 @@ try {
removeDeviceData(deviceId: string, callback: AsyncCallback&lt;void&gt;): void
Deletes data of a device. This API uses an asynchronous callback to return the result.
> **NOTE**<br/>
> **NOTE**
>
> **deviceId** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications.
> For details about how to obtain **deviceId**, see [sync()](#sync).
......@@ -2869,7 +2869,7 @@ try {
removeDeviceData(deviceId: string): Promise&lt;void&gt;
Deletes data of a device. This API uses a promise to return the result.
> **NOTE**<br/>
> **NOTE**
>
> **deviceId** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications.
> For details about how to obtain **deviceId**, see [sync()](#sync).
......@@ -4548,7 +4548,7 @@ try {
sync(deviceIds: string[], mode: SyncMode, delayMs?: number): void
Synchronizes the KV store manually. For details about the synchronization modes of KV stores, see [Cross-Device Synchronization of KV Stores](../../database/data-sync-of-kv-store.md).
> **NOTE**<br/>
> **NOTE**
>
> The value of **deviceIds** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications.
......@@ -4617,7 +4617,7 @@ deviceManager.createDeviceManager('bundleName', (err, value) => {
sync(deviceIds: string[], query: Query, mode: SyncMode, delayMs?: number): void
Synchronizes the KV store manually. This API returns the result synchronously. For details about the synchronization modes of KV stores, see [Cross-Device Synchronization of KV Stores](../../database/data-sync-of-kv-store.md).
> **NOTE**<br/>
> **NOTE**
>
> The value of **deviceIds** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications.
......@@ -4735,7 +4735,7 @@ Subscribes to synchronization complete events.
| Name | Type | Mandatory| Description |
| ------------ | --------------------------------------------- | ---- | ------------------------------------------------------ |
| event | string | Yes | Event to subscribe to. The value is **syncComplete**, which indicates a synchronization complete event.|
| syncCallback | Callback&lt;Array&lt;[string, number]&gt;&gt; | Yes | Callback invoked to return the synchronization complete event. |
| syncCallback | Callback&lt;Array&lt;[string, number]&gt;&gt; | Yes | Callback invoked to return the synchronization complete event.|
**Example**
......@@ -4769,7 +4769,7 @@ Unsubscribes from data changes.
| Name | Type | Mandatory| Description |
| -------- | --------------------------------------------------------- | ---- | -------------------------------------------------------- |
| event | string | Yes | Event to unsubscribe from. The value is **dataChange**, which indicates a data change event.|
| listener | Callback&lt;[ChangeNotification](#changenotification)&gt; | No | Callback for data changes. |
| listener | Callback&lt;[ChangeNotification](#changenotification)&gt; | No | Callback for the data change event. |
**Error codes**
......@@ -5044,7 +5044,7 @@ try {
get(deviceId: string, key: string, callback: AsyncCallback&lt;boolean | string | number | Uint8Array&gt;): void
Obtains a string value that matches the specified device ID and key. This API uses an asynchronous callback to return the result.
> **NOTE**<br/>
> **NOTE**
>
> **deviceId** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications.
> For details about how to obtain **deviceId**, see [sync()](#sync).
......@@ -5099,7 +5099,7 @@ try {
get(deviceId: string, key: string): Promise&lt;boolean | string | number | Uint8Array&gt;
Obtains a string value that matches the specified device ID and key. This API uses a promise to return the result.
> **NOTE**<br/>
> **NOTE**
>
> **deviceId** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications.
> For details about how to obtain **deviceId**, see [sync()](#sync).
......@@ -5279,7 +5279,7 @@ try {
getEntries(deviceId: string, keyPrefix: string, callback: AsyncCallback&lt;Entry[]&gt;): void
Obtains all KV pairs that match the specified device ID and key prefix. This API uses an asynchronous callback to return the result.
> **NOTE**<br/>
> **NOTE**
>
> **deviceId** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications.
> For details about how to obtain **deviceId**, see [sync()](#sync).
......@@ -5346,7 +5346,7 @@ try {
getEntries(deviceId: string, keyPrefix: string): Promise&lt;Entry[]&gt;
Obtains all KV pairs that match the specified device ID and key prefix. This API uses a promise to return the result.
> **NOTE**<br/>
> **NOTE**
>
> **deviceId** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications.
> For details about how to obtain **deviceId**, see [sync()](#sync).
......@@ -5542,7 +5542,7 @@ try {
getEntries(deviceId: string, query: Query, callback: AsyncCallback&lt;Entry[]&gt;): void
Obtains the KV pairs that match the specified device ID and **Query** object. This API uses an asynchronous callback to return the result.
> **NOTE**<br/>
> **NOTE**
>
> **deviceId** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications.
> For details about how to obtain **deviceId**, see [sync()](#sync).
......@@ -5614,7 +5614,7 @@ try {
getEntries(deviceId: string, query: Query): Promise&lt;Entry[]&gt;
Obtains the KV pairs that match the specified device ID and **Query** object. This API uses a promise to return the result.
> **NOTE**<br/>
> **NOTE**
>
> **deviceId** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications.
> For details about how to obtain **deviceId**, see [sync()](#sync).
......@@ -5822,7 +5822,7 @@ try {
getResultSet(deviceId: string, keyPrefix: string, callback: AsyncCallback&lt;KVStoreResultSet&gt;): void
Obtains a **KVStoreResultSet** object that matches the specified device ID and key prefix. This API uses an asynchronous callback to return the result.
> **NOTE**<br/>
> **NOTE**
>
> **deviceId** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications.
> For details about how to obtain **deviceId**, see [sync()](#sync).
......@@ -5877,7 +5877,7 @@ try {
getResultSet(deviceId: string, keyPrefix: string): Promise&lt;KVStoreResultSet&gt;
Obtains a **KVStoreResultSet** object that matches the specified device ID and key prefix. This API uses a promise to return the result.
> **NOTE**<br/>
> **NOTE**
>
> **deviceId** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications.
> For details about how to obtain **deviceId**, see [sync()](#sync).
......@@ -5933,7 +5933,7 @@ try {
getResultSet(deviceId: string, query: Query, callback: AsyncCallback&lt;KVStoreResultSet&gt;): void
Obtains a **KVStoreResultSet** object that matches the specified device ID and **Query** object. This API uses an asynchronous callback to return the result.
> **NOTE**<br/>
> **NOTE**
>
> **deviceId** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications.
> For details about how to obtain **deviceId**, see [sync()](#sync).
......@@ -6009,7 +6009,7 @@ try {
getResultSet(deviceId: string, query: Query): Promise&lt;KVStoreResultSet&gt;
Obtains a **KVStoreResultSet** object that matches the specified device ID and **Query** object. This API uses a promise to return the result.
> **NOTE**<br/>
> **NOTE**
>
> **deviceId** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications.
> For details about how to obtain **deviceId**, see [sync()](#sync).
......@@ -6152,7 +6152,7 @@ try {
getResultSet(query: Query, callback:AsyncCallback&lt;KVStoreResultSet&gt;): void
Obtains a **KVStoreResultSet** object that matches the specified **Query** object for this device. This API uses an asynchronous callback to return the result.
> **NOTE**<br/>
> **NOTE**
>
> **deviceId** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications.
> For details about how to obtain **deviceId**, see [sync()](#sync).
......@@ -6341,7 +6341,7 @@ try {
getResultSet(deviceId: string, predicates: dataSharePredicates.DataSharePredicates, callback: AsyncCallback&lt;KVStoreResultSet&gt;): void
Obtains a **KVStoreResultSet** object that matches the specified predicate object and device ID. This API uses an asynchronous callback to return the result.
> **NOTE**<br/>
> **NOTE**
>
> **deviceId** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications.
> For details about how to obtain **deviceId**, see [sync()](#sync).
......@@ -6402,7 +6402,7 @@ try {
getResultSet(deviceId: string, predicates: dataSharePredicates.DataSharePredicates): Promise&lt;KVStoreResultSet&gt;
Obtains a **KVStoreResultSet** object that matches the specified predicate object and device ID. This API uses a promise to return the result.
> **NOTE**<br/>
> **NOTE**
>
> **deviceId** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications.
> For details about how to obtain **deviceId**, see [sync()](#sync).
......@@ -6583,7 +6583,7 @@ try {
getResultSize(deviceId: string, query: Query, callback: AsyncCallback&lt;number&gt;): void;
Obtains the number of results that matches the specified device ID and **Query** object. This API uses an asynchronous callback to return the result.
> **NOTE**<br/>
> **NOTE**
>
> **deviceId** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications.
> For details about how to obtain **deviceId**, see [sync()](#sync).
......@@ -6650,7 +6650,7 @@ try {
getResultSize(deviceId: string, query: Query): Promise&lt;number&gt;
Obtains the number of results that matches the specified device ID and **Query** object. This API uses a promise to return the result.
> **NOTE**<br/>
> **NOTE**
>
> **deviceId** is obtained by [deviceManager.getTrustedDeviceListSync](js-apis-device-manager.md#gettrusteddevicelistsync). The APIs of the **deviceManager** module are system interfaces and available only to system applications.
> For details about how to obtain **deviceId**, see [sync()](#sync).
......@@ -6712,4 +6712,3 @@ try {
console.error(`Failed to get resultSize.code is ${e.code},message is ${e.message}`);
}
```
<!--no_check-->
\ No newline at end of file
# @ohos.application.uriPermissionManager (URI Permission Management)
> **NOTE**
>
> The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version.
The **uriPermissionManager** module provides APIs for granting permissions on a file to or revoking the granted permission from an application. The file is identified by a uniform resource identifier (URI).
## Modules to Import
```js
import UriPermissionManager from '@ohos.application.uriPermissionManager';
```
## uriPermissionManager.grantUriPermission
grantUriPermission(uri: string, flag: wantConstant.Flags, accessTokenId: number, callback: AsyncCallback&lt;number&gt;): void
Grants permission on the file of the specified URI to an application. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| uri | string | Yes| URI of the file, for example, **fileshare:///com.samples.filesharetest.FileShare/person/10**.|
| flag | [wantConstant.Flags](js-apis-ability-wantConstant.md#wantconstantflags) | Yes| Read or write permission on the file to grant.|
| targetBundleName | string | Yes| Bundle name of the application, to which the permission is granted.|
| callback | AsyncCallback&lt;number&gt; | Yes| Callback invoked to return the result. If the operation is successful, **0** is returned; otherwise, **-1** is returned.|
**Example**
```js
import WantConstant from '@ohos.ability.wantConstant';
let targetBundleName = 'com.example.test_case1'
let uri = "fileshare:///com.samples.filesharetest.FileShare/person/10"
uriPermissionManager.grantUriPermission(uri, WantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION, targetBundleName, (result) => {
console.log("result.code = " + result.code)
})
```
## uriPermissionManager.grantUriPermission
grantUriPermission(uri: string, flag: wantConstant.Flags, accessTokenId: number): Promise&lt;number&gt;
Grants permission on the file of the specified URI to an application. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| uri | string | Yes| URI of the file, for example, **fileshare:///com.samples.filesharetest.FileShare/person/10**.|
| flag | [wantConstant.Flags](js-apis-ability-wantConstant.md#wantconstantflags) | Yes| Read or write permission on the file to grant.|
| targetBundleName | string | Yes| Bundle name of the application, to which the permission is granted.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;number&gt; | Promise used to return the result. If the operation is successful, **0** is returned; otherwise, **-1** is returned.|
**Example**
```js
import WantConstant from '@ohos.ability.wantConstant';
let targetBundleName = 'com.example.test_case1'
let uri = "fileshare:///com.samples.filesharetest.FileShare/person/10"
uriPermissionManager.grantUriPermission(uri, wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION, targetBundleName)
.then((data) => {
console.log('Verification succeeded.' + data)
}).catch((error) => {
console.log('Verification failed.');
})
```
## uriPermissionManager.revokeUriPermission
revokeUriPermission(uri: string, accessTokenId: number, callback: AsyncCallback&lt;number&gt;): void
Revokes the permission on the file of the specified URI from an application. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| uri | string | Yes| URI of the file, for example, **fileshare:///com.samples.filesharetest.FileShare/person/10**.|
| targetBundleName | string | Yes| Bundle name of the application, from which the permission is revoked.|
| callback | AsyncCallback&lt;number&gt; | Yes| Callback invoked to return the result. If the operation is successful, **0** is returned; otherwise, **-1** is returned.|
**Example**
```js
import WantConstant from '@ohos.ability.wantConstant';
let targetBundleName = 'com.example.test_case1'
let URI = "fileshare:///com.samples.filesharetest.FileShare/person/10"
uriPermissionManager.revokeUriPermission(uri, targetBundleName, (result) => {
console.log("result.code = " + result.code)
})
```
## uriPermissionManager.revokeUriPermission
revokeUriPermission(uri: string, flag: wantConstant.Flags, accessTokenId: number): Promise&lt;number&gt;
Revokes the permission on the file of the specified URI from an application. This API uses a promise to return the result.
**System capability**: SystemCapability.Ability.AbilityRuntime.Core
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| uri | string | Yes| URI of the file, for example, **fileshare:///com.samples.filesharetest.FileShare/person/10**.|
| targetBundleName | string | Yes| Bundle name of the application, from which the permission is revoked.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;number&gt; | Promise used to return the result. If the operation is successful, **0** is returned; otherwise, **-1** is returned.|
**Example**
```js
import WantConstant from '@ohos.ability.wantConstant';
let targetBundleName = 'com.example.test_case1'
let uri = "fileshare:///com.samples.filesharetest.FileShare/person/10"
uriPermissionManager.revokeUriPermission(uri, targetBundleName)
.then((data) => {
console.log('Verification succeeded.' + data)
}).catch((error) => {
console.log('Verification failed.');
})
```
......@@ -436,7 +436,7 @@ Allows an application to obtain the sensitive permissions that have been granted
## ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION
Allows an application to set attributes for the applications of other users.
Allows an application to set the attributes of applications of other users.
**Permission level**: system_core
......@@ -496,7 +496,7 @@ Allows an application to read data from a gyroscope sensor or uncalibrated gyros
## ohos.permission.INSTALL_BUNDLE
Allows an application to install and uninstall other applications.
Allows an application to install and uninstall other applications (except enterprise InHouse applications).
**Permission level**: system_core
......@@ -974,6 +974,26 @@ Allows the device administrator to set bundle installation policies.
**Enable via ACL**: TRUE
## ohos.permission.ENTERPRISE_SET_NETWORK
Allows the device administrator application to set network information.
**Permission level**: system_basic
**Authorization mode**: system_grant
**Enable via ACL**: TRUE
## ohos.permission.ENTERPRISE_MANAGE_SET_APP_RUNNING_POLICY
Allows the device administrator application to set application running policies.
**Permission level**: system_basic
**Authorization mode**: system_grant
**Enable via ACL**: TRUE
## ohos.permission.NFC_TAG
Allows an application to read NFC tag information.
......@@ -1146,7 +1166,7 @@ Allows an application to add, remove, and modify call logs.
## ohos.permission.WRITE_CONTACTS
Allows an application to add, remove, and modify contacts.
Allows an application to add, remove, and modify Contacts.
**Permission level**: system_basic
......@@ -1500,7 +1520,7 @@ Allows an application to manage private credentials and query certificate status
## ohos.permission.ACCESS_PUSH_SERVICE
Allows an application to to access the Ability of the push service.
Allows an application to access the Ability of the push service.
**Permission level**: system_basic
......@@ -1628,6 +1648,26 @@ Allows an application to have backup and restore capabilities.
**Enable via ACL**: TRUE
## ohos.permission.CLOUDFILE_SYNC_MANAGER
Allows an application to obtain the device-cloud synchronization management capability.
**Permission level**: system_basic
**Authorization mode**: system_grant
**Enable via ACL**: TRUE
## ohos.permission.CLOUDFILE_SYNC
Allows an application to perform device-cloud synchronization.
**Permission level**: system_basic
**Authorization mode**: system_grant
**Enable via ACL**: TRUE
## ohos.permission.FILE_ACCESS_MANAGER
Allows a file management application to access user data files through the FAF.
......@@ -1640,7 +1680,7 @@ Allows a file management application to access user data files through the FAF.
## ohos.permission.MANAGE_AUDIO_CONFIG
Allows an application to to mute microphones globally.
Allows an application to mute microphones globally.
**Permission level**: system_basic
......@@ -1757,3 +1797,83 @@ Allows an application to use ultrasonic sensing.
**Authorization mode**: system_grant
**Enable ACL**: FALSE
## ohos.permission.INSTALL_ENTERPRISE_BUNDLE
Allows an application to install and uninstall enterprise InHouse applications.
**Permission level**: system_core
**Authorization mode**: system_grant
**Enable via ACL**: TRUE
## ohos.permission.PROXY_AUTHORIZATION_URI
Allows the application proxy to authorize the URI.
**Permission level**: system_basic
**Authorization mode**: system_grant
**Enable ACL**: FALSE
## ohos.permission.GET_INSTALLED_BUNDLE_LIST
Allows an application to obtain the list of installed applications.
**Permission level**: system_basic
**Authorization mode**: user_grant
**Enable via ACL**: TRUE
## ohos.permission.MANAGE_DISTRIBUTED_ACCOUNTS
Allows an application to manage distributed account information.
**Permission level**: system_basic
**Authorization mode**: system_grant
**Enable via ACL**: TRUE
## ohos.permission.GET_DISTRIBUTED_ACCOUNTS
Allows an application to obtain distributed account information.
**Permission level**: system_basic
**Authorization mode**: system_grant
**Enable via ACL**: TRUE
## ohos.permission.GET_LOCAL_ACCOUNTS
Allows an application to obtain local account information.
**Permission level**: system_basic
**Authorization mode**: system_grant
**Enable via ACL**: TRUE
## ohos.permission.READ_HIVIEW_SYSTEM
Allows an application to access HiView data.
**Permission level**: system_basic
**Authorization mode**: system_grant
**Enable via ACL**: TRUE
## ohos.permission.WRITE_HIVIEW_SYSTEM
Allows an application to modify HiView data.
**Permission level**: system_basic
**Authorization mode**: system_grant
**Enable via ACL**: TRUE
......@@ -11,26 +11,11 @@ You can also customize a new component through proper combination of components
Components can be classified into the following types based on their functions.
| Type | Components |
| -------- | -------- |
| Type | Components |
| --------- | ---------------------------------------- |
| Container | badge, dialog, div, form, list, list-item, list-item-group, panel, popup, refresh, stack, stepper, stepper-item, swiper, tabs, tab-bar, tab-content |
| Basic | button, chart, divider, image, image-animator, input, label, marquee, menu, option, picker, picker-view, piece, progress, qrcode, rating, richtext, search, select, slider, span, switch, text, textarea, toolbar, toolbar-item, toggle |
| Media | video |
| Canvas | canvas |
| Grid | grid-container, grid-row, grid-col |
| SVG | svg, rect, circle, ellipse, path, line, polyline, polygon, text, tspan, textPath, animate, animateMotion, animateTransform |
## Samples
The following samples are provided to help you better understand how to develop components:
- [`JsPanel`: Content Display Panel (JavaScript, API 8)](https://gitee.com/openharmony/app_samples/tree/master/UI/JsPanel)
- [`Popup`: JavaScript Bubble (API 8)](https://gitee.com/openharmony/app_samples/tree/master/UI/Popup)
- [`RefreshContainer`: Refresh Container (JavaScript, API 8)](https://gitee.com/openharmony/app_samples/tree/master/UI/RefreshContainer)
- [`JSComponments`: JavaScript Bubble (API 8)](https://gitee.com/openharmony/app_samples/tree/master/UI/JSComponments)
- [`JsUserRegistration`: User Registration (JavaScript, API 8)](https://gitee.com/openharmony/app_samples/tree/master/UI/JsUserRegistration)
- [`ECG`: Heart Rate Detection (JavaScript, API 7)](https://gitee.com/openharmony/app_samples/tree/master/common/ECG)
- [`Badge`: Badge (JavaScript, API 8)](https://gitee.com/openharmony/app_samples/tree/master/UI/Badge)
- [`JsVideo`: JsVideo (API 8)](https://gitee.com/openharmony/app_samples/tree/master/media/JsVideo)
- [Rating (JavaScript)](https://gitee.com/openharmony/codelabs/tree/master/JSUI/RatingApplication)
- [Simple Video Player](https://gitee.com/openharmony/codelabs/tree/master/Media/VideoOpenHarmony)
| Basic | button, chart, divider, image, image-animator, input, label, marquee, menu, option, picker, picker-view, piece, progress, qrcode, rating, richtext, search, select, slider, span, switch, text, textarea, toolbar, toolbar-item, toggle |
| Media | video |
| Canvas | canvas |
| Grid | grid-container, grid-row, grid-col |
| SVG | svg, rect, circle, ellipse, path, line, polyline, polygon, text, tspan, textPath, animate, animateMotion, animateTransform |
\ No newline at end of file
# Web
- [Web Component Overview](web-component-overview.md)
- [Loading Pages by Using the Web Component](web-page-loading-with-web-components.md)
- Setting Basic Attributes and Events
- [Setting the Dark Mode](web-set-dark-mode.md)
- [Uploading Files](web-file-upload.md)
- [Opening Pages in a New Window](web-open-in-new-window.md)
- [Managing Location Permissions](web-geolocation-permission.md)
- Using Frontend Page JavaScript Code on the Application
- [Invoking Frontend Page Functions on the Application](web-in-app-frontend-page-function-invoking.md)
- [Invoking Application Functions on the Frontend Page](web-in-page-app-function-invoking.md)
- [Establishing a Data Channel Between the Application and Frontend Page](web-app-page-data-channel.md)
- [Managing Page Redirection and Browsing History Navigation](web-redirection-and-browsing-history-mgmt.md)
- [Managing Cookies and Data Storage](web-cookie-and-data-storage-mgmt.md)
- [Customizing Page Request Responses](web-resource-interception-request-mgmt.md)
- [Debugging Frontend Pages by Using DevTools](web-debugging-with-devtools.md)
# Establishing a Data Channel Between the Application and the Frontend Page
The [createWebMessagePorts()](../reference/apis/js-apis-webview.md#createwebmessageports) API allows you to create message ports to implement communication between the application and frontend page.
In the following example, **createWebMessagePorts** is used to create message ports on the application and [postMessage()](../reference/apis/js-apis-webview.md#postmessage) is used to forward one of the message ports to the frontend page so that the application and frontend page can exchange messages with each other over the port.
- Application code:
```ts
// xxx.ets
import web_webview from '@ohos.web.webview';
@Entry
@Component
struct WebComponent {
controller: web_webview.WebviewController = new web_webview.WebviewController();
ports: web_webview.WebMessagePort[];
@State sendFromEts: string = 'Send this message from ets to HTML';
@State receivedFromHtml: string = 'Display received message send from HTML';
build() {
Column() {
// Display the content received from the HTML side.
Text(this.receivedFromHtml)
// Send the content in the text box to the HTML side.
TextInput({placeholder: 'Send this message from ets to HTML'})
.onChange((value: string) => {
this.sendFromEts = value;
})
Button('postMessage')
.onClick(() => {
try {
// 1. Create two message ports.
this.ports = this.controller.createWebMessagePorts();
// 2. Register a callback for the message port (for example, port 1) on the application.
this.ports[1].onMessageEvent((result: web_webview.WebMessage) => {
let msg = 'Got msg from HTML:';
if (typeof(result) === 'string') {
console.info(`received string message from html5, string is: ${result}`);
msg = msg + result;
} else if (typeof(result) === 'object') {
if (result instanceof ArrayBuffer) {
console.info(`received arraybuffer from html5, length is: ${result.byteLength}`);
msg = msg + 'lenght is ' + result.byteLength;
} else {
console.info('not support');
}
} else {
console.info('not support');
}
this.receivedFromHtml = msg;
})
// 3. Send the other message port (for example, port 0) to the HTML side, which then saves the message port.
this.controller.postMessage('__init_port__', [this.ports[0]], '*');
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
})
// 4. Use the message port on the application to send messages to the message port that has been sent to the HTML side.
Button('SendDataToHTML')
.onClick(() => {
try {
if (this.ports && this.ports[1]) {
this.ports[1].postMessageEvent(this.sendFromEts);
} else {
console.error(`ports is null, Please initialize first`);
}
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
})
Web({ src: $rawfile('xxx.html'), controller: this.controller })
}
}
}
```
- Frontend page code:
```html
<!--xxx.html-->
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>WebView Message Port Demo</title>
</head>
<script>
var h5Port;
var output = document.querySelector('.output');
window.addEventListener('message', function (event) {
if (event.data === '__init_port__') {
if (event.ports[0] !== null) {
h5Port = event.ports[0]; // 1. Save the port sent from the eTS side.
h5Port.onmessage = function (event) {
// 2. Receive messages sent from the eTS side.
var msg = 'Got message from ets:';
var result = event.data;
if (typeof(result) === 'string') {
console.info(`received string message from html5, string is: ${result}`);
msg = msg + result;
} else if (typeof(result) === 'object') {
if (result instanceof ArrayBuffer) {
console.info(`received arraybuffer from html5, length is:` ${result.byteLength}`);
msg = msg + 'lenght is ' + result.byteLength;
} else {
console.info('not support');
}
} else {
console.info('not support');
}
output.innerHTML = msg;
}
}
}
})
// 3. Use H5Port to send messages to the eTS side.
function PostMsgToEts(data) {
if (h5Port) {
h5Port.postMessage(data);
} else {
console.error('h5Port is null, Please initialize first');
}
}
</script>
<body>
<h1>WebView Message Port Demo</h1>
<div>
<input type="button" value="SendToEts" onclick="PostMsgToEts(msgFromJS.value);"/><br/>
<input id="msgFromJS" type="text" value="send this message from HTML to ets"/><br/>
</div>
<p class="output">display received message send from ets</p>
</body>
</html>
```
# Web Component Overview
In addition to displaying web page content on applications, the **Web** component provides you with some other helpful functions, including:
- **Page loading**: provides a full set of basic frontend page loading capabilities, which allow you to load network pages, local pages, and HTML text data.
- **Page interaction**: supports a wide range of page interaction modes, which allow you to set the dark mode for frontend pages, load pages in a new window, manage location permissions and cookies, and use frontend page JavaScript code on the application.
- **Page debugging**: uses DevTools to debug frontend pages.
To help you better understand the features of the **Web** component, the following sections will exemplify use of the **Web** component in common application scenarios.
# Managing Cookies and Data Storage
## Cookie Management
A cookie is a segment of data sent from the server to the client to uniquely identify a user during network access. The client may hold the data and provide it to the server at later interactions so that the server can quickly identify the client identity and status.
The **Web** component provides the **WebCookieManager** class for you to manage cookie information, which is stored in the **/proc/{pid}/root/data/storage/el2/base/cache/web/Cookiesd** file in the application sandbox path.
The following uses [setCookie()](../reference/apis/js-apis-webview.md#setcookie) as an example to describe how to set a cookie's value to **test** for **www.example.com**. For details about functions and usage of other APIs, see [WebCookieManager()](../reference/apis/js-apis-webview.md#webcookiemanager).
```ts
// xxx.ets
import web_webview from '@ohos.web.webview';
@Entry
@Component
struct WebComponent {
controller: web_webview.WebviewController = new web_webview.WebviewController();
build() {
Column() {
Button('setCookie')
.onClick(() => {
try {
web_webview.WebCookieManager.setCookie('https://www.example.com', 'value=test');
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
})
Web({ src: 'www.example.com', controller: this.controller })
}
}
}
```
## Cache and Storage Management
Network resource requests are relatively time-consuming during website access. You can use store resources locally by means of cache and Dom Storage to fasten the access to the same website.
### Cache
Use [cacheMode()](../reference/arkui-ts/ts-basic-components-web.md#cachemode) to configure the cache mode for page resources. Four cache modes are supported:
- **Default**: Page resources in a cache that has not expired are preferentially used. If the cache does not exist, page resources are obtained from the network.
- **None**: Page resources are loaded from the cache. If the cache does not exist, page resources are obtained from the network.
- **Online**: Page resources are not loaded from the cache. All resources are obtained from the network.
- **Only**: Page resources are only loaded from the cache.
In the following example, the cache mode is set to **None**.
```ts
// xxx.ets
import web_webview from '@ohos.web.webview';
@Entry
@Component
struct WebComponent {
@State mode: CacheMode = CacheMode.None;
controller: web_webview.WebviewController = new web_webview.WebviewController();
build() {
Column() {
Web({ src: 'www.example.com', controller: this.controller })
.cacheMode(this.mode)
}
}
}
```
To obtain up-to-date resources, you can use [removeCache()](../reference/apis/js-apis-webview.md#removecache) to clear cached resources. The sample code is as follows:
```ts
// xxx.ets
import web_webview from '@ohos.web.webview';
@Entry
@Component
struct WebComponent {
@State mode: CacheMode = CacheMode.None;
controller: web_webview.WebviewController = new web_webview.WebviewController();
build() {
Column() {
Button('removeCache')
.onClick(() => {
try {
// If this parameter is set to true, the cache in both the ROM and RAM is cleared. If this parameter is set to false, only the cache in the RAM is cleared.
this.controller.removeCache(true);
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
})
Web({ src: 'www.example.com', controller: this.controller })
.cacheMode(this.mode)
}
}
}
```
### Dom Storage
Dom Storage falls into Session Storage and Local Storage. Wherein, Session Storage applies to the temporary data, and its data storage and release follow the session lifecycle; Local Storage applies to the persistent data, which is flushed to the application directory. In both storage modes, data is stored in a form of key-value pair, and is usually used when a page that needs to be stored on the client is accessed. You can use [domStorageAccess()](../reference/arkui-ts/ts-basic-components-web.md#domstorageaccess) to enable Dom Storage. The following is the sample code:
```ts
// xxx.ets
import web_webview from '@ohos.web.webview';
@Entry
@Component
struct WebComponent {
controller: web_webview.WebviewController = new web_webview.WebviewController();
build() {
Column() {
Web({ src: 'www.example.com', controller: this.controller })
.domStorageAccess(true)
}
}
}
```
# Debugging Frontend Pages by Using DevTools
The **Web** component supports debugging of web frontend pages by using DevTools, a web frontend development and debugging tool that allows you to debug an application's frontend pages on a PC. Before you do this, use [setWebDebuggingAccess()](../reference/apis/js-apis-webview.md#setwebdebuggingaccess) to enable frontend page debugging for the **Web** component.
To use DevTools for frontend page debugging, perform the following steps:
1. Enable web frontend page debugging in the application code.
```ts
// xxx.ets
import web_webview from '@ohos.web.webview';
@Entry
@Component
struct WebComponent {
controller: web_webview.WebviewController = new web_webview.WebviewController();
aboutToAppear() {
// Enable web frontend page debugging.
web_webview.WebviewController.setWebDebuggingAccess(true);
}
build() {
Column() {
Web({ src: 'www.example.com', controller: this.controller })
}
}
}
```
2. Connect your device to a PC, and configure port mapping on the PC as follows:
```
// Configure port mapping.
hdc fport tcp:9222 tcp:9222
// View port mapping.
hdc fport ls
```
3. Enter **chrome://inspect/\#devices** in the address box of the Chrome browser on the PC. Once the device is identified, you can get started with page debugging. The debugging effect is as follows:
**Figure 1** Page debugging effect
![debug-effect](figures/debug-effect.png)
# Uploading Files
The **Web** component supports file uploading on a frontend page. You can use [onShowFileSelector()](../reference/arkui-ts/ts-basic-components-web.md#onshowfileselector9) to process file upload requests sent from a frontend page.
In the following example, when a user clicks the **Upload** button on the frontend page, the application receives a file upload request through [onShowFileSelector()](../reference/arkui-ts/ts-basic-components-web.md#onshowfileselector9), which carries the path of the local file to be uploaded.
- Application code:
```ts
// xxx.ets
import web_webview from '@ohos.web.webview';
@Entry
@Component
struct WebComponent {
controller: WebController = new WebController()
build() {
Column() {
// Load the local.html page.
Web({ src: $rawfile('local.html'), controller: this.controller })
.onShowFileSelector((event) => {
// Set the path of the local file to be uploaded.
let fileList: Array<string> = [
'xxx/test.png',
]
event.result.handleFileList(fileList)
return true;
})
}
}
}
```
- Code of the **local.html** page:
```html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Document</title>
</head>
<body>
<!-- Click the Upload button -->
<input type="file" value="file"></br>
</body>
</html>
```
# Managing Location Permissions
The **Web** component provides the location permission management capability. You can use [onGeolocationShow()](../reference/arkui-ts/ts-basic-components-web.md#ongeolocationshow) to manage the location permission specific to a website. Based on the API response, the **Web** component determines whether to grant the location permission to the frontend page. To obtain the device location, you need to declare the [ohos.permission.LOCATION](../security/accesstoken-guidelines.md) permission.
In the following example, when a user clicks the **Get Location** button on the frontend page, the **Web** component notifies the application of the location permission request in a pop-up window.
- Frontend page code:
```html
<!DOCTYPE html>
<html>
<body>
<p id="locationInfo">Location information</p>
<button onclick="getLocation()">Get Location</button>
<script>
var locationInfo=document.getElementById("locationInfo");
function getLocation(){
if (navigator.geolocation) {
<!-- Access to the device location by the frontend page -->
navigator.geolocation.getCurrentPosition(showPosition);
}
}
function showPosition(position){
locationInfo.innerHTML="Latitude: " + position.coords.latitude + "<br />Longitude: " + position.coords.longitude;
}
</script>
</body>
</html>
```
- Application code:
```ts
// xxx.ets
import web_webview from '@ohos.web.webview';
@Entry
@Component
struct WebComponent {
controller: web_webview.WebviewController = new web_webview.WebviewController();
build() {
Column() {
Web({ src:$rawfile('getLocation.html'), controller:this.controller })
.geolocationAccess(true)
.onGeolocationShow((event) => { // Notification of the location permission request
AlertDialog.show({
title: 'Location Permission',
message:'Grant access to the device location?',
primaryButton: {
value: 'cancel',
action: () => {
event.geolocation.invoke(event.origin, false, false); // Deny access to the device location.
}
},
secondaryButton: {
value: 'ok',
action: () => {
event.geolocation.invoke(event.origin, true, false); // Allow access to the device location.
}
},
cancel: () => {
event.geolocation.invoke(event.origin, false, false); // Deny access to the device location.
}
})
})
}
}
}
```
# Invoking Frontend Page Functions on the Application
You can call [runJavaScript()](../reference/apis/js-apis-webview.md#runjavascript) on an application to call JavaScript functions of frontend pages.
In the following example, when a user clicks the **runJavaScript** button on the application, the **htmlTest()** API of the frontend page will be triggered.
- Frontend page code:
```html
<!-- index.html -->
<!DOCTYPE html>
<html>
<body>
<script>
function htmlTest() {
console.info('JavaScript Hello World! ');
}
</script>
</body>
</html>
```
- Application code:
```ts
// xxx.ets
import web_webview from '@ohos.web.webview';
@Entry
@Component
struct WebComponent {
webviewController: web_webview.WebviewController = new web_webview.WebviewController();
build() {
Column() {
Web({ src: $rawfile('index.html'), controller: this.webviewController})
Button('runJavaScript')
.onClick(() => {
this.webviewController.runJavaScript('htmlTest()');
})
}
}
}
```
# Invoking Application Functions on the Frontend Page
You can use the **Web** component to register application code with frontend pages. After the registration is done, frontend pages can use the registered object names to call application functions.
Two methods are available for registering the application code:<br>Call [javaScriptProxy()](../reference/arkui-ts/ts-basic-components-web.md#javascriptproxy) during **Web** component initialization.<br> Call [registerJavaScriptProxy()](../reference/apis/js-apis-webview.md#registerjavascriptproxy) after **Web** component initialization.
The following example registers the **test()** function with the frontend page. This way, the **test()** function can be triggered and run on the frontend page.
- Sample code for using [javaScriptProxy()](../reference/arkui-ts/ts-basic-components-web.md#javascriptproxy):
```ts
// xxx.ets
import web_webview from '@ohos.web.webview';
@Entry
@Component
struct WebComponent {
webviewController: web_webview.WebviewController = new web_webview.WebviewController();
// Declare the object to be registered.
testObj = {
test: () => {
return 'ArkTS Hello World!';
}
}
build() {
Column() {
// Load the local index.html page.
Web({ src: $rawfile('index.html'), controller: this.webviewController})
// Inject the object to the web client.
.javaScriptProxy({
object: this.testObj,
name: "testObjName",
methodList: ["test"],
controller: this.webviewController
})
}
}
}
```
- Sample code for using [registerJavaScriptProxy()](../reference/apis/js-apis-webview.md#registerjavascriptproxy):
```ts
// xxx.ets
import web_webview from '@ohos.web.webview';
@Entry
@Component
struct Index {
webviewController: web_webview.WebviewController = new web_webview.WebviewController();
testObj = {
test: (data) => {
return "ArkUI Web Component";
},
toString: () => {
console.info('Web Component toString');
}
}
build() {
Column() {
Button('refresh')
.onClick(() => {
try {
this.webviewController.refresh();
} catch (error) {
console.error(`Errorcode: ${error.code}, Message: ${error.message}`);
}
})
Button('Register JavaScript To Window')
.onClick(() => {
try {
this.webviewController.registerJavaScriptProxy(this.testObj, "objName", ["test", "toString"]);
} catch (error) {
console.error(`Errorcode: ${error.code}, Message: ${error.message}`);
}
})
Web({ src: $rawfile('index.html'), controller: this.webviewController })
}
}
}
```
> **NOTE**
>
> If you use [registerJavaScriptProxy()](../reference/apis/js-apis-webview.md#registerjavascriptproxy) to register a function, call **[refresh()]**(../reference/apis/js-apis-webview.md#refresh) for the function to take effect.
- Sample code for invoking application functions on the **index.htm** frontend page:
```html
<!-- index.html -->
<!DOCTYPE html>
<html>
<body>
<button type="button" onclick="callArkTS()">Click Me!</button>
<p id="demo"></p>
<script>
function callArkTS() {
let str = testObjName.test();
document.getElementById("demo").innerHTML = str;
console.info('ArkTS Hello World! :' + str);
}
</script>
</body>
</html>
```
# Opening Pages in a New Window
The **Web** component provides the capability of opening pages in a new window. You can call [multiWindowAccess()](../reference/arkui-ts/ts-basic-components-web.md#multiwindowaccess9) to specify whether to allow a web page to be opened in a new window. When a new window is opened in the **Web** component, the application will receive a window opening event through [onWindowNew()](../reference/arkui-ts/ts-basic-components-web.md#onwindownew9). You need to add the code for processing the window opening request in the event callback.
> **NOTE**
>
> - If [allowWindowOpenMethod()](../reference/arkui-ts/ts-basic-components-web.md#allowwindowopenmethod10) is set to **true**, you can open a new window in the frontend page by invoking its JavaScript functions.
>
> - If you do not want to open a new window in [onWindowNew()](../reference/arkui-ts/ts-basic-components-web.md#onwindownew9), set the return value of [ControllerHandler.setWebController()](../reference/arkui-ts/ts-basic-components-web.md#setwebcontroller9) to **null**.
In the following example, when a user clicks the **Open Page in New Window** button, the application receives a window opening event in the [onWindowNew()](../reference/arkui-ts/ts-basic-components-web.md#onwindownew9) callback.
- Application code:
For details about how to create a window, see [Web Development Examples] (https://gitee.com/openharmony/applications_app_samples/tree/master/code/BasicFeature/Web/Browser).
```ts
// xxx.ets
import web_webview from '@ohos.web.webview';
@Entry
@Component
struct WebComponent {
controller: web_webview.WebviewController = new web_webview.WebviewController();
build() {
Column() {
Web({ src:$rawfile("window.html"), controller: this.controller })
.multiWindowAccess(true)
.onWindowNew((event) => {
console.info("onWindowNew...");
var popController: web_webview.WebviewController = new web_webview.WebviewController();
// Create a window, associate it with popController, and have popController returned to the Web component. If you do not need to open a new window, set the return value to event.handler.setWebController(null).
event.handler.setWebController(popController);
})
}
}
}
```
- Code of the **window.html** page:
```html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>WindowEvent</title>
</head>
<body>
<input type="button" value="Open Page in New Window" onclick="OpenNewWindow()">
<script type="text/javascript">
function OpenNewWindow()
{
let openedWindow = window.open("about:blank", "", "location=no,status=no,scrollvars=no");
if (openedWindow) {
openedWindow.document.body.write("<p>This is my window</p>");
} else {
log.innerHTML = "window.open failed";
}
}
</script>
</body>
</html>
```
# Loading Pages by Using the Web Component
Page loading is a basic function of the **Web** component. Depending on the data source, page loading falls into three types: loading of network pages, loading of local pages, and loading of HTML rich text data.
If acquisition of network resources is involved in page loading, you need to declare the [ohos.permission.INTERNET](../security/accesstoken-guidelines.md) permission.
## Loading Network Pages
You can specify the default network page to be loaded when creating a **Web** component. After the default network page is loaded, call [loadUrl()](../reference/apis/js-apis-webview.md#loadurl) if you want to change the network page displayed by the **Web** component.
In the following example, after the **www.example.com** page is loaded by the **Web** component, **loadUrl** is called to change the displayed page to **www.example1.com**.
```ts
// xxx.ets
import web_webview from '@ohos.web.webview';
@Entry
@Component
struct WebComponent {
webviewController: web_webview.WebviewController = new web_webview.WebviewController();
build() {
Column() {
Button('loadUrl')
.onClick(() => {
try {
// Upon button clicking, call loadUrl to redirect to www.example1.com.
this.webviewController.loadUrl('www.example1.com');
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
})
// When creating a Web component, set the default network page to be loaded to www.example.com.
Web({ src: 'www.example.com', controller: this.webviewController})
}
}
}
```
## Loading Local Pages
Local page files are stored in the application's **rawfile** directory. You can specify the local page to be loaded by default when creating a **Web** component. After page loading is complete, you can call [loadUrl()](../reference/apis/js-apis-webview.md#loadurl) to change the displayed page of the **Web** component.
The following example shows how to load a local page file.
- Local page file in the application's resources/rawfile directory:
**Figure 1** Path of local page files
![resource-path](figures/resource-path.png)
- Application code:
```ts
// xxx.ets
import web_webview from '@ohos.web.webview';
@Entry
@Component
struct WebComponent {
webviewController: web_webview.WebviewController = new web_webview.WebviewController();
build() {
Column() {
Button('loadUrl')
.onClick(() => {
try {
// Upon button clicking, call loadUrl to redirect to local1.html.
this.webviewController.loadUrl($rawfile("local1.html"));
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
})
// When creating a Web component, load the local.html file through $rawfile.
Web({ src: $rawfile("local.html"), controller: this.webviewController })
}
}
}
```
- Code of the **local.html** page:
```html
<!-- local.html -->
<!DOCTYPE html>
<html>
<body>
<p>Hello World</p>
</body>
</html>
```
## Loading HTML Rich Text Data
The **Web** component provides the [loadData()](../reference/apis/js-apis-webview.md#loaddata) API for you to load HTML rich text data. This API is applicable if you want to display some page sections instead of the entire page.
```ts
// xxx.ets
import web_webview from '@ohos.web.webview';
@Entry
@Component
struct WebComponent {
controller: web_webview.WebviewController = new web_webview.WebviewController();
build() {
Column() {
Button('loadData')
.onClick(() => {
try {
// Upon button clicking, call loadData to load HTML rich text data.
this.controller.loadData(
'<html><body bgcolor=\"white\">Source:<pre>source</pre></body></html>',
'text/html',
'UTF-8'
);
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
})
// When creating a Web component, set the default network page to be loaded to www.example.com.
Web({ src: 'www.example.com', controller: this.controller })
}
}
}
```
# Managing Page Redirection and Browsing History Navigation
## History Navigation
When a user clicks a web page link on the frontend page, the **Web** component automatically opens and loads the target website by default. When the current page is assigned a new loading link, the address of the accessed web page is automatically recorded. You can call [forward()](../reference/apis/js-apis-webview.md#forward) or [backward()](../reference/apis/js-apis-webview.md#backward) to browse the previous or next history record.
In the following example, when a user clicks the button, **backward()** is called to go back to the previous page.
```ts
// xxx.ets
import web_webview from '@ohos.web.webview';
@Entry
@Component
struct WebComponent {
webviewController: web_webview.WebviewController = new web_webview.WebviewController();
build() {
Column() {
Button('loadData')
.onClick(() => {
if (this.webviewController.accessBackward()) {
this.webviewController.backward();
return true;
}
})
Web({ src: 'https://www.example.com/cn/', controller: this.webviewController})
}
}
}
```
If a previous record exists, [accessBackward()](../reference/apis/js-apis-webview.md#accessbackward) will return **true**. Similarly, you can call [accessForward()](../reference/apis/js-apis-webview.md#accessforward) to check whether a next record exists. If you skip the check, [forward()](../reference/apis/js-apis-webview.md#forward) and [backward()](../reference/apis/js-apis-webview.md#backward) will not trigger any action if the user has navigated to the end of history records.
## Page Redirection
The **Web** component provides the [onUrlLoadIntercept()](../reference/arkui-ts/ts-basic-components-web.md#onurlloadintercept) API to redirect you from one page to another.
In the following example, the frontend page **route.html** is loaded on to the application home page **Index.ets**, and the user is redirected to the application page **ProfilePage.ets** when clicking the link on the **route.html** page.
- Code of the **index.ets** page:
```ts
// index.ets
import web_webview from '@ohos.web.webview';
import router from '@ohos.router';
@Entry
@Component
struct WebComponent {
webviewController: web_webview.WebviewController = new web_webview.WebviewController();
build() {
Column() {
Web({ src: $rawfile('route.html'), controller: this.webviewController })
.onUrlLoadIntercept((event) => {
let url: string = event.data as string;
if (url.indexOf('native://') === 0) {
// Redirect to another page.
router.pushUrl({ url:url.substring(9) })
return true;
}
return false;
})
}
}
}
```
- Code of the **route.html** page:
```html
<!-- route.html -->
<!DOCTYPE html>
<html>
<body>
<div>
<a href="native://pages/ProfilePage">My Profile</a>
</div>
</body>
</html>
```
- Code of the **ProfilePage.ets** page:
```ts
@Entry
@Component
struct ProfilePage {
@State message: string = 'Hello World';
build() {
Column() {
Text(this.message)
.fontSize(20)
}
}
}
```
## Cross-Application Redirection
The **Web** component supports redirection from one application to another.
In the following example, when a user clicks the link on the frontend page **call.html**, the user will be redirected to the dial screen of the phone app.
- Application code:
```ts
// xxx.ets
import web_webview from '@ohos.web.webview';
import call from '@ohos.telephony.call';
@Entry
@Component
struct WebComponent {
webviewController: web_webview.WebviewController = new web_webview.WebviewController();
build() {
Column() {
Web({ src: $rawfile('xxx.html'), controller: this.webviewController})
.onUrlLoadIntercept((event) => {
let url: string = event.data as string;
// Check whether the link is redirecting to the dial screen of the phone app.
if (url.indexOf('tel://') === 0) {
// Redirect to the dial screen.
call.makeCall(url.substring(6), (err) => {
if (!err) {
console.info('make call succeeded.');
} else {
console.info('make call fail, err is:' + JSON.stringify(err));
}
});
return true;
}
return false;
})
}
}
}
```
- Code of the **call.html** page:
```html
<!-- call.html -->
<!DOCTYPE html>
<html>
<body>
<div>
<a href="tel://xxx xxxx xxx">Dial number</a>
</div>
</body>
</html>
```
# Customizing Page Request Responses
The **Web** component supports customization of the response to intercepted page requests. You can call [onInterceptRequest()](../reference/arkui-ts/ts-basic-components-web.md#oninterceptrequest9) to customize web page responses, file resource responses, etc.
When a resource loading request is initiated on a web page, the application layer will receive the request. The application layer then constructs a local resource response and sends it to the web kernel. On receiving the response, the web kernel parses the response and loads page resources accordingly.
In the following example, the **Web** component intercepts the web page request **https://www.intercept.com/test.html** and constructs a custom response in the application code.
- Code of the **example.html** page:
```html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>example</title>
</head>
<body>
<!-- Page resource request ->
<a href="https://www.intercept.com/test.html">intercept test!</a>
</body>
</html>
```
- Application code:
```ts
// xxx.ets
import web_webview from '@ohos.web.webview';
@Entry
@Component
struct WebComponent {
controller: web_webview.WebviewController = new web_webview.WebviewController()
responseResource: WebResourceResponse = new WebResourceResponse()
// Customize a response.
@State webData: string = '<!DOCTYPE html>\n' +
'<html>\n'+
'<head>\n'+
'<title>intercept test</title>\n'+
'</head>\n'+
'<body>\n'+
'<h1>intercept ok</h1>\n'+
'</body>\n'+
'</html>'
build() {
Column() {
Web({ src: $rawfile('example.html'), controller: this.controller })
.onInterceptRequest((event) => {
console.info('url:' + event.request.getRequestUrl());
// Intercept the web page request.
if (event.request.getRequestUrl() !== 'https://www.intercept.com/test.html') {
return null;
}
// Construct a custom response.
this.responseResource.setResponseData(this.webData);
this.responseResource.setResponseEncoding('utf-8');
this.responseResource.setResponseMimeType('text/html');
this.responseResource.setResponseCode(200);
this.responseResource.setReasonMessage('OK');
return this.responseResource;
})
}
}
}
```
# Setting the Dark Mode
The **Web** component allows you to set the dark mode for frontend pages.
- Call [darkMode()](../reference/arkui-ts/ts-basic-components-web.md#darkmode9) to configure an expected dark mode. [WebDarkMode.Off](../reference/arkui-ts/ts-basic-components-web.md#webdarkmode9) indicates that the dark mode is disabled. [WebDarkMode.On](../reference/arkui-ts/ts-basic-components-web.md#webdarkmode9) indicates that the dark mode is enabled and its setting follows the frontend page. [WebDarkMode.Auto](../reference/arkui-ts/ts-basic-components-web.md#webdarkmode9) indicates that the dark mode is enabled and its setting follows the system.
In the following example, the dark mode setting is configured to follow the system by using [darkMode()](../reference/arkui-ts/ts-basic-components-web.md#darkmode9).
```ts
// xxx.ets
import web_webview from '@ohos.web.webview';
@Entry
@Component
struct WebComponent {
controller: web_webview.WebviewController = new web_webview.WebviewController();
@State mode: WebDarkMode = WebDarkMode.Auto;
build() {
Column() {
Web({ src: 'www.example.com', controller: this.controller })
.darkMode(this.mode)
}
}
}
```
- Call [forceDarkAccess()](../reference/arkui-ts/ts-basic-components-web.md#forcedarkaccess9) to forcibly set the dark mode for the frontend page and configure its setting not to follow the frontend page or system. In this mode, you need to specify **WebDarkMode.On** when calling **darkMode()**.
In the following example, [forceDarkAccess()](../reference/arkui-ts/ts-basic-components-web.md#forcedarkaccess9) is used to forcibly set the dark mode for the frontend page.
```ts
// xxx.ets
import web_webview from '@ohos.web.webview';
@Entry
@Component
struct WebComponent {
controller: web_webview.WebviewController = new web_webview.WebviewController();
@State mode: WebDarkMode = WebDarkMode.On;
@State access: boolean = true;
build() {
Column() {
Web({ src: 'www.example.com', controller: this.controller })
.darkMode(this.mode)
.forceDarkAccess(this.access)
}
}
}
```
......@@ -720,6 +720,41 @@
- [Lifecycle Definition](reference/arkui-js/js-components-custom-lifecycle.md)
- [Dynamic Component Creation](reference/arkui-js/js-components-create-elements.md)
- [Data Type Attributes](reference/arkui-js/js-appendix-types.md)
- JavaScript-compatible Web-like Development Paradigm (ArkUI.Lite)
- Framework Overview
- [File Organization](js-framework-file.md)
- ["js" Tag](js-framework-js-tag.md)
- [app.js](js-framework-js-file.md)
- Syntax
- [HML](js-framework-syntax-hml.md)
- [CSS](js-framework-syntax-css.md)
- [JavaScript](js-framework-syntax-js.md)
- Universal Component Information
- [Universal Events](js-common-events.md)
- [Universal Attributes](js-common-attributes.md)
- [Universal Styles](js-common-styles.md)
- [Animation Styles](js-components-common-animation.md)
- Container Components
- [div](js-components-container-div.md)
- [list](js-components-container-list.md)
- [list-item](js-components-container-list-item.md)
- [stack](js-components-container-stack.md)
- [swiper](js-components-container-swiper.md)
- Basic Components
- [chart](js-components-basic-chart.md)
- [image](js-components-basic-image.md)
- [image-animator](js-components-basic-image-animator.md)
- [input](js-components-basic-input.md)
- [marquee](js-components-basic-marquee.md)
- [picker-view](js-components-basic-picker-view.md)
- [progress](js-components-basic-progress.md)
- [qrcode](js-components-basic-qrcode.md)
- [slider](js-components-basic-slider.md)
- [switch](js-components-basic-switch.md)
- [text](js-components-basic-text.md)
- Canvas Components
- [canvas](js-components-canvas-canvas.md)
- [CanvasRenderingContext2D](js-components-canvas-canvasrenderingcontext2d.md)
- JS Service Widget UI Components
- JS Service Widget UI Framework
- [File Organization](reference/js-service-widget-ui/js-service-widget-file.md)
......@@ -922,6 +957,7 @@
- [@ohos.curves (Interpolation Calculation)](reference/apis/js-apis-curve.md)
- [@ohos.matrix4 (Matrix Transformation)](reference/apis/js-apis-matrix4.md)
- [@ohos.mediaquery (Media Query)](reference/apis/js-apis-mediaquery.md)
- [@ohos.pluginComponent (PluginComponentManager)](reference/apis/js-apis-plugincomponent.md)
- [@ohos.promptAction (Prompt)](reference/apis/js-apis-promptAction.md)
- [@ohos.router (Page Routing)](reference/apis/js-apis-router.md)
- Graphics
......@@ -1132,6 +1168,7 @@
- [@ohos.systemParameter (System Parameter)](reference/apis/js-apis-system-parameter.md)
- [@ohos.systemTime (System Time and Time Zone)](reference/apis/js-apis-system-time.md)
- [@ohos.usb (USB Management)](reference/apis/js-apis-usb-deprecated.md)
- [@ohos.usbV9 (USB Management)](reference/apis/js-apis-usb.md)
- [@system.app (Application Context)](reference/apis/js-apis-system-app.md)
- [@system.battery (Battery Information)](reference/apis/js-apis-system-battery.md)
- [@system.bluetooth (Bluetooth)](reference/apis/js-apis-system-bluetooth.md)
......@@ -1252,6 +1289,104 @@
- Test
- [UiTest Error Codes](reference/errorcodes/errorcode-uitest.md)
- Native APIs
- Modules
- [Native XComponent](reference/native-apis/_o_h___native_x_component.md)
- [HiLog](reference/native-apis/_hi_log.md)
- [NativeWindow](reference/native-apis/_native_window.md)
- [OH_NativeBuffer](reference/native-apis/_o_h___native_buffer.md)
- [Drawing](reference/native-apis/_drawing.md)
- [OH_NativeImage](reference/native-apis/_o_h___native_image.md)
- [NativeVsync](reference/native-apis/_native_vsync.md)
- [Image](reference/native-apis/image.md)
- [Rawfile](reference/native-apis/rawfile.md)
- [MindSpore](reference/native-apis/_mind_spore.md)
- [NeuralNeworkRuntime](reference/native-apis/_neural_nework_runtime.md)
- [AudioDecoder](reference/native-apis/_audio_decoder.md)
- [AudioEncoder](reference/native-apis/_audio_encoder.md)
- [CodecBase](reference/native-apis/_codec_base.md)
- [VideoDecoder](reference/native-apis/_video_decoder.md)
- [VideoEncoder](reference/native-apis/_video_encoder.md)
- [Core](reference/native-apis/_core.md)
- [HuksKeyApi](reference/native-apis/_huks_key_api.md)
- [HuksParamSetApi](reference/native-apis/_huks_param_set_api.md)
- [HuksTypeApi](reference/native-apis/_huks_type_api.md)
- Head Files
- [drawing_bitmap.h](reference/native-apis/drawing__bitmap_8h.md)
- [drawing_brush.h](reference/native-apis/drawing__brush_8h.md)
- [drawing_canvas.h](reference/native-apis/drawing__canvas_8h.md)
- [drawing_color.h](reference/native-apis/drawing__color_8h.md)
- [drawing_font_collection.h](reference/native-apis/drawing__font__collection_8h.md)
- [drawing_path.h](reference/native-apis/drawing__path_8h.md)
- [drawing_pen.h](reference/native-apis/drawing__pen_8h.md)
- [drawing_text_declaration.h](reference/native-apis/drawing__text__declaration_8h.md)
- [drawing_text_typography.h](reference/native-apis/drawing__text__typography_8h.md)
- [drawing_types.h](reference/native-apis/drawing__types_8h.md)
- [external_window.h](reference/native-apis/external__window_8h.md)
- [image_pixel_map_napi.h](reference/native-apis/image__pixel__map__napi_8h.md)
- [log.h](reference/native-apis/log_8h.md)
- [native_buffer.h](reference/native-apis/native__buffer_8h.md)
- [native_image.h](reference/native-apis/native__image_8h.md)
- [native_interface_xcomponent.h](reference/native-apis/native__interface__xcomponent_8h.md)
- [native_vsync.h](reference/native-apis/native__vsync_8h.md)
- [raw_dir.h](reference/native-apis/raw__dir_8h.md)
- [raw_file_manager.h](reference/native-apis/raw__file__manager_8h.md)
- [raw_file.h](reference/native-apis/raw__file_8h.md)
- [context.h](reference/native-apis/context_8h.md)
- [data_type.h](reference/native-apis/data__type_8h.md)
- [format.h](reference/native-apis/format_8h.md)
- [model.h](reference/native-apis/model_8h.md)
- [status.h](reference/native-apis/status_8h.md)
- [tensor.h](reference/native-apis/tensor_8h.md)
- [types.h](reference/native-apis/types_8h.md)
- [neural_network_runtime_type.h](reference/native-apis/neural__network__runtime__type_8h.md)
- [neural_network_runtime.h](reference/native-apis/neural__network__runtime_8h.md)
- [native_avcodec_audiodecoder.h](reference/native-apis/native__avcodec__audiodecoder_8h.md)
- [native_avcodec_audioencoder.h](reference/native-apis/native__avcodec__audioencoder_8h.md)
- [native_avcodec_base.h](reference/native-apis/native__avcodec__base_8h.md)
- [native_avcodec_videodecoder.h](reference/native-apis/native__avcodec__videodecoder_8h.md)
- [native_avcodec_videoencoder.h](reference/native-apis/native__avcodec__videoencoder_8h.md)
- [native_averrors.h](reference/native-apis/native__averrors_8h.md)
- [native_avformat.h](reference/native-apis/native__avformat_8h.md)
- [native_avmemory.h](reference/native-apis/native__avmemory_8h.md)
- [native_huks_api.h](reference/native-apis/native__huks__api_8h.md)
- [native_huks_param.h](reference/native-apis/native__huks__param_8h.md)
- [native_huks_type.h](reference/native-apis/native__huks__type_8h.md)
- Structs
- [OH_Drawing_BitmapFormat](reference/native-apis/_o_h___drawing___bitmap_format.md)
- [OH_NativeBuffer_Config](reference/native-apis/_o_h___native_buffer___config.md)
- [OH_NativeXComponent_Callback](reference/native-apis/_o_h___native_x_component___callback.md)
- [OH_NativeXComponent_MouseEvent](reference/native-apis/_o_h___native_x_component___mouse_event.md)
- [OH_NativeXComponent_MouseEvent_Callback](reference/native-apis/_o_h___native_x_component___mouse_event___callback.md)
- [OH_NativeXComponent_TouchEvent](reference/native-apis/_o_h___native_x_component___touch_event.md)
- [OH_NativeXComponent_TouchPoint](reference/native-apis/_o_h___native_x_component___touch_point.md)
- [OHExtDataHandle](reference/native-apis/_o_h_ext_data_handle.md)
- [OHHDRMetaData](reference/native-apis/_o_h_h_d_r_meta_data.md)
- [OhosPixelMapCreateOps](reference/native-apis/_ohos_pixel_map_create_ops.md)
- [OhosPixelMapInfo](reference/native-apis/_ohos_pixel_map_info.md)
- [RawFileDescriptor](reference/native-apis/_raw_file_descriptor.md)
- [Region](reference/native-apis/_region.md)
- [Rect](reference/native-apis/_rect.md)
- [OH_AI_CallBackParam](reference/native-apis/_o_h___a_i___call_back_param.md)
- [OH_AI_ShapeInfo](reference/native-apis/_o_h___a_i___shape_info.md)
- [OH_AI_TensorHandleArray](reference/native-apis/_o_h___a_i___tensor_handle_array.md)
- [OH_NN_Memory](reference/native-apis/_o_h___n_n___memory.md)
- [OH_NN_QuantParam](reference/native-apis/_o_h___n_n___quant_param.md)
- [OH_NN_Tensor](reference/native-apis/_o_h___n_n___tensor.md)
- [OH_NN_UInt32Array](reference/native-apis/_o_h___n_n___u_int32_array.md)
- [OH_AVCodecAsyncCallback](reference/native-apis/_o_h___a_v_codec_async_callback.md)
- [OH_AVCodecBufferAttr](reference/native-apis/_o_h___a_v_codec_buffer_attr.md)
- [OH_Huks_Blob](reference/native-apis/_o_h___huks___blob.md)
- [OH_Huks_CertChain](reference/native-apis/_o_h___huks___cert_chain.md)
- [OH_Huks_KeyInfo](reference/native-apis/_o_h___huks___key_info.md)
- [OH_Huks_KeyMaterial25519](reference/native-apis/_o_h___huks___key_material25519.md)
- [OH_Huks_KeyMaterialDh](reference/native-apis/_o_h___huks___key_material_dh.md)
- [OH_Huks_KeyMaterialDsa](reference/native-apis/_o_h___huks___key_material_dsa.md)
- [OH_Huks_KeyMaterialEcc](reference/native-apis/_o_h___huks___key_material_ecc.md)
- [OH_Huks_KeyMaterialRsa](reference/native-apis/_o_h___huks___key_material_rsa.md)
- [OH_Huks_Param](reference/native-apis/_o_h___huks___param.md)
- [OH_Huks_ParamSet](reference/native-apis/_o_h___huks___param_set.md)
- [OH_Huks_PubKeyInfo](reference/native-apis/_o_h___huks___pub_key_info.md)
- [OH_Huks_Result](reference/native-apis/_o_h___huks___result.md)
- Standard Libraries Supported by Native APIs
- [Node_API](reference/native-lib/third_party_napi/napi.md)
- [libuv](reference/native-lib/third_party_libuv/libuv.md)
......@@ -1281,3 +1416,4 @@
- [Usage of Third- and Fourth-Party Libraries](faqs/faqs-third-party-library.md)
- [IDE Usage](faqs/faqs-ide.md)
- [Development Board](faqs/faqs-development-board.md)
<!--no_check-->
......@@ -8,6 +8,7 @@ By default, OpenHarmony provides the battery level based on the current battery
### Constraints
The configuration path for battery level customization is subject to the [configuration policy](https://gitee.com/openharmony/customization_config_policy). In this development guide, `/vendor` is used as an example of the configuration path. During actual development, you need to modify the customization path based on the product configuration policy.
## How to Develop
......@@ -36,7 +37,7 @@ The following uses [DAYU200](https://gitee.com/openharmony/vendor_hihope/tree/ma
├── battery_config.json
```
3. Write the custom `battery_config.json` file by referring to the `battery_config.json` file in the default folder of battery level configuration. For example:
3. Write the custom `battery_config.json` file by referring to the [battery_config.json](https://gitee.com/openharmony/powermgr_battery_manager/blob/master/services/native/profile/battery_config.json) file in the default folder of battery level configuration. For example:
```json
{
......@@ -54,7 +55,7 @@ The following uses [DAYU200](https://gitee.com/openharmony/vendor_hihope/tree/ma
**Table 1** Battery level configuration
| Battery Bevel| Battery Volume| Description|
| Battery Level| Battery Volume| Description|
| -------- | -------- | -------- |
| shutdown | 5 | Power-off battery level|
| critical | 10 | Extremely low battery level|
......@@ -65,7 +66,7 @@ The following uses [DAYU200](https://gitee.com/openharmony/vendor_hihope/tree/ma
| full | 100 | Full battery level|
4. Write the `BUILD.gn` file by referring to the `BUILD.gn` in the default folder of battery level configuration to pack the `battery_config.json` file to the `//vendor/etc/battery` directory. The configuration is as follows:
4. Write the `BUILD.gn` file by referring to the [BUILD.gn](https://gitee.com/openharmony/powermgr_battery_manager/blob/master/services/native/profile/BUILD.gn) file in the default folder of battery level configuration to pack the `battery_config.json` file to the `//vendor/etc/battery` directory. The configuration is as follows:
```shell
import("//build/ohos.gni") # Reference build/ohos.gni.
......@@ -292,6 +293,8 @@ The following uses [DAYU200](https://gitee.com/openharmony/vendor_hihope/tree/ma
## Reference
During development, you can refer to the [default battery level configuration](https://gitee.com/openharmony/powermgr_battery_manager/blob/master/services/native/profile/battery_config.json), as shown below:
```json
{
"soc": {
......@@ -306,4 +309,4 @@ During development, you can refer to the [default battery level configuration](h
}
```
Packing path: `/system/etc/battery`
Packing path: /system/etc/battery
......@@ -8,6 +8,7 @@ OpenHarmony provides the battery level and LED color mapping by default. Some pr
### Constraints
The configuration path for battery level customization is subject to the [configuration policy](https://gitee.com/openharmony/customization_config_policy). In this development guide, `/vendor` is used as an example of the configuration path. During actual development, you need to modify the customization path based on the product configuration policy.
## How to Develop
......@@ -36,7 +37,7 @@ The following uses [DAYU200](https://gitee.com/openharmony/vendor_hihope/tree/ma
├── battery_config.json
```
3. Write the custom `battery_config.json` file by referring to the `battery_config.json` file in the default folder of battery level and LED color mapping configuration. For example:
3. Write the custom `battery_config.json` file by referring to the [battery_config.json](https://gitee.com/openharmony/powermgr_battery_manager/blob/master/services/native/profile/battery_config.json) file in the default folder of battery level and LED color mapping configuration. For example:
```json
{
......@@ -57,18 +58,23 @@ The following uses [DAYU200](https://gitee.com/openharmony/vendor_hihope/tree/ma
}
```
**Table 1** Description of the battery level and LED color mapping configuration
**Table 1** Description of battery levels
| Item| Description|
| Battery Level| Description|
| -------- | -------- |
| low | Low battery level|
| normal | Normal battery level|
| high | High battery level|
**Table 2** Configuration items for the battery level range and LED color
| Configuration Item| Description|
| -------- | -------- |
| soc | Battery level range|
| rgb | LED RGB combination|
4. Write the `BUILD.gn` file by referring to the `BUILD.gn` in the default folder of battery level and LED color mapping configuration to pack the `battery_config.json` file to the `//vendor/etc/battery` directory. The configuration is as follows:
4. Write the `BUILD.gn` file by referring to the [BUILD.gn](https://gitee.com/openharmony/powermgr_battery_manager/blob/master/services/native/profile/BUILD.gn) file in the default folder of battery level and LED color mapping configuration to pack the `battery_config.json` file to the `//vendor/etc/battery` directory. The configuration is as follows:
```shell
import("//build/ohos.gni") # Reference build/ohos.gni.
......@@ -207,6 +213,8 @@ The following uses [DAYU200](https://gitee.com/openharmony/vendor_hihope/tree/ma
## Reference
During development, you can refer to the [default battery level and LED color mapping configuration](https://gitee.com/openharmony/powermgr_battery_manager/blob/master/services/native/profile/battery_config.json), as shown below:
```json
{
"light": {
......@@ -226,4 +234,4 @@ During development, you can refer to the [default battery level and LED color ma
}
```
Packing path: `/system/etc/battery`
Packing path: /system/etc/battery
......@@ -195,7 +195,7 @@
- OpenHarmony Third-Party Components
- [OpenHarmony Third-Party Components](third-party-components/third-party-components-introduction.md)
- [Using OpenHarmony JS and TS Third-Party Components](third-party-components/npm-third-party-guide.md)
- [Using OpenHarmony JS and TS Third-Party Components](third-party-components/ohpm-third-party-guide.md)
- Contribution
- [How to Contribute](contribute/how-to-contribute.md)
......
......@@ -33,7 +33,7 @@
## 通过跨设备启动UIAbility和ServiceExtensionAbility组件实现多端协同(无返回数据)
在设备A上通过发起端应用提供的启动按钮,启动设备B上指定的UIAbility。
在设备A上通过发起端应用提供的启动按钮,启动设备B上指定的UIAbility与ServiceExtensionAbility
### 接口说明
......@@ -43,6 +43,8 @@
| **接口名** | **描述** |
| -------- | -------- |
| startAbility(want:&nbsp;Want,&nbsp;callback:&nbsp;AsyncCallback&lt;void&gt;):&nbsp;void; | 启动UIAbility和ServiceExtensionAbility(callback形式)。 |
| stopServiceExtensionAbility(want:&nbsp;Want,&nbsp;callback:&nbsp;AsyncCallback&lt;void&gt;):&nbsp;void; | 退出启动的ServiceExtensionAbility(callback形式)。 |
| stopServiceExtensionAbility(want:&nbsp;Want):&nbsp;Promise&lt;void&gt;; | 退出启动的ServiceExtensionAbility(Promise形式)。 |
### 开发步骤
......@@ -98,6 +100,22 @@
})
```
5. 当设备A发起端应用不需要设备B上的ServiceExtensionAbility时,可调用stopServiceExtensionAbility(../reference/apis/js-apis-inner-application-uiAbilityContext.md#uiabilitycontextstopserviceextensionability)接口退出。(该接口不支持UIAbility的退出,UIAbility由用户手动通过任务管理退出)
```ts
let want = {
deviceId: getRemoteDeviceId(),
bundleName: 'com.example.myapplication',
abilityName: 'FuncAbility',
moduleName: 'module1', // moduleName非必选
}
// 退出由startAbility接口启动的ServiceExtensionAbility
this.context.stopServiceExtensionAbility(want).then(() => {
console.info("stop service extension ability success")
}).catch((err) => {
console.info("stop service extension ability err is " + JSON.stringify(err))
})
```
## 通过跨设备启动UIAbility组件实现多端协同(获取返回数据)
......
......@@ -128,7 +128,7 @@ OpenHarmony系统预置的播控中心,作为媒体会话控制方与音视频
// 注册服务异常监听
AVSessionManager.on('sessionServiceDie', () => {
// 服务端异常,应用清理资源
console.info('服务端异常');
console.info(`服务端异常`);
})
```
......@@ -153,16 +153,16 @@ OpenHarmony系统预置的播控中心,作为媒体会话控制方与音视频
// 注册会话激活状态变更监听
controller.on('activeStateChange', (isActive) => {
if (isActive) {
console.info('控制器卡片按键高亮');
console.info(`控制器卡片按键高亮`);
} else {
console.info('控制器卡片按键变更为无效');
console.info(`控制器卡片按键变更为无效`);
}
});
// 注册会话销毁监听
controller.on('sessionDestroy', () => {
console.info('on sessionDestroy : SUCCESS ');
info(`on sessionDestroy : SUCCESS `);
controller.destroy().then(() => {
console.info('destroy : SUCCESS ');
console.info(`destroy : SUCCESS`);
}).catch((err) => {
console.error(`Failed to destroy session. Code: ${err.code}, message: ${err.message}`);
});
......@@ -290,14 +290,14 @@ OpenHarmony系统预置的播控中心,作为媒体会话控制方与音视频
command : 'This is my custom command'
}
await controller.sendCommonCommand(commandName, args).then(() => {
console.info('SendCommonCommand successfully');
console.info(`SendCommonCommand successfully`);
}).catch((err) => {
console.error(`Failed to send common command. Code: ${err.code}, message: ${err.message}`);
})
// 设置指定播放列表单项的ID,供session选择播放
let queueItemId: number = 0;
await controller.skipToQueueItem(queueItemId).then(() => {
console.info('SkipToQueueItem successfully');
console.info(`SkipToQueueItem successfully`);
}).catch((err) => {
console.error(`Failed to skip to queue item. Code: ${err.code}, message: ${err.message}`);
});
......@@ -316,7 +316,7 @@ OpenHarmony系统预置的播控中心,作为媒体会话控制方与音视频
if (err) {
console.error(`Failed to destroy controller. Code: ${err.code}, message: ${err.message}`);
} else {
console.info('Destroy controller SUCCESS');
console.info(`Destroy controller SUCCESS`);
}
});
}
......
......@@ -74,7 +74,7 @@
artist: 'ARTIST'
};
session.setAVMetadata(metadata).then(() => {
console.info('SetAVMetadata successfully');
console.info(`SetAVMetadata successfully`);
}).catch((err) => {
console.error(`Failed to set AVMetadata. Code: ${err.code}, message: ${err.message}`);
});
......@@ -87,7 +87,7 @@
if (err) {
console.error(`Failed to set AVPlaybackState. Code: ${err.code}, message: ${err.message}`);
} else {
console.info('SetAVPlaybackState successfully');
console.info(`SetAVPlaybackState successfully`);
}
});
}
......@@ -132,7 +132,7 @@
lyric : 'This is my lyric'
}
await session.dispatchSessionEvent(eventName, args).then(() => {
console.info('Dispatch session event successfully');
console.info(`Dispatch session event successfully`);
}).catch((err) => {
console.error(`Failed to dispatch session event. Code: ${err.code}, message: ${err.message}`);
})
......@@ -150,7 +150,7 @@
extra : 'This is my custom meida packet'
}
await session.setExtras(extras).then(() => {
console.info('Set extras successfully');
console.info(`Set extras successfully`);
}).catch((err) => {
console.error(`Failed to set extras. Code: ${err.code}, message: ${err.message}`);
})
......@@ -175,23 +175,23 @@
// 一般在监听器中会对播放器做相应逻辑处理
// 不要忘记处理完后需要通过set接口同步播放相关信息,参考上面的用例
session.on('play', () => {
console.info('on play , do play task');
console.info(`on play , do play task`);
// do some tasks ···
});
session.on('pause', () => {
console.info('on pause , do pause task');
console.info(`on pause , do pause task`);
// do some tasks ···
});
session.on('stop', () => {
console.info('on stop , do stop task');
console.info(`on stop , do stop task`);
// do some tasks ···
});
session.on('playNext', () => {
console.info('on playNext , do playNext task');
console.info(`on playNext , do playNext task`);
// do some tasks ···
});
session.on('playPrevious', () => {
console.info('on playPrevious , do playPrevious task');
console.info(`on playPrevious , do playPrevious task`);
// do some tasks ···
});
session.on('fastForward', () => {
......@@ -312,7 +312,7 @@
if (err) {
console.error(`Failed to destroy session. Code: ${err.code}, message: ${err.message}`);
} else {
console.info('Destroy : SUCCESS ');
console.info(`Destroy : SUCCESS `);
}
});
}
......
......@@ -36,13 +36,13 @@
let audioDevices;
await audioRoutingManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG).then((data) => {
audioDevices = data;
console.info('Promise returned to indicate that the device list is obtained.');
console.info(`Promise returned to indicate that the device list is obtained.`);
}).catch((err) => {
console.error(`Failed to get devices. Code: ${err.code}, message: ${err.message}`);
});
AVSessionManager.castAudio('all', audioDevices).then(() => {
console.info('createController : SUCCESS');
console.info(`createController : SUCCESS`);
}).catch((err) => {
console.error(`Failed to cast audio. Code: ${err.code}, message: ${err.message}`);
});
......
......@@ -275,7 +275,7 @@ struct ReaderComp {
build() {
Row() {
Text(this.title)
Text(`... ${this.readIt ? 'I have read' : 'I have bot read it'}`)
Text(`... ${this.readIt ? 'I have read' : 'I have not read it'}`)
.onClick(() => this.readIt = true)
}
}
......
......@@ -295,7 +295,7 @@ OpenHarmony系统对无图标应用严格管控。如果HAP中没有配置入口
| [launchType](../application-models/uiability-launch-type.md) | 标识当前UIAbility组件的启动模式,可选标签值:<br/>-&nbsp;multiton:标准实例模式,每次启动创建一个新的实例。<br/>-&nbsp;singleton:单实例模式,仅第一次启动创建新实例。<br/>-&nbsp;specified:指定实例模式,运行时由开发者决定是否创建新实例。 | 字符串 | 可缺省,该标签缺省为“singleton”。 |
| description | 标识当前UIAbility组件的描述信息,标签值是字符串类型(最长255字节)或对描述内容的资源索引,要求采用资源索引方式,以支持多语言。 | 字符串 | 该标签可缺省,缺省值为空。 |
| icon | 标识当前UIAbility组件的图标,标签值为图标资源文件的索引。 | 字符串 | 该标签可缺省,缺省值为空。<br/>如果UIAbility被配置为MainElement,该标签必须配置。 |
| label | 标识当前UIAbility组件对用户显示的名称,标签值配置为该名称的资源索引以支持多语言。<br/>如果UIAbility被配置当前Module的mainElement时,该标签必须配置,且应用内唯一。 | 字符串 | 该标签不可缺省。 |
| label | 标识当前UIAbility组件对用户显示的名称,标签值配置为该名称的资源索引以支持多语言。 | 字符串 | 该标签可缺省,缺省值为空。<br/>如果UIAbility被配置为MainElement,该标签必须配置。 |
| permissions | 标识当前UIAbility组件自定义的权限信息。当其他应用访问该UIAbility时,需要申请相应的权限信息。<br/>一个数组元素为一个权限名称。通常采用反向域名格式(最大255字节),取值为系统预定义的权限。 | 字符串数组 | 该标签可缺省,缺省值为空。 |
| [metadata](#metadata标签) | 标识当前UIAbility组件的元信息。 | 对象数组 | 该标签可缺省,缺省值为空。 |
| exported | 标识当前UIAbility组件是否可以被其他应用调用。<br/>-&nbsp;true:表示可以被其他应用调用。<br/>-&nbsp;false:表示不可以被其他应用调用。 | 布尔值 | 该标签可缺省,缺省值为false。 |
......
......@@ -261,7 +261,7 @@ OpenHarmony系统对无图标应用严格管控。如果HAP中没有配置入口
| name | 标识Ability名称。取值可采用反向域名方式表示,由包名和类名组成,如"com.example.myapplication.EntryAbility";也可采用"."开头的类名方式表示,如".EntryAbility"。<br/>Ability的名称,需在一个应用的范围内保证唯一。说明:在使用DevEco&nbsp;Studio新建项目时,默认生成首个Ability的配置,即"config.json"中"EntryAbility"的配置。如使用其他IDE工具,可自定义名称。该标签最大长度为127个字节。 | 字符串 | 不可缺省 |
| description | 标识对Ability的描述。取值可以是描述性内容,也可以是对描述性内容的资源索引,以支持多语言。该标签最大长度为255个字节。 | 字符串 | 可缺省,缺省值为空。 |
| icon | 标识Ability图标资源文件的索引。取值示例:$media:ability_icon。如果在该Ability的skills属性中,actions的取值包含&nbsp;"action.system.home",entities取值中包含"entity.system.home",则该Ability的icon将同时作为应用的icon。如果存在多个符合条件的Ability,则取位置靠前的Ability的icon作为应用的icon。<br/>说明:应用的"icon"和"label"是用户可感知配置项,需要区别于当前所有已有的应用"icon"或"label"(至少有一个不同)。 | 字符串 | 可缺省,缺省值为空。 |
| label | 标识Ability对用户显示的名称。取值可以是Ability名称,也可以是对该名称的资源索引,以支持多语言。如果在该Ability的skills属性中,actions的取值包含&nbsp;"action.system.home",entities取值中包含"entity.system.home",则该Ability的label将同时作为应用的label。如果存在多个符合条件的Ability,则取位置靠前的Ability的label作为应用的label。<br/>说明:&nbsp;应用的"icon"和"label"是用户可感知配置项,需要区别于当前所有已有的应用"icon"或"label"(至少有一个不同)。该标签为资源文件中定义的字符串的引用,或以"{}"包括的字符串。该标签最大长度为255个字节。 | 字符串 | 可缺省,缺省值为空。 |
| label | 标识Ability对用户显示的名称。取值是对该名称的资源索引,支持多语言,例:$string:ability_label。如果在该Ability的skills属性中,actions的取值包含&nbsp;"action.system.home",entities取值中包含"entity.system.home",则该Ability的label将同时作为应用的label。如果存在多个符合条件的Ability,则取位置靠前的Ability的label作为应用的label。<br/>说明:&nbsp;应用的"icon"和"label"是用户可感知配置项,需要区别于当前所有已有的应用"icon"或"label"(至少有一个不同)。该标签为资源文件中定义的字符串的引用,或以"{}"包括的字符串。该标签最大长度为255个字节。 | 字符串 | 可缺省,缺省值为空。 |
| uri | 标识Ability的统一资源标识符。该标签最大长度为255个字节。 | 字符串 | 可缺省,对于data类型的Ability不可缺省。 |
| launchType | 标识Ability的启动模式,支持"standard"和"singleton"两种模式:<br/>standard:表示该Ability可以有多实例。该模式适用于大多数应用场景。<br/>singleton:表示该Ability在所有任务栈中仅可以有一个实例。例如,具有全局唯一性的呼叫来电界面即采用"singleton"模式。该标签仅适用于默认设备、平板、智慧屏、车机、智能穿戴。 | 字符串 | 可缺省,缺省值为"singleton"。 |
| visible | 标识Ability是否可以被其他应用调用。<br/>true:可以被其他应用调用。<br/>false:不能被其他应用调用。 | 布尔类型 | 可缺省,缺省值为"false"。 |
......
......@@ -314,8 +314,6 @@
- [Timer (定时器)](js-apis-timer.md)
- application
- [AccessibilityExtensionContext (辅助功能扩展上下文)](js-apis-inner-application-accessibilityExtensionContext.md)
- imf
- [InputMethodCommon](js-apis-inputmethod-InputMethodCommon.md)
- 设备管理
- [@ohos.batteryInfo (电量信息)](js-apis-battery-info.md)
......@@ -356,8 +354,9 @@
- 定制管理
- [@ohos.configPolicy (配置策略)](js-apis-configPolicy.md)
- [@ohos.enterprise.accountManager (帐户管理)](js-apis-enterprise-accountManager.md)
- [@ohos.enterprise.bundleManager (包管理)](js-apis-enterprise-bundleManager.md)
- [@ohos.enterprise.adminManager (企业设备管理)](js-apis-enterprise-adminManager.md)
- [@ohos.enterprise.applicationManager (应用管理)](js-apis-enterprise-applicationManager.md)
- [@ohos.enterprise.bundleManager (包管理)](js-apis-enterprise-bundleManager.md)
- [@ohos.enterprise.dateTimeManager (系统时间管理)](js-apis-enterprise-dateTimeManager.md)
- [@ohos.enterprise.deviceControl (设备控制管理)](js-apis-enterprise-deviceControl.md)
- [@ohos.enterprise.deviceInfo (设备信息管理)](js-apis-enterprise-deviceInfo.md)
......
......@@ -145,6 +145,29 @@ Extension生命周期回调,如果是connectAbility拉起的服务,会在onC
}
```
如果生成返回值RemoteObject依赖一个异步接口,可以使用异步生命周期:
```ts
import rpc from '@ohos.rpc';
class StubTest extends rpc.RemoteObject{
constructor(des) {
super(des);
}
onConnect(code, data, reply, option) {
}
}
async function getDescriptor() {
// 调用异步函数...
return "asyncTest"
}
class ServiceExt extends ServiceExtension {
async onConnect(want) {
console.log(`onConnect , want: ${want.abilityName}`);
let descriptor = await getDescriptor();
return new StubTest(descriptor);
}
}
```
## ServiceExtensionAbility.onDisconnect
......@@ -172,6 +195,17 @@ Extension的生命周期回调,客户端执行断开连接服务时回调。
}
```
在执行完onDisconnect生命周期回调后,应用可能会退出,从而可能导致onDisconnect中的异步函数未能正确执行,比如异步写入数据库。可以使用异步生命周期,以确保异步onDisconnect完成后再继续后续的生命周期。
```ts
class ServiceExt extends ServiceExtension {
async onDisconnect(want) {
console.log('onDisconnect, want: ${want.abilityName}');
// 调用异步函数...
}
}
```
## ServiceExtensionAbility.onReconnect
onReconnect(want: Want): void;
......
......@@ -132,6 +132,7 @@ UIAbility生命周期回调,在销毁时回调,执行资源清理等操作
**示例:**
```ts
class MyUIAbility extends UIAbility {
onDestroy() {
......@@ -140,6 +141,16 @@ UIAbility生命周期回调,在销毁时回调,执行资源清理等操作
}
```
在执行完onDestroy生命周期回调后,应用可能会退出,从而可能导致onDestroy中的异步函数未能正确执行,比如异步写入数据库。可以使用异步生命周期,以确保异步onDestroy完成后再继续后续的生命周期。
```ts
class MyUIAbility extends UIAbility {
async onDestroy() {
console.log('onDestroy');
// 调用异步函数...
}
}
```
## UIAbility.onForeground
......
# @ohos.enterprise.applicationManager(应用管理)
本模块提供应用管理能力,包括添加应用运行黑名单、获取应用运行黑名单、移除应用运行黑名单等。仅企业设备管理员应用才能调用。
> **说明:**
>
> 本模块首批接口从API version 10开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块
```js
import applicationManager from '@ohos.enterprise.applicationManager';
```
## applicationManager.addDisallowedRunningBundles
addDisallowedRunningBundles(admin: Want, appIds: Array\<string>, callback: AsyncCallback&lt;void&gt;): void;
指定设备管理员应用添加应用运行黑名单接口,使用callback形式返回是否添加成功。添加至黑名单的应用不允许在管理员用户下运行,否则允许运行。
**需要权限:** ohos.permission.ENTERPRISE_MANAGE_SET_APP_RUNNING_POLICY
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
**系统API**: 此接口为系统接口。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------- | ---- | ------------------------------- |
| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 |
| appIds | Array&lt;string&gt; | 是 | 应用运行的黑名单。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。当接口调用成功,err为null,否则为错误对象。 |
**错误码**
以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md)
| 错误码ID | 错误信息 |
| ------- | ---------------------------------------------------------------------------- |
| 9200001 | the application is not an administrator of the device. |
| 9200002 | the administrator application does not have permission to manage the device. |
**示例:**
```js
let wantTemp = {
bundleName: "com.example.myapplication",
abilityName: "EntryAbility",
};
let appIds = {"com.example.myapplication"};
applicationManager.addDisallowedRunningBundles(wantTemp, appIds, (error) => {
if (error != null) {
console.log("error code:" + error.code + " error message:" + error.message);
}
});
```
## applicationManager.addDisallowedRunningBundles
addDisallowedRunningBundles(admin: Want, appIds: Array\<string>, userId: number, callback: AsyncCallback&lt;void&gt;): void;
指定设备管理员应用添加应用运行黑名单接口,使用callback形式返回是否添加成功。添加至黑名单的应用不允许在指定用户(通过userId指定)下运行,否则允许运行。
**需要权限:** ohos.permission.ENTERPRISE_MANAGE_SET_APP_RUNNING_POLICY
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
**系统API**: 此接口为系统接口。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ----- | ----------------------------------- | ---- | ------- |
| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 |
| appIds | Array&lt;string&gt; | 是 | 应用运行的黑名单。 |
| userId | number | 是 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数,当接口调用成功,err为null,否则为错误对象。 |
**错误码**
以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md)
| 错误码ID | 错误信息 |
| ------- | ---------------------------------------------------------------------------- |
| 9200001 | the application is not an administrator of the device. |
| 9200002 | the administrator application does not have permission to manage the device. |
**示例:**
```js
let wantTemp = {
bundleName: "com.example.myapplication",
abilityName: "EntryAbility",
};
let appIds = {"com.example.myapplication"};
applicationManager.addDisallowedRunningBundles(wantTemp, appIds, 100, (error) => {
if (error != null) {
console.log("error code:" + error.code + " error message:" + error.message);
}
});
```
## applicationManager.addDisallowedRunningBundles
addDisallowedRunningBundles(admin: Want, appIds: Array\<string>, userId?: number): Promise&lt;void&gt;;
指定设备管理员应用添加应用运行黑名单接口,使用promise形式返回是否添加成功。如果调用接口时传入了可选参数userId,则添加至黑名单的应用不允许在指定用户下运行,如果调用接口时没有传入参数userId,则添加至黑名单的应用不允许在当前用户下运行。
**需要权限:** ohos.permission.ENTERPRISE_MANAGE_SET_APP_RUNNING_POLICY
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
**系统API**: 此接口为系统接口。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ----- | ----------------------------------- | ---- | ------- |
| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 |
| appIds | Array&lt;string&gt; | 是 | 应用运行的黑名单。 |
| userId | number | 否 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 |
**返回值:**
| 类型 | 说明 |
| --------------------- | ------------------------- |
| Promise&lt;void&gt; | 无返回结果的Promise对象。当指定设备管理员应用添加应用运行黑名单失败时会抛出错误对象。 |
**错误码**
以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md)
| 错误码ID | 错误信息 |
| ------- | ---------------------------------------------------------------------------- |
| 9200001 | the application is not an administrator of the device. |
| 9200002 | the administrator application does not have permission to manage the device. |
**示例:**
```js
let wantTemp = {
bundleName: "com.example.myapplication",
abilityName: "EntryAbility",
};
let appIds = {"com.example.myapplication"};
applicationManager.addDisallowedRunningBundles(wantTemp, appIds, 100).then(() => {
console.log("success");
}).catch(error => {
console.log("error code:" + error.code + " error message:" + error.message);
});
```
## applicationManager.removeDisallowedRunningBundles
removeDisallowedRunningBundles(admin: Want, appIds: Array\<string>, callback: AsyncCallback&lt;void&gt;): void;
指定设备管理员应用移除应用运行黑名单接口,使用callback形式返回移除结果。在黑名单存在的情况下,在应用运行黑名单中的应用不允许在当前用户下运行。
**需要权限:** ohos.permission.ENTERPRISE_MANAGE_SET_APP_RUNNING_POLICY
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
**系统API**: 此接口为系统接口。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------- | ---- | ------------------------------- |
| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 |
| appIds | Array&lt;string&gt; | 是 | 应用运行的黑名单。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。当接口调用成功,err为null,否则为错误对象。 |
**错误码**
以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md)
| 错误码ID | 错误信息 |
| ------- | ---------------------------------------------------------------------------- |
| 9200001 | the application is not an administrator of the device. |
| 9200002 | the administrator application does not have permission to manage the device. |
**示例:**
```js
let wantTemp = {
bundleName: "com.example.myapplication",
abilityName: "EntryAbility",
};
let appIds = {"com.example.myapplication"};
applicationManager.removeDisallowedRunningBundles(wantTemp, appIds, (error) => {
if (error != null) {
console.log("error code:" + error.code + " error message:" + error.message);
}
});
```
## applicationManager.removeDisallowedRunningBundles
removeDisallowedRunningBundles(admin: Want, appIds: Array\<string>, userId: number, callback: AsyncCallback&lt;void&gt;): void;
指定设备管理员应用移除应用运行黑名单接口,使用callback形式返回移除结果。在黑名单存在的情况下,在应用运行黑名单中的应用不允许在指定用户(通过userId指定)下运行。
**需要权限:** ohos.permission.ENTERPRISE_MANAGE_SET_APP_RUNNING_POLICY
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
**系统API**: 此接口为系统接口。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ----- | ----------------------------------- | ---- | ------- |
| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 |
| appIds | Array&lt;string&gt; | 是 | 应用运行的黑名单。 |
| userId | number | 是 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。当接口调用成功,err为null,否则为错误对象。 |
**错误码**
以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md)
| 错误码ID | 错误信息 |
| ------- | ---------------------------------------------------------------------------- |
| 9200001 | the application is not an administrator of the device. |
| 9200002 | the administrator application does not have permission to manage the device. |
**示例:**
```js
let wantTemp = {
bundleName: "com.example.myapplication",
abilityName: "EntryAbility",
};
let appIds = {"com.example.myapplication"};
applicationManager.removeDisallowedRunningBundles(wantTemp, appIds, 100, (error) => {
if (error != null) {
console.log("error code:" + error.code + " error message:" + error.message);
}
});
```
## applicationManager.removeDisallowedRunningBundles
removeDisallowedRunningBundles(admin: Want, appIds: Array\<string>, userId?: number): Promise&lt;void&gt;;
指定设备管理员应用移除应用运行黑名单接口,使用promise形式返回移除结果。在黑名单存在的情况下,如果调用接口时传入参数userId,则在应用运行黑名单中的应用不允许在指定用户下运行,如果调用接口时没有传入参数userId,则在应用运行黑名单中的应用不允许在当前用户下运行。
**需要权限:** ohos.permission.ENTERPRISE_MANAGE_SET_APP_RUNNING_POLICY
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
**系统API**: 此接口为系统接口。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ----- | ----------------------------------- | ---- | ------- |
| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 |
| appIds | Array&lt;string&gt; | 是 | 应用运行的黑名单。 |
| userId | number | 否 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 |
**返回值:**
| 类型 | 说明 |
| --------------------- | ------------------------- |
| Promise&lt;void&gt; | 无返回结果的Promise对象。当指定设备管理员应用移除应用运行黑名单失败时会抛出错误对象。 |
**错误码**
以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md)
| 错误码ID | 错误信息 |
| ------- | ---------------------------------------------------------------------------- |
| 9200001 | the application is not an administrator of the device. |
| 9200002 | the administrator application does not have permission to manage the device. |
**示例:**
```js
let wantTemp = {
bundleName: "com.example.myapplication",
abilityName: "EntryAbility",
};
let appIds = {"com.example.myapplication"};
applicationManager.removeDisallowedRunningBundles(wantTemp, appIds, 100).then(() => {
console.log("success");
}).catch(error => {
console.log("error code:" + error.code + " error message:" + error.message);
});
```
## applicationManager.getDisallowedRunningBundles
getDisallowedRunningBundles(admin: Want, callback: AsyncCallback&lt;Array&lt;string&gt;&gt;): void;
指定管理员应用获取管理员用户下的应用运行黑名单接口,使用callback形式返回获取应用运行黑名单。
**需要权限:** ohos.permission.ENTERPRISE_MANAGE_SET_APP_RUNNING_POLICY
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
**系统API**: 此接口为系统接口。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------- | ---- | ------------------------------- |
| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 |
| callback | AsyncCallback&lt;Array&lt;string&gt;&gt; | 是 | 回调函数,当接口调用成功,err为null,否则为错误对象。 |
**错误码**
以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md)
| 错误码ID | 错误信息 |
| ------- | ---------------------------------------------------------------------------- |
| 9200001 | the application is not an administrator of the device. |
| 9200002 | the administrator application does not have permission to manage the device. |
**示例:**
```js
let wantTemp = {
bundleName: "com.example.myapplication",
abilityName: "EntryAbility",
};
applicationManager.getDisallowedRunningBundles(wantTemp, (error) => {
if (error != null) {
console.log("error code:" + error.code + " error message:" + error.message);
}
});
```
## applicationManager.getDisallowedRunningBundles
getDisallowedRunningBundles(admin: Want, userId: number, callback: AsyncCallback&lt;Array&lt;string&gt;&gt;): void;
指定管理员应用获取指定用户(通过userId指定)下的应用运行黑名单接口,使用callback形式返回获取应用运行黑名单。
**需要权限:** ohos.permission.ENTERPRISE_MANAGE_SET_APP_RUNNING_POLICY
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
**系统API**: 此接口为系统接口。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------- | ---- | ------------------------------- |
| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 |
| userId | number | 是 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 |
| callback | AsyncCallback&lt;Array&lt;string&gt;&gt; | 是 | 回调函数,当接口调用成功,err为null,否则为错误对象。 |
**错误码**
以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md)
| 错误码ID | 错误信息 |
| ------- | ---------------------------------------------------------------------------- |
| 9200001 | the application is not an administrator of the device. |
| 9200002 | the administrator application does not have permission to manage the device. |
**示例:**
```js
let wantTemp = {
bundleName: "com.example.myapplication",
abilityName: "EntryAbility",
};
applicationManager.getDisallowedRunningBundles(wantTemp, 100, (error) => {
if (error != null) {
console.log("error code:" + error.code + " error message:" + error.message);
}
});
```
## applicationManager.getDisallowedRunningBundles
getDisallowedRunningBundles(admin: Want, userId?: number): Promise&lt;Array&lt;string&gt;&gt;;
如果调用接口时传入参数userId,指定管理员应用获取指定用户下应用运行黑名单接口,如果调用接口时没有传入参数userId,指定管理员应用获取当前用户下应用运行黑名单接口,使用promise形式返回获取应用运行黑名单。
**需要权限:** ohos.permission.ENTERPRISE_MANAGE_SET_APP_RUNNING_POLICY
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
**系统API**: 此接口为系统接口。
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ----- | ----------------------------------- | ---- | ------- |
| admin | [Want](js-apis-app-ability-want.md) | 是 | 设备管理员应用。 |
| userId | number | 否 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 |
**返回值:**
| 类型 | 说明 |
| --------------------- | ------------------------- |
| Promise&lt;Array&lt;string&gt;&gt; | Promise对象,返回管理员用户下的应用运行黑名单。 |
**错误码**
以下的错误码的详细介绍请参见[企业设备管理错误码](../errorcodes/errorcode-enterpriseDeviceManager.md)
| 错误码ID | 错误信息 |
| ------- | ---------------------------------------------------------------------------- |
| 9200001 | the application is not an administrator of the device. |
| 9200002 | the administrator application does not have permission to manage the device. |
**示例:**
```js
let wantTemp = {
bundleName: "com.example.myapplication",
abilityName: "EntryAbility",
};
applicationManager.getDisallowedRunningBundles(wantTemp, 100).then(() => {
console.log("success");
}).catch(error => {
console.log("error code:" + error.code + " error message:" + error.message);
});
```
......@@ -447,6 +447,93 @@ copyFileSync(src: string|number, dest: string|number, mode?: number): void
fs.copyFileSync(srcPath, dstPath);
```
## fs.copyDir<sup>10+</sup>
copyDir(src: string, dest: string, mode?: number): Promise\<void>
复制源文件夹至目标路径下,使用Promise异步回调。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | --------------------------- |
| src | string | 是 | 源文件夹的应用沙箱路径。 |
| dest | string | 是 | 目标文件夹的应用沙箱路径。 |
| mode | number | 否 | 复制模式。默认mode为0。<br/>-&nbsp; mode为0,文件级别抛异常。目标文件夹下存在与源文件夹名冲突的文件夹,若冲突文件夹下存在同名文件,则抛出异常。源文件夹下未冲突的文件全部移动至目标文件夹下,目标文件夹下未冲突文件将继续保留,且冲突文件信息将在抛出异常的data属性中以Array\<[ConflictFiles](#conflictfiles)>形式提供。<br/>-&nbsp; mode为1,文件级别强制覆盖。目标文件夹下存在与源文件夹名冲突的文件夹,若冲突文件夹下存在同名文件,则强制覆盖冲突文件夹下所有同名文件,未冲突文件将继续保留。|
**返回值:**
| 类型 | 说明 |
| ------------------- | ---------------------------- |
| Promise&lt;void&gt; | Promise对象。无返回值。 |
**错误码:**
接口抛出错误码的详细介绍请参见[基础文件IO错误码](../errorcodes/errorcode-filemanagement.md#基础文件io错误码)
**示例:**
```js
// copy directory from srcPath to destPath
let srcPath = pathDir + "/srcDir/";
let destPath = pathDir + "/destDir/";
fs.copyDir(srcPath, destPath, 0).then(() => {
console.info("copy directory succeed");
}).catch((err) => {
if (err.code == 13900015) {
for (let i = 0; i < err.data.length; i++) {
console.info("copy directory failed with conflicting files: " + err.data[i].srcFile +
" " + err.data[i].destFile);
}
} else {
console.info("copy directory failed with error message: " + err.message + ", error code: " + err.code);
}
});
```
## fs.copyDir<sup>10+</sup>
copyDir(src: string, dest: string, mode?: number, callback: AsyncCallback\<void>): void
复制源文件夹至目标路径下,使用Callback异步回调。
**系统能力**:SystemCapability.FileManagement.File.FileIO
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | --------------------------- |
| src | string | 是 | 源文件夹的应用沙箱路径。 |
| dest | string | 是 | 目标文件夹的应用沙箱路径。 |
| mode | number | 否 | 复制模式。默认mode为0。<br/>-&nbsp; mode为0,文件级别抛异常。目标文件夹下存在与源文件夹名冲突的文件夹,若冲突文件夹下存在同名文件,则抛出异常。源文件夹下未冲突的文件全部移动至目标文件夹下,目标文件夹下未冲突文件将继续保留,且冲突文件信息将在抛出异常的data属性中以Array\<[ConflictFiles](#conflictfiles)>形式提供。<br/>-&nbsp; mode为1,文件级别强制覆盖。目标文件夹下存在与源文件夹名冲突的文件夹,若冲突文件夹下存在同名文件,则强制覆盖冲突文件夹下所有同名文件,未冲突文件将继续保留。|
| callback | AsyncCallback&lt;void&gt; | 是 | 异步复制文件夹之后的回调。 |
**错误码:**
接口抛出错误码的详细介绍请参见[基础文件IO错误码](../errorcodes/errorcode-filemanagement.md#基础文件io错误码)
**示例:**
```js
// copy directory from srcPath to destPath
let srcPath = pathDir + "/srcDir/";
let destPath = pathDir + "/destDir/";
fs.copyDir(srcPath, destPath, 0, (err) => {
if (err && err.code == 13900015) {
for (let i = 0; i < err.data.length; i++) {
console.info("copy directory failed with conflicting files: " + err.data[i].srcFile +
" " + err.data[i].destFile);
}
} else if (err) {
console.info("copy directory failed with error message: " + err.message + ", error code: " + err.code);
} else {
console.info("copy directory succeed");
}
});
```
## fs.mkdir
mkdir(path: string): Promise&lt;void&gt;
......@@ -1924,8 +2011,8 @@ moveDir(src: string, dest: string, mode?: number): Promise\<void>
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | --------------------------- |
| src | string | 是 | 源文件夹的应用沙箱路径。 |
| dest | string | 是 | 目标应用沙箱路径。 |
| mode | number | 否 | 移动模式。默认mode为0。<br/>-&nbsp;mode为0,文件夹级别抛异常。若目标路径存在与源文件夹名冲突的文件夹,则抛出异常。<br/>-&nbsp;mode为1,文件级别抛异常。目标路径存在与源文件夹名冲突的文件夹,若此目标文件夹下存在与源文件夹下同名文件,则抛出异常。源文件夹下未冲突的文件全部移动至此目标文件夹下,此目标文件夹下未冲突文件将继续保留,且冲突文件信息将在抛出异常的data属性中提供。<br/>-&nbsp; mode为2,文件级别强制覆盖。目标路径存在与源文件夹名冲突的文件夹,若此目标文件夹下存在与源文件夹下同名文件,则强制覆盖此目标文件夹下所有同名文件。目标文件夹下未冲突文件将继续保留。<br/>-&nbsp; mode为3,文件夹级别强制覆盖。移动源文件夹至目标路径下,目标文件夹与源文件夹内容完全一致。目标文件夹下所有原始文件将不会保留。|
| dest | string | 是 | 目标文件夹的应用沙箱路径。 |
| mode | number | 否 | 移动模式。默认mode为0。<br/>-&nbsp;mode为0,文件夹级别抛异常。若目标文件夹下存在与源文件夹名冲突的文件夹,则抛出异常。<br/>-&nbsp;mode为1,文件级别抛异常。目标文件夹下存在与源文件夹名冲突的文件夹,若冲突文件夹下存在同名文件,则抛出异常。源文件夹下未冲突的文件全部移动至目标文件夹下,目标文件夹下未冲突文件将继续保留,且冲突文件信息将在抛出异常的data属性中以Array\<[ConflictFiles](#conflictfiles)>形式提供。<br/>-&nbsp; mode为2,文件级别强制覆盖。目标文件夹下存在与源文件夹名冲突的文件夹,若冲突文件夹下存在同名文件,则强制覆盖冲突文件夹下所有同名文件,未冲突文件将继续保留。<br/>-&nbsp; mode为3,文件夹级别强制覆盖。移动源文件夹至目标文件夹下,目标文件夹下移动的文件夹内容与源文件夹完全一致。若目标文件夹下存在与源文件夹名冲突的文件夹,该文件夹下所有原始文件将不会保留。|
**返回值:**
......@@ -1940,7 +2027,7 @@ moveDir(src: string, dest: string, mode?: number): Promise\<void>
**示例:**
```js
// move directory from srcPath to destPath/srcPath
// move directory from srcPath to destPath
let srcPath = pathDir + "/srcDir/";
let destPath = pathDir + "/destDir/";
fs.moveDir(srcPath, destPath, 1).then(() => {
......@@ -1970,8 +2057,8 @@ moveDir(src: string, dest: string, mode?: number, callback: AsyncCallback\<void>
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | --------------------------- |
| src | string | 是 | 源文件夹的应用沙箱路径。 |
| dest | string | 是 | 目标应用沙箱路径。 |
| mode | number | 否 | 移动模式。默认mode为0。<br/>-&nbsp;mode为0,文件夹级别抛异常。若目标路径存在与源文件夹名冲突的文件夹,则抛出异常。<br/>-&nbsp;mode为1,文件级别抛异常。目标路径存在与源文件夹名冲突的文件夹,若此目标文件夹下存在与源文件夹下同名文件,则抛出异常。源文件夹下未冲突的文件全部移动至此目标文件夹下,此目标文件夹下未冲突文件将继续保留,且冲突文件信息将在抛出异常的data属性中提供。<br/>-&nbsp; mode为2,文件级别强制覆盖。目标路径存在与源文件夹名冲突的文件夹,若此目标文件夹下存在与源文件夹下同名文件,则强制覆盖此目标文件夹下所有同名文件。目标文件夹下未冲突文件将继续保留。<br/>-&nbsp; mode为3,文件夹级别强制覆盖。移动源文件夹至目标路径下,目标文件夹与源文件夹内容完全一致。目标文件夹下所有原始文件将不会保留。|
| dest | string | 是 | 目标文件夹的应用沙箱路径。 |
| mode | number | 否 | 移动模式。默认mode为0。<br/>-&nbsp;mode为0,文件夹级别抛异常。若目标文件夹下存在与源文件夹名冲突的文件夹,则抛出异常。<br/>-&nbsp;mode为1,文件级别抛异常。目标文件夹下存在与源文件夹名冲突的文件夹,若冲突文件夹下存在同名文件,则抛出异常。源文件夹下未冲突的文件全部移动至目标文件夹下,目标文件夹下未冲突文件将继续保留,且冲突文件信息将在抛出异常的data属性中以Array\<[ConflictFiles](#conflictfiles)>形式提供。<br/>-&nbsp; mode为2,文件级别强制覆盖。目标文件夹下存在与源文件夹名冲突的文件夹,若冲突文件夹下存在同名文件,则强制覆盖冲突文件夹下所有同名文件,未冲突文件将继续保留。<br/>-&nbsp; mode为3,文件夹级别强制覆盖。移动源文件夹至目标文件夹下,目标文件夹下移动的文件夹内容与源文件夹完全一致。若目标文件夹下存在与源文件夹名冲突的文件夹,该文件夹下所有原始文件将不会保留。|
| callback | AsyncCallback&lt;void&gt; | 是 | 异步移动文件夹之后的回调。 |
**错误码:**
......@@ -1981,7 +2068,7 @@ moveDir(src: string, dest: string, mode?: number, callback: AsyncCallback\<void>
**示例:**
```js
// move directory from srcPath to destPath/srcPath
// move directory from srcPath to destPath
let srcPath = pathDir + "/srcDir/";
let destPath = pathDir + "/destDir/";
fs.moveDir(srcPath, destPath, 1, (err) => {
......@@ -3266,3 +3353,14 @@ open接口flags参数常量。文件打开标签。
| fileSizeOver | number | 文件大小匹配,大于等于指定大小的文件。 |
| lastModifiedAfter | number | 文件最近修改时间匹配,在指定时间点及之后的文件。 |
| excludeMedia | boolean | 是否排除Media中已有的文件。 |
## ConflictFiles
**系统能力**:SystemCapability.FileManagement.File.FileIO
冲突文件信息,支持copyDir及moveDir接口使用。
| 名称 | 类型 | 说明 |
| ----------- | --------------- | ------------------ |
| srcFile | string | 源冲突文件路径。 |
| destFile | string | 目标冲突文件路径。 |
......@@ -814,7 +814,7 @@ httpRequest.off('dataProgress');
| extraData | string<sup>6+</sup> \| Object<sup>6+</sup> \| ArrayBuffer<sup>8+</sup> | 否 | 发送请求的额外数据,默认无此字段。<br />- 当HTTP请求为POST、PUT等方法时,此字段为HTTP请求的content,以UTF-8编码形式作为请求体。<sup>6+</sup><br />- 当HTTP请求为GET、OPTIONS、DELETE、TRACE、CONNECT等方法时,此字段为HTTP请求参数的补充。开发者需传入Encode编码后的string类型参数,Object类型的参数无需预编码,参数内容会拼接到URL中进行发送;ArrayBuffer类型的参数不会做拼接处理。<sup>6+</sup> |
| expectDataType<sup>9+</sup> | [HttpDataType](#httpdatatype9) | 否 | 指定返回数据的类型,默认无此字段。如果设置了此参数,系统将优先返回指定的类型。 |
| usingCache<sup>9+</sup> | boolean | 否 | 是否使用缓存,默认为true。 |
| priority<sup>9+</sup> | number | 否 | 优先级,范围\[0,1000],默认是0。 |
| priority<sup>9+</sup> | number | 否 | 优先级,范围[1,1000],默认是1。 |
| header | Object | 否 | HTTP请求头字段。默认{'Content-Type': 'application/json'}。 |
| readTimeout | number | 否 | 读取超时时间。单位为毫秒(ms),默认为60000ms。<br />设置为0表示不会出现超时情况。 |
| connectTimeout | number | 否 | 连接超时时间。单位为毫秒(ms),默认为60000ms。 |
......
# InputMethodCommon
> **说明:**
> 本模块首批接口从API version 10 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
输入法框架接口定义的公共属性信息。
## Direction
光标移动方向类型枚举。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
| 名称 | 值 | 说明 |
| ------------ | ---- | ---------- |
| CURSOR_UP | 1 | 光标上移。 |
| CURSOR_DOWN | 2 | 光标下移。 |
| CURSOR_LEFT | 3 | 光标左移。 |
| CURSOR_RIGHT | 4 | 光标右移。 |
## Range
描述选中文本的范围。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
| 名称 | 类型 | 可读 | 可写 | 说明 |
| ----- | ------ | ---- | ---- | ---------------------------------- |
| start | number | 是 | 是 | 选中文本的首字符在编辑框的索引值。 |
| end | number | 是 | 是 | 选中文本的末字符在编辑框的索引值。 |
## Movement
描述进行选中文本动作时光标移动的方向。
**系统能力:** SystemCapability.MiscServices.InputMethodFramework
| 名称 | 类型 | 可读 | 可写 | 说明 |
| --------- | ----------------------- | ---- | ---- | ---------------------------------- |
| direction | [Direction](#direction) | 是 | 是 | 进行选中文本动作时光标移动的方向。 |
......@@ -38,9 +38,9 @@ Extension生命周期回调,在拉起Extension输入法应用时调用,执
```js
class InputMethodExt extends InputMethodExtensionAbility {
onCreate(want) {
console.log('onCreate, want:' + want.abilityName);
}
onCreate(want) {
console.log('onCreate, want:' + want.abilityName);
}
}
```
......@@ -56,8 +56,8 @@ Extension生命周期回调,在销毁输入法应用时回调,执行资源
```js
class InputMethodExt extends InputMethodExtensionAbility {
onDestroy() {
console.log('onDestroy');
}
onDestroy() {
console.log('onDestroy');
}
}
```
......@@ -21,9 +21,9 @@ import InputMethodExtensionContext from '@ohos.InputMethodExtensionContext';
```js
import InputMethodExtensionAbility from '@ohos.InputMethodExtensionAbility';
class EntryAbility extends InputMethodExtensionAbility {
onCreate() {
let context = this.context;
}
onCreate() {
let context = this.context;
}
}
```
......@@ -44,8 +44,8 @@ destroy(callback: AsyncCallback\<void>): void
**示例:**
```js
this.context.destroy((err) => {
console.log('destroy result:' + JSON.stringify(err));
this.context.destroy(() => {
console.log('Succeeded in destroying context.');
});
```
......@@ -67,8 +67,6 @@ destroy(): Promise\<void>;
```js
this.context.destroy().then(() => {
console.log('Succeed in destoring context.');
}).catch((error) => {
console.log('Failed to destory context: ' + JSON.stringify(error));
console.log('Succeed in destroying context.');
});
```
......@@ -121,7 +121,7 @@ install(hapFilePaths: Array&lt;string&gt;, installParam: InstallParam, callback:
| 17700036 | Failed to install the HSP because lacks appropriate permissions. |
| 17700039 | Failed to install because disallow install a shared bundle by hapFilePaths. |
| 17700041 | Failed to install because enterprise device management disallow install. |
| 17700044 | Failed to install because the isolationMode does not match the system. |
| 17700044 | Failed to install the HAP because the isolationMode configured is not supported. |
**示例:**
......@@ -185,7 +185,7 @@ install(hapFilePaths: Array&lt;string&gt;, callback: AsyncCallback&lt;void&gt;):
| 17700036 | Failed to install the HSP because lacks appropriate permissions. |
| 17700039 | Failed to install because disallow install a shared bundle by hapFilePaths. |
| 17700041 | Failed to install because enterprise device management disallow install. |
| 17700044 | Failed to install because the isolationMode does not match the system. |
| 17700044 | Failed to install the HAP because the isolationMode configured is not supported. |
**示例:**
......@@ -253,7 +253,7 @@ install(hapFilePaths: Array\<string\>, installParam?: InstallParam) : Promise\<v
| 17700036 | Failed to install the HSP because lacks appropriate permissions. |
| 17700039 | Failed to install because disallow install a shared bundle by hapFilePaths. |
| 17700041 | Failed to install because enterprise device management disallow install. |
| 17700044 | Failed to install because the isolationMode does not match the system. |
| 17700044 | Failed to install the HAP because the isolationMode configured is not supported. |
**示例:**
......
......@@ -15,7 +15,7 @@ import connection from '@ohos.net.connection'
createNetConnection(netSpecifier?: NetSpecifier, timeout?: number): NetConnection
返回一个NetConnection对象,netSpecifier指定关注的网络的各项特征,timeout是超时时间(单位是毫秒),netSpecifier是timeout的必要条件,两者都没有则表示关注默认网络。
返回一个NetConnection对象,netSpecifier指定关注的网络的各项特征;timeout是超时时间(单位是毫秒);netSpecifier是timeout的必要条件,两者都没有则表示关注默认网络。
**系统能力**:SystemCapability.Communication.NetManager.Core
......@@ -23,8 +23,8 @@ createNetConnection(netSpecifier?: NetSpecifier, timeout?: number): NetConnectio
| 参数名 | 类型 | 必填 | 说明 |
| ------------ | ----------------------------- | ---- | ------------------------------------------------------------ |
| netSpecifier | [NetSpecifier](#netspecifier) | 否 | 指定网络的各项特征,不指定关注默认网络。 |
| timeout | number | 否 | 获取netSpecifier指定的网络时的超时时间,仅netSpecifier存在时生效。 |
| netSpecifier | [NetSpecifier](#netspecifier) | 否 | 指定网络的各项特征,不指定或为undefined时关注默认网络。 |
| timeout | number | 否 | 获取netSpecifier指定的网络时的超时时间,仅netSpecifier存在时生效,undefined时默认值为0。 |
**返回值:**
......@@ -1840,7 +1840,7 @@ connection.getDefaultNet().then(function (netHandle) {
| ------ | ------ | --- |------------------------- |
| host | string | 否 | 代理服务器主机名。 |
| port | number | 否 | 主机端口。 |
| exclusionList | Array<string> | 否 | 不使用代理服务器的屏蔽列表。 |
| exclusionList | Array<string> | 否 | 不使用代理服务器的屏蔽列表,列表内元素拼接后长度不可超过96字节。<br>例如:“baidu.com,zhihu.com”为20字节。 |
## NetSpecifier
......
......@@ -1613,7 +1613,7 @@ resume(callback: AsyncCallback&lt;void&gt;): void
| enableMetered | boolean | 否 | 设置是否允许在按流量计费的连接下下载(默认使用false)。<br/>-&nbsp;true:是<br/>-&nbsp;false:否 |
| enableRoaming | boolean | 否 | 设置是否允许在漫游网络中下载(默认使用false)。 <br/>-&nbsp;true:是<br/>-&nbsp;false:否|
| description | string | 否 | 设置下载会话的描述。 |
| filePath<sup>7+</sup> | string | 否 | 设置下载路径。<br/>-&nbsp;filePath:'/data/storage/el2/base/haps/entry/files/test.txt':将文件存储在绝对路径下。<br/>-&nbsp;FA模型下使用[context](js-apis-inner-app-context.md#contextgetcachedir) 获取应用存储路径,比如:\`${featureAbility.getContext().getFilesDir()}/test.txt\`,并将文件存储在此路径下。<br/>-&nbsp;Stage模型下使用[AbilityContext](js-apis-inner-application-context.md) 类获取文件路径,比如:\`${globalThis.abilityContext.tempDir}/test.txt\`,并将文件存储在此路径下。|
| filePath<sup>7+</sup> | string | 否 | 设置下载路径。<br/>-&nbsp;FA模型下使用[context](js-apis-inner-app-context.md#contextgetcachedir) 获取应用存储路径,比如:\`${featureAbility.getContext().getFilesDir()}/test.txt\`,并将文件存储在此路径下。<br/>-&nbsp;Stage模型下使用[AbilityContext](js-apis-inner-application-context.md) 类获取文件路径,比如:\`${globalThis.abilityContext.tempDir}/test.txt\`,并将文件存储在此路径下。|
| networkType | number | 否 | 设置允许下载的网络类型(默认使用NETWORK_MOBILE&NETWORK_WIFI)。<br/>-&nbsp;NETWORK_MOBILE:0x00000001<br/>-&nbsp;NETWORK_WIFI:0x00010000|
| title | string | 否 | 设置下载任务名称。 |
| background<sup>9+</sup> | boolean | 否 | 后台任务通知开关,开启后可在通知中显示下载状态(默认使用false)。 |
......
......@@ -1570,9 +1570,9 @@ FA卡片的使用信息的属性集合。
| 名称 | 类型 | 必填 | 说明 |
| --------------------- | ------ | ---- | ---------------------------------------- |
| bundleName | string | | 应用包名。 |
| eventId | number | | 应用事件类型。 |
| eventOccurredTime | number | | 应用事件发生的时间戳。 |
| bundleName | string | | 应用包名。 |
| eventId | number | | 应用事件类型。 |
| eventOccurredTime | number | | 应用事件发生的时间戳。 |
| appGroup | number | 否 | 应用程序的使用优先级组。|
| indexOfLink | string | 否 | 快捷方式id。|
| nameOfClass | string | 否 | 类名。|
......
......@@ -19,7 +19,7 @@ import taskpool from '@ohos.taskpool';
## Priority
表示所创建任务(Task)的优先级。(暂未支持)
表示所创建任务(Task)的优先级。
**系统能力:** SystemCapability.Utils.Lang
......@@ -29,6 +29,45 @@ import taskpool from '@ohos.taskpool';
| MEDIUM | 1 | 任务为中优先级。 |
| LOW | 2 | 任务为低优先级。 |
**示例:**
```ts
function func(args) {
"use concurrent";
console.log("func: " + args);
return args;
}
async function taskpoolTest() {
let task = new taskpool.Task(func, 100);
let highCount = 0;
let mediumCount = 0;
let lowCount = 0;
let allCount = 100;
for (let i = 0; i < allCount; i++) {
taskpool.execute(task, taskpool.Priority.LOW).then((res: number) => {
lowCount++;
console.log("taskpool lowCount is :" + lowCount);
}).catch((e) => {
console.error("low task error: " + e);
})
taskpool.execute(task, taskpool.Priority.MEDIUM).then((res: number) => {
mediumCount++;
console.log("taskpool mediumCount is :" + mediumCount);
}).catch((e) => {
console.error("medium task error: " + e);
})
taskpool.execute(task, taskpool.Priority.HIGH).then((res: number) => {
highCount++;
console.log("taskpool highCount is :" + highCount);
}).catch((e) => {
console.error("high task error: " + e);
})
}
}
taskpoolTest();
```
## Task
表示任务。使用以下方法前,需要先构造Task。
......@@ -46,7 +85,7 @@ Task的构造函数。
| 参数名 | 类型 | 必填 | 说明 |
| ------ | --------- | ---- | -------------------------------------------------------------------- |
| func | Function | 是 | 任务执行需要传入函数,支持的函数返回值类型请查[序列化支持类型](#序列化支持类型)。 |
| args | unknown[] | 否 | 任务执行传入函数的参数,支持的参数类型请查[序列化支持类型](#序列化支持类型)。 |
| args | unknown[] | 否 | 任务执行传入函数的参数,支持的参数类型请查[序列化支持类型](#序列化支持类型)默认值为undefined。 |
**错误码:**
......@@ -81,7 +120,7 @@ let task = new taskpool.Task(func, "this is my first Task");
execute(func: Function, ...args: unknown[]): Promise\<unknown>
任务池执行任务,需要传入待执行的函数和函数所需的参数,此执行模式不可取消任务。
将待执行的函数放入taskpool内部任务队列等待,等待分发到工作线程执行。当前执行模式不可取消任务。
**系统能力:** SystemCapability.Utils.Lang
......@@ -90,7 +129,7 @@ execute(func: Function, ...args: unknown[]): Promise\<unknown>
| 参数名 | 类型 | 必填 | 说明 |
| ------ | --------- | ---- | ---------------------------------------------------------------------- |
| func | Function | 是 | 执行的逻辑需要传入函数,支持的函数返回值类型请查[序列化支持类型](#序列化支持类型)。 |
| args | unknown[] | 否 | 执行逻辑的函数所需要的参数,支持的参数类型请查[序列化支持类型](#序列化支持类型)。 |
| args | unknown[] | 否 | 执行逻辑的函数所需要的参数,支持的参数类型请查[序列化支持类型](#序列化支持类型)默认值为undefined。 |
**返回值:**
......@@ -129,16 +168,16 @@ taskpoolTest();
execute(task: Task, priority?: Priority): Promise\<unknown>
任务池执行任务,需要传入已创建的任务,此执行模式可取消任务
将创建好的任务放入taskpool内部任务队列等待,等待分发到工作线程执行。当前执行模式可尝试调用cancel进行任务取消
**系统能力:** SystemCapability.Utils.Lang
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------- | ---- | ------------------------------------ |
| task | [Task](#task) | 是 | 需要在任务池中执行的任务。 |
| priority | [Priority](#priority) | 否 | 等待执行的任务的优先级(暂未支持)。 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------- | ---- | ---------------------------------------- |
| task | [Task](#task) | 是 | 需要在任务池中执行的任务。 |
| priority | [Priority](#priority) | 否 | 等待执行的任务的优先级,该参数默认值为MEDIUM |
**返回值:**
......@@ -197,18 +236,18 @@ cancel(task: Task): void
| 10200015 | If the task is not exist. |
| 10200016 | If the task is running. |
**示例:**
**任务取消成功示例:**
```ts
@Concurrent
function func(args) {
"use concurrent";
console.log("func: " + args);
return args;
}
async function taskpoolTest() {
let task = new taskpool.Task(func, 100);
let value = await taskpool.execute(task);
taskpool.execute(task);
try {
taskpool.cancel(task);
} catch (e) {
......@@ -219,6 +258,66 @@ async function taskpoolTest() {
taskpoolTest();
```
**已执行的任务取消失败示例:**
```ts
function func(args) {
"use concurrent";
console.log("func: " + args);
return args;
}
async function taskpoolTest() {
let task = new taskpool.Task(func, 100);
let value = taskpool.execute(task);
let start = new Date().getTime();
while (new Date().getTime() - start < 1000) { // 延时1s,确保任务已执行
continue;
}
try {
taskpool.cancel(task); //任务已执行,取消失败
} catch (e) {
console.log("taskpool.cancel occur error:" + e);
}
}
taskpoolTest();
```
**正在执行的任务取消失败示例:**
```ts
function func(args) {
"use concurrent";
console.log("func: " + args);
return args;
}
async function taskpoolTest() {
let task1 = new taskpool.Task(func, 100);
let task2 = new taskpool.Task(func, 200);
let task3 = new taskpool.Task(func, 300);
let task4 = new taskpool.Task(func, 400);
let task5 = new taskpool.Task(func, 500);
let task6 = new taskpool.Task(func, 600);
let res1 = taskpool.execute(task1);
let res2 = taskpool.execute(task2);
let res3 = taskpool.execute(task3);
let res4 = taskpool.execute(task4);
let res5 = taskpool.execute(task5);
let res6 = taskpool.execute(task6);
try {
taskpool.cancel(task1); // task1任务正在执行,取消失败
} catch (e) {
console.log("taskpool.cancel occur error:" + e);
}
}
taskpoolTest();
```
## 其他说明
### 序列化支持类型
......
......@@ -2701,7 +2701,7 @@ try {
### off('avoidAreaChange')<sup>9+</sup>
off(type: 'avoidAreaChange', callback: Callback&lt;{AvoidAreaType, AvoidArea}&gt;): void
off(type: 'avoidAreaChange', callback?: Callback&lt;{AvoidAreaType, AvoidArea}&gt;): void
关闭系统规避区变化的监听。
......@@ -3471,7 +3471,7 @@ let colorSpace = windowClass.getWindowColorSpace();
setWindowBackgroundColor(color: string): void
设置窗口的背景色。Stage模型下,该接口需要在[loadContent](#loadcontent9)后使用。
设置窗口的背景色。Stage模型下,该接口需要在[loadContent()](#loadcontent9)[setUIContent()](#setuicontent9)调用生效后使用。
**系统能力:** SystemCapability.WindowManager.WindowManager.Core
......@@ -6024,7 +6024,7 @@ promise.then((data)=> {
setBackgroundColor(color: string, callback: AsyncCallback&lt;void&gt;): void
设置窗口的背景色,使用callback异步回调。Stage模型下,该接口需要在[loadContent](#loadcontent9)[setUIContent()](#setuicontent9)后使用。
设置窗口的背景色,使用callback异步回调。Stage模型下,该接口需要在[loadContent()](#loadcontent9)[setUIContent()](#setuicontent9)调用生效后使用。
> **说明:**
>
......@@ -6056,7 +6056,7 @@ windowClass.setBackgroundColor(color, (err) => {
setBackgroundColor(color: string): Promise&lt;void&gt;
设置窗口的背景色,使用Promise异步回调。Stage模型下,该接口需要在[loadContent](#loadcontent9)[setUIContent()](#setuicontent9)后使用。
设置窗口的背景色,使用Promise异步回调。Stage模型下,该接口需要在[loadContent()](#loadcontent9)[setUIContent()](#setuicontent9)调用生效后使用。
> **说明:**
>
......
......@@ -14,118 +14,118 @@
## 属性
| 名称 | 类型 | 必填 | 描述 |
| -------- | -------- | -------- | -------- |
| type | string | 否 | 设置图表类型(不支持动态修改),可选项有:<br/>-&nbsp;bar:柱状图。<br/>-&nbsp;line:线形图。<br>默认值:line |
| options | ChartOptions | 是 | 图表参数设置,柱状图和线形图必须设置参数设置。可以设置x轴、y轴的最小值、最大值、刻度数、是否显示,线条宽度、是否平滑等。(不支持动态修改) |
| datasets | Array&lt;ChartDataset&gt; | 是 | 数据集合,柱状图和线形图必须设置数据集合。可以设置多条数据集及其背景色。 |
| id | string | 否 | 组件的唯一标识。 |
| style | string | 否 | 组件的样式声明。 |
| class | string | 否 | 组件的样式类,用于引用样式表。 |
| ref | string | 否 | 用来指定指向子元素的引用信息,该引用将注册到父组件的$refs&nbsp;属性对象上。 |
| 名称 | 类型 | 必填 | 描述 |
| -------- | ------------------------- | ---- | ---------------------------------------- |
| type | string | 否 | 设置图表类型(不支持动态修改),可选项有:<br/>-&nbsp;bar:柱状图。<br/>-&nbsp;line:线形图。<br>默认值:line |
| options | ChartOptions | 是 | 图表参数设置,柱状图和线形图必须设置参数设置。可以设置x轴、y轴的最小值、最大值、刻度数、是否显示,线条宽度、是否平滑等。(不支持动态修改) |
| datasets | Array&lt;ChartDataset&gt; | 是 | 数据集合,柱状图和线形图必须设置数据集合。可以设置多条数据集及其背景色。 |
| id | string | 否 | 组件的唯一标识。 |
| style | string | 否 | 组件的样式声明。 |
| class | string | 否 | 组件的样式类,用于引用样式表。 |
| ref | string | 否 | 用来指定指向子元素的引用信息,该引用将注册到父组件的$refs&nbsp;属性对象上。 |
**表2** ChartOptions
**表1** ChartOptions
| 名称 | 类型 | 必填 | 描述 |
| -------- | -------- | -------- | -------- |
| xAxis | ChartAxis | 是 | x轴参数设置。可以设置x轴最小值、最大值、刻度数以及是否显示。 |
| yAxis | ChartAxis | 是 | y轴参数设置。可以设置y轴最小值、最大值、刻度数以及是否显示。 |
| series | ChartSeries | 否 | 数据序列参数设置。可以设置:<br>1. 线的样式,如线宽、是否平滑;<br>2. 设置线最前端位置白点的样式和大小。<br/>**说明:**<br>仅线形图支持。 |
| 名称 | 类型 | 必填 | 描述 |
| ------ | ----------- | ---- | ---------------------------------------- |
| xAxis | ChartAxis | 是 | x轴参数设置。可以设置x轴最小值、最大值、刻度数以及是否显示。 |
| yAxis | ChartAxis | 是 | y轴参数设置。可以设置y轴最小值、最大值、刻度数以及是否显示。 |
| series | ChartSeries | 否 | 数据序列参数设置。可以设置:<br>1. 线的样式,如线宽、是否平滑;<br>2. 设置线最前端位置白点的样式和大小。<br/>**说明:**<br>仅线形图支持。 |
**表3** ChartDataset
**表2** ChartDataset
| 名称 | 类型 | 默认值 | 必填 | 描述 |
| -------- | -------- | -------- | -------- | -------- |
| backgroundColor(deprecated) | &lt;color&gt; | \#ff6384 | 否 | 设置线或柱的颜色(不推荐使用)。 |
| strokeColor | &lt;color&gt; | \#ff6384 | 否 | 线条颜色。仅线形图支持。 |
| fillColor | &lt;color&gt; | \#ff6384 | 否 | 填充颜色。线形图表示填充的渐变颜色。 |
| data | Array&lt;number&gt; | - | 是 | 设置绘制线或柱中的点集。 |
| gradient | boolean | false | 否 | 设置是否显示填充渐变颜色。仅线形图支持。 |
| 名称 | 类型 | 默认值 | 必填 | 描述 |
| --------------------------- | ------------------- | -------- | ---- | -------------------- |
| backgroundColor(deprecated) | &lt;color&gt; | \#ff6384 | 否 | 设置线或柱的颜色(不推荐使用)。 |
| strokeColor | &lt;color&gt; | \#ff6384 | 否 | 线条颜色。仅线形图支持。 |
| fillColor | &lt;color&gt; | \#ff6384 | 否 | 填充颜色。线形图表示填充的渐变颜色。 |
| data | Array&lt;number&gt; | - | 是 | 设置绘制线或柱中的点集。 |
| gradient | boolean | false | 否 | 设置是否显示填充渐变颜色。仅线形图支持。 |
**表4** ChartAxis
**表3** ChartAxis
| 名称 | 类型 | 默认值 | 必填 | 描述 |
| -------- | -------- | -------- | -------- | -------- |
| min | number | 0 | 否 | 轴的最小值。<br/>不支持负数。仅线形图支持。 |
| max | number | 100 | 否 | 轴的最大值。<br/>不支持负数。仅线形图支持。 |
| axisTick | number | 10 | 否 | 轴显示的刻度数量。<br/>**说明:**<br/>仅支持1~20,且具体显示的效果与如下计算值有关(图的宽度所占的像素/(max-min))。<br/>因轻量级智能穿戴为整型运行,在除不尽的情况下会有误差产生,具体的表现形式是x轴末尾可能会空出一段。<br/>在柱状图中,每组数据显示的柱子数量与刻度数量一致,且柱子显示在刻度处。 |
| display | boolean | false | 否 | 是否显示轴。 |
| color | &lt;color&gt; | \#c0c0c0 | 否 | 轴颜色。 |
| 名称 | 类型 | 默认值 | 必填 | 描述 |
| -------- | ------------- | -------- | ---- | ---------------------------------------- |
| min | number | 0 | 否 | 轴的最小值。<br/>不支持负数。仅线形图支持。 |
| max | number | 100 | 否 | 轴的最大值。<br/>不支持负数。仅线形图支持。 |
| axisTick | number | 10 | 否 | 轴显示的刻度数量。<br/>**说明:**<br/>仅支持1~20,且具体显示的效果与如下计算值有关(图的宽度所占的像素/(max-min))。<br/>因轻量级智能穿戴为整型运行,在除不尽的情况下会有误差产生,具体的表现形式是x轴末尾可能会空出一段。<br/>在柱状图中,每组数据显示的柱子数量与刻度数量一致,且柱子显示在刻度处。 |
| display | boolean | false | 否 | 是否显示轴。 |
| color | &lt;color&gt; | \#c0c0c0 | 否 | 轴颜色。 |
**表5** ChartSeries
**表4** ChartSeries
| 名称 | 类型 | 必填 | 描述 |
| -------- | -------- | -------- | -------- |
| lineStyle | ChartLineStyle | 否 | 线样式设置,如线宽、是否平滑。 |
| headPoint | PointStyle | 否 | 线最前端位置白点的样式和大小。 |
| topPoint | PointStyle | 否 | 最高点的样式和大小。 |
| bottomPoint | PointStyle | 否 | 最低点的样式和大小。 |
| loop | ChartLoop | 否 | 设置屏幕显示满时,是否需要重头开始绘制。 |
| 名称 | 类型 | 必填 | 描述 |
| ----------- | -------------- | ---- | -------------------- |
| lineStyle | ChartLineStyle | 否 | 线样式设置,如线宽、是否平滑。 |
| headPoint | PointStyle | 否 | 线最前端位置白点的样式和大小。 |
| topPoint | PointStyle | 否 | 最高点的样式和大小。 |
| bottomPoint | PointStyle | 否 | 最低点的样式和大小。 |
| loop | ChartLoop | 否 | 设置屏幕显示满时,是否需要重头开始绘制。 |
**表6** ChartLineStyle
**表5** ChartLineStyle
| 名称 | 类型 | 默认值 | 必填 | 描述 |
| -------- | -------- | -------- | -------- | -------- |
| width | &lt;length&gt; | 1px | 否 | 线宽设置。 |
| smooth | boolean | false | 否 | 是否平滑。 |
| 名称 | 类型 | 默认值 | 必填 | 描述 |
| ------ | -------------- | ----- | ---- | ----- |
| width | &lt;length&gt; | 1px | 否 | 线宽设置。 |
| smooth | boolean | false | 否 | 是否平滑。 |
**表7** PointStyle
**表6** PointStyle
| 名称 | 类型 | 默认值 | 必填 | 描述 |
| -------- | -------- | -------- | -------- | -------- |
| shape | string | circle | 否 | 高亮点的形状。可选值为:<br/>-&nbsp;circle:圆形。 |
| size | &lt;length&gt; | 5px | 否 | 高亮点的大小。 |
| strokeWidth | &lt;length&gt; | 1px | 否 | 边框宽度 |
| strokeColor | &lt;color&gt; | \#ff0000 | 否 | 边框颜色。 |
| fillColor | &lt;color&gt; | \#ff0000 | 否 | 填充颜色。 |
| display | boolean | true | 否 | 是否高亮显示。 |
| 名称 | 类型 | 默认值 | 必填 | 描述 |
| ----------- | -------------- | -------- | ---- | ---------------------------------- |
| shape | string | circle | 否 | 高亮点的形状。可选值为:<br/>-&nbsp;circle:圆形。 |
| size | &lt;length&gt; | 5px | 否 | 高亮点的大小。 |
| strokeWidth | &lt;length&gt; | 1px | 否 | 边框宽度 |
| strokeColor | &lt;color&gt; | \#ff0000 | 否 | 边框颜色。 |
| fillColor | &lt;color&gt; | \#ff0000 | 否 | 填充颜色。 |
| display | boolean | true | 否 | 是否高亮显示。 |
**表8** ChartLoop
**表7** ChartLoop
| 名称 | 类型 | 默认值 | 必填 | 描述 |
| -------- | -------- | -------- | -------- | -------- |
| margin | &lt;length&gt; | 1 | 否 | 擦除点的个数(最新绘制的点与最老的点之间的横向距离)。注意:轻量设备margin和topPoint/bottomPoint/headPoint同时使用时,有概率出现point正好位于擦除区域的情况,导致point不可见,因此不建议同时使用。 |
| 名称 | 类型 | 默认值 | 必填 | 描述 |
| ------ | -------------- | ---- | ---- | ---------------------------------------- |
| margin | &lt;length&gt; | 1 | 否 | 擦除点的个数(最新绘制的点与最老的点之间的横向距离)。注意:轻量设备margin和topPoint/bottomPoint/headPoint同时使用时,有概率出现point正好位于擦除区域的情况,导致point不可见,因此不建议同时使用。 |
## 方法
| 方法 | 参数 | 描述 |
| -------- | -------- | -------- |
| 方法 | 参数 | 描述 |
| ------ | ---------------------------------------- | ---------------------------------------- |
| append | {<br/>serial:&nbsp;number,&nbsp;//&nbsp;设置要更新的线形图数据下标<br/>data:&nbsp;Array&lt;number&gt;,&nbsp;//&nbsp;设置新增的数据<br/>} | 往已有的数据序列中动态添加数据,根据serial指定目标序列,serial为datasets数组的下标,从0开始。注意:不会更新datasets[index].data。仅线形图支持,按横坐标加1递增(与xAxis&nbsp;min/max设置相关)。 |
## 事件
| 名称 | 参数 | 描述 |
| -------- | -------- | -------- |
| click | - | 点击动作触发该事件。 |
| longpress | - | 长按动作触发该事件。 |
| 名称 | 参数 | 描述 |
| ------------------ | --------------------------------- | ----------- |
| click | - | 点击动作触发该事件。 |
| longpress | - | 长按动作触发该事件。 |
| swipe<sup>5+</sup> | [SwipeEvent](js-common-events.md) | 组件上快速滑动后触发。 |
## 样式
| 名称 | 类型 | 默认值 | 必填 | 描述 |
| -------- | -------- | -------- | -------- | -------- |
| width | &lt;length&gt;&nbsp;\|&nbsp;&lt;percentage&gt;<sup>5+</sup> | - | 否 | 设置组件自身的宽度。<br/><br/>未设置时组件宽度默认为0。 |
| height | &lt;length&gt;&nbsp;\|&nbsp;&lt;percentage&gt;<sup>5+</sup> | - | 否 | 设置组件自身的高度。<br/><br/>未设置时组件高度默认为0。 |
| padding | &lt;length&gt; | 0 | 否 | 使用简写属性设置所有的内边距属性。<br/>&nbsp;&nbsp;该属性可以有1到4个值:<br/>-&nbsp;指定一个值时,该值指定四个边的内边距。<br/>-&nbsp;指定两个值时,第一个值指定上下两边的内边距,第二个指定左右两边的内边距。<br/>-&nbsp;指定三个值时,第一个指定上边的内边距,第二个指定左右两边的内边距,第三个指定下边的内边距。<br/>-&nbsp;指定四个值时分别为上、右、下、左边的内边距(顺时针顺序)。 |
| padding-[left\|top\|right\|bottom] | &lt;length&gt; | 0 | 否 | 设置左、上、右、下内边距属性。 |
| margin | &lt;length&gt;&nbsp;\|&nbsp;&lt;percentage&gt;<sup>5+</sup> | 0 | 否 | 使用简写属性设置所有的外边距属性,该属性可以有1到4个值。<br/>-&nbsp;只有一个值时,这个值会被指定给全部的四个边。<br/>-&nbsp;两个值时,第一个值被匹配给上和下,第二个值被匹配给左和右。<br/>-&nbsp;三个值时,第一个值被匹配给上,&nbsp;第二个值被匹配给左和右,第三个值被匹配给下。<br/>-&nbsp;四个值时,会依次按上、右、下、左的顺序匹配&nbsp;(即顺时针顺序)。 |
| margin-[left\|top\|right\|bottom] | &lt;length&gt;&nbsp;\|&nbsp;&lt;percentage&gt;<sup>5+</sup> | 0 | 否 | 设置左、上、右、下外边距属性。 |
| border-width | &lt;length&gt; | 0 | 否 | 使用简写属性设置元素的所有边框宽度。 |
| border-color | &lt;color&gt; | black | 否 | 使用简写属性设置元素的所有边框颜色。 |
| border-radius | &lt;length&gt; | - | 否 | border-radius属性是设置元素的外边框圆角半径。 |
| background-color | &lt;color&gt; | - | 否 | 设置背景颜色。 |
| display | string | flex | 否 | 确定一个元素所产生的框的类型,可选值为:<br/>-&nbsp;flex:弹性布局。<br/>-&nbsp;none:不渲染此元素。 |
| [left\|top] | &lt;length&gt;&nbsp;\|&nbsp;&lt;percentage&gt;<sup>6+</sup> | - | 否 | left\|top确定元素的偏移位置。<br/>-&nbsp;left属性规定元素的左边缘。该属性定义了定位元素左外边距边界与其包含块左边界之间的偏移。<br/>-&nbsp;top属性规定元素的顶部边缘。该属性定义了一个定位元素的上外边距边界与其包含块上边界之间的偏移。 |
| 名称 | 类型 | 默认值 | 必填 | 描述 |
| ---------------------------------- | ---------------------------------------- | ----- | ---- | ---------------------------------------- |
| width | &lt;length&gt;&nbsp;\|&nbsp;&lt;percentage&gt;<sup>5+</sup> | - | 否 | 设置组件自身的宽度。<br/><br/>未设置时组件宽度默认为0。 |
| height | &lt;length&gt;&nbsp;\|&nbsp;&lt;percentage&gt;<sup>5+</sup> | - | 否 | 设置组件自身的高度。<br/><br/>未设置时组件高度默认为0。 |
| padding | &lt;length&gt; | 0 | 否 | 使用简写属性设置所有的内边距属性。<br/>&nbsp;&nbsp;该属性可以有1到4个值:<br/>-&nbsp;指定一个值时,该值指定四个边的内边距。<br/>-&nbsp;指定两个值时,第一个值指定上下两边的内边距,第二个指定左右两边的内边距。<br/>-&nbsp;指定三个值时,第一个指定上边的内边距,第二个指定左右两边的内边距,第三个指定下边的内边距。<br/>-&nbsp;指定四个值时分别为上、右、下、左边的内边距(顺时针顺序)。 |
| padding-[left\|top\|right\|bottom] | &lt;length&gt; | 0 | 否 | 设置左、上、右、下内边距属性。 |
| margin | &lt;length&gt;&nbsp;\|&nbsp;&lt;percentage&gt;<sup>5+</sup> | 0 | 否 | 使用简写属性设置所有的外边距属性,该属性可以有1到4个值。<br/>-&nbsp;只有一个值时,这个值会被指定给全部的四个边。<br/>-&nbsp;两个值时,第一个值被匹配给上和下,第二个值被匹配给左和右。<br/>-&nbsp;三个值时,第一个值被匹配给上,&nbsp;第二个值被匹配给左和右,第三个值被匹配给下。<br/>-&nbsp;四个值时,会依次按上、右、下、左的顺序匹配&nbsp;(即顺时针顺序)。 |
| margin-[left\|top\|right\|bottom] | &lt;length&gt;&nbsp;\|&nbsp;&lt;percentage&gt;<sup>5+</sup> | 0 | 否 | 设置左、上、右、下外边距属性。 |
| border-width | &lt;length&gt; | 0 | 否 | 使用简写属性设置元素的所有边框宽度。 |
| border-color | &lt;color&gt; | black | 否 | 使用简写属性设置元素的所有边框颜色。 |
| border-radius | &lt;length&gt; | - | 否 | border-radius属性是设置元素的外边框圆角半径。 |
| background-color | &lt;color&gt; | - | 否 | 设置背景颜色。 |
| display | string | flex | 否 | 确定一个元素所产生的框的类型,可选值为:<br/>-&nbsp;flex:弹性布局。<br/>-&nbsp;none:不渲染此元素。 |
| [left\|top] | &lt;length&gt;&nbsp;\|&nbsp;&lt;percentage&gt;<sup>6+</sup> | - | 否 | left\|top确定元素的偏移位置。<br/>-&nbsp;left属性规定元素的左边缘。该属性定义了定位元素左外边距边界与其包含块左边界之间的偏移。<br/>-&nbsp;top属性规定元素的顶部边缘。该属性定义了一个定位元素的上外边距边界与其包含块上边界之间的偏移。 |
## 示例
1. 线形图
```html
<!-- xxx.hml -->
<div class="container">
......@@ -134,7 +134,7 @@
</div>
```
```css
/* xxx.css */
.container {
......@@ -155,7 +155,7 @@
}
```
```js
// xxx.js
export default {
......@@ -211,7 +211,7 @@
![lite_line](figures/lite_line.PNG)
2. 柱状图
```html
<!-- xxx.hml -->
<div class="container">
......@@ -219,7 +219,7 @@
</div>
```
```css
/* xxx.css */
.container {
......@@ -236,7 +236,7 @@
}
```
```js
// xxx.js
export default {
......
......@@ -14,68 +14,68 @@
## 属性
| 名称 | 类型 | 默认值 | 必填 | 描述 |
| -------- | -------- | -------- | -------- | -------- |
| images | Array&lt;ImageFrame&gt; | - | 是 | 设置图片帧信息集合。每一帧的帧信息包含图片路径、图片大小和图片位置信息。目前支持以下图片格式:png、jpg和bmp。ImageFrame的详细说明请见表1。<br/>**说明:**<br/>使用时需要使用数据绑定的方式,如images&nbsp;=&nbsp;{{images}},js中声明相应变量:images:&nbsp;[{src:&nbsp;"/common/heart-rate01.png"},&nbsp;{src:&nbsp;"/common/heart-rate02.png"}]。 |
| iteration | number&nbsp;\|&nbsp;string | infinite | 否 | 设置帧动画播放次数。number表示固定次数,infinite枚举表示无限次数播放。 |
| reverse | boolean | false | 否 | 设置播放顺序。false表示从第1张图片播放到最后1张图片;&nbsp;true表示从最后1张图片播放到第1张图片。 |
| fixedsize | boolean | true | 否 | 设置图片大小是否固定为组件大小。&nbsp;true表示图片大小与组件大小一致,此时设置图片的width&nbsp;、height&nbsp;、top&nbsp;和left属性是无效的。false表示每一张图片的&nbsp;width&nbsp;、height&nbsp;、top和left属性都要单独设置。 |
| duration | string | - | 是 | 设置单次播放时长。单位支持[s(秒)\|ms(毫秒)],默认单位为ms。&nbsp;duration为0时,不播放图片。&nbsp;值改变只会在下一次循环开始时生效。 |
| fillmode<sup>5+</sup> | string | forwards | 否 | 指定帧动画执行结束后的状态。可选项有:<br/>-&nbsp;none:恢复初始状态。<br/>-&nbsp;forwards:保持帧动画结束时的状态(在最后一个关键帧中定义)。 |
| id | string | - | 否 | 组件的唯一标识。 |
| style | string | - | 否 | 组件的样式声明。 |
| class | string | - | 否 | 组件的样式类,用于引用样式表。 |
| ref | string | - | 否 | 用来指定指向子元素的引用信息,该引用将注册到父组件的$refs&nbsp;属性对象上。 |
**表2** ImageFrame说明
| 名称 | 类型 | 默认值 | 必填 | 描述 |
| -------- | -------- | -------- | -------- | -------- |
| src | &lt;uri&gt; | - | 是 | 图片路径。 |
| width | &lt;length&gt; | 0 | 否 | 图片宽度。 |
| height | &lt;length&gt; | 0 | 否 | 图片高度。 |
| top | &lt;length&gt; | 0 | 否 | 图片相对于组件左上角的纵向坐标。 |
| left | &lt;length&gt; | 0 | 否 | 图片相对于组件左上角的横向坐标。 |
| 名称 | 类型 | 默认值 | 必填 | 描述 |
| --------------------- | -------------------------- | -------- | ---- | ---------------------------------------- |
| images | Array&lt;ImageFrame&gt; | - | 是 | 设置图片帧信息集合。每一帧的帧信息包含图片路径、图片大小和图片位置信息。目前支持以下图片格式:png、jpg和bmp。ImageFrame的详细说明请见表1。<br/>**说明:**<br/>使用时需要使用数据绑定的方式,如images&nbsp;=&nbsp;{{images}},js中声明相应变量:images:&nbsp;[{src:&nbsp;"/common/heart-rate01.png"},&nbsp;{src:&nbsp;"/common/heart-rate02.png"}]。 |
| iteration | number&nbsp;\|&nbsp;string | infinite | 否 | 设置帧动画播放次数。number表示固定次数,infinite枚举表示无限次数播放。 |
| reverse | boolean | false | 否 | 设置播放顺序。false表示从第1张图片播放到最后1张图片;&nbsp;true表示从最后1张图片播放到第1张图片。 |
| fixedsize | boolean | true | 否 | 设置图片大小是否固定为组件大小。&nbsp;true表示图片大小与组件大小一致,此时设置图片的width&nbsp;、height&nbsp;、top&nbsp;和left属性是无效的。false表示每一张图片的&nbsp;width&nbsp;、height&nbsp;、top和left属性都要单独设置。 |
| duration | string | - | 是 | 设置单次播放时长。单位支持[s(秒)\|ms(毫秒)],默认单位为ms。&nbsp;duration为0时,不播放图片。&nbsp;值改变只会在下一次循环开始时生效。 |
| fillmode<sup>5+</sup> | string | forwards | 否 | 指定帧动画执行结束后的状态。可选项有:<br/>-&nbsp;none:恢复初始状态。<br/>-&nbsp;forwards:保持帧动画结束时的状态(在最后一个关键帧中定义)。 |
| id | string | - | 否 | 组件的唯一标识。 |
| style | string | - | 否 | 组件的样式声明。 |
| class | string | - | 否 | 组件的样式类,用于引用样式表。 |
| ref | string | - | 否 | 用来指定指向子元素的引用信息,该引用将注册到父组件的$refs&nbsp;属性对象上。 |
**表1** ImageFrame说明
| 名称 | 类型 | 默认值 | 必填 | 描述 |
| ------ | -------------- | ---- | ---- | ---------------- |
| src | &lt;uri&gt; | - | 是 | 图片路径。 |
| width | &lt;length&gt; | 0 | 否 | 图片宽度。 |
| height | &lt;length&gt; | 0 | 否 | 图片高度。 |
| top | &lt;length&gt; | 0 | 否 | 图片相对于组件左上角的纵向坐标。 |
| left | &lt;length&gt; | 0 | 否 | 图片相对于组件左上角的横向坐标。 |
## 事件
| 名称 | 参数 | 描述 |
| -------- | -------- | -------- |
| stop | - | 帧动画结束时触发。 |
| click | - | 点击动作触发该事件。 |
| longpress | - | 长按动作触发该事件。 |
| 名称 | 参数 | 描述 |
| ------------------ | --------------------------------- | ----------- |
| stop | - | 帧动画结束时触发。 |
| click | - | 点击动作触发该事件。 |
| longpress | - | 长按动作触发该事件。 |
| swipe<sup>5+</sup> | [SwipeEvent](js-common-events.md) | 组件上快速滑动后触发。 |
## 样式
| 名称 | 类型 | 默认值 | 必填 | 描述 |
| -------- | -------- | -------- | -------- | -------- |
| width | &lt;length&gt;&nbsp;\|&nbsp;&lt;percentage&gt;<sup>5+</sup> | - | 否 | 设置组件自身的宽度。<br/><br/>未设置时组件宽度默认为0。 |
| height | &lt;length&gt;&nbsp;\|&nbsp;&lt;percentage&gt;<sup>5+</sup> | - | 否 | 设置组件自身的高度。<br/><br/>未设置时组件高度默认为0。 |
| padding | &lt;length&gt; | 0 | 否 | 使用简写属性设置所有的内边距属性。<br/>&nbsp;&nbsp;该属性可以有1到4个值:<br/>-&nbsp;指定一个值时,该值指定四个边的内边距。<br/>-&nbsp;指定两个值时,第一个值指定上下两边的内边距,第二个指定左右两边的内边距。<br/>-&nbsp;指定三个值时,第一个指定上边的内边距,第二个指定左右两边的内边距,第三个指定下边的内边距。<br/>-&nbsp;指定四个值时分别为上、右、下、左边的内边距(顺时针顺序)。 |
| padding-[left\|top\|right\|bottom] | &lt;length&gt; | 0 | 否 | 设置左、上、右、下内边距属性。 |
| margin | &lt;length&gt;&nbsp;\|&nbsp;&lt;percentage&gt;<sup>5+</sup> | 0 | 否 | 使用简写属性设置所有的外边距属性,该属性可以有1到4个值。<br/>-&nbsp;只有一个值时,这个值会被指定给全部的四个边。<br/>-&nbsp;两个值时,第一个值被匹配给上和下,第二个值被匹配给左和右。<br/>-&nbsp;三个值时,第一个值被匹配给上,&nbsp;第二个值被匹配给左和右,第三个值被匹配给下。<br/>-&nbsp;四个值时,会依次按上、右、下、左的顺序匹配&nbsp;(即顺时针顺序)。 |
| margin-[left\|top\|right\|bottom] | &lt;length&gt;&nbsp;\|&nbsp;&lt;percentage&gt;<sup>5+</sup> | 0 | 否 | 设置左、上、右、下外边距属性。 |
| border-width | &lt;length&gt; | 0 | 否 | 使用简写属性设置元素的所有边框宽度。 |
| border-color | &lt;color&gt; | black | 否 | 使用简写属性设置元素的所有边框颜色。 |
| border-radius | &lt;length&gt; | - | 否 | border-radius属性是设置元素的外边框圆角半径。 |
| background-color | &lt;color&gt; | - | 否 | 设置背景颜色。 |
| opacity<sup>5+</sup> | number | 1 | 否 | 元素的透明度,取值范围为0到1,1表示为不透明,0表示为完全透明。 |
| display | string | flex | 否 | 确定一个元素所产生的框的类型,可选值为:<br/>-&nbsp;flex:弹性布局。<br/>-&nbsp;none:不渲染此元素。 |
| [left\|top] | &lt;length&gt;&nbsp;\|&nbsp;&lt;percentage&gt;<sup>6+</sup> | - | 否 | left\|top确定元素的偏移位置。<br/>-&nbsp;left属性规定元素的左边缘。该属性定义了定位元素左外边距边界与其包含块左边界之间的偏移。<br/>-&nbsp;top属性规定元素的顶部边缘。该属性定义了一个定位元素的上外边距边界与其包含块上边界之间的偏移。 |
| 名称 | 类型 | 默认值 | 必填 | 描述 |
| ---------------------------------- | ---------------------------------------- | ----- | ---- | ---------------------------------------- |
| width | &lt;length&gt;&nbsp;\|&nbsp;&lt;percentage&gt;<sup>5+</sup> | - | 否 | 设置组件自身的宽度。<br/><br/>未设置时组件宽度默认为0。 |
| height | &lt;length&gt;&nbsp;\|&nbsp;&lt;percentage&gt;<sup>5+</sup> | - | 否 | 设置组件自身的高度。<br/><br/>未设置时组件高度默认为0。 |
| padding | &lt;length&gt; | 0 | 否 | 使用简写属性设置所有的内边距属性。<br/>&nbsp;&nbsp;该属性可以有1到4个值:<br/>-&nbsp;指定一个值时,该值指定四个边的内边距。<br/>-&nbsp;指定两个值时,第一个值指定上下两边的内边距,第二个指定左右两边的内边距。<br/>-&nbsp;指定三个值时,第一个指定上边的内边距,第二个指定左右两边的内边距,第三个指定下边的内边距。<br/>-&nbsp;指定四个值时分别为上、右、下、左边的内边距(顺时针顺序)。 |
| padding-[left\|top\|right\|bottom] | &lt;length&gt; | 0 | 否 | 设置左、上、右、下内边距属性。 |
| margin | &lt;length&gt;&nbsp;\|&nbsp;&lt;percentage&gt;<sup>5+</sup> | 0 | 否 | 使用简写属性设置所有的外边距属性,该属性可以有1到4个值。<br/>-&nbsp;只有一个值时,这个值会被指定给全部的四个边。<br/>-&nbsp;两个值时,第一个值被匹配给上和下,第二个值被匹配给左和右。<br/>-&nbsp;三个值时,第一个值被匹配给上,&nbsp;第二个值被匹配给左和右,第三个值被匹配给下。<br/>-&nbsp;四个值时,会依次按上、右、下、左的顺序匹配&nbsp;(即顺时针顺序)。 |
| margin-[left\|top\|right\|bottom] | &lt;length&gt;&nbsp;\|&nbsp;&lt;percentage&gt;<sup>5+</sup> | 0 | 否 | 设置左、上、右、下外边距属性。 |
| border-width | &lt;length&gt; | 0 | 否 | 使用简写属性设置元素的所有边框宽度。 |
| border-color | &lt;color&gt; | black | 否 | 使用简写属性设置元素的所有边框颜色。 |
| border-radius | &lt;length&gt; | - | 否 | border-radius属性是设置元素的外边框圆角半径。 |
| background-color | &lt;color&gt; | - | 否 | 设置背景颜色。 |
| opacity<sup>5+</sup> | number | 1 | 否 | 元素的透明度,取值范围为0到1,1表示为不透明,0表示为完全透明。 |
| display | string | flex | 否 | 确定一个元素所产生的框的类型,可选值为:<br/>-&nbsp;flex:弹性布局。<br/>-&nbsp;none:不渲染此元素。 |
| [left\|top] | &lt;length&gt;&nbsp;\|&nbsp;&lt;percentage&gt;<sup>6+</sup> | - | 否 | left\|top确定元素的偏移位置。<br/>-&nbsp;left属性规定元素的左边缘。该属性定义了定位元素左外边距边界与其包含块左边界之间的偏移。<br/>-&nbsp;top属性规定元素的顶部边缘。该属性定义了一个定位元素的上外边距边界与其包含块上边界之间的偏移。 |
## 方法
| 名称 | 参数 | 描述 |
| -------- | -------- | -------- |
| start | - | 开始播放图片帧动画。再次调用,重新从第1帧开始播放。 |
| pause | - | 暂停播放图片帧动画。 |
| stop | - | 停止播放图片帧动画。 |
| resume | - | 继续播放图片帧。 |
| getState | - | 获取播放状态。可能值有:<br/>-&nbsp;playing:播放中<br/>-&nbsp;paused:已暂停<br/>-&nbsp;stopped:已停止。 |
| 名称 | 参数 | 描述 |
| -------- | ---- | ---------------------------------------- |
| start | - | 开始播放图片帧动画。再次调用,重新从第1帧开始播放。 |
| pause | - | 暂停播放图片帧动画。 |
| stop | - | 停止播放图片帧动画。 |
| resume | - | 继续播放图片帧。 |
| getState | - | 获取播放状态。可能值有:<br/>-&nbsp;playing:播放中<br/>-&nbsp;paused:已暂停<br/>-&nbsp;stopped:已停止。 |
## 示例
......
......@@ -14,52 +14,52 @@
## 属性
| 名称 | 类型 | 默认值 | 必填 | 描述 |
| -------- | -------- | -------- | -------- | -------- |
| min | number | 0 | 否 | 滑动选择器的最小值。 |
| max | number | 100 | 否 | 滑动选择器的最大值。 |
| value | number | 0 | 否 | 滑动选择器的初始值。 |
| id | string | - | 否 | 组件的唯一标识。 |
| style | string | - | 否 | 组件的样式声明。 |
| class | string | - | 否 | 组件的样式类,用于引用样式表。 |
| ref | string | - | 否 | 用来指定指向子元素的引用信息,该引用将注册到父组件的$refs&nbsp;属性对象上。 |
| 名称 | 类型 | 默认值 | 必填 | 描述 |
| ----- | ------ | ---- | ---- | ---------------------------------------- |
| min | number | 0 | 否 | 滑动选择器的最小值。 |
| max | number | 100 | 否 | 滑动选择器的最大值。 |
| value | number | 0 | 否 | 滑动选择器的初始值。 |
| id | string | - | 否 | 组件的唯一标识。 |
| style | string | - | 否 | 组件的样式声明。 |
| class | string | - | 否 | 组件的样式类,用于引用样式表。 |
| ref | string | - | 否 | 用来指定指向子元素的引用信息,该引用将注册到父组件的$refs&nbsp;属性对象上。 |
## 事件
| 名称 | 参数 | 描述 |
| -------- | -------- | -------- |
| change | ChangeEvent | 选择值发生变化时触发该事件。 |
| click | - | 点击动作触发该事件。 |
| longpress | - | 长按动作触发该事件。 |
| swipe<sup>5+</sup> | [SwipeEvent](js-common-events.md) | 组件上快速滑动后触发。 |
| 名称 | 参数 | 描述 |
| ------------------ | --------------------------------- | -------------- |
| change | ChangeEvent | 选择值发生变化时触发该事件。 |
| click | - | 点击动作触发该事件。 |
| longpress | - | 长按动作触发该事件。 |
| swipe<sup>5+</sup> | [SwipeEvent](js-common-events.md) | 组件上快速滑动后触发。 |
**表2** ChangeEvent
**表1** ChangeEvent
| 属性 | 类型 | 说明 |
| -------- | -------- | -------- |
| 属性 | 类型 | 说明 |
| ---------------------------------------- | ------ | ------------- |
| progress<sup>(deprecated<sup>5+</sup>)</sup> | string | 当前slider的进度值。 |
| value<sup>5+</sup> | number | 当前slider的进度值。 |
| value<sup>5+</sup> | number | 当前slider的进度值。 |
## 样式
| 名称 | 类型 | 默认值 | 必填 | 描述 |
| -------- | -------- | -------- | -------- | -------- |
| color | &lt;color&gt; | \#000000 | 否 | 滑动条的背景颜色。 |
| selected-color | &lt;color&gt; | \#ffffff | 否 | 滑动条的已选择颜色。 |
| width | &lt;length&gt;&nbsp;\|&nbsp;&lt;percentage&gt;<sup>5+</sup> | - | 否 | 设置组件自身的宽度。<br/><br/>未设置时组件宽度默认为0。 |
| height | &lt;length&gt;&nbsp;\|&nbsp;&lt;percentage&gt;<sup>5+</sup> | - | 否 | 设置组件自身的高度。<br/><br/>未设置时组件高度默认为0。 |
| padding | &lt;length&gt; | 0 | 否 | 使用简写属性设置所有的内边距属性。<br/>&nbsp;&nbsp;该属性可以有1到4个值:<br/>-&nbsp;指定一个值时,该值指定四个边的内边距。<br/>-&nbsp;指定两个值时,第一个值指定上下两边的内边距,第二个指定左右两边的内边距。<br/>-&nbsp;指定三个值时,第一个指定上边的内边距,第二个指定左右两边的内边距,第三个指定下边的内边距。<br/>-&nbsp;指定四个值时分别为上、右、下、左边的内边距(顺时针顺序)。 |
| padding-[left\|top\|right\|bottom] | &lt;length&gt; | 0 | 否 | 设置左、上、右、下内边距属性。 |
| margin | &lt;length&gt;&nbsp;\|&nbsp;&lt;percentage&gt;<sup>5+</sup> | 0 | 否 | 使用简写属性设置所有的外边距属性,该属性可以有1到4个值。<br/>-&nbsp;只有一个值时,这个值会被指定给全部的四个边。<br/>-&nbsp;两个值时,第一个值被匹配给上和下,第二个值被匹配给左和右。<br/>-&nbsp;三个值时,第一个值被匹配给上,&nbsp;第二个值被匹配给左和右,第三个值被匹配给下。<br/>-&nbsp;四个值时,会依次按上、右、下、左的顺序匹配&nbsp;(即顺时针顺序)。 |
| margin-[left\|top\|right\|bottom] | &lt;length&gt;&nbsp;\|&nbsp;&lt;percentage&gt;<sup>5+</sup> | 0 | 否 | 设置左、上、右、下外边距属性。 |
| border-width | &lt;length&gt; | 0 | 否 | 使用简写属性设置元素的所有边框宽度。 |
| border-color | &lt;color&gt; | black | 否 | 使用简写属性设置元素的所有边框颜色。 |
| border-radius | &lt;length&gt; | - | 否 | border-radius属性是设置元素的外边框圆角半径。 |
| background-color | &lt;color&gt; | - | 否 | 设置背景颜色。 |
| display | string | flex | 否 | 确定一个元素所产生的框的类型,可选值为:<br/>-&nbsp;flex:弹性布局。<br/>-&nbsp;none:不渲染此元素。 |
| [left\|top] | &lt;length&gt;&nbsp;\|&nbsp;&lt;percentage&gt;<sup>6+</sup> | - | 否 | left\|top确定元素的偏移位置。<br/>-&nbsp;left属性规定元素的左边缘。该属性定义了定位元素左外边距边界与其包含块左边界之间的偏移。<br/>-&nbsp;top属性规定元素的顶部边缘。该属性定义了一个定位元素的上外边距边界与其包含块上边界之间的偏移。 |
| 名称 | 类型 | 默认值 | 必填 | 描述 |
| ---------------------------------- | ---------------------------------------- | -------- | ---- | ---------------------------------------- |
| color | &lt;color&gt; | \#000000 | 否 | 滑动条的背景颜色。 |
| selected-color | &lt;color&gt; | \#ffffff | 否 | 滑动条的已选择颜色。 |
| width | &lt;length&gt;&nbsp;\|&nbsp;&lt;percentage&gt;<sup>5+</sup> | - | 否 | 设置组件自身的宽度。<br/><br/>未设置时组件宽度默认为0。 |
| height | &lt;length&gt;&nbsp;\|&nbsp;&lt;percentage&gt;<sup>5+</sup> | - | 否 | 设置组件自身的高度。<br/><br/>未设置时组件高度默认为0。 |
| padding | &lt;length&gt; | 0 | 否 | 使用简写属性设置所有的内边距属性。<br/>&nbsp;&nbsp;该属性可以有1到4个值:<br/>-&nbsp;指定一个值时,该值指定四个边的内边距。<br/>-&nbsp;指定两个值时,第一个值指定上下两边的内边距,第二个指定左右两边的内边距。<br/>-&nbsp;指定三个值时,第一个指定上边的内边距,第二个指定左右两边的内边距,第三个指定下边的内边距。<br/>-&nbsp;指定四个值时分别为上、右、下、左边的内边距(顺时针顺序)。 |
| padding-[left\|top\|right\|bottom] | &lt;length&gt; | 0 | 否 | 设置左、上、右、下内边距属性。 |
| margin | &lt;length&gt;&nbsp;\|&nbsp;&lt;percentage&gt;<sup>5+</sup> | 0 | 否 | 使用简写属性设置所有的外边距属性,该属性可以有1到4个值。<br/>-&nbsp;只有一个值时,这个值会被指定给全部的四个边。<br/>-&nbsp;两个值时,第一个值被匹配给上和下,第二个值被匹配给左和右。<br/>-&nbsp;三个值时,第一个值被匹配给上,&nbsp;第二个值被匹配给左和右,第三个值被匹配给下。<br/>-&nbsp;四个值时,会依次按上、右、下、左的顺序匹配&nbsp;(即顺时针顺序)。 |
| margin-[left\|top\|right\|bottom] | &lt;length&gt;&nbsp;\|&nbsp;&lt;percentage&gt;<sup>5+</sup> | 0 | 否 | 设置左、上、右、下外边距属性。 |
| border-width | &lt;length&gt; | 0 | 否 | 使用简写属性设置元素的所有边框宽度。 |
| border-color | &lt;color&gt; | black | 否 | 使用简写属性设置元素的所有边框颜色。 |
| border-radius | &lt;length&gt; | - | 否 | border-radius属性是设置元素的外边框圆角半径。 |
| background-color | &lt;color&gt; | - | 否 | 设置背景颜色。 |
| display | string | flex | 否 | 确定一个元素所产生的框的类型,可选值为:<br/>-&nbsp;flex:弹性布局。<br/>-&nbsp;none:不渲染此元素。 |
| [left\|top] | &lt;length&gt;&nbsp;\|&nbsp;&lt;percentage&gt;<sup>6+</sup> | - | 否 | left\|top确定元素的偏移位置。<br/>-&nbsp;left属性规定元素的左边缘。该属性定义了定位元素左外边距边界与其包含块左边界之间的偏移。<br/>-&nbsp;top属性规定元素的顶部边缘。该属性定义了一个定位元素的上外边距边界与其包含块上边界之间的偏移。 |
## 示例
......
......@@ -45,8 +45,8 @@
**表1** 媒体逻辑操作符
| 类型 | 说明 |
| --------------- | ------------------------------------------------------------ |
| 类型 | 说明 |
| --------------- | ---------------------------------------- |
| and | 将多个媒体特征(Media&nbsp;Feature)以“与”的方式连接成一个媒体查询,只有当所有媒体特征都为true,查询条件成立。另外,它还可以将媒体类型和媒体功能结合起来。<br/>例如:screen&nbsp;and&nbsp;(device-type:&nbsp;liteWearable)&nbsp;and&nbsp;(max-height:&nbsp;454)&nbsp;表示当设备类型是智能穿戴同时应用的最大高度小于等于454个像素单位时成立。 |
| or<sup>9+</sup> | 将多个媒体特征以“或”的方式连接成一个媒体查询,如果存在结果为true的媒体特征,则查询条件成立。<br/>例如:screen&nbsp;and&nbsp;(max-height:&nbsp;454) &nbsp;or&nbsp;&nbsp;(round-screen:true)表示当应用高度小于等于454个像素单位或者设备屏幕是圆形时,条件成立。 |
......@@ -55,18 +55,18 @@
## 媒体特征
| 类型 | 说明 |
| ---------------- | ------------------------------------------------------------ |
| height | 应用页面显示区域的高度。 |
| min-height | 应用页面显示区域的最小高度。 |
| max-height | 应用页面显示区域的最大高度。 |
| width | 应用页面显示区域的宽度。 |
| min-width | 应用页面显示区域的最小宽度。 |
| max-width | 应用页面显示区域的最大宽度。 |
| 类型 | 说明 |
| ---------------- | ---------------------------------------- |
| height | 应用页面显示区域的高度。 |
| min-height | 应用页面显示区域的最小高度。 |
| max-height | 应用页面显示区域的最大高度。 |
| width | 应用页面显示区域的宽度。 |
| min-width | 应用页面显示区域的最小宽度。 |
| max-width | 应用页面显示区域的最大宽度。 |
| aspect-ratio | 应用页面显示区域的宽度与高度的比值。<br/>例如:aspect-ratio: 1/2 |
| min-aspect-ratio | 应用页面显示区域的宽度与高度的最小比值。 |
| max-aspect-ratio | 应用页面显示区域的宽度与高度的最大比值。 |
| round-screen | 屏幕类型,圆形屏幕为 true,&nbsp;非圆形屏幕为&nbsp;false。 |
| round-screen | 屏幕类型,圆形屏幕为 true,&nbsp;非圆形屏幕为&nbsp;false。 |
## 通用媒体特征示例代码
......
......@@ -30,7 +30,7 @@ Checkbox(options?:&nbsp;{name?: string, group?: string })
| 名称 | 参数类型 | 描述 |
| ------------- | ------- | -------- |
| select | boolean | 设置多选框是否选中。<br/>默认值:false<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 |
| select | boolean | 设置多选框是否选中。<br/>默认值:false<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。<br />从API version 10开始,该属性支持[$$](../../quick-start/arkts-two-way-sync.md)双向绑定变量。 |
| selectedColor | [ResourceColor](ts-types.md#resourcecolor) | 设置多选框选中状态颜色。<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 |
| unselectedColor<sup>10+</sup> | [ResourceColor](ts-types.md#resourcecolor) | 设置多选框非选中状态边框颜色。 |
| mark<sup>10+</sup> | [MarkStyle](#markstyle10对象说明) | 多选框内部图标样式。 |
......
......@@ -30,7 +30,7 @@ CheckboxGroup(options?: { group?: string })
| 名称 | 参数类型 | 描述 |
| -------- | -------- | -------- |
| selectAll | boolean | 设置是否全选。<br/>默认值:false,若同组的[Checkbox](ts-basic-components-checkbox.md)设置了select属性,则Checkbox的优先级高。<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。<br/>**说明:** <br/>若同组的[Checkbox](ts-basic-components-checkbox.md)显式设置了select属性,则Checkbox的优先级高。 |
| selectAll | boolean | 设置是否全选。<br/>默认值:false,若同组的[Checkbox](ts-basic-components-checkbox.md)设置了select属性,则Checkbox的优先级高。<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。<br/>**说明:** <br/>若同组的[Checkbox](ts-basic-components-checkbox.md)显式设置了select属性,则Checkbox的优先级高。<br />从API version 10开始,该属性支持[$$](../../quick-start/arkts-two-way-sync.md)双向绑定变量。 |
| selectedColor | [ResourceColor](ts-types.md#resourcecolor) | 设置被选中或部分选中状态的颜色。<br/>从API version 9开始,该接口支持在ArkTS卡片中使用。 |
| unselectedColor<sup>10+</sup> | [ResourceColor](ts-types.md#resourcecolor) | 设置非选中状态边框颜色。 |
| mark<sup>10+</sup> | [MarkStyle](#markstyle10对象说明) | 多选框内部图标样式。 |
......
......@@ -36,7 +36,7 @@ MenuItem(value?: MenuItemOptions| CustomBuilder)
| 名称 | 参数类型 | 描述 |
| ------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ |
| selected | boolean | 设置菜单项是否选中。<br />默认值:false |
| selected | boolean | 设置菜单项是否选中。<br />默认值:false<br />从API version 10开始,该参数支持[$$](../../quick-start/arkts-two-way-sync.md)双向绑定变量。 |
| selectIcon | boolean \| [ResourceStr](ts-types.md#resourcestr)<sup>10+</sup> | 当菜单项被选中时,是否显示被选中的图标。<br/>默认值:false<br/>true: 菜单项被选中时,显示默认的对勾图标<br/>false: 即使菜单项被选中也不显示图标<br/>ResourceStr: 菜单项被选中时,显示指定的图标 |
| contentFont<sup>10+</sup> | [Font](ts-types.md#font) | 设置菜单项中内容信息的字体样式。 |
| contentFontColor<sup>10+</sup> | [ResourceColor](ts-types.md#resourcecolor) | 设置菜单项中内容信息的字体颜色。 |
......
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册