diff --git a/CODEOWNERS b/CODEOWNERS index 9a557753d3206996fb43ed7fe73d482968fee112..04a7ef69a6d8c7efd805b8683dae335ffaee0225 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -210,6 +210,7 @@ zh-cn/application-dev/reference/apis/js-apis-router.md @HelloCrease zh-cn/application-dev/reference/apis/js-apis-display.md @ge-yafang zh-cn/application-dev/reference/apis/js-apis-screenshot.md @ge-yafang zh-cn/application-dev/reference/apis/js-apis-window.md @ge-yafang +zh-cn/application-dev/reference/apis/js-apis-effectKit.md @ge-yafang zh-cn/application-dev/reference/apis/js-apis-application-WindowExtensionAbility.md @ge-yafang zh-cn/application-dev/reference/apis/js-apis-screen.md @ge-yafang zh-cn/application-dev/reference/apis/js-apis-windowAnimationManager.md @ge-yafang diff --git a/en/application-dev/ability/figures/stage-call.png b/en/application-dev/ability/figures/stage-call.png index 28f2a0f7ea9d86fc81e0c1a37d556384b14a9bdd..4c0c0770a4dce6f275b0fc355f70c5dfca2adb17 100644 Binary files a/en/application-dev/ability/figures/stage-call.png and b/en/application-dev/ability/figures/stage-call.png differ diff --git a/en/application-dev/ability/stage-call.md b/en/application-dev/ability/stage-call.md index 6b5823e76db2c95190111a55b9d2ef43ddd2d946..cad2aeddec2ae0782776009d4a8a9b092bace023 100644 --- a/en/application-dev/ability/stage-call.md +++ b/en/application-dev/ability/stage-call.md @@ -1,43 +1,63 @@ # Ability Call Development ## When to Use -Ability call is an extension of the ability capabilities. It enables an ability to be invoked by external systems. In this way, the ability can be displayed as a UI page on the foreground and created and run on the background. You can use the **Call** APIs to implement data sharing between different abilities through inter-process communication (IPC). There are two roles in the ability call: caller and callee. The following scenarios are involved in the ability call development: -- Creating a callee -- Accessing the callee +Ability call is an extension of the ability capability. It enables an ability to be invoked by and communicate with external systems. The ability invoked can be either started in the foreground or created and run in the background. You can use the ability call to implement data sharing between two abilities (caller ability and callee ability) through inter-process communication (IPC). -The following figure shows the ability call process. +The core API used for the ability call is `startAbilityByCall`, which differs from `startAbility` in the following ways: + - `startAbilityByCall` supports ability startup in the foreground and background, whereas `startAbility` supports ability startup in the foreground only. + - The caller ability can use the `Caller` object returned by `startAbilityByCall` to communicate with the callee ability, but `startAbility` does not provide the communication capability. +Ability call is usually used in the following scenarios: +- Communicating with the callee ability +- Starting the callee ability in the background + +**Table 1** Terms used in the ability call +|Term|Description| +|:------|:------| +|Caller ability|Ability that triggers the ability call.| +|Callee ability|Ability invoked by the ability call.| +|Caller |Object returned by `startAbilityByCall` and used by the caller ability to communicate with the callee ability.| +|Callee |Object held by the callee ability to communicate with the caller ability.| +|IPC |Inter-process communication.| + +The ability call process is as follows: + - The caller ability uses `startAbilityByCall` to obtain a `Caller` object and uses `call()` of the `Caller` object to send data to the callee ability. + - The callee ability, which holds a `Callee` object, uses `on()` of the `Callee` object to register a callback. This callback is invoked when the callee ability receives data from the caller ability. ![stage-call](figures/stage-call.png) -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
-> The startup mode of the callee must be **singleton**. -> Currently, only system applications and Service Extension abilities can use the **Call** APIs to access the callee. +> **NOTE**
+> The launch type of the callee ability must be `singleton`. +> Currently, only system applications can use the ability call. ## Available APIs The table below describes the ability call APIs. For details, see [Ability](../reference/apis/js-apis-application-ability.md#caller). -**Table 1** Ability call APIs +**Table 2** Ability call APIs |API|Description| |:------|:------| -|startAbilityByCall(want: Want): Promise\|Obtains the caller interface of the specified ability and, if the specified ability is not running, starts the ability in the background.| -|on(method: string, callback: CalleeCallBack): void|Callback invoked when the callee registers a method.| -|off(method: string): void|Callback invoked when the callee deregisters a method.| -|call(method: string, data: rpc.Sequenceable): Promise\|Sends agreed sequenceable data to the callee.| -|callWithResult(method: string, data: rpc.Sequenceable): Promise\|Sends agreed sequenceable data to the callee and returns the agreed sequenceable data.| -|release(): void|Releases the caller interface.| -|onRelease(callback: OnReleaseCallBack): void|Registers a callback that is invoked when the caller is disconnected.| +|startAbilityByCall(want: Want): Promise\|Starts an ability in the foreground (through the `want` configuration) or background (default) and obtains the `Caller` object for communication with the ability. For details, see [AbilityContext](../reference/apis/js-apis-ability-context.md#abilitycontextstartabilitybycall) or [ServiceExtensionContext](../reference/apis/js-apis-service-extension-context.md#serviceextensioncontextstartabilitybycall).| +|on(method: string, callback: CalleeCallBack): void|Callback invoked when the callee ability registers a method.| +|off(method: string): void|Callback invoked when the callee ability deregisters a method.| +|call(method: string, data: rpc.Sequenceable): Promise\|Sends agreed sequenceable data to the callee ability.| +|callWithResult(method: string, data: rpc.Sequenceable): Promise\|Sends agreed sequenceable data to the callee ability and obtains the agreed sequenceable data returned by the callee ability.| +|release(): void|Releases the `Caller` object.| +|onRelease(callback: OnReleaseCallBack): void|Callback invoked when the `Caller` object is released.| ## How to Develop -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
-> The sample code snippets provided in the **How to Develop** section are used to show specific development steps. They may not be able to run independently. -### Creating a Callee -For the callee, implement the callback to receive data and the methods to marshal and unmarshal data. When data needs to be received, use the **on** API to register a listener. When data does not need to be received, use the **off** API to deregister the listener. -1. Configure the ability startup mode. +The procedure for developing the ability call is as follows: +1. Create a callee ability. +2. Access the callee ability. +> **NOTE** +> +> The code snippets provided in the **How to Develop** section are used to show specific development steps. They may not be able to run independently. +### Creating a Callee Ability +For the callee ability, implement the callback to receive data and the methods to marshal and unmarshal data. When data needs to be received, use `on()` to register a listener. When data does not need to be received, use `off()` to deregister the listener. +**1. Configure the ability launch type.** - Set the ability of the callee to **singleton** in the **module.json5** file. + Set `launchType` of the callee ability to `singleton` in the `module.json5` file. |JSON Field|Description| |:------|:------| -|"launchType"|Ability startup mode. Set this parameter to **singleton**.| +|"launchType"|Ability launch type. Set this parameter to `singleton`.| An example of the ability configuration is as follows: ```json @@ -51,13 +71,13 @@ An example of the ability configuration is as follows: "visible": true }] ``` -2. Import the **Ability** module. -``` +**2. Import the Ability module.** +```ts import Ability from '@ohos.application.Ability' ``` -3. Define the agreed sequenceable data. +**3. Define the agreed sequenceable data.** - The data formats sent and received by the caller and callee must be consistent. In the following example, the data consists of numbers and strings. The sample code snippet is as follows: + The data formats sent and received by the caller and callee abilities must be consistent. In the following example, the data formats are number and string. The code snippet is as follows: ```ts export default class MySequenceable { num: number = 0 @@ -81,23 +101,23 @@ export default class MySequenceable { } } ``` -4. Implement **Callee.on** and **Callee.off**. +**4. Implement `Callee.on` and `Callee.off`.** - The time to register a listener for the callee depends on your application. The data sent and received before the listener is registered and that after the listener is deregistered are not processed. In the following example, the **MSG_SEND_METHOD** listener is registered in **onCreate** of the ability and deregistered in **onDestroy**. After receiving sequenceable data, the application processes the data and returns the data result. You need to implement processing based on service requirements. The sample code snippet is as follows: + The time to register a listener for the callee ability depends on your application. The data sent and received before the listener is registered and that after the listener is deregistered are not processed. In the following example, the `MSG_SEND_METHOD` listener is registered in `onCreate` of the ability and deregistered in `onDestroy`. After receiving sequenceable data, the application processes the data and returns the data result. You need to implement processing based on service requirements. The code snippet is as follows: ```ts const TAG: string = '[CalleeAbility]' const MSG_SEND_METHOD: string = 'CallSendMsg' function sendMsgCallback(data) { - Logger.log(TAG, 'CalleeSortFunc called') + console.log('CalleeSortFunc called') - // Obtain the sequenceable data sent by the caller. + // Obtain the sequenceable data sent by the caller ability. let receivedData = new MySequenceable(0, '') data.readSequenceable(receivedData) - Logger.log(TAG, `receiveData[${receivedData.num}, ${receivedData.str}]`) + console.log(`receiveData[${receivedData.num}, ${receivedData.str}]`) // Process the data. - // Return the sequenceable data result to the caller. + // Return the sequenceable data result to the caller ability. return new MySequenceable(receivedData.num + 1, `send ${receivedData.str} succeed`) } @@ -106,7 +126,7 @@ export default class CalleeAbility extends Ability { try { this.callee.on(MSG_SEND_METHOD, sendMsgCallback) } catch (error) { - Logger.error(TAG, `${MSG_SEND_METHOD} register failed with error ${JSON.stringify(error)}`) + console.log(`${MSG_SEND_METHOD} register failed with error ${JSON.stringify(error)}`) } } @@ -120,15 +140,27 @@ export default class CalleeAbility extends Ability { } ``` -### Accessing the Callee -1. Import the **Ability** module. -``` +### Accessing the Callee Ability +**1. Import the Ability module.** +```ts import Ability from '@ohos.application.Ability' ``` -2. Obtain the caller interface. +**2. Obtain the `Caller` object.** - The **context** attribute of the ability implements **startAbilityByCall** to obtain the caller interface of the ability. The following example uses **this.context** to obtain the **context** attribute of the **Ability** instance, uses **startAbilityByCall** to start the callee, obtain the caller interface, and register the **onRelease** listener of the caller. You need to implement processing based on service requirements. The sample code snippet is as follows: + The `context` attribute of the ability implements `startAbilityByCall` to obtain the `Caller` object for communication. The following example uses `this.context` to obtain the `context` attribute of the ability, uses `startAbilityByCall` to start the callee ability, obtain the `Caller` object, and register the `onRelease` listener of the caller ability. You need to implement processing based on service requirements. The code snippet is as follows: ```ts +// Register the onRelease listener of the caller ability. +private regOnRelease(caller) { + try { + caller.onRelease((msg) => { + console.log(`caller onRelease is called ${msg}`) + }) + console.log('caller register OnRelease succeed') + } catch (error) { + console.log(`caller register OnRelease failed with ${error}`) + } +} + async onButtonGetCaller() { try { this.caller = await context.startAbilityByCall({ @@ -136,73 +168,74 @@ async onButtonGetCaller() { abilityName: 'CalleeAbility' }) if (this.caller === undefined) { - Logger.error(TAG, 'get caller failed') + console.log('get caller failed') return } - Logger.log(TAG, 'get caller success') + console.log('get caller success') this.regOnRelease(this.caller) } catch (error) { - Logger.error(TAG, `get caller failed with ${error}`) + console.log(`get caller failed with ${error}`) } -}.catch((error) => { - console.error(TAG + 'get caller failed with ' + error) -}) +} ``` - In the cross-device scenario, you need to specify the ID of the peer device. The sample code snippet is as follows: + In the cross-device scenario, you need to specify the ID of the peer device. The code snippet is as follows: ```ts -let TAG = '[MainAbility] ' -var caller = undefined -let context = this.context - -context.startAbilityByCall({ - deviceId: getRemoteDeviceId(), - bundleName: 'com.samples.CallApplication', - abilityName: 'CalleeAbility' -}).then((data) => { - if (data != null) { - caller = data - console.log(TAG + 'get remote caller success') - // Register the onRelease listener of the caller. - caller.onRelease((msg) => { - console.log(TAG + 'remote caller onRelease is called ' + msg) - }) - console.log(TAG + 'remote caller register OnRelease succeed') - } -}).catch((error) => { - console.error(TAG + 'get remote caller failed with ' + error) -}) +async onButtonGetRemoteCaller() { + var caller = undefined + var context = this.context + + context.startAbilityByCall({ + deviceId: getRemoteDeviceId(), + bundleName: 'com.samples.CallApplication', + abilityName: 'CalleeAbility' + }).then((data) => { + if (data != null) { + caller = data + console.log('get remote caller success') + // Register the onRelease listener of the caller ability. + caller.onRelease((msg) => { + console.log(`remote caller onRelease is called ${msg}`) + }) + console.log('remote caller register OnRelease succeed') + } + }).catch((error) => { + console.error(`get remote caller failed with ${error}`) + }) +} ``` - Obtain the ID of the peer device from **DeviceManager**. Note that the **getTrustedDeviceListSync** API is open only to system applications. The sample code snippet is as follows: + Obtain the ID of the peer device from `DeviceManager`. Note that the `getTrustedDeviceListSync` API is open only to system applications. The code snippet is as follows: ```ts import deviceManager from '@ohos.distributedHardware.deviceManager'; var dmClass; function getRemoteDeviceId() { if (typeof dmClass === 'object' && dmClass != null) { - var list = dmClass.getTrustedDeviceListSync(); + var list = dmClass.getTrustedDeviceListSync() if (typeof (list) == 'undefined' || typeof (list.length) == 'undefined') { - console.log("MainAbility onButtonClick getRemoteDeviceId err: list is null"); - return; + console.log("MainAbility onButtonClick getRemoteDeviceId err: list is null") + return } - console.log("MainAbility onButtonClick getRemoteDeviceId success:" + list[0].deviceId); - return list[0].deviceId; + console.log("MainAbility onButtonClick getRemoteDeviceId success:" + list[0].deviceId) + return list[0].deviceId } else { - console.log("MainAbility onButtonClick getRemoteDeviceId err: dmClass is null"); + console.log("MainAbility onButtonClick getRemoteDeviceId err: dmClass is null") } } ``` - In the cross-device scenario, the application must also apply for the data synchronization permission from end users. The sample code snippet is as follows: + In the cross-device scenario, your application must also apply for the data synchronization permission from end users. The code snippet is as follows: ```ts -let context = this.context -let permissions: Array = ['ohos.permission.DISTRIBUTED_DATASYNC'] -context.requestPermissionsFromUser(permissions).then((data) => { - console.log("Succeed to request permission from user with data: "+ JSON.stringify(data)) -}).catch((error) => { - console.log("Failed to request permission from user with error: "+ JSON.stringify(error)) -}) +requestPermission() { + let context = this.context + let permissions: Array = ['ohos.permission.DISTRIBUTED_DATASYNC'] + context.requestPermissionsFromUser(permissions).then((data) => { + console.log("Succeed to request permission from user with data: "+ JSON.stringify(data)) + }).catch((error) => { + console.log("Failed to request permission from user with error: "+ JSON.stringify(error)) + }) +} ``` -3. Send agreed sequenceable data. +**3. Send agreed sequenceable data.** - The sequenceable data can be sent to the callee with or without a return value. The method and sequenceable data must be consistent with those of the callee. The following example describes how to invoke the **Call** API to send data to the callee. The sample code snippet is as follows: + The sequenceable data can be sent to the callee ability with or without a return value. The method and sequenceable data must be consistent with those of the callee ability. The following example describes how to send data to the callee ability. The code snippet is as follows: ```ts const MSG_SEND_METHOD: string = 'CallSendMsg' async onButtonCall() { @@ -210,12 +243,12 @@ async onButtonCall() { let msg = new MySequenceable(1, 'origin_Msg') await this.caller.call(MSG_SEND_METHOD, msg) } catch (error) { - Logger.error(TAG, `caller call failed with ${error}`) + console.log(`caller call failed with ${error}`) } } ``` - In the following, **CallWithResult** is used to send data **originMsg** to the callee and assign the data processed by the **CallSendMsg** method to **backMsg**. The sample code snippet is as follows: + In the following, `CallWithResult` is used to send data `originMsg` to the callee ability and assign the data processed by the `CallSendMsg` method to `backMsg`. The code snippet is as follows: ```ts const MSG_SEND_METHOD: string = 'CallSendMsg' originMsg: string = '' @@ -224,26 +257,28 @@ async onButtonCallWithResult(originMsg, backMsg) { try { let msg = new MySequenceable(1, originMsg) const data = await this.caller.callWithResult(MSG_SEND_METHOD, msg) - Logger.log(TAG, 'caller callWithResult succeed') + console.log('caller callWithResult succeed') let result = new MySequenceable(0, '') data.readSequenceable(result) backMsg(result.str) - Logger.log(TAG, `caller result is [${result.num}, ${result.str}]`) + console.log(`caller result is [${result.num}, ${result.str}]`) } catch (error) { - Logger.error(TAG, `caller callWithResult failed with ${error}`) + console.log(`caller callWithResult failed with ${error}`) } } ``` -4. Release the caller interface. +**4. Release the `Caller` object.** - When the caller interface is no longer required, call the **release** API to release it. The sample code snippet is as follows: + When the `Caller` object is no longer required, use `release()` to release it. The code snippet is as follows: ```ts -try { - this.caller.release() - this.caller = undefined - Logger.log(TAG, 'caller release succeed') -} catch (error) { - Logger.error(TAG, `caller release failed with ${error}`) +releaseCall() { + try { + this.caller.release() + this.caller = undefined + console.log('caller release succeed') + } catch (error) { + console.log(`caller release failed with ${error}`) + } } ``` diff --git a/en/application-dev/quick-start/start-with-ets-stage.md b/en/application-dev/quick-start/start-with-ets-stage.md index 7703ff56e9336bb5e648a63eb3e7df470f0d88a5..7c623151a90c6f7fe278ee9354ff3232456b6026 100644 --- a/en/application-dev/quick-start/start-with-ets-stage.md +++ b/en/application-dev/quick-start/start-with-ets-stage.md @@ -285,7 +285,7 @@ You can implement page redirection through the page router, which finds the targ 1. Connect the development board running the OpenHarmony standard system to the computer. -2. Choose **File** > **Project Structure...** > **Project** > **SigningConfigs**, and select **Automatically generate signaure**. Wait until the automatic signing is complete, and click **OK**. See the following figure. +2. Choose **File** > **Project Structure...** > **Project** > **SigningConfigs**, and select **Automatically generate signature**. Wait until the automatic signing is complete, and click **OK**. See the following figure. ![06](figures/06.png) diff --git a/en/application-dev/reference/apis/js-apis-ability-context.md b/en/application-dev/reference/apis/js-apis-ability-context.md index cd4e27214b3617970071bcfb8e4e5b1c76bc2a2c..9aab0179f06478fef211871d29e90daa33cf5609 100644 --- a/en/application-dev/reference/apis/js-apis-ability-context.md +++ b/en/application-dev/reference/apis/js-apis-ability-context.md @@ -5,8 +5,8 @@ The **AbilityContext** module, inherited from **Context**, implements the contex This module provides APIs for accessing ability-specific resources. You can use the APIs to start and terminate an ability, obtain the caller interface, and request permissions from users by displaying a dialog box. > **NOTE** -> -> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. +> +> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The APIs of this module can be used only in the stage model. ## Usage @@ -78,7 +78,7 @@ Starts an ability with start options specified. This API uses an asynchronous ca | callback | AsyncCallback<void> | Yes| Callback used to return the result.| **Example** - + ```js var want = { "deviceId": "", @@ -127,7 +127,7 @@ Starts an ability. This API uses a promise to return the result. windowMode: 0, }; this.context.startAbility(want, options) - .then((data) => { + .then(() => { console.log('Operation successful.') }).catch((error) => { console.log('Operation failed.'); @@ -407,8 +407,8 @@ Starts a new Service Extension ability. This API uses a promise to return the re "abilityName": "MainAbility" }; this.context.startServiceExtensionAbility(want) - .then((data) => { - console.log('---------- startServiceExtensionAbility success, data: -----------', data); + .then(() => { + console.log('---------- startServiceExtensionAbility success -----------'); }) .catch((err) => { console.log('---------- startServiceExtensionAbility fail, err: -----------', err); @@ -477,8 +477,8 @@ Starts a new Service Extension ability with the account ID specified. This API u }; var accountId = 100; this.context.startServiceExtensionAbilityWithAccount(want,accountId) - .then((data) => { - console.log('---------- startServiceExtensionAbilityWithAccount success, data: -----------', data); + .then(() => { + console.log('---------- startServiceExtensionAbilityWithAccount success -----------'); }) .catch((err) => { console.log('---------- startServiceExtensionAbilityWithAccount fail, err: -----------', err); @@ -539,8 +539,8 @@ Stops a Service Extension ability in the same application. This API uses a promi "abilityName": "MainAbility" }; this.context.stopServiceExtensionAbility(want) - .then((data) => { - console.log('---------- stopServiceExtensionAbility success, data: -----------', data); + .then(() => { + console.log('---------- stopServiceExtensionAbility success -----------'); }) .catch((err) => { console.log('---------- stopServiceExtensionAbility fail, err: -----------', err); @@ -610,8 +610,8 @@ Stops a Service Extension ability in the same application with the account ID sp }; var accountId = 100; this.context.stopServiceExtensionAbilityWithAccount(want,accountId) - .then((data) => { - console.log('---------- stopServiceExtensionAbilityWithAccount success, data: -----------', data); + .then(() => { + console.log('---------- stopServiceExtensionAbilityWithAccount success -----------'); }) .catch((err) => { console.log('---------- stopServiceExtensionAbilityWithAccount fail, err: -----------', err); @@ -658,8 +658,8 @@ Terminates this ability. This API uses a promise to return the result. **Example** ```js - this.context.terminateSelf().then((data) => { - console.log('success:' + JSON.stringify(data)); + this.context.terminateSelf().then(() => { + console.log('success'); }).catch((error) => { console.log('failed:' + JSON.stringify(error)); }); @@ -848,11 +848,11 @@ Disconnects a connection. This API uses a promise to return the result. | Promise\ | Promise used to return the result.| **Example** - + ```js var connectionNumber = 0; - this.context.disconnectAbility(connectionNumber).then((data) => { - console.log('disconnectAbility success, data: ', data); + this.context.disconnectAbility(connectionNumber).then(() => { + console.log('disconnectAbility success'); }).catch((err) => { console.log('disconnectAbility fail, err: ', err); }); @@ -888,7 +888,7 @@ Disconnects a connection. This API uses an asynchronous callback to return the r startAbilityByCall(want: Want): Promise<Caller>; -Starts an ability in the foreground or background and obtains the caller interface for communication with the ability. +Starts an ability in the foreground or background and obtains the caller object for communicating with the ability. **System capability**: SystemCapability.Ability.AbilityRuntime.Core @@ -905,11 +905,11 @@ Starts an ability in the foreground or background and obtains the caller interfa | Promise<Caller> | Promise used to return the caller object to communicate with.| **Example** - + ```js let caller = undefined; - // Start an ability in the background without passing parameters. + // Start an ability in the background by not passing parameters. var wantBackground = { bundleName: "com.example.myservice", moduleName: "entry", @@ -1050,8 +1050,8 @@ Starts an ability with the account ID specified. This API uses a promise to retu windowMode: 0, }; this.context.startAbilityWithAccount(want, accountId, options) - .then((data) => { - console.log('---------- startAbilityWithAccount success, data: -----------', data); + .then(() => { + console.log('---------- startAbilityWithAccount success -----------'); }) .catch((err) => { console.log('---------- startAbilityWithAccount fail, err: -----------', err); @@ -1074,13 +1074,13 @@ Requests permissions from the user by displaying a dialog box. This API uses an | callback | AsyncCallback<[PermissionRequestResult](js-apis-permissionrequestresult.md)> | Yes| Callback used to return the result.| **Example** - + ```js var permissions=['com.example.permission'] this.context.requestPermissionsFromUser(permissions,(result) => { console.log('requestPermissionsFromUserresult:' + JSON.stringify(result)); }); - + ``` @@ -1105,7 +1105,7 @@ Requests permissions from the user by displaying a dialog box. This API uses a p | Promise<[PermissionRequestResult](js-apis-permissionrequestresult.md)> | Promise used to return the result.| **Example** - + ```js var permissions=['com.example.permission'] this.context.requestPermissionsFromUser(permissions).then((data) => { @@ -1133,7 +1133,7 @@ Sets a label for this ability in the mission. This API uses an asynchronous call | callback | AsyncCallback<void> | Yes| Callback used to return the result.| **Example** - + ```js this.context.setMissionLabel("test",(result) => { console.log('requestPermissionsFromUserresult:' + JSON.stringify(result)); @@ -1162,10 +1162,10 @@ Sets a label for this ability in the mission. This API uses a promise to return | Promise<void> | Promise used to return the result.| **Example** - + ```js - this.context.setMissionLabel("test").then((data) => { - console.log('success:' + JSON.stringify(data)); + this.context.setMissionLabel("test").then(() => { + console.log('success'); }).catch((error) => { console.log('failed:' + JSON.stringify(error)); }); @@ -1188,7 +1188,7 @@ Sets an icon for this ability in the mission. This API uses an asynchronous call | callback | AsyncCallback\ | Yes| Callback used to return the result.| **Example** - + ```js import image from '@ohos.multimedia.image' var imagePixelMap; @@ -1235,7 +1235,7 @@ Sets an icon for this ability in the mission. This API uses a promise to return | Promise<void> | Promise used to return the result.| **Example** - + ```js import image from '@ohos.multimedia.image' var imagePixelMap; @@ -1254,8 +1254,8 @@ Sets an icon for this ability in the mission. This API uses a promise to return console.log('--------- createPixelMap fail, err: ---------', err) }); this.context.setMissionIcon(imagePixelMap) - .then((data) => { - console.log('-------------- setMissionIcon success, data: -------------', data); + .then(() => { + console.log('-------------- setMissionIcon success -------------'); }) .catch((err) => { console.log('-------------- setMissionIcon fail, err: -------------', err); diff --git a/en/application-dev/reference/apis/js-apis-ability-wantConstant.md b/en/application-dev/reference/apis/js-apis-ability-wantConstant.md index 545da5d468feefce2440a356812356e6206e11e3..619ed387b6338fa06a064b3848a3491ee7ea08c9 100644 --- a/en/application-dev/reference/apis/js-apis-ability-wantConstant.md +++ b/en/application-dev/reference/apis/js-apis-ability-wantConstant.md @@ -32,7 +32,7 @@ Enumerates the action constants of the **Want** object. | ACTION_DISMISS_ALARM | ohos.want.action.dismissAlarm | Action of launching the UI for deleting an alarm. | | ACTION_DISMISS_TIMER | ohos.want.action.dismissTimer | Action of launching the UI for dismissing a timer. | | ACTION_SEND_SMS | ohos.want.action.sendSms | Action of launching the UI for sending an SMS message. | -| ACTION_CHOOSE | ohos.want.action.choose | Action of launching the UI for openning a contact or picture. | +| ACTION_CHOOSE | ohos.want.action.choose | Action of launching the UI for opening a contact or picture. | | ACTION_IMAGE_CAPTURE8+ | ohos.want.action.imageCapture | Action of launching the UI for photographing. | | ACTION_VIDEO_CAPTURE8+ | ohos.want.action.videoCapture | Action of launching the UI for shooting a video. | | ACTION_SELECT | ohos.want.action.select | Action of launching the UI for application selection. | diff --git a/en/application-dev/reference/apis/js-apis-application-Want.md b/en/application-dev/reference/apis/js-apis-application-Want.md index fd15443a5b2ac2b28642a0c89d441cdbee5d6866..b7f2605363e849a8d5531b9ebda7d2277a2fd11c 100644 --- a/en/application-dev/reference/apis/js-apis-application-Want.md +++ b/en/application-dev/reference/apis/js-apis-application-Want.md @@ -49,6 +49,7 @@ import Want from '@ohos.application.Want'; - Passing a file descriptor (FD) ``` js + import fileio from '@ohos.fileio'; var fd; try { fd = fileio.openSync("/data/storage/el2/base/haps/pic.png"); @@ -59,9 +60,9 @@ import Want from '@ohos.application.Want'; "deviceId": "", // An empty deviceId indicates the local device. "bundleName": "com.extreme.test", "abilityName": "MainAbility", - "moduleName": "entry" // moduleName is optional. + "moduleName": "entry", // moduleName is optional. "parameters": { - "keyFd":{"type":"FD", "value":fd} + "keyFd":{"type":"FD", "value":fd} } }; this.context.startAbility(want, (error) => { diff --git a/en/application-dev/reference/apis/js-apis-audio.md b/en/application-dev/reference/apis/js-apis-audio.md index f019d61969e28699cc1324a6f8d8af29ba7d60f6..7fa4e76c7a448d1272d1a50b8da71e0303b27762 100644 --- a/en/application-dev/reference/apis/js-apis-audio.md +++ b/en/application-dev/reference/apis/js-apis-audio.md @@ -4911,7 +4911,7 @@ audioCapturer.getBufferSize().then((data) => { console.info(`AudioFrameworkRecLog: getBufferSize: SUCCESS ${data}`); bufferSize = data; }).catch((err) => { - console.error(`AudioFrameworkRecLog: getBufferSize: EROOR: ${err}`); + console.error(`AudioFrameworkRecLog: getBufferSize: ERROR: ${err}`); }); audioCapturer.read(bufferSize, true, async(err, buffer) => { if (!err) { diff --git a/en/application-dev/reference/apis/js-apis-call.md b/en/application-dev/reference/apis/js-apis-call.md index 1631e3318f49bd07012e836449dfa4431a67db65..ac82d0b2e610751bd000849ec35337363b0dcb3a 100644 --- a/en/application-dev/reference/apis/js-apis-call.md +++ b/en/application-dev/reference/apis/js-apis-call.md @@ -2810,10 +2810,11 @@ This is a system API. | Name | Value | Description | | -------------------- | ---- | ------------ | -| DEVICE_EARPIECE | 0 | Headset device. | -| DEVICE_SPEAKER | 1 | Speaker device.| -| DEVICE_WIRED_HEADSET | 2 | Wired headset device.| +| DEVICE_EARPIECE | 0 | Earpiece. | +| DEVICE_SPEAKER | 1 | Speaker.| +| DEVICE_WIRED_HEADSET | 2 | Wired headset.| | DEVICE_BLUETOOTH_SCO | 3 | Bluetooth SCO device. | +| DEVICE_MIC | 4 | Microphone. | ## CallRestrictionType8+ diff --git a/en/application-dev/reference/apis/js-apis-camera.md b/en/application-dev/reference/apis/js-apis-camera.md index f9c55898029eee1a6782df976cfd40ec43574735..5a88150801a77616a6954139376edead865f55a8 100644 --- a/en/application-dev/reference/apis/js-apis-camera.md +++ b/en/application-dev/reference/apis/js-apis-camera.md @@ -631,7 +631,7 @@ Creates a **PreviewOutput** instance. This API uses a promise to return the resu **Example** ```js -cameraManager.createPreviewOutput(profile, survaceId).then((previewoutput) => { +cameraManager.createPreviewOutput(profile, surfaceId).then((previewoutput) => { console.log('Promise returned with previewOutput created.'); }) ``` @@ -2262,7 +2262,7 @@ cameraInput.isExposureModeSupported(camera.ExposureMode.EXPOSURE_MODE_LOCKEN,(er console.log(`Failed to check exposure mode supported ${err.message}`); return ; } - console.log('Callback returned with the successful excution of isExposureModeSupported'); + console.log('Callback returned with the successful execution of isExposureModeSupported'); }) ``` @@ -2365,7 +2365,7 @@ cameraInput.setExposureMode(camera.ExposureMode.EXPOSURE_MODE_LOCKEN,(err) => { console.log(`Failed to set the exposure mode ${err.message}`); return ; } - console.log('Callback returned with the successful excution of setExposureMode'); + console.log('Callback returned with the successful execution of setExposureMode'); }) ``` @@ -2464,7 +2464,7 @@ cameraInput.setMeteringPoint(Point1,(err) => { console.log(`Failed to set the exposure point ${err.message}`); return ; } - console.log('Callback returned with the successful excution of setMeteringPoint'); + console.log('Callback returned with the successful execution of setMeteringPoint'); }) ``` @@ -2571,7 +2571,7 @@ cameraInput.setExposureBias(-4,(err) => { console.log(`Failed to set the exposure bias ${err.message}`); return ; } - console.log('Callback returned with the successful excution of setExposureBias'); + console.log('Callback returned with the successful execution of setExposureBias'); }) ``` @@ -3545,7 +3545,7 @@ previewOutput.stop((err) => { console.error(`Failed to stop the previewOutput. ${err.message}`); return; } - console.log('Callback returned with previewOutput stoped.'); + console.log('Callback returned with previewOutput stopped.'); }) ``` @@ -3567,7 +3567,7 @@ Stops outputting preview streams. This API uses a promise to return the result. ```js previewOutput.stop().then(() => { - console.log('Callback returned with previewOutput stoped.'); + console.log('Callback returned with previewOutput stopped.'); }) ``` @@ -4476,7 +4476,7 @@ metadataOutput.stop((err) => { console.error(`Failed to stop the metadataOutput. ${err.message}`); return; } - console.log('Callback returned with metadataOutput stoped.'); + console.log('Callback returned with metadataOutput stopped.'); }) ``` @@ -4498,7 +4498,7 @@ Stops outputting metadata. This API uses a promise to return the result. ```js metadataOutput.stop().then(() => { - console.log('Callback returned with metadataOutput stoped.'); + console.log('Callback returned with metadataOutput stopped.'); }) ``` diff --git a/en/application-dev/reference/apis/js-apis-errorManager.md b/en/application-dev/reference/apis/js-apis-errorManager.md index 69d3c3bf8240d370a364294d4089aa445f3809cc..4a39fdd6b0031be7e3fcbdfc7a570609ba217a1b 100644 --- a/en/application-dev/reference/apis/js-apis-errorManager.md +++ b/en/application-dev/reference/apis/js-apis-errorManager.md @@ -33,8 +33,7 @@ var observer = { console.log('onUnhandledException, errorMsg: ', errorMsg) } } -const registerErrorObserverNumber=errorManager.registerErrorObserver(observer) -console.info(registerErrorObserverNumber) +errorManager.registerErrorObserver(observer) ``` ## ErrorManager.unregisterErrorObserver @@ -123,11 +122,4 @@ var observer = { } } errorManager.registerErrorObserver(observer) - .then((data) => { - console.log('----------- registerErrorObserver success ----------', data); - }) - .catch((err) => { - console.log('----------- registerErrorObserver fail ----------', err); - }) - ``` diff --git a/en/application-dev/reference/apis/js-apis-formInfo.md b/en/application-dev/reference/apis/js-apis-formInfo.md index eace629fc87a608f2235f9887c4b0e075ce38b4e..950da73f21bd3ac1ee8e8fe8a57989714a95d6dd 100644 --- a/en/application-dev/reference/apis/js-apis-formInfo.md +++ b/en/application-dev/reference/apis/js-apis-formInfo.md @@ -105,7 +105,7 @@ Enumerates the widget parameters. | TEMPORARY_KEY | "ohos.extra.param.key.form_temporary" | Temporary widget. | | ABILITY_NAME_KEY9+ | "ohos.extra.param.key.ability_name" | Ability name. | | DEVICE_ID_KEY9+ | "ohos.extra.param.key.device_id" | Device ID.
This is a system API. | -| BUNDLE_NAME_KEY9+ | "ohos.extra.param.key.bundle_name" | Key that specifies the target bundle name.
This is a system API. | +| BUNDLE_NAME_KEY9+ | "ohos.extra.param.key.bundle_name" | Key that specifies the target bundle name.| ## FormDimension diff --git a/en/application-dev/reference/apis/js-apis-hisysevent.md b/en/application-dev/reference/apis/js-apis-hisysevent.md index 022682c82230162ebb586898aed0b54ac6a59e30..e3c08ce24cf92eda9534812d664aa466c4b7c1ef 100644 --- a/en/application-dev/reference/apis/js-apis-hisysevent.md +++ b/en/application-dev/reference/apis/js-apis-hisysevent.md @@ -89,7 +89,7 @@ Writes event information to the event file. This API uses a promise to return th | Name | Type | Mandatory| Description| | --------- | ----------------------- | ---- | --------------- | -| eventType | [EventType](#eventtype) | Yes | Application event type.| +| info | [SysEventInfo](#syseventinfo) | Yes | System event information.| **Return value** diff --git a/en/application-dev/reference/apis/js-apis-i18n.md b/en/application-dev/reference/apis/js-apis-i18n.md index b68a5b15487f310dd6b05058c68af75840098062..dc6d5ed6e1c8589733ee79c22cf3b413d7f80141 100644 --- a/en/application-dev/reference/apis/js-apis-i18n.md +++ b/en/application-dev/reference/apis/js-apis-i18n.md @@ -1,10 +1,13 @@ # Internationalization – I18N +This module provides system-related or enhanced I18N capabilities, such as locale management, phone number formatting, and calendar, through supplementary I18N APIs that are not defined in ECMA 402. + +The [Intl](js-apis-intl.md) module provides basic I18N capabilities through the standard I18N APIs defined in ECMA 402. It works with the I18N module to provide a complete suite of I18N capabilities. + + > **NOTE** > -> - The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. -> -> - This module provides system-related or enhanced I18N capabilities, such as locale management, phone number formatting, and calendar, through supplementary I18N interfaces that are not defined in ECMA 402. For details about the basic I18N capabilities, see [Intl](js-apis-intl.md). +> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. ## Modules to Import diff --git a/en/application-dev/reference/apis/js-apis-image.md b/en/application-dev/reference/apis/js-apis-image.md index efd8277b83ac1cbe39a19ebad0fbf49cdf020190..20776d6cc80e501da6ae7accd069ebb502894f86 100644 --- a/en/application-dev/reference/apis/js-apis-image.md +++ b/en/application-dev/reference/apis/js-apis-image.md @@ -92,7 +92,7 @@ Provides APIs to read or write image pixel map data and obtain image pixel map i readPixelsToBuffer(dst: ArrayBuffer): Promise\ -Reads image pixel map data and writes the data to an **ArrayBuffer**. This API uses a promise to return the result. If the pixel map is created in the BGRA_8888 format, the pixel map data read is the same as the original data. +Reads data of this pixel map and writes the data to an **ArrayBuffer**. This API uses a promise to return the result. If this pixel map is created in the BGRA_8888 format, the data read is the same as the original data. **System capability**: SystemCapability.Multimedia.Image.Core @@ -123,7 +123,7 @@ pixelmap.readPixelsToBuffer(readBuffer).then(() => { readPixelsToBuffer(dst: ArrayBuffer, callback: AsyncCallback\): void -Reads image pixel map data and writes the data to an **ArrayBuffer**. This API uses an asynchronous callback to return the result. If the pixel map is created in the BGRA_8888 format, the pixel map data read is the same as the original data. +Reads data of this pixel map and writes the data to an **ArrayBuffer**. This API uses an asynchronous callback to return the result. If this pixel map is created in the BGRA_8888 format, the data read is the same as the original data. **System capability**: SystemCapability.Multimedia.Image.Core @@ -810,7 +810,7 @@ Crops this image based on the input size. This API uses an asynchronous callback ```js async function () { - await pixelMap.crop(3x3); + await pixelMap.crop({ x: 0, y: 0, size: { height: 100, width: 100 } }); } ``` @@ -838,7 +838,7 @@ Crops this image based on the input size. This API uses a promise to return the ```js async function () { - await pixelMap.crop(3x3); + await pixelMap.crop({ x: 0, y: 0, size: { height: 100, width: 100 } }); } ``` @@ -910,7 +910,7 @@ Creates an **ImageSource** instance based on the URI. | Name| Type | Mandatory| Description | | ------ | ------ | ---- | ---------------------------------- | -| uri | string | Yes | Image path. Currently, only the application sandbox path is supported.| +| uri | string | Yes | Image path. Currently, only the application sandbox path is supported.
Currently, the following raw formats are supported: .jpg, .png, .gif, .bmp, and .webp.| **Return value** @@ -937,7 +937,7 @@ Creates an **ImageSource** instance based on the URI. | Name | Type | Mandatory| Description | | ------- | ------------------------------- | ---- | ----------------------------------- | -| uri | string | Yes | Image path. Currently, only the application sandbox path is supported. | +| uri | string | Yes | Image path. Currently, only the application sandbox path is supported.
Currently, the following raw formats are supported: .jpg, .png, .gif, .bmp, and .webp.| | options | [SourceOptions](#sourceoptions9) | Yes | Image properties, including the image index and default property value.| **Return value** @@ -1569,7 +1569,7 @@ Packs an image. This API uses an asynchronous callback to return the result. | Name | Type | Mandatory| Description | | -------- | ---------------------------------- | ---- | ---------------------------------- | | source | [ImageSource](#imagesource) | Yes | Image to pack. | -| option | [PackingOption](#packingoption) | Yes | Option for image packing. | +| option | [PackingOption](#packingoption) | Yes | Option for image packing. | | callback | AsyncCallback\ | Yes | Callback used to return the packed data.| **Example** @@ -2166,7 +2166,7 @@ Enumerates the scale modes of images. | Name | Default Value| Description | | --------------- | ------ | -------------------------------------------------- | | CENTER_CROP | 1 | Scales the image so that it fills the requested bounds of the target and crops the extra.| -| FIT_TARGET_SIZE | 2 | Reduces the image size to the dimensions of the target. | +| FIT_TARGET_SIZE | 0 | Reduces the image size to the dimensions of the target. | ## SourceOptions9+ @@ -2231,7 +2231,7 @@ Defines the option for image packing. | Name | Type | Readable| Writable| Description | | ------- | ------ | ---- | ---- | --------------------------------------------------- | -| format | string | Yes | Yes | Format of the packed image. | +| format | string | Yes | Yes | Format of the packed image.
Currently, the following raw formats are supported: .jpg, .png, .gif, .bmp, and .webp. | | quality | number | Yes | Yes | Quality of the output image during JPEG encoding. The value ranges from 1 to 100.| ## GetImagePropertyOptions7+ diff --git a/en/application-dev/reference/apis/js-apis-intl.md b/en/application-dev/reference/apis/js-apis-intl.md index 3060af2da4bd047461f0cce0d866753bd8caf36a..cae08502ee91872765050fbb53fe6701bc2cbb9b 100644 --- a/en/application-dev/reference/apis/js-apis-intl.md +++ b/en/application-dev/reference/apis/js-apis-intl.md @@ -1,9 +1,13 @@ # Internationalization – Intl -> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** -> - The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. -> -> - This module provides basic I18N capabilities, such as time and date formatting, number formatting, and string sorting, through the standard I18N interfaces defined in ECMA 402. For details about the enhanced I18N capabilities, see [I18N](js-apis-i18n.md). +This module provides basic I18N capabilities, such as time and date formatting, number formatting, and string sorting, through the standard I18N APIs defined in ECMA 402. + +The [I18N](js-apis-i18n.md) module provides enhanced I18N capabilities through supplementary APIs that are not defined in ECMA 402. It works with the Intl module to provide a complete suite of I18N capabilities. + +> **NOTE** +> +> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. + ## Modules to Import diff --git a/en/application-dev/reference/apis/js-apis-radio.md b/en/application-dev/reference/apis/js-apis-radio.md index ee61f71f78a97411006f72225f5ac4a65e09e300..d094a5c7e3abd27ebc042ab377543a3d2898b1e1 100644 --- a/en/application-dev/reference/apis/js-apis-radio.md +++ b/en/application-dev/reference/apis/js-apis-radio.md @@ -70,7 +70,7 @@ let promise = radio.getRadioTech(slotId); promise.then(data => { console.log(`getRadioTech success, data->${JSON.stringify(data)}`); }).catch(err => { - console.log(`getRadioTech fail, err->${JSON.stringify(err)}`); + console.log(`getRadioTech failed, err->${JSON.stringify(err)}`); }); ``` @@ -157,7 +157,7 @@ let promise = radio.getNetworkState(slotId); promise.then(data => { console.log(`getNetworkState success, promise: data->${JSON.stringify(data)}`); }).catch(err => { - console.log(`getNetworkState fail, promise: err->${JSON.stringify(err)}`); + console.log(`getNetworkState failed, promise: err->${JSON.stringify(err)}`); }); ``` @@ -215,7 +215,7 @@ let promise = radio.getNetworkSelectionMode(slotId); promise.then(data => { console.log(`getNetworkSelectionMode success, promise: data->${JSON.stringify(data)}`); }).catch(err => { - console.log(`getNetworkSelectionMode fail, promise: err->${JSON.stringify(err)}`); + console.log(`getNetworkSelectionMode failed, promise: err->${JSON.stringify(err)}`); }); ``` @@ -273,7 +273,7 @@ let promise = radio.getISOCountryCodeForNetwork(slotId); promise.then(data => { console.log(`getISOCountryCodeForNetwork success, promise: data->${JSON.stringify(data)}`); }).catch(err => { - console.log(`getISOCountryCodeForNetwork fail, promise: err->${JSON.stringify(err)}`); + console.log(`getISOCountryCodeForNetwork failed, promise: err->${JSON.stringify(err)}`); }); ``` @@ -322,7 +322,7 @@ let promise = radio.getPrimarySlotId(); promise.then(data => { console.log(`getPrimarySlotId success, promise: data->${JSON.stringify(data)}`); }).catch(err => { - console.error(`getPrimarySlotId fail, promise: err->${JSON.stringify(err)}`); + console.error(`getPrimarySlotId failed, promise: err->${JSON.stringify(err)}`); }); ``` @@ -380,7 +380,7 @@ let promise = radio.getSignalInformation(slotId); promise.then(data => { console.log(`getSignalInformation success, promise: data->${JSON.stringify(data)}`); }).catch(err => { - console.error(`getSignalInformation fail, promise: err->${JSON.stringify(err)}`); + console.error(`getSignalInformation failed, promise: err->${JSON.stringify(err)}`); }); ``` @@ -496,7 +496,7 @@ let promise = radio.isRadioOn(slotId); promise.then(data => { console.log(`isRadioOn success, promise: data->${JSON.stringify(data)}`); }).catch(err => { - console.error(`isRadioOn fail, promise: err->${JSON.stringify(err)}`); + console.error(`isRadioOn failed, promise: err->${JSON.stringify(err)}`); }); ``` @@ -554,7 +554,7 @@ let promise = radio.getOperatorName(slotId); promise.then(data => { console.log(`getOperatorName success, promise: data->${JSON.stringify(data)}`); }).catch(err => { - console.log(`getOperatorName fail, promise: err->${JSON.stringify(err)}`); + console.log(`getOperatorName failed, promise: err->${JSON.stringify(err)}`); }); ``` @@ -564,7 +564,7 @@ setPrimarySlotId(slotId: number, callback: AsyncCallback): void Sets the ID of the slot in which the primary card is located. This API uses an asynchronous callback to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.SET_TELEPHONY_STATE @@ -593,7 +593,7 @@ setPrimarySlotId\(slotId: number\): Promise\ Sets the ID of the slot in which the primary card is located. This API uses a promise to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.SET_TELEPHONY_STATE @@ -619,7 +619,7 @@ let promise = radio.setPrimarySlotId(slotId); promise.then(data => { console.log(`setPrimarySlotId success, promise: data->${JSON.stringify(data)}`); }).catch(err => { - console.log(`setPrimarySlotId fail, promise: err->${JSON.stringify(err)}`); + console.log(`setPrimarySlotId failed, promise: err->${JSON.stringify(err)}`); }); ``` @@ -629,7 +629,7 @@ getIMEI(callback: AsyncCallback): void Obtains the IMEI of the SIM card in a card slot. This API uses an asynchronous callback to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.GET_TELEPHONY_STATE @@ -656,7 +656,7 @@ getIMEI(slotId: number, callback: AsyncCallback): void Obtains the IMEI of the SIM card in the specified slot. This API uses an asynchronous callback to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.GET_TELEPHONY_STATE @@ -685,7 +685,7 @@ getIMEI(slotId?: number): Promise Obtains the IMEI of the SIM card in a card slot. This API uses a promise to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.GET_TELEPHONY_STATE @@ -711,7 +711,7 @@ let promise = radio.getIMEI(slotId); promise.then(data => { console.log(`getIMEI success, promise: data->${JSON.stringify(data)}`); }).catch(err => { - console.error(`getIMEI fail, promise: err->${JSON.stringify(err)}`); + console.error(`getIMEI failed, promise: err->${JSON.stringify(err)}`); }); ``` @@ -721,7 +721,7 @@ getMEID(callback: AsyncCallback): void Obtains the MEID of the SIM card in a card slot. This API uses an asynchronous callback to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.GET_TELEPHONY_STATE @@ -748,7 +748,7 @@ getMEID(slotId: number, callback: AsyncCallback): void Obtains the MEID of the SIM card in the specified slot. This API uses an asynchronous callback to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.GET_TELEPHONY_STATE @@ -777,7 +777,7 @@ getMEID(slotId?: number): Promise Obtains the MEID of the SIM card in the specified slot. This API uses a promise to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.GET_TELEPHONY_STATE @@ -803,7 +803,7 @@ let promise = radio.getMEID(slotId); promise.then(data => { console.log(`getMEID success, promise: data->${JSON.stringify(data)}`); }).catch(err => { - console.error(`getMEID fail, promise: err->${JSON.stringify(err)}`); + console.error(`getMEID failed, promise: err->${JSON.stringify(err)}`); }); ``` @@ -813,7 +813,7 @@ getUniqueDeviceId(callback: AsyncCallback): void Obtains the unique device ID of the SIM card in a card slot. This API uses an asynchronous callback to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.GET_TELEPHONY_STATE @@ -840,7 +840,7 @@ getUniqueDeviceId(slotId: number, callback: AsyncCallback): void Obtains the unique device ID of the SIM card in the specified slot. This API uses an asynchronous callback to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.GET_TELEPHONY_STATE @@ -869,7 +869,7 @@ getUniqueDeviceId(slotId?: number): Promise Obtains the unique device ID of the SIM card in the specified slot. This API uses a promise to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.GET_TELEPHONY_STATE @@ -895,7 +895,7 @@ let promise = radio.getUniqueDeviceId(slotId); promise.then(data => { console.log(`getUniqueDeviceId success, promise: data->${JSON.stringify(data)}`); }).catch(err => { - console.error(`getUniqueDeviceId fail, promise: err->${JSON.stringify(err)}`); + console.error(`getUniqueDeviceId failed, promise: err->${JSON.stringify(err)}`); }); ``` @@ -905,7 +905,7 @@ sendUpdateCellLocationRequest\(callback: AsyncCallback\): void Sends a cell location update request. This API uses an asynchronous callback to return the result. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.CoreService @@ -929,7 +929,7 @@ sendUpdateCellLocationRequest\(slotId: number, callback: AsyncCallback\): Sends a cell location update request for the SIM card in the specified slot. This API uses an asynchronous callback to return the result. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.CoreService @@ -955,7 +955,7 @@ sendUpdateCellLocationRequest\(slotId?: number): Promise Sends a cell location update request for the SIM card in the specified slot.This API uses a promise to return the result. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.CoreService @@ -979,7 +979,7 @@ let promise = radio.sendUpdateCellLocationRequest(slotId); promise.then(data => { console.log(`sendUpdateCellLocationRequest success, promise: data->${JSON.stringify(data)}`); }).catch(err => { - console.log(`sendUpdateCellLocationRequest fail, promise: err->${JSON.stringify(err)}`); + console.log(`sendUpdateCellLocationRequest failed, promise: err->${JSON.stringify(err)}`); }); ``` @@ -989,7 +989,7 @@ getCellInformation(callback: AsyncCallback>): void Obtains cell information. This API uses an asynchronous callback to return the result. -This is a system API. +**System API**: This is a system API. **Required permissions**: ohos.permission.LOCATION @@ -1016,7 +1016,7 @@ getCellInformation(slotId: number, callback: AsyncCallback\> Obtains cell information for the SIM card in the specified slot. This API uses a promise to return the result. -This is a system API. +**System API**: This is a system API. **Required permissions**: ohos.permission.LOCATION @@ -1071,7 +1071,7 @@ let promise = radio.getCellInformation(slotId); promise.then(data => { console.log(`getCellInformation success, promise: data->${JSON.stringify(data)}`); }).catch(err => { - console.error(`getCellInformation fail, promise: err->${JSON.stringify(err)}`); + console.error(`getCellInformation failed, promise: err->${JSON.stringify(err)}`); }); ``` @@ -1081,7 +1081,7 @@ setNetworkSelectionMode\(options: NetworkSelectionModeOptions, callback: AsyncCa Sets the network selection mode. This API uses an asynchronous callback to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.SET_TELEPHONY_STATE @@ -1120,7 +1120,7 @@ setNetworkSelectionMode\(options: NetworkSelectionModeOptions\): Promise Sets the network selection mode. This API uses a promise to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.SET_TELEPHONY_STATE @@ -1157,7 +1157,7 @@ let promise = radio.setNetworkSelectionMode(networkSelectionModeOptions); promise.then(data => { console.log(`setNetworkSelectionMode success, promise: data->${JSON.stringify(data)}`); }).catch(err => { - console.log(`setNetworkSelectionMode fail, promise: err->${JSON.stringify(err)}`); + console.log(`setNetworkSelectionMode failed, promise: err->${JSON.stringify(err)}`); }); ``` @@ -1167,7 +1167,7 @@ getNetworkSearchInformation\(slotId: number, callback: AsyncCallback Obtains network search information for the SIM card in the specified slot. This API uses a promise to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.GET_TELEPHONY_STATE @@ -1219,7 +1219,7 @@ let promise = radio.getNetworkSearchInformation(0); promise.then(data => { console.log(`getNetworkSearchInformation success, promise: data->${JSON.stringify(data)}`); }).catch(err => { - console.log(`getNetworkSearchInformation fail, promise: err->${JSON.stringify(err)}`); + console.log(`getNetworkSearchInformation failed, promise: err->${JSON.stringify(err)}`); }); ``` @@ -1229,7 +1229,7 @@ getNrOptionMode(callback: AsyncCallback): void Obtains the NR option mode. This API uses an asynchronous callback to return the result. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.CoreService @@ -1254,7 +1254,7 @@ getNrOptionMode(slotId: number, callback: AsyncCallback): void Obtains the NR option mode for the SIM card in the specified slot. This API uses an asynchronous callback to return the result. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.CoreService @@ -1281,7 +1281,7 @@ getNrOptionMode(slotId?: number): Promise Obtains the NR option mode for the SIM card in the specified slot. This API uses a promise to return the result. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.CoreService @@ -1305,7 +1305,7 @@ let promise = radio.getNrOptionMode(slotId); promise.then(data => { console.log(`getNrOptionMode success, promise: data->${JSON.stringify(data)}`); }).catch(err => { - console.error(`getNrOptionMode fail, promise: err->${JSON.stringify(err)}`); + console.error(`getNrOptionMode failed, promise: err->${JSON.stringify(err)}`); }); ``` @@ -1315,7 +1315,7 @@ turnOnRadio(callback: AsyncCallback): void Turns on the radio function. This API uses an asynchronous callback to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.SET_TELEPHONY_STATE @@ -1342,7 +1342,7 @@ turnOnRadio(slotId: number, callback: AsyncCallback): void Turns on the radio function for the SIM card in the specified slot. This API uses an asynchronous callback to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.SET_TELEPHONY_STATE @@ -1371,7 +1371,7 @@ turnOnRadio(slotId?: number): Promise Turns on the radio function for the SIM card in the specified slot. This API uses a promise to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.SET_TELEPHONY_STATE @@ -1397,7 +1397,7 @@ let promise = radio.turnOnRadio(slotId); promise.then(data => { console.log(`turnOnRadio success, promise: data->${JSON.stringify(data)}`); }).catch(err => { - console.error(`turnOnRadio fail, promise: err->${JSON.stringify(err)}`); + console.error(`turnOnRadio failed, promise: err->${JSON.stringify(err)}`); }); ``` @@ -1407,7 +1407,7 @@ turnOffRadio(callback: AsyncCallback): void Turns off the radio function. This API uses an asynchronous callback to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.SET_TELEPHONY_STATE @@ -1434,7 +1434,7 @@ turnOffRadio(slotId: number, callback: AsyncCallback): void Turns off the radio function for the SIM card in the specified slot. This API uses an asynchronous callback to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.SET_TELEPHONY_STATE @@ -1463,7 +1463,7 @@ turnOffRadio(slotId?: number): Promise Turns off the radio function for the SIM card in the specified slot. This API uses a promise to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.SET_TELEPHONY_STATE @@ -1489,7 +1489,7 @@ let promise = radio.turnOffRadio(slotId); promise.then(data => { console.log(`turnOffRadio success, promise: data->${JSON.stringify(data)}`); }).catch(err => { - console.error(`turnOffRadio fail, promise: err->${JSON.stringify(err)}`); + console.error(`turnOffRadio failed, promise: err->${JSON.stringify(err)}`); }); ``` @@ -1499,7 +1499,7 @@ setPreferredNetwork\(slotId: number, networkMode: PreferredNetworkMode, callback Sets the preferred network for the SIM card in the specified slot. This API uses an asynchronous callback to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.SET_TELEPHONY_STATE @@ -1527,7 +1527,7 @@ setPreferredNetwork(slotId: number, networkMode: PreferredNetworkMode): Promise< Sets the preferred network for the SIM card in the specified slot. This API uses a promise to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.SET_TELEPHONY_STATE @@ -1553,7 +1553,7 @@ let promise = radio.setPreferredNetwork(0, 1); promise.then(data => { console.log(`setPreferredNetwork success, promise: data->${JSON.stringify(data)}`); }).catch(err => { - console.log(`setPreferredNetwork fail, promise: err->${JSON.stringify(err)}`); + console.log(`setPreferredNetwork failed, promise: err->${JSON.stringify(err)}`); }); ``` @@ -1563,7 +1563,7 @@ getPreferredNetwork\(slotId: number, callback: AsyncCallback Obtains the preferred network for the SIM card in the specified slot. This API uses a promise to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.GET_TELEPHONY_STATE @@ -1615,7 +1615,7 @@ let promise = radio.getPreferredNetwork(0); promise.then(data => { console.log(`getPreferredNetwork success, promise: data->${JSON.stringify(data)}`); }).catch(err => { - console.log(`getPreferredNetwork fail, promise: err->${JSON.stringify(err)}`); + console.log(`getPreferredNetwork failed, promise: err->${JSON.stringify(err)}`); }); ``` @@ -1625,7 +1625,7 @@ getImsRegInfo(slotId: number, imsType: ImsServiceType, callback: AsyncCallback Obtains the IMS registration status of the specified IMS service type for the SIM card in the specified slot. This API uses a promise to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.GET_TELEPHONY_STATE @@ -1679,7 +1679,7 @@ let promise = radio.getImsRegInfo(0, 1); promise.then(data => { console.log(`getImsRegInfo success, promise: data->${JSON.stringify(data)}`); }).catch(err => { - console.log(`getImsRegInfo fail, promise: err->${JSON.stringify(err)}`); + console.log(`getImsRegInfo failed, promise: err->${JSON.stringify(err)}`); }); ``` @@ -1689,7 +1689,7 @@ on(type: 'imsRegStateChange', slotId: number, imsType: ImsServiceType, callback: Enables listening for **imsRegStateChange** events for the SIM card in the specified slot. This API uses an asynchronous callback to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.GET_TELEPHONY_STATE @@ -1718,7 +1718,7 @@ off(type: 'imsRegStateChange', slotId: number, imsType: ImsServiceType, callback Disables listening for **imsRegStateChange** events for the SIM card in the specified slot. This API uses an asynchronous callback to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.GET_TELEPHONY_STATE @@ -1857,7 +1857,7 @@ Enumerates network selection modes. Enumerates preferred network modes. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.CoreService @@ -1902,7 +1902,7 @@ This is a system API. Defines the cell information. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.CoreService @@ -1918,7 +1918,7 @@ This is a system API. Defines the CDMA cell information. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.CoreService @@ -1934,7 +1934,7 @@ This is a system API. Defines the GSM cell information. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.CoreService @@ -1951,7 +1951,7 @@ This is a system API. Defines the LTE cell information. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.CoreService @@ -1970,7 +1970,7 @@ This is a system API. Defines the NR cell information. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.CoreService @@ -1987,7 +1987,7 @@ This is a system API. Defines the TD-SCDMA cell information. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.CoreService @@ -2004,7 +2004,7 @@ This is a system API. Defines the WCDMA cell information. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.CoreService @@ -2021,7 +2021,7 @@ This is a system API. Enumerates NR selection modes. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.CoreService @@ -2036,7 +2036,7 @@ This is a system API. Defines the network search result. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.CoreService @@ -2049,7 +2049,7 @@ This is a system API. Defines the network information. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.CoreService @@ -2064,7 +2064,7 @@ This is a system API. Enumerates network information states. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.CoreService @@ -2079,7 +2079,7 @@ This is a system API. Defines the network selection mode. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.CoreService @@ -2094,7 +2094,7 @@ This is a system API. Enumerates IMS registration states. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.CoreService @@ -2107,7 +2107,7 @@ This is a system API. Enumerates IMS registration technologies. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.CoreService @@ -2122,7 +2122,7 @@ This is a system API. Defines the IMS registration information. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.CoreService @@ -2135,7 +2135,7 @@ This is a system API. Enumerates IMS service types. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.CoreService diff --git a/en/application-dev/reference/apis/js-apis-service-extension-context.md b/en/application-dev/reference/apis/js-apis-service-extension-context.md index 5a521ffca5fcefb393551effd6b02bc69a9d64aa..7ed184b2a61aaaf781a37b9137e8f510a2ffbc2f 100644 --- a/en/application-dev/reference/apis/js-apis-service-extension-context.md +++ b/en/application-dev/reference/apis/js-apis-service-extension-context.md @@ -724,15 +724,17 @@ Disconnects this ability from the Service ability. This API uses a promise to re startAbilityByCall(want: Want): Promise<Caller>; -Starts an ability in the background and obtains the caller interface for communication. +Starts an ability in the foreground or background and obtains the caller object for communicating with the ability. **System capability**: SystemCapability.Ability.AbilityRuntime.Core +**System API**: This is a system API and cannot be called by third-party applications. + **Parameters** | Name| Type| Mandatory| Description| | -------- | -------- | -------- | -------- | -| want | [Want](js-apis-application-Want.md) | Yes| Information about the target ability, including the ability name, module name, bundle name, and device ID. If the device ID is left blank or the default value is used, the local ability will be started.| +| want | [Want](js-apis-application-Want.md) | Yes| Information about the ability to start, including **abilityName**, **moduleName**, **bundleName**, **deviceId** (optional), and **parameters** (optional). If **deviceId** is left blank or null, the local ability is started. If **parameters** is left blank or null, the ability is started in the background.| **Return value** @@ -744,16 +746,38 @@ Starts an ability in the background and obtains the caller interface for communi ```js let caller = undefined; - this.context.startAbilityByCall({ + + // Start an ability in the background by not passing parameters. + var wantBackground = { bundleName: "com.example.myservice", moduleName: "entry", abilityName: "MainAbility", deviceId: "" - }).then((obj) => { - caller = obj; - console.log('Caller GetCaller Get ' + caller); - }).catch((e) => { - console.log('Caller GetCaller error ' + e); - }); + }; + this.context.startAbilityByCall(wantBackground) + .then((obj) => { + caller = obj; + console.log('GetCaller Success'); + }).catch((error) => { + console.log(`GetCaller failed with ${error}`); + }); + + // Start an ability in the foreground with ohos.aafwk.param.callAbilityToForeground in parameters set to true. + var wantForeground = { + bundleName: "com.example.myservice", + moduleName: "entry", + abilityName: "MainAbility", + deviceId: "", + parameters: { + "ohos.aafwk.param.callAbilityToForeground": true + } + }; + this.context.startAbilityByCall(wantForeground) + .then((obj) => { + caller = obj; + console.log('GetCaller success'); + }).catch((error) => { + console.log(`GetCaller failed with ${error}`); + }); ``` diff --git a/en/application-dev/reference/apis/js-apis-sim.md b/en/application-dev/reference/apis/js-apis-sim.md index f9475d2e7d76b6ccf20f6b0f32d01969fdccfbbb..a2d761225c3169bd6d9f5a7603232d4050c0342b 100644 --- a/en/application-dev/reference/apis/js-apis-sim.md +++ b/en/application-dev/reference/apis/js-apis-sim.md @@ -511,7 +511,7 @@ getSimAccountInfo(slotId: number, callback: AsyncCallback): voi Obtains account information of the SIM card in the specified slot. This API uses an asynchronous callback to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.GET_TELEPHONY_STATE @@ -539,7 +539,7 @@ getSimAccountInfo(slotId: number): Promise Obtains account information of the SIM card in the specified slot. This API uses a promise to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.GET_TELEPHONY_STATE @@ -574,7 +574,7 @@ getActiveSimAccountInfoList(callback: AsyncCallback>): vo Obtains the account information list of the active SIM card. This API uses an asynchronous callback to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.GET_TELEPHONY_STATE @@ -601,7 +601,7 @@ getActiveSimAccountInfoList(): Promise>; Obtains the account information list of the active SIM card. This API uses a promise to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.GET_TELEPHONY_STATE @@ -630,7 +630,7 @@ setDefaultVoiceSlotId(slotId: number, callback: AsyncCallback): void Sets the default slot ID of the SIM card that provides voice services. This API uses an asynchronous callback to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.SET_TELEPHONY_STATE @@ -658,7 +658,7 @@ setDefaultVoiceSlotId(slotId: number): Promise\ Sets the default slot ID of the SIM card that provides voice services. This API uses a promise to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.SET_TELEPHONY_STATE @@ -693,7 +693,7 @@ setShowName\(slotId: number, name: string,callback: AsyncCallback\): void Sets a display name for the SIM card in the specified slot. This API uses an asynchronous callback to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.SET_TELEPHONY_STATE @@ -722,7 +722,7 @@ setShowName\(slotId: number, name: string\): Promise\ Sets a display name for the SIM card in the specified slot. This API uses a promise to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.SET_TELEPHONY_STATE @@ -759,7 +759,7 @@ getShowName(slotId: number, callback: AsyncCallback): void Obtains the name of the SIM card in the specified slot. This API uses an asynchronous callback to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.GET_TELEPHONY_STATE @@ -787,7 +787,7 @@ getShowName(slotId: number): Promise Obtains the name of the SIM card in the specified slot. This API uses a promise to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.GET_TELEPHONY_STATE @@ -822,7 +822,7 @@ setShowNumber\(slotId: number, number: string,callback: AsyncCallback\): Sets a display number for the SIM card in the specified slot. This API uses an asynchronous callback to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.SET_TELEPHONY_STATE @@ -852,7 +852,7 @@ setShowNumber\(slotId: number,number: string\): Promise\ Sets a display number for the SIM card in the specified slot. This API uses a promise to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.SET_TELEPHONY_STATE @@ -889,7 +889,7 @@ getShowNumber(slotId: number,callback: AsyncCallback): void Obtains the display number of the SIM card in the specified slot. This API uses an asynchronous callback to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.GET_TELEPHONY_STATE @@ -917,7 +917,7 @@ getShowNumber(slotId: number): Promise Obtains the display number of the SIM card in the specified slot. This API uses a promise to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.GET_TELEPHONY_STATE @@ -952,7 +952,7 @@ activateSim(slotId: number, callback: AsyncCallback): void Activates the SIM card in the specified slot. This API uses an asynchronous callback to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.SET_TELEPHONY_STATE @@ -980,7 +980,7 @@ activateSim(slotId: number): Promise\ Activates the SIM card in the specified slot. This API uses a promise to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.SET_TELEPHONY_STATE @@ -1015,7 +1015,7 @@ deactivateSim(slotId: number, callback: AsyncCallback): void Deactivates the SIM card in the specified slot. This API uses an asynchronous callback to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.SET_TELEPHONY_STATE @@ -1043,7 +1043,7 @@ deactivateSim(slotId: number): Promise\ Deactivates the SIM card in the specified slot. This API uses a promise to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.SET_TELEPHONY_STATE @@ -1078,7 +1078,7 @@ setLockState(slotId: number, options: LockInfo, callback: AsyncCallback Sets the lock status of the SIM card in the specified slot. This API uses a promise to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.SET_TELEPHONY_STATE @@ -1153,7 +1153,7 @@ getLockState(slotId: number, lockType: LockType, callback: AsyncCallback Obtains the lock status of the SIM card in the specified slot. This API uses a promise to return the result. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.CoreService @@ -1214,7 +1214,7 @@ alterPin(slotId: number, newPin: string, oldPin: string, callback: AsyncCallback Changes the PIN of the SIM card in the specified slot. This API uses an asynchronous callback to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.SET_TELEPHONY_STATE @@ -1244,7 +1244,7 @@ alterPin(slotId: number, newPin: string, oldPin: string): Promise Unlocks the PIN of the SIM card in the specified slot. This API uses a promise to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.SET_TELEPHONY_STATE @@ -1415,7 +1415,7 @@ unlockPuk(slotId: number,newPin: string,puk: string ,callback: AsyncCallback Unlocks PIN 2 of the SIM card in the specified slot. This API uses a promise to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.SET_TELEPHONY_STATE @@ -1553,7 +1553,7 @@ unlockPuk2(slotId: number, newPin2: string, puk2: string, callback: AsyncCallbac Unlocks PUK 2 of the SIM card in the specified slot. This API uses an asynchronous callback to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.SET_TELEPHONY_STATE @@ -1585,7 +1585,7 @@ unlockPuk2(slotId: number, newPin2: string, puk2: string): Promise<LockStatus Unlocks PUK 2 of the SIM card in the specified slot. This API uses a promise to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.SET_TELEPHONY_STATE @@ -1644,7 +1644,7 @@ getSimIccId(slotId: number, callback: AsyncCallback): void Obtains the IC card identity (ICCID) of the SIM card in the specified slot. This API uses an asynchronous callback to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.GET_TELEPHONY_STATE @@ -1672,7 +1672,7 @@ getSimIccId(slotId: number): Promise Obtains the ICCID of the SIM card in the specified slot. This API uses a promise to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.GET_TELEPHONY_STATE @@ -1707,7 +1707,7 @@ getVoiceMailIdentifier(slotId: number, callback: AsyncCallback): void Obtains the voice mailbox alpha identifier of the SIM card in the specified slot. This API uses an asynchronous callback to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.GET_TELEPHONY_STATE @@ -1735,7 +1735,7 @@ getVoiceMailIdentifier(slotId: number): Promise Obtains the voice mailbox alpha identifier of the SIM card in the specified slot. This API uses a promise to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.GET_TELEPHONY_STATE @@ -1770,7 +1770,7 @@ getVoiceMailNumber(slotId: number, callback: AsyncCallback): void Obtains the voice mailbox number of the SIM card in the specified slot. This API uses an asynchronous callback to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.GET_TELEPHONY_STATE @@ -1798,7 +1798,7 @@ getVoiceMailNumber(slotId: number): Promise Obtains the voice mailbox number of the SIM card in the specified slot. This API uses a promise to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.GET_TELEPHONY_STATE @@ -1833,7 +1833,7 @@ setVoiceMailInfo(slotId: number, mailName: string, mailNumber: string, callback: Sets voice mailbox information for the SIM card in the specified slot. This API uses an asynchronous callback to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.SET_TELEPHONY_STATE @@ -1863,7 +1863,7 @@ setVoiceMailInfo(slotId: number, mailName: string, mailNumber: string): Promise< Sets voice mailbox information for the SIM card in the specified slot. This API uses a promise to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.SET_TELEPHONY_STATE @@ -1900,7 +1900,7 @@ getSimTelephoneNumber(slotId: number, callback: AsyncCallback): void Obtains the mobile subscriber ISDN number (MSISDN) of the SIM card in the specified slot. This API uses an asynchronous callback to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.GET_TELEPHONY_STATE @@ -1928,7 +1928,7 @@ getSimTelephoneNumber(slotId: number): Promise Obtains the MSISDN of the SIM card in the specified slot. This API uses a promise to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.GET_TELEPHONY_STATE @@ -1963,7 +1963,7 @@ getSimGid1(slotId: number, callback: AsyncCallback): void Obtains the group identifier level 1 (GID1) of the SIM card in the specified slot. This API uses an asynchronous callback to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.GET_TELEPHONY_STATE @@ -1991,7 +1991,7 @@ getSimGid1(slotId: number): Promise Obtains the GID1 of the SIM card in the specified slot. This API uses a promise to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.GET_TELEPHONY_STATE @@ -2026,7 +2026,7 @@ getIMSI(slotId: number, callback: AsyncCallback): void Obtains the international mobile subscriber identity (IMSI) of the SIM card in the specified slot. This API uses an asynchronous callback to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.GET_TELEPHONY_STATE @@ -2054,7 +2054,7 @@ getIMSI(slotId: number): Promise Obtains the IMSI of the SIM card in the specified slot. This API uses a promise to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.GET_TELEPHONY_STATE @@ -2089,7 +2089,7 @@ getOperatorConfigs(slotId: number, callback: AsyncCallback> Obtains the carrier configuration of the SIM card in the specified slot. This API uses a promise to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.GET_TELEPHONY_STATE @@ -2152,7 +2152,7 @@ queryIccDiallingNumbers(slotId: number, type: ContactType, callback: AsyncCallba Queries contact numbers of the SIM card in the specified slot. This API uses an asynchronous callback to return the result. -This is a system API. +**System API**: This is a system API. **Permission required**: ohos.permission.READ_CONTACTS @@ -2181,7 +2181,7 @@ queryIccDiallingNumbers(slotId: number, type: ContactType): Promise): vo Sends an envelope command to the SIM card in the specified slot. This API uses an asynchronous callback to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.SET_TELEPHONY_STATE @@ -2483,7 +2483,7 @@ sendEnvelopeCmd(slotId: number, cmd: string): Promise Sends an envelope command to the SIM card in the specified slot. This API uses a promise to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.SET_TELEPHONY_STATE @@ -2519,7 +2519,7 @@ sendTerminalResponseCmd(slotId: number, cmd: string, callback: AsyncCallback Sends a terminal response command to the SIM card in the specified slot. This API uses a promise to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.SET_TELEPHONY_STATE @@ -2584,7 +2584,7 @@ unlockSimLock(slotId: number, lockInfo: PersoLockInfo, callback: AsyncCallback): void Obtains the opkey of the SIM card in the specified slot. This API uses an asynchronous callback to return the result. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.CoreService @@ -2683,7 +2683,7 @@ getOpKey(slotId: number): Promise Obtains the opkey of the SIM card in the specified slot. This API uses a promise to return the result. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.CoreService @@ -2716,7 +2716,7 @@ getOpName(slotId: number, callback: AsyncCallback): void Obtains the OpName of the SIM card in the specified slot. This API uses an asynchronous callback to return the result. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.CoreService @@ -2742,7 +2742,7 @@ getOpName(slotId: number): Promise Obtains the OpName of the SIM card in the specified slot. This API uses a promise to return the result. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.CoreService @@ -2807,7 +2807,7 @@ Enumerates SIM card types. Enumerates lock types. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.CoreService @@ -2820,7 +2820,7 @@ This is a system API. Enumerates lock states. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.CoreService @@ -2833,7 +2833,7 @@ This is a system API. Enumerates personalized lock types. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.CoreService @@ -2854,7 +2854,7 @@ This is a system API. Defines the lock status response. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.CoreService @@ -2867,7 +2867,7 @@ This is a system API. Defines the lock information. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.CoreService @@ -2881,7 +2881,7 @@ This is a system API. Defines the personalized lock information. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.CoreService @@ -2894,7 +2894,7 @@ This is a system API. Defines the ICC account information. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.CoreService @@ -2912,7 +2912,7 @@ This is a system API. Defines the carrier configuration. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.CoreService @@ -2925,7 +2925,7 @@ This is a system API. Defines the contact number information. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.CoreService @@ -2940,7 +2940,7 @@ This is a system API. Enumerates contact types. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.CoreService diff --git a/en/application-dev/reference/apis/js-apis-sms.md b/en/application-dev/reference/apis/js-apis-sms.md index 9039fb774527e9ed6bbd43c95b0996afdc94780d..5443e18d1bd7e01ca1bbe74f62fdd9cce061e343 100644 --- a/en/application-dev/reference/apis/js-apis-sms.md +++ b/en/application-dev/reference/apis/js-apis-sms.md @@ -71,7 +71,7 @@ let promise = sms.createMessage(pdu, specification); promise.then(data => { console.log(`createMessage success, promise: data->${JSON.stringify(data)}`); }).catch(err => { - console.error(`createMessage fail, promise: err->${JSON.stringify(err)}`); + console.error(`createMessage failed, promise: err->${JSON.stringify(err)}`); }); ``` @@ -154,7 +154,7 @@ let promise = sms.getDefaultSmsSlotId(); promise.then(data => { console.log(`getDefaultSmsSlotId success, promise: data->${JSON.stringify(data)}`); }).catch(err => { - console.error(`getDefaultSmsSlotId fail, promise: err->${JSON.stringify(err)}`); + console.error(`getDefaultSmsSlotId failed, promise: err->${JSON.stringify(err)}`); }); ``` @@ -164,7 +164,7 @@ setDefaultSmsSlotId\(slotId: number,callback: AsyncCallback<void>\): void Sets the default slot of the SIM card used to send SMS messages. This API uses an asynchronous callback to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.SET_TELEPHONY_STATE @@ -192,7 +192,7 @@ setDefaultSmsSlotId\(slotId: number\): Promise<void> Sets the default slot of the SIM card used to send SMS messages. This API uses a promise to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.SET_TELEPHONY_STATE @@ -217,7 +217,7 @@ let promise = sms.setDefaultSmsSlotId(0); promise.then(data => { console.log(`setDefaultSmsSlotId success, promise: data->${JSON.stringify(data)}`); }).catch(err => { - console.error(`setDefaultSmsSlotId fail, promise: err->${JSON.stringify(err)}`); + console.error(`setDefaultSmsSlotId failed, promise: err->${JSON.stringify(err)}`); }); ``` @@ -227,7 +227,7 @@ setSmscAddr\(slotId: number, smscAddr: string, callback: AsyncCallback\): Sets the short message service center (SMSC) address. This API uses an asynchronous callback to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.SET_TELEPHONY_STATE (a system permission) @@ -258,7 +258,7 @@ setSmscAddr\(slotId: number, smscAddr: string\): Promise\ Sets the SMSC address. This API uses a promise to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.SET_TELEPHONY_STATE (a system permission) @@ -286,7 +286,7 @@ let promise = sms.setSmscAddr(slotId, smscAddr); promise.then(data => { console.log(`setSmscAddr success, promise: data->${JSON.stringify(data)}`); }).catch(err => { - console.error(`setSmscAddr fail, promise: err->${JSON.stringify(err)}`); + console.error(`setSmscAddr failed, promise: err->${JSON.stringify(err)}`); }); ``` @@ -297,7 +297,7 @@ getSmscAddr\(slotId: number, callback: AsyncCallback\): void Obtains the SMSC address. This API uses an asynchronous callback to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.GET_TELEPHONY_STATE (a system permission) @@ -326,7 +326,7 @@ getSmscAddr\(slotId: number\): Promise Obtains the SMSC address. This API uses a promise to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.GET_TELEPHONY_STATE (a system permission) @@ -352,7 +352,7 @@ let promise = sms.getSmscAddr(slotId); promise.then(data => { console.log(`getSmscAddr success, promise: data->${JSON.stringify(data)}`); }).catch(err => { - console.error(`getSmscAddr fail, promise: err->${JSON.stringify(err)}`); + console.error(`getSmscAddr failed, promise: err->${JSON.stringify(err)}`); }); ``` @@ -381,7 +381,7 @@ splitMessage(content: string, callback: AsyncCallback>): void Splits an SMS message into multiple segments. This API uses an asynchronous callback to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.SEND_MESSAGES @@ -410,7 +410,7 @@ splitMessage(content: string): Promise> Splits an SMS message into multiple segments. This API uses a promise to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.SEND_MESSAGES @@ -436,7 +436,7 @@ let promise = sms.splitMessage(content); promise.then(data => { console.log(`splitMessage success, promise: data->${JSON.stringify(data)}`); }).catch(err => { - console.error(`splitMessage fail, promise: err->${JSON.stringify(err)}`); + console.error(`splitMessage failed, promise: err->${JSON.stringify(err)}`); }); ``` @@ -446,7 +446,7 @@ addSimMessage(options: SimMessageOptions, callback: AsyncCallback): void Adds a SIM message. This API uses an asynchronous callback to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.RECEIVE_SMS,ohos.permission.SEND_MESSAGES @@ -480,7 +480,7 @@ addSimMessage(options: SimMessageOptions): Promise Adds a SIM message. This API uses a promise to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.RECEIVE_SMS,ohos.permission.SEND_MESSAGES @@ -511,7 +511,7 @@ let promise = sms.addSimMessage(simMessageOptions); promise.then(data => { console.log(`addSimMessage success, promise: data->${JSON.stringify(data)}`); }).catch(err => { - console.error(`addSimMessage fail, promise: err->${JSON.stringify(err)}`); + console.error(`addSimMessage failed, promise: err->${JSON.stringify(err)}`); }); ``` @@ -521,7 +521,7 @@ delSimMessage(slotId: number, msgIndex: number, callback: AsyncCallback): Deletes a SIM message. This API uses an asynchronous callback to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.RECEIVE_SMS,ohos.permission.SEND_MESSAGES @@ -552,7 +552,7 @@ delSimMessage(slotId: number, msgIndex: number): Promise Deletes a SIM message. This API uses a promise to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.RECEIVE_SMS,ohos.permission.SEND_MESSAGES @@ -580,7 +580,7 @@ let promise = sms.delSimMessage(slotId, msgIndex); promise.then(data => { console.log(`delSimMessage success, promise: data->${JSON.stringify(data)}`); }).catch(err => { - console.error(`delSimMessage fail, promise: err->${JSON.stringify(err)}`); + console.error(`delSimMessage failed, promise: err->${JSON.stringify(err)}`); }); ``` @@ -590,7 +590,7 @@ updateSimMessage(options: UpdateSimMessageOptions, callback: AsyncCallback Updates a SIM message. This API uses a promise to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.RECEIVE_SMS,ohos.permission.SEND_MESSAGES @@ -657,7 +657,7 @@ let promise = sms.updateSimMessage(updateSimMessageOptions); promise.then(data => { console.log(`updateSimMessage success, promise: data->${JSON.stringify(data)}`); }).catch(err => { - console.error(`updateSimMessage fail, promise: err->${JSON.stringify(err)}`); + console.error(`updateSimMessage failed, promise: err->${JSON.stringify(err)}`); }); ``` @@ -667,7 +667,7 @@ getAllSimMessages(slotId: number, callback: AsyncCallback> Obtains all SIM card messages. This API uses a promise to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.RECEIVE_SMS @@ -722,7 +722,7 @@ let promise = sms.getAllSimMessages(slotId); promise.then(data => { console.log(`getAllSimMessages success, promise: data->${JSON.stringify(data)}`); }).catch(err => { - console.error(`getAllSimMessages fail, promise: err->${JSON.stringify(err)}`); + console.error(`getAllSimMessages failed, promise: err->${JSON.stringify(err)}`); }); ``` @@ -732,7 +732,7 @@ setCBConfig(options: CBConfigOptions, callback: AsyncCallback): void Sets the cell broadcast configuration. This API uses an asynchronous callback to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.RECEIVE_SMS @@ -766,7 +766,7 @@ setCBConfig(options: CBConfigOptions): Promise Sets the cell broadcast configuration. This API uses a promise to return the result. -This is a system API. +**System API**: This is a system API. **Required permission**: ohos.permission.RECEIVE_SMS @@ -797,7 +797,7 @@ let promise = sms.setCBConfig(cbConfigOptions); promise.then(data => console.log(`setCBConfig success, promise: data->${JSON.stringify(data)}`); }).catch(err => { - console.error(`setCBConfig fail, promise: err->${JSON.stringify(err)}`); + console.error(`setCBConfig failed, promise: err->${JSON.stringify(err)}`); }); ``` @@ -807,7 +807,7 @@ getSmsSegmentsInfo(slotId: number, message: string, force7bit: boolean, callback Obtains SMS message segment information. This API uses an asynchronous callback to return the result. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.SmsMms @@ -836,7 +836,7 @@ getSmsSegmentsInfo(slotId: number, message: string, force7bit: boolean): Promise Obtains SMS message segment information. This API uses a promise to return the result. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.SmsMms @@ -862,7 +862,7 @@ let promise = sms.getSmsSegmentsInfo(slotId, "message", false); promise.then(data => console.log(`getSmsSegmentsInfo success, promise: data->${JSON.stringify(data)}`); }).catch(err => { - console.error(`getSmsSegmentsInfo fail, promise: err->${JSON.stringify(err)}`); + console.error(`getSmsSegmentsInfo failed, promise: err->${JSON.stringify(err)}`); }); ``` @@ -872,7 +872,7 @@ isImsSmsSupported(callback: AsyncCallback): void Checks whether SMS is supported on IMS. This API uses an asynchronous callback to return the result. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.SmsMms @@ -897,7 +897,7 @@ isImsSmsSupported(): Promise Checks whether SMS is supported on IMS. This API uses a promise to return the result. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.SmsMms @@ -914,7 +914,7 @@ let promise = sms.isImsSmsSupported(); promise.then(data => { console.log(`isImsSmsSupported success, promise: data->${JSON.stringify(data)}`); }).catch(err => { - console.error(`isImsSmsSupported fail, promise: err->${JSON.stringify(err)}`); + console.error(`isImsSmsSupported failed, promise: err->${JSON.stringify(err)}`); }); ``` @@ -924,7 +924,7 @@ getImsShortMessageFormat(callback: AsyncCallback): void Obtains the SMS format supported by the IMS. This API uses an asynchronous callback to return the result. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.SmsMms @@ -949,7 +949,7 @@ getImsShortMessageFormat(): Promise Obtains the SMS format supported by the IMS. This API uses a promise to return the result. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.SmsMms @@ -966,7 +966,7 @@ let promise = sms.getImsShortMessageFormat(); promise.then(data => { console.log(`getImsShortMessageFormat success, promise: data->${JSON.stringify(data)}`); }).catch(err => { - console.error(`getImsShortMessageFormat fail, promise: err->${JSON.stringify(err)}`); + console.error(`getImsShortMessageFormat failed, promise: err->${JSON.stringify(err)}`); }); ``` @@ -976,7 +976,7 @@ decodeMms(mmsFilePathName: string | Array, callback: AsyncCallback): Promise Decodes MMS messages. This API uses a promise to return the result. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.SmsMms @@ -1027,7 +1027,7 @@ let promise = sms.getSmscAddr(mmsFilePathName); promise.then(data => { console.log(`decodeMms success, promise: data->${JSON.stringify(data)}`); }).catch(err => { - console.error(`decodeMms fail, promise: err->${JSON.stringify(err)}`); + console.error(`decodeMms failed, promise: err->${JSON.stringify(err)}`); }); ``` @@ -1037,7 +1037,7 @@ encodeMms(mms: MmsInformation, callback: AsyncCallback>): void Encodes MMS messages. This API uses an asynchronous callback to return the result. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.SmsMms @@ -1072,7 +1072,7 @@ encodeMms(mms: MmsInformation): Promise> Encodes MMS messages. This API uses a promise to return the result. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.SmsMms @@ -1104,7 +1104,7 @@ let promise = sms.encodeMms(mmsInformation); promise.then(data => { console.log(`encodeMms success, promise: data->${JSON.stringify(data)}`); }).catch(err => { - console.error(`encodeMms fail, promise: err->${JSON.stringify(err)}`); + console.error(`encodeMms failed, promise: err->${JSON.stringify(err)}`); }); ``` @@ -1203,7 +1203,7 @@ Enumerates SMS message sending results. Defines the MMS message information. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.SmsMms @@ -1217,7 +1217,7 @@ This is a system API. Defines an MMS message sending request. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.SmsMms @@ -1243,7 +1243,7 @@ This is a system API. Defines the MMS message sending configuration. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.SmsMms @@ -1258,7 +1258,7 @@ This is a system API. Defines an MMS notification index. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.SmsMms @@ -1279,7 +1279,7 @@ This is a system API. Defines an MMS confirmation index. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.SmsMms @@ -1293,7 +1293,7 @@ This is a system API. Defines the MMS message retrieval configuration. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.SmsMms @@ -1318,7 +1318,7 @@ This is a system API. Defines the original MMS message reading index. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.SmsMms @@ -1336,7 +1336,7 @@ This is a system API. Defines the MMS message reading index. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.SmsMms @@ -1354,7 +1354,7 @@ This is a system API. Defines the attachment of an MMS message. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.SmsMms @@ -1375,7 +1375,7 @@ This is a system API. Defines an MMSC address. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.SmsMms @@ -1388,7 +1388,7 @@ This is a system API. Enumerates message types. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.SmsMms @@ -1408,7 +1408,7 @@ This is a system API. Enumerates MMS message priorities. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.SmsMms @@ -1422,7 +1422,7 @@ This is a system API. Enumerates MMS versions. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.SmsMms @@ -1437,7 +1437,7 @@ This is a system API. Enumerates MMS character sets. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.SmsMms @@ -1462,7 +1462,7 @@ This is a system API. Enumerates disposition types. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.SmsMms @@ -1476,7 +1476,7 @@ This is a system API. Enumerates report types. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.SmsMms @@ -1489,7 +1489,7 @@ This is a system API. Defines the cell broadcast configuration options. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.SmsMms @@ -1505,7 +1505,7 @@ This is a system API. Defines the SIM message status. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.SmsMms @@ -1521,7 +1521,7 @@ This is a system API. Enumerates RAN types. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.SmsMms @@ -1534,7 +1534,7 @@ This is a system API. Enumerates SMS encoding schemes. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.SmsMms @@ -1549,7 +1549,7 @@ This is a system API. Defines the SIM message options. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.SmsMms @@ -1564,7 +1564,7 @@ This is a system API. Defines the updating SIM message options. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.SmsMms @@ -1580,7 +1580,7 @@ This is a system API. Defines a SIM message. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.SmsMms @@ -1594,7 +1594,7 @@ This is a system API. Defines an MMS message delivery index. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.SmsMms @@ -1610,7 +1610,7 @@ This is a system API. Defines an MMS response index. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.SmsMms @@ -1625,7 +1625,7 @@ This is a system API. Defines the SMS message segment information. -This is a system API. +**System API**: This is a system API. **System capability**: SystemCapability.Telephony.SmsMms diff --git a/en/application-dev/security/accesstoken-guidelines.md b/en/application-dev/security/accesstoken-guidelines.md index 34cb80a01eef6521c327d848e02b1fb3d5325fd7..4349c32625fd1d28c230f6d60c2120641a6c7f33 100644 --- a/en/application-dev/security/accesstoken-guidelines.md +++ b/en/application-dev/security/accesstoken-guidelines.md @@ -123,7 +123,7 @@ In this example, declare the permission under the **acls** field: "allowed-acls": [ "ohos.permission.PERMISSION2" ] - }, + } } ``` diff --git a/en/application-dev/task-management/background-task-dev-guide.md b/en/application-dev/task-management/background-task-dev-guide.md index e820da263fb189ab9a2717c45a31a82d830a8cbc..6b01a096d29d9e6c96b2172f9fddadb7a7bb1801 100644 --- a/en/application-dev/task-management/background-task-dev-guide.md +++ b/en/application-dev/task-management/background-task-dev-guide.md @@ -265,7 +265,7 @@ import featureAbility from '@ohos.ability.featureAbility'; import wantAgent from '@ohos.wantAgent'; import rpc from "@ohos.rpc"; -function startBackgroundRunning() { +function startContinuousTask() { let wantAgentInfo = { // List of operations to be executed after the notification is clicked. wants: [ @@ -293,7 +293,7 @@ function startBackgroundRunning() { }); } -function stopBackgroundRunning() { +function stopContinuousTask() { backgroundTaskManager.stopBackgroundRunning(featureAbility.getContext()).then(() => { console.info("Operation stopBackgroundRunning succeeded"); }).catch((err) => { @@ -301,6 +301,13 @@ function stopBackgroundRunning() { }); } +async function processAsyncJobs() { + // Execute the continuous task. + + // After the continuous task is complete, call the API to release resources. + stopContinuousTask(); +} + let mMyStub; class MyStub extends rpc.RemoteObject { @@ -315,11 +322,11 @@ class MyStub extends rpc.RemoteObject { console.log('ServiceAbility onRemoteRequest called'); // The meaning of code is user-defined. if (code === 1) { - // Received the request code for requesting a continuous task. + // Receive the request code for requesting a continuous task. startContinuousTask(); // Execute the continuous task. } else if (code === 2) { - // Received the request code for canceling the continuous task. + // Receive the request code for canceling the continuous task. stopContinuousTask(); } else { console.log('ServiceAbility unknown request code'); @@ -332,9 +339,9 @@ export default { onStart(want) { console.info('ServiceAbility onStart'); mMyStub = new MyStub("ServiceAbility-test"); - startBackgroundRunning(); - // Execute a specific continuous task in the background. - stopBackgroundRunning(); + // Call the API to start the task. + startContinuousTask(); + processAsyncJobs(); }, onStop() { console.info('ServiceAbility onStop'); diff --git a/en/application-dev/windowmanager/application-window-fa.md b/en/application-dev/windowmanager/application-window-fa.md index 75b71275759c812aaf3c69707e07a4378ba7e333..082e6d32b5354eec0e020cbeed605b7a30e0d2c8 100644 --- a/en/application-dev/windowmanager/application-window-fa.md +++ b/en/application-dev/windowmanager/application-window-fa.md @@ -53,7 +53,7 @@ You can create a subwindow, such as a dialog box, and set its properties. ```js import window from '@ohos.window'; - var windowClass = null; + let windowClass = null; // 1. Method 1: Create a subwindow. window.create("subWindow", window.WindowType.TYPE_APP, (err, data) => { if (err.code) { @@ -86,7 +86,6 @@ You can create a subwindow, such as a dialog box, and set its properties. 2. Set the properties of the subwindow. After the subwindow is created, you can set its properties, such as the size, position, background color, and brightness. - ```js // 2. Move the subwindow. @@ -110,7 +109,6 @@ You can create a subwindow, such as a dialog box, and set its properties. 3. Load content for the subwindow and show it. Call `loadContent` and `show` to load and display the content in the subwindow. - ```js // 3. Load the page content to the subwindow. @@ -134,7 +132,6 @@ You can create a subwindow, such as a dialog box, and set its properties. 4. Destroy the subwindow. When the subwindow is no longer needed, you can call `destroy` to destroy it. - ```js // 4. Destroy the subwindow when a click event outside the window is detected. @@ -160,13 +157,16 @@ To create a better video watching and gaming experience, you can use the immersi 1. Obtain the main window. - The immersive window feature can be implemented only after the main window is obtained. You can call `window.getTopWindow` to obtain the main window. - + > **NOTE** + > + > The immersive window feature can be implemented only after the main window is obtained. + > + > Ensure that the top window of the application is the main window. You can use `window.getTopWindow` to obtain the main window. ```js import window from '@ohos.window'; - var mainWindowClass = null; + let mainWindowClass = null; // 1. Obtain the main window. window.getTopWindow((err, data) => { if (err.code) { @@ -186,7 +186,7 @@ To create a better video watching and gaming experience, you can use the immersi ```js // 2. Use method 1 to implement the immersive effect. - var isFullScreen = true; + let isFullScreen = true; mainWindowClass.setFullScreen(isFullScreen, (err, data) => { if (err.code) { console.error('Failed to enable the full-screen mode. Cause:' + JSON.stringify(err)); @@ -195,7 +195,7 @@ To create a better video watching and gaming experience, you can use the immersi console.info('Succeeded in enabling the full-screen mode. Data: ' + JSON.stringify(data)); }); // 2. Use method 2 to implement the immersive effect. - var names = []; + let names = []; mainWindowClass.setSystemBarEnable(names, (err, data) => { if (err.code) { console.error('Failed to set the system bar to be visible. Cause:' + JSON.stringify(err)); @@ -204,7 +204,7 @@ To create a better video watching and gaming experience, you can use the immersi console.info('Succeeded in setting the system bar to be visible. Data: ' + JSON.stringify(data)); }); // 2. Use method 3 to implement the immersive effect. - var isLayoutFullScreen = true; + let isLayoutFullScreen = true; mainWindowClass.setLayoutFullScreen(isLayoutFullScreen, (err, data) => { if (err.code) { console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err)); @@ -212,7 +212,7 @@ To create a better video watching and gaming experience, you can use the immersi } console.info('Succeeded in setting the window layout to full-screen mode. Data: ' + JSON.stringify(data)); }); - var SystemBarProperties = { + let sysBarProps = { statusBarColor: '#ff00ff', navigationBarColor: '#00ff00', // The following properties are supported since API version 7. @@ -222,7 +222,7 @@ To create a better video watching and gaming experience, you can use the immersi statusBarContentColor: '#ffffff', navigationBarContentColor: '#ffffff' }; - mainWindowClass.setSystemBarProperties(SystemBarProperties, (err, data) => { + mainWindowClass.setSystemBarProperties(sysBarProps, (err, data) => { if (err.code) { console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(err)); return; @@ -234,7 +234,6 @@ To create a better video watching and gaming experience, you can use the immersi 3. Load content for the immersive window and show it. Call `loadContent` and `show` to load and display the content in the immersive window. - ```js // 3. Load the page content to the immersive window. diff --git a/en/application-dev/windowmanager/application-window-stage.md b/en/application-dev/windowmanager/application-window-stage.md index f0598cf8bfb90fe275f8fa45fb759b7093be21e2..98ae7d7d708c91f0d2920da23143d79e382ac653 100644 --- a/en/application-dev/windowmanager/application-window-stage.md +++ b/en/application-dev/windowmanager/application-window-stage.md @@ -56,25 +56,21 @@ In the stage model, the main window of an application is created and maintained ### How to Develop 1. Obtain the main window. - Call `getMainWindow` to obtain the main window of the application. 2. Set the properties of the main window. - You can set multiple properties of the main window, such as the background color, brightness, and whether the main window is touchable. The code snippet below uses the `touchable` property as an example. 3. Load content for the main window. - Call `loadContent` to load the page content to the main window. - ```ts import Ability from '@ohos.application.Ability' class MainAbility extends Ability { onWindowStageCreate(windowStage) { // 1. Obtain the main window of the application. - var windowClass = null; + let windowClass = null; windowStage.getMainWindow((err, data) => { if (err.code) { console.error('Failed to obtain the main window. Cause: ' + JSON.stringify(err)); @@ -83,7 +79,7 @@ class MainAbility extends Ability { windowClass = data; console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data)); // 2. Set the touchable property of the main window. - var isTouchable = true; + let isTouchable = true; windowClass.setTouchable(isTouchable, (err, data) => { if (err.code) { console.error('Failed to set the window to be touchable. Cause:' + JSON.stringify(err)); @@ -113,31 +109,26 @@ You can create an application subwindow, such as a dialog box, and set its prope ### How to Develop 1. Create or obtain a subwindow. - Call `createSubWindow` to create a subwindow. - + Call `getSubWindow` to obtain a subwindow. 2. Set the properties of the subwindow. - After the subwindow is created, you can set its properties, such as the size, position, background color, and brightness. 3. Load content for the subwindow and show it. - Call `loadContent` and `show` to load and display the content in the subwindow. 4. Destroy the subwindow. - When the subwindow is no longer needed, you can call `destroy` to destroy it. - - + ```ts import Ability from '@ohos.application.Ability' class MainAbility extends Ability { onWindowStageCreate(windowStage) { // 1. Create a subwindow. - var sub_windowClass = null; + let sub_windowClass = null; windowStage.createSubWindow("mySubWindow", (err, data) => { if (err.code) { console.error('Failed to create the subwindow. Cause: ' + JSON.stringify(err)); @@ -210,7 +201,6 @@ To create a better video watching and gaming experience, you can use the immersi ### How to Develop 1. Obtain the main window. - Call `getMainWindow` to obtain the main window of the application. 2. Implement the immersive effect. You can use any of the following methods: @@ -219,17 +209,15 @@ To create a better video watching and gaming experience, you can use the immersi - Method 3: Call `setLayoutFullScreen` to enable the full-screen mode for the main window layout. Call `setSystemProperties` to set the opacity, background color, text color, and highlighted icon of the navigation bar and status bar to ensure that their display effect is consistent with that of the main window. 3. Load content for the immersive window and show it. - Call `loadContent` and `show` to load and display the content in the immersive window. - - + ```ts import Ability from '@ohos.application.Ability' class MainAbility extends Ability { onWindowStageCreate(windowStage) { // 1. Obtain the main window of the application. - var windowClass = null; + let windowClass = null; windowStage.getMainWindow((err, data) => { if (err.code) { console.error('Failed to obtain the main window. Cause: ' + JSON.stringify(err)); @@ -239,7 +227,7 @@ To create a better video watching and gaming experience, you can use the immersi console.info('Succeeded in obtaining the main window. Data: ' + JSON.stringify(data)); // 2. Use method 1 to implement the immersive effect. - var isFullScreen = true; + let isFullScreen = true; windowClass.setFullScreen(isFullScreen, (err, data) => { if (err.code) { console.error('Failed to enable the full-screen mode. Cause:' + JSON.stringify(err)); @@ -248,7 +236,7 @@ To create a better video watching and gaming experience, you can use the immersi console.info('Succeeded in enabling the full-screen mode. Data: ' + JSON.stringify(data)); }); // 2. Use method 2 to implement the immersive effect. - var names = []; + let names = []; windowClass.setSystemBarEnable(names, (err, data) => { if (err.code) { console.error('Failed to set the system bar to be visible. Cause:' + JSON.stringify(err)); @@ -257,7 +245,7 @@ To create a better video watching and gaming experience, you can use the immersi console.info('Succeeded in setting the system bar to be visible. Data: ' + JSON.stringify(data)); }); // 2. Use method 3 to implement the immersive effect. - var isLayoutFullScreen = true; + let isLayoutFullScreen = true; windowClass.setLayoutFullScreen(isLayoutFullScreen, (err, data) => { if (err.code) { console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err)); @@ -265,7 +253,7 @@ To create a better video watching and gaming experience, you can use the immersi } console.info('Succeeded in setting the window layout to full-screen mode. Data: ' + JSON.stringify(data)); }); - var SystemBarProperties = { + let sysBarProps = { statusBarColor: '#ff00ff', navigationBarColor: '#00ff00', // The following properties are supported since API version 7. @@ -275,7 +263,7 @@ To create a better video watching and gaming experience, you can use the immersi statusBarContentColor: '#ffffff', navigationBarContentColor: '#ffffff' }; - windowClass.setSystemBarProperties(SystemBarProperties, (err, data) => { + windowClass.setSystemBarProperties(sysBarProps, (err, data) => { if (err.code) { console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(err)); return; @@ -312,13 +300,10 @@ A floating window is created based on an existing task. It is always displayed i ### How to Develop 1. Apply for permissions. - To create a floating window (of the `WindowType.TYPE_FLOAT` type), you must configure the `ohos.permission.SYSTEM_FLOAT_WINDOW` permission in the `requestPermissions` field of the `module.json5` file. For details about the file, see [Application Package Structure Configuration File](../quick-start/stage-structure.md). > **NOTE** - > > If the task for creating the floating window is reclaimed by the system, the floating window will no longer be displayed. If you want the floating window to be displayed in such a case, apply for a [continuous task](../task-management/background-task-overview.md). - ```json { @@ -339,15 +324,12 @@ A floating window is created based on an existing task. It is always displayed i ``` 2. Create a floating window. - Call `window.create` to create a floating window. 3. Set properties for the floating window. - After the floating window is created, you can set its properties, such as the size, position, background color, and brightness. 4. Load content for the floating window and show it. - Call `loadContent` and `show` to load and display the content in the floating window. 5. Destroy the floating window. @@ -362,8 +344,8 @@ A floating window is created based on an existing task. It is always displayed i class MainAbility extends Ability { onWindowStageCreate(windowStage) { // 2. Create a floating window. - var windowClass = null; - window.create(this.context, "floatWindow", window.WindowType.TYPE_FlOAT, (err, data) => { + let windowClass = null; + window.create(this.context, "floatWindow", window.WindowType.TYPE_FLOAT, (err, data) => { if (err.code) { console.error('Failed to create the floatWindow. Cause: ' + JSON.stringify(err)); return; @@ -415,4 +397,4 @@ A floating window is created based on an existing task. It is always displayed i }); } }; - ``` \ No newline at end of file + ``` diff --git a/en/application-dev/windowmanager/system-window-stage.md b/en/application-dev/windowmanager/system-window-stage.md index 2bc119ddc5d8c63337b95ef72b25af2c93d7b281..d3870d665bb39be5c4b454f6fd5e10b189758ea0 100644 --- a/en/application-dev/windowmanager/system-window-stage.md +++ b/en/application-dev/windowmanager/system-window-stage.md @@ -11,7 +11,7 @@ For details, see [Window](../reference/apis/js-apis-window.md). | Instance| API| Description| | -------- | -------- | -------- | -| Window static method| create(ctx: Context, id: string, type: WindowType, callback: AsyncCallback<Window>): void | Creates a system window when `ctx` is [ServiceExtensionContext](../reference/apis/js-apis-service-extension-context.md).
-`ctx`: application context.
-`type`: window type. | +| Window static method| create(ctx: Context, id: string, type: WindowType, callback: AsyncCallback<Window>): void | Creates a system window when `ctx` is [ServiceExtensionContext](../reference/apis/js-apis-service-extension-context.md).
-`ctx`: application context.
-`type`: window type. | | Window | resetSize(width: number, height: number, callback: AsyncCallback<void>): void | Changes the window size.| | Window | moveTo(x: number, y: number, callback: AsyncCallback<void>): void | Moves this window.| | Window | loadContent(path: string, callback: AsyncCallback<void>): void | Loads the page content to this window.| @@ -47,14 +47,12 @@ This section uses the volume bar as an example to describe the steps for system import ExtensionContext from '@ohos.application.ServiceExtensionAbility'; import window from '@ohos.window'; -var windowClass = null; - export default class ServiceExtensionAbility1 extends ExtensionContext { onCreate(want) { console.log("[Demo] MainAbility onCreate") globalThis.abilityWant = want; // 1. Create a volume bar window. - var windowClass = null; + let windowClass = null; window.create(this.context, "volume", window.WindowType.TYPE_VOLUME_OVERLAY, (err, data) => { if (err.code) { console.error('Failed to create the volume window. Cause:' + JSON.stringify(err)); diff --git a/en/device-dev/subsystems/subsys-dfx-hisysevent-listening.md b/en/device-dev/subsystems/subsys-dfx-hisysevent-listening.md index ca5cdeb43229fda462a6b498d19563fcff88eaa7..6f131e191a5d4b4fa20beae01941c17f16b343f6 100644 --- a/en/device-dev/subsystems/subsys-dfx-hisysevent-listening.md +++ b/en/device-dev/subsystems/subsys-dfx-hisysevent-listening.md @@ -1,124 +1,159 @@ -# HiSysEvent Listening +# HiSysEvent Listening -## Overview -### Introduction +## Overview -HiSysEvent supports listening for events across processes. You can register a listener to listen for concerned events on a real-time basis. For example, you can enable the battery module to listen for power consumption events for power usage analysis. - -### Constraints - -Before subscribing to system events, you need to configure HiSysEvent logging. For details, see [HiSysEvent Logging Configuration](subsys-dfx-hisysevent-logging-config.md). - -## Development Guidelines - -### Available APIs - -**Table 1** Description of EventListener APIs -| Name| Description | -| -------- | --------- | -|int32_t HiSysEventManager::AddEventListener(std::shared_ptr<HiSysEventSubscribeCallBack> listener, std::vector<ListenerRule>& rules)|Registers a listener for system events. You can listen for certain events by specifying rules.

Input arguments:
  • **listener**: callback object for system events.
  • **rules**: rules for event listening.
Return value:
  • **0**: registration is successful.
  • Other values: Registration has failed.
| -|int32_t HiSysEventManager::RemoveListener(std::shared_ptr<HiSysEventSubscribeCallBack> listener)|Removes the listener for system events.

Input arguments:
  • **listener**: callback object for system events.
Return value:
  • **0**: Cancel registration is successful.
  • Other values: Cancel registration has failed.
| +### Introduction -**Table 2** Description of ListenerRule - -| API| Description | -| -------- | --------- | -|ListenerRule(const std::string& tag, RuleType ruleType = RuleType::WHOLE_WORD)|Constructor used to create a **ListenerRule** object based on the event tag.

Input arguments:
  • **tag**: indicates the event tag for the **ListenerRule** object. The value is a string of 1 to 16 characters, including uppercase letters, lowercase letters, and digits.
  • **ruleType**: indicates the type of the **ListenerRule** object. The value is an enum defined by **RuleType**.
| -|ListenerRule(const std::string& domain, const std::string& eventName, RuleType ruleType = RuleType::WHOLE_WORD)|Constructor used to create a **ListenerRule** object based on the event domain and event name.

Input arguments:
  • **domain**: indicates the event domain for the **ListenerRule** object. The value is a string of 1 to 16 characters, including uppercase letters, digits, and underscores (_).
  • **eventName**: indicates the event name for the **ListenerRule** object. The value is a string of 1 to 32 characters, including uppercase letters, digits, and underscores (_).
  • **ruleType**: indicates the type of the **ListenerRule** object. The value is an enum defined by **RuleType**.
| -|ListenerRule(const std::string& domain, const std::string& eventName, const std::string& tag, RuleType ruleType = RuleType::WHOLE_WORD)|Constructor used to create a **ListenerRule** object based on the event domain, event name, and event tag.

Input arguments:
  • **tag**: indicates the event tag for the **ListenerRule** object. The value is a string of 1 to 16 characters, including uppercase letters, lowercase letters, and digits.
  • **domain**: indicates the event domain for the **ListenerRule** object. The value is a string of 1 to 16 characters, including uppercase letters, digits, and underscores (_).
  • **eventName**: indicates the event name for the **ListenerRule** object. The value is a string of 1 to 32 characters, including uppercase letters, digits, and underscores (_).
  • **ruleType**: indicates the type of the **ListenerRule** object. The value is an enum defined by **RuleType**.
| - -**Table 3** Description of RuleType - -| Value | Description | -| ------------ | ------------- | -| WHOLE_WORD | Whole word matching | -| PREFIX | Prefix matching | -| REGULAR | Regular expression matching | - -**Table 4** Description of HiSysEventSubscribeCallBack - -| API| Description | -| -------- | --------- | -|void HiSysEventSubscribeCallBack::OnHandle(const std::string& domain, const std::string& eventName, const int eventType, const std::string& eventDetail)|Provides the callback of system events.

Input arguments:
  • **domain**: indicates the domain to which the event belongs.
  • **eventName**: indicates the event name.
  • **eventType**: indicates the event type.
  • **eventDetail**: indicates the event information, in JSON format.
Return value:
None.| +HiSysEvent supports listening for events across processes. You can register a listener to listen for concerned events on a real-time basis. For example, you can enable the battery module to listen for power consumption events for power usage analysis. -### Development Example -C++ +### Constraints -1. Develop the source code. +Before subscribing to system events, you need to configure HiSysEvent logging. For details, see [HiSysEvent Logging Configuration](../subsystems/subsys-dfx-hisysevent-logging-config.md). - Import the **DemoListener.h** header file, which contains the **DemoListener** class for implementing the custom event callback. - ``` - #ifndef DEMO_LISTENER_H - #define DEMO_LISTENER_H +## Development Guidelines - #include "hisysevent_subscribe_callback.h" - #include +### Available APIs - class DemoListener : public OHOS::HiviewDFX::HiSysEventSubscribeCallBack { - public: - explicit DemoListener() : HiSysEventSubscribeCallBack() {} - void OnHandle(const std::string& domain, const std::string& eventName, const int eventType, - const std::string& eventDetail); - virtual ~DemoListener() {} - void OnServiceDied(); - }; + **Table 1** Description of HiSysEventListener APIs - #endif // DEMO_LISTENER_H - ``` +| API| Description| +| -------- | -------- | +| int32_t HiSysEventManager::AddListener(std::shared_ptr<HiSysEventListener> listener, std::vector<ListenerRule>& rules) | Registers a listener for system events. You can listen for certain events by specifying rules.
Input arguments:
- **listener**: callback object for system events.
- **rules**: rules for event listening.
Return value:
- **0**: Registration is successful.
- A negative value: Registration has failed.| +| int32_t HiSysEventManager::RemoveListener(std::shared_ptr<HiSysEventListener> listener) | Removes the listener for system events.
Input arguments:
- **listener**: callback object for system events.
Return value:
- **0**: Canceling registration is successful.
- A negative value: Canceling registration has failed. | - Create the **DemoListener.cpp** file, and add the implementation logic of the custom event callback API in the **DemoListener** class. + **Table 2** Description of ListenerRule - ``` - #include "demo_listener.h" +| API| Description| +| -------- | -------- | +| ListenerRule(const std::string& tag, RuleType ruleType = RuleType::WHOLE_WORD) | Constructor used to create a **ListenerRule** object based on the event tag.
Input arguments:
- **tag**: event tag for the **ListenerRule** object. The value is a string of 1 to 16 characters, including uppercase letters, lowercase letters, and digits.
- **ruleType**: type of the **ListenerRule** object. The value is an enum defined by **RuleType**.| +| ListenerRule(const std::string& domain, const std::string& eventName, RuleType ruleType = RuleType::WHOLE_WORD) | Constructor used to create a **ListenerRule** object based on the event domain and event name.
Input arguments:
- **domain**: event domain for the **ListenerRule** object. The value is a string of 1 to 16 characters, including uppercase letters, digits, and underscores.
- **eventName**: event name for the **ListenerRule** object. The value is a string of 1 to 32 characters, including uppercase letters, digits, and underscores.
- **ruleType**: type of the **ListenerRule** object. The value is an enum defined by **RuleType**.| +| ListenerRule(const std::string& domain, const std::string& eventName, const std::string& tag, RuleType ruleType = RuleType::WHOLE_WORD) | Constructor used to create a **ListenerRule** object based on the event domain, event name, and event tag.
Input arguments:
- **tag**: event tag for the **ListenerRule** object. The value is a string of 1 to 16 characters, including uppercase letters, lowercase letters, and digits.
- **domain**: event domain for the **ListenerRule** object. The value is a string of 1 to 16 characters, including uppercase letters, digits, and underscores.
- **eventName**: event name for the **ListenerRule** object. The value is a string of 1 to 32 characters, including uppercase letters, digits, and underscores.
- **ruleType**: type of the **ListenerRule** object. The value is an enum defined by **RuleType**.| - #include + **Table 3** Description of RuleType - void DemoListener::OnHandle(const std::string& domain, const std::string& eventName, - const int eventType, const std::string& eventDetail) - { - std::cout << eventDetail << std::endl; - } +| Value| Description| +| -------- | -------- | +| WHOLE_WORD | Whole word matching| +| PREFIX | Prefix matching| +| REGULAR | Regular expression matching| - void DemoListener::OnServiceDied() - { - std::cout << std::string("service disconnect, exit") << std::endl; - exit(0); - } - ``` + **Table 4** Description of HiSysEventListener - Call the **AddEventListener** API of the **HiSysEventManager** class to add a listener for system events. +| API| Description| +| -------- | -------- | +| void HiSysEventListener::OnEvent(std::shared_ptr<HiSysEventRecord> sysEvent) | Callback object for system events.
Input arguments:
- **sysEvent**: real-time system events.
Return value:
None.| +| void HiSysEventListener::OnServiceDied() | Callback object for service exceptions.
Input arguments:
None.
Return value:
None.| - ``` - std::shared_ptr demoListener = nullptr; - try { - demoListener = std::make_shared(); - } catch(...) { - // Catch exception thrown by make_shared - } - if (demoListener != nullptr) { - // Add a ListenerRule object based on the event tag, with RuleType left unspecified (in this case, ruleType is defaulted to WHOLE_WORD). - ListenerRule tagRule("dfx"); - // Add a ListenerRule object based on the event tag, with RuleType set as REGULAR. - ListenerRule regRule("dfx.*", RuleType::REGULAR); - // Add a ListenerRule object based on the event domain and event name, with RuleType set as PREFIX. - ListenerRule domainNameRule("HIVIEWDFX", "APP_USAGE", RuleType::PREFIX); - std::vector sysRules; - sysRules.push_back(tagRule); - sysRules.push_back(regRule); - sysRules.push_back(domainNameRule); - HiSysEventManager::AddEventListener(demoListener, sysRules); - } - ``` - -2. Configure the **BUILD.gn** file. - - In the **BUILD.gn** file, add the **libhisyseventmanager** library that depends on the **hisysevent\_native** component. - - ``` - external_deps = [ "hisysevent_native:libhisyseventmanager", ] - ``` +**Table 5** Description of HiSysEventRecord +| API| Description| +| -------- | -------- | +|std::string HiSysEventRecord::AsJson()|Obtains the content of a system event.
Input arguments:
None.
Return value:
Content of the system event.| +|std::string HiSysEventRecord::GetDomain()|Obtains the domain name of a system event.
Input arguments:
None.
Return value:
Domain name of the system event.| +|std::string HiSysEventRecord::GetEventName()|Obtains the name of a system event.
Input arguments:
None.
Return value:
Name of the system event.| +|HiSysEvent::EventType HiSysEventRecord::GetEventType()|Obtains the type of a system event.
Input arguments:
None.
Return value:
Type of the system event.| +|std::string HiSysEventRecord::GetLevel()|Obtains the level of a system event.
Input arguments:
None.
Return value:
Level of the system event.| +|std::string HiSysEventRecord::GetTag()|Obtains the tag of a system event.
Input arguments:
None.
Return value:
Tag of the system event.| +|std::string HiSysEventRecord::GetTimeZone()|Obtains the time zone of a system event.
Input arguments:
None.
Return value:
Time zone, in the format of **+0800**.| +|int HiSysEventRecord::GetTraceFlag()|Obtains the distributed call chain tracing flag of a system event.
Input arguments:
None.
Return value:
Distributed call chain tracing flag.| +|int64_t HiSysEventRecord::GetPid()|Obtains the ID of the process that flushes a system event to the disk.
Input arguments:
None.
Return value:
Process ID.| +|int64_t HiSysEventRecord::GetTid()|Obtains the thread ID of the process that flushes a system event to the disk.
Input arguments:
None.
Return value:
Thread ID.| +|int64_t HiSysEventRecord::GetUid()|Obtains the user ID of the process that flushes a system event to the disk.
Input arguments:
None.
Return value:
User ID.| +|uint64_t HiSysEventRecord::GetPspanId()|Obtains the parent span ID of the distributed call chain tracing task.
Input arguments:
None.
Return value:
Parent span ID of the distributed call chain tracing task.| +|uint64_t HiSysEventRecord::GetSpandId()|Obtains the span ID of the distributed call chain tracing task.
Input arguments:
None.
Return value:
Span ID of the distributed call chain tracing task.| +|uint64_t HiSysEventRecord::GetTime()|Obtains the timestamp of a system event.
Input arguments:
None.
Return value:
Timestamp of the system event.| +|uint64_t HiSysEventRecord::GetTraceId()|Obtains the ID of the distributed call chain tracing task.
Input arguments:
None.
Return value:
ID of the distributed call chain tracing task.| +|void HiSysEventRecord::GetParamNames(std::vector<std::string>& params)|Obtains all key names of a system event.
Input arguments:
- **params**: key name array reference.
Return value:
None.| +|int HiSysEventRecord::GetParamValue(const std::string& param, int64_t& value)|Parses the value of the **param** key in a system event into an int64\_t value.
Input arguments:
- **param**: key name.
- **value**: int64\_t reference.
Return value:
- **0**: Parsing is successful.
- **-1**: Parsing failed due to initialization error.
- **-2**: Parsing failed due to nonexistent key name.
- **-3**: Parsing failed due to type mismatch.| +|int HiSysEventRecord::GetParamValue(const std::string& param, uint64_t& value)|Parses the value of the **param** key in a system event into a uint64\_t value.
Input arguments:
- **param**: key name.
- **value**: uint64\_t reference.
Return value:
- **0**: Parsing is successful.
- **-1**: Parsing failed due to initialization error.
- **-2**: Parsing failed due to nonexistent key name.
- **-3**: Parsing failed due to type mismatch.| +|int HiSysEventRecord::GetParamValue(const std::string& param, double& value)|Parses the value of the **param** key in a system event into a double value.
Input arguments:
- **param**: key name.
- **value**: double reference.
Return value:
- **0**: Parsing is successful.
- **-1**: Parsing failed due to initialization error.
- **-2**: Parsing failed due to nonexistent key name.
- **-3**: Parsing failed due to type mismatch.| +|int HiSysEventRecord::GetParamValue(const std::string& param, std::string& value)|Parses the value of the **param** key in a system event into a string value.
Input arguments:
- **param**: key name.
- **value**: std::string reference.
Return value:
- **0**: Parsing is successful.
- **-1**: Parsing failed due to initialization error.
- **-2**: Parsing failed due to nonexistent key name.
- **-3**: Parsing failed due to type mismatch.| +|int HiSysEventRecord::GetParamValue(const std::string& param, std::vector<int64_t>& value)|Parses the value of the **param** key in a system event into an int64\_t array.
Input arguments:
- **param**: key name.
- **value**: int64\_t array reference.
Return value:
- **0**: Parsing is successful.
- **-1**: Parsing failed due to initialization error.
- **-2**: Parsing failed due to nonexistent key name.
- **-3**: Parsing failed due to type mismatch.| +|int HiSysEventRecord::GetParamValue(const std::string& param, std::vector<uint64_t>& value)|Parses the value of the **param** key in a system event into a uint64\_t array.
Input arguments:
- **param**: key name.
- **value**: uint64\_t array reference.
Return value:
- **0**: Parsing is successful.
- **-1**: Parsing failed due to initialization error.
- **-2**: Parsing failed due to nonexistent key name.
- **-3**: Parsing failed due to type mismatch.| +|int HiSysEventRecord::GetParamValue(const std::string& param, std::vector<double>& value)|Parses the value of the **param** key in a system event into a double array.
Input arguments:
- **param**: key name.
- **value**: double array reference.
Return value:
- **0**: Parsing is successful.
- **-1**: Parsing failed due to initialization error.
- **-2**: Parsing failed due to nonexistent key name.
- **-3**: Parsing failed due to type mismatch.| +|int HiSysEventRecord::GetParamValue(const std::string& param, std::vector<std::string>& value)|Parses the value of the **param** key in a system event into a string array.
Input arguments:
- **param**: key name.
- **value**: std::string array reference.
Return value:
- **0**: Parsing is successful.
- **-1**: Parsing failed due to initialization error.
- **-2**: Parsing failed due to nonexistent key name.
- **-3**: Parsing failed due to type mismatch.| + + +## How to Develop + + +### **C++** + +The following provides an example of how to use C++ APIs of **HiSysEvent**. + +1. Develop the source code. + Import the **DemoListener.h** header file, which contains the **DemoListener** class for implementing the custom event callback. + + ``` + #ifndef DEMO_LISTENER_H + #define DEMO_LISTENER_H + + #include "hisysevent_listener.h" + + #include + + class DemoListener : public OHOS::HiviewDFX::HiSysEventListener { + public: + explicit DemoListener() : HiSysEventListener() {} + virtual ~DemoListener() {} + + public: + void OnEvent(std::shared_ptr sysEvent); + void OnServiceDied(); + }; + + #endif // DEMO_LISTENER_H + ``` + + Create the **DemoListener.cpp** file, and add the implementation logic of the custom event callback API in the **DemoListener** class. + + ``` + #include "demo_listener.h" + + #include + + void DemoListener::OnEvent(std::shared_ptr sysEvent) + { + if (sysEvent == nullptr) { + return; + } + std::cout << sysEvent.AsJson() << std::endl; + } + + void DemoListener::OnServiceDied() + { + std::cout << std::string("service disconnect, exit") << std::endl; + exit(0); + } + ``` + + Call the **AddEventListener** API of the **HiSysEventManager** class to add a listener for system events. + + ``` + auto demoListener = std::make_shared(); + // Add a ListenerRule object based on the event tag, with RuleType left unspecified (in this case, ruleType is defaulted to WHOLE_WORD). + ListenerRule tagRule("dfx"); + // Add a ListenerRule object based on the event tag, with RuleType set as REGULAR. + ListenerRule regRule("dfx.*", RuleType::REGULAR); + // Add a ListenerRule object based on the event domain and event name, with RuleType set as PREFIX. + ListenerRule domainNameRule("HIVIEWDFX", "APP_USAGE", RuleType::PREFIX); + std::vector sysRules; + sysRules.push_back(tagRule); + sysRules.push_back(regRule); + sysRules.push_back(domainNameRule); + HiSysEventManager::AddEventListener(demoListener, sysRules); + ``` + +2. Configure the **BUILD.gn** file. + In the **BUILD.gn** file, add the **libhisysevent** and **libhisyseventmanager** libraries that depend on the **hisysevent_native** component. + + ``` + external_deps = [ + "hisysevent_native:libhisysevent", + "hisysevent_native:libhisyseventmanager", + ] + ``` diff --git a/en/device-dev/subsystems/subsys-dfx-hisysevent-query.md b/en/device-dev/subsystems/subsys-dfx-hisysevent-query.md index f9ffdfd5983a14da9a8c2b834869fd70a501d666..efd82769f4b5f0c093a3d73a9910ac21dac1c48e 100644 --- a/en/device-dev/subsystems/subsys-dfx-hisysevent-query.md +++ b/en/device-dev/subsystems/subsys-dfx-hisysevent-query.md @@ -1,103 +1,111 @@ -# HiSysEvent Query +# HiSysEvent Query -## Overview -HiSysEvent provides an API for you to query system events. You can query concerned events by specifying search criteria. For example, for a power consumption module, you can query required system events for analysis. +## Overview -## Development Guidelines +HiSysEvent allows you to query system events by specifying search criteria. For example, for a power consumption module, you can query required system events for analysis. -### Available APIs -**Table 1** Description of the HiSysEvent query API +## Development Guidelines -| Name| Description | -| -------- | --------- | -| int32_t HiSysEventManager::QueryHiSysEvent(struct QueryArg& queryArg, std::vector<QueryRule>& queryRules, std::shared_ptr<HiSysEventQueryCallBack> queryCallBack) | Queries system events by specifying search criteria such as the time segment, event domain, and event name.

Input arguments:
  • **queryArg**: event query parameter.
  • **queryRules**: event filtering rules.
  • **queryRules**: callback object for query results.
Return value:
  • **0**: The query is successful.
  • Other values: The query has failed.
| +### Available APIs -**Table 2** Description of QueryArg +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> +> For details about the **HiSysEventRecord** argument in the **OnQuery()** method of **HiSysEventQueryCallback**, see Table 5 in [HiSysEvent Listening](subsys-dfx-hisysevent-listening.md). -| Attribute| Description | -| -------- | --------- | -| beginTime | Start time, in the **long long int** format.| -| endTime | End time, in the **long long int** format.| -| maxEvents | Maximum number of returned events, in the **int** format.| - -**Table 3** Description of QueryRule - -| API| Description | -| -------- | --------- | -| QueryRule(const std::string& domain, const std::vector<std::string>& eventList) | Constructor used to create a **QueryRule** object.

Input arguments:
  • **domain: domain to which the event of the **QueryRule** object belongs, in the **string** format. By default, an empty string indicates that the domain is successfully matched.
  • **eventList**: event name list, in the **std::vector<std::string>** format. By default, an empty string indicates that the event names on the list are successfully matched.
| - -**Table 4** Description of HiSysEventQueryCallBack - -| API| Description | -| -------- | --------- | -| void HiSysEventQueryCallBack::OnQuery(const ::std::vector<std::string>& sysEvent, const ::std::vector<int64_t>& seq) | Callback object for event query.

Input arguments:
  • **sysEvent**: event set.
  • **seq**: event sequence set.
Return value:
None.| -| void HiSysEventQueryCallBack::OnComplete(int32_t reason, int32_t total) | Callback object for completion of event query.

Input arguments:
  • **reason**: reason for completion of event query. The default value is **0**.
  • **total**: total number of events returned in this query.
Return value:
None.| - -### Development Example - -C++ - -1. Develop the source code. - - - Import the corresponding header file: + **Table 1** Description of the HiSysEvent query API - hisysevent\_manager.h +| API| Description| +| -------- | -------- | +| int32_t HiSysEventManager::Query(struct QueryArg& arg, std::vector<QueryRule>& rules, std::shared_ptr<HiSysEventQueryCallback> callback) | Queries system events by specifying search criteria such as the time segment, event domain, and event name.
Input arguments:
- **arg**: event query parameter.
- **rules**: rules for event filtering.
- **callback**: callback object for event query.
Return value:
- **0**: Query is successful.
- A negative value: Query has failed.| - - Implement the callback API. + **Table 2** Description of QueryArg - void HiSysEventQueryCallBack::OnQuery\(const ::std::vector<std::string>& sysEvent, const ::std::vector& seq\) - - void HiSysEventQueryCallBack::OnComplete\(int32\_t reason, int32\_t total\) - - - Invoke the query API in the corresponding service logic. - - HiSysEventManager::QueryHiSysEvent\(struct QueryArg& queryArg, std::vector& queryRules, std::shared\_ptr queryCallBack\) - - - ``` - // In this example, you'll query all system events. - #include "hisysevent_manager.h" - #include - - namespace OHOS { - namespace HiviewDFX { - // Implement the query callback API. - void HiSysEventToolQuery::OnQuery(const ::std::vector& sysEvent, - const ::std::vector& seq) - { - for_each(sysEvent.cbegin(), sysEvent.cend(), [](const std::string &tmp) { - std::cout << tmp << std::endl; - }); - } - - void HiSysEventToolQuery::OnComplete(int32_t reason, int32_t total) - { - return; - } - } // namespace HiviewDFX - } // namespace OHOS - - // Invoke the query callback API to obtain system events. - std::shared_ptr queryCallBack = nullptr; - try { - queryCallBack = std::make_shared(); - } catch(...) { - // Catch exception thrown by make_shared - } - if (queryCallBack != nullptr) { - struct QueryArg args(clientCmdArg.beginTime, clientCmdArg.endTime, clientCmdArg.maxEvents); - std::vector rules; - HiSysEventManager::QueryHiSysEvent(args, rules, queryCallBack); - } - ``` - -2. Modify the **BUILD.gn** file. - - In the **BUILD.gn** file, add the **libhisyseventmanager** library that depends on the **hisysevent\_native** component. +| Attribute| Description| +| -------- | -------- | +| beginTime | Start time, in the **long long int** format.| +| endTime | End time, in the **long long int** format.| +| maxEvents | Maximum number of returned events, in the **int** format.| - ``` - external_deps = [ "hisysevent_native:libhisyseventmanager", ] - ``` + **Table 3** Description of QueryRule + +| API| Description| +| -------- | -------- | +| QueryRule(const std::string& domain, const std::vector<std::string>& eventList) | Constructor used to create a **QueryRule** object.
Input arguments:
- **domain**: domain to which the event of the **QueryRule** object belongs, in the string format. By default, an empty string indicates that the domain is successfully matched.
- **eventList**: event name list, in the **std::vector<std::string>** format. By default, an empty string indicates that the event names on the list are successfully matched.| + + **Table 4** Description of HiSysEventQueryCallback + +| API| Description| +| -------- | -------- | +| void HiSysEventQueryCallback::OnQuery(std::shared_ptr<std::vector<HiSysEventRecord>> sysEvents) | Callback object for event query.
Input arguments:
- **sysEvents**: event list.
Return value:
None.| +| void HiSysEventQueryCallback::OnComplete(int32_t reason, int32_t total) | Callback object for completion of event query.
Input arguments:
- **reason**: reason for completion of event query. The default value is **0**.
- **total**: total number of events returned in this query.
Return value:
None.| + +### How to Develop + +**C++** + +1. Develop the source code. + Import the corresponding header file: + + ``` + #include "hisysevent_manager.h" + ``` + + Implement the callback API. + + ``` + void HiSysEventQueryCallback::OnQuery(std::shared_ptr> sysEvents) + void HiSysEventQueryCallback::OnComplete(int32_t reason, int32_t total) + ``` + + Invoke the query API in the corresponding service logic. + + ``` + HiSysEventManager::Query(struct QueryArg& queryArg, + std::vector& queryRules, std::shared_ptr queryCallBack) + ``` + + In this example, you'll query all system events. + + ``` + #include "hisysevent_manager.h" + #include + + namespace OHOS { + namespace HiviewDFX { + // Implement the query callback API. + void HiSysEventToolQuery::OnQuery(std::shared_ptr> sysEvents) + { + if (sysEvents == nullptr) { + return; + } + for_each((*sysEvents).cbegin(), (*sysEvents).cend(), [](const HiSysEventRecord& event) { + std::cout << event.AsJson() << std::endl; + }); + } + + void HiSysEventToolQuery::OnComplete(int32_t reason, int32_t total) + { + return; + } + } // namespace HiviewDFX + } // namespace OHOS + + // Invoke the query callback API to obtain system events. + auto queryCallBack = std::make_shared(); + struct QueryArg args(clientCmdArg.beginTime, clientCmdArg.endTime, clientCmdArg.maxEvents); + std::vector rules; + HiSysEventManager::QueryHiSysEvent(args, rules, queryCallBack); + ``` + +2. Modify the **BUILD.gn** file. + In the **BUILD.gn** file, add the **libhisysevent** and **libhisyseventmanager** libraries that depend on the **hisysevent_native** component. + + ``` + external_deps = [ + "hisysevent_native:libhisysevent", + "hisysevent_native:libhisyseventmanager", + ] + ``` diff --git a/en/device-dev/subsystems/subsys-dfx-hisysevent-tool.md b/en/device-dev/subsystems/subsys-dfx-hisysevent-tool.md index 15fd6220152829b8e8ca6f62551caa25d8a9e088..4dccc4dbf082cc1121443c00adbef531b2b5ed23 100644 --- a/en/device-dev/subsystems/subsys-dfx-hisysevent-tool.md +++ b/en/device-dev/subsystems/subsys-dfx-hisysevent-tool.md @@ -17,7 +17,7 @@ The HiSysEvent tool is a command line tool preconfigured in the **/system/bin** | Option| Description| | -------- | -------- | - | -r | Subscribes to real-time system events based on the default settings. When this option is specified, any real-time system event will be printed on the console.| + | -r | Subscription to real-time system events based on the default settings. When this option is specified, any real-time system event will be printed on the console.| - Command for enabling the debugging mode: @@ -29,7 +29,7 @@ The HiSysEvent tool is a command line tool preconfigured in the **/system/bin** | Option| Description| | -------- | -------- | - | -d | Subscribes to real-time system events in debugging mode.| + | -d | Subscription to real-time system events in debugging mode.| - Command for subscribing to real-time system events by event tag: @@ -96,7 +96,7 @@ The HiSysEvent tool is a command line tool preconfigured in the **/system/bin** | Option| Description| | -------- | -------- | - | -l | Queries historical system events based on the default settings. A maximum of 1,000 latest system events will be returned.| + | -l | Query of historical system events based on the default settings. A maximum of 10,000 system events will be returned.| - Command for querying historical system events within the specified period of time: @@ -130,7 +130,7 @@ The HiSysEvent tool is a command line tool preconfigured in the **/system/bin** | Option| Description| | -------- | -------- | - | -m | Maximum number of historical system events that can be queried. The value ranges from **0** to **1000**. The number of returned system events is not more than the value of this parameter.| + | -m | Maximum number of historical system events that can be queried. The number of returned system events is not more than the value of this parameter.| Example: @@ -151,7 +151,7 @@ The HiSysEvent tool is a command line tool preconfigured in the **/system/bin** | Option| Description| | -------- | -------- | - | -v | Used with the subscription command **-r** and query command **-l**. If system event validity check is enabled, invalid content contained in system events will be highlighted in red.| + | -v | Used with the **-r** and **-l** commands. If system event validity check is enabled, invalid content contained in system events will be highlighted in red.| Example: diff --git a/en/readme/Security.md b/en/readme/Security.md index 64360e70df2ab0eb532ac4733a2b13e7813a62de..be28352799d150be5f99be63155d9cd6d899d109 100644 --- a/en/readme/Security.md +++ b/en/readme/Security.md @@ -97,7 +97,7 @@ Security subsystem [security_device_auth](https://gitee.com/openharmony/security_device_auth) -[security_permission](https://gitee.com/openharmony/security_permission) +[security_permission_lite](https://gitee.com/openharmony/security_permission_lite) [security_device_security_level](https://gitee.com/openharmony/security_device_security_level) diff --git a/zh-cn/application-dev/IDL/idl-guidelines.md b/zh-cn/application-dev/IDL/idl-guidelines.md index 5c2cadf08ea84b332bbe9c375b27bbbd2e83a699..76fc15b2e5939b5bf2c03d9ccc4bcb7a8a11f659 100644 --- a/zh-cn/application-dev/IDL/idl-guidelines.md +++ b/zh-cn/application-dev/IDL/idl-guidelines.md @@ -7,7 +7,7 @@ ![IDL-interface-description](./figures/IDL-interface-description.png) -OpenHarmony IDL接口描述语言主要用于: + **OpenHarmony IDL接口描述语言主要用于:** - 声明系统服务对外提供的服务接口,根据接口声明在编译时生成跨进程调用(IPC)或跨设备调用(RPC)的代理(Proxy)和桩(Stub)的C/C++代码或JS/TS代码。 @@ -17,7 +17,7 @@ OpenHarmony IDL接口描述语言主要用于: ![IPC-RPC-communication-model](./figures/IPC-RPC-communication-model.png) -使用OpenHarmony IDL接口描述语言声明接口具有以下优点: + **使用OpenHarmony IDL接口描述语言声明接口具有以下优点:** - OpenHarmony IDL中是以接口的形式定义服务,可以专注于定义而隐藏实现细节。 @@ -59,7 +59,7 @@ sequenceable namespace.typename sequenceable a.b..C.D ``` -上述声明在生成的的C++头文件中将被解析为如下代码: + 上述声明在生成的的C++头文件中将被解析为如下代码: ```cpp #include “a/b/d.h” @@ -81,15 +81,15 @@ import MySequenceable from "./my_sequenceable" 需要注意的是,IDL并不负责该类型的代码实现,仅仅按照指定的形式引入该头文件或import指定模块,并使用该类型,因此开发者需要自行保证引入目录、命名空间及类型的正确性。 #### 接口类型 -接口类型是指OpenHarmony IDL文件中定义的接口。对于当前IDL文件中定义的接口,可以直接使用它作为方法参数类型或返回值类型。而在其它OpenHarmony IDL文件中定义的接口,则需要在文件的头部进行前置声明。 + 接口类型是指OpenHarmony IDL文件中定义的接口。对于当前IDL文件中定义的接口,可以直接使用它作为方法参数类型或返回值类型。而在其它OpenHarmony IDL文件中定义的接口,则需要在文件的头部进行前置声明。 -C++中声明的形式与sequenceable类型相似,具体而言可以有如下形式: + C++中声明的形式与sequenceable类型相似,具体而言可以有如下形式: ```cpp interface includedir..namespace.typename ``` -TS中声明的形式,具体而言可以有如下形式: + TS中声明的形式,具体而言可以有如下形式: ```ts interface namespace.interfacename @@ -495,7 +495,7 @@ function connectAbility: void { 开发者可以通过 IPC 接口,将某个类从一个进程发送至另一个进程。但是,必须确保 IPC 通道的另一端可使用该类的代码,并且该类必须支持marshalling和unmarshalling方法。OpenHarmony 需要通过该marshalling和unmarshalling方法将对象序列化和反序列化成各进程能识别的对象。 -如需创建支持sequenceable 类型数据,开发者必须执行以下操作: + **如需创建支持sequenceable 类型数据,开发者必须执行以下操作:** 1. 实现marshalling方法,它会获取对象的当前状态并将其序列化后写入Parcel。 2. 实现unmarshalling方法,它会从Parcel中反序列化出对象。 diff --git a/zh-cn/application-dev/Readme-CN.md b/zh-cn/application-dev/Readme-CN.md index ca55f0618ada3fb2452e5f5a3637fb661367d776..08d96de0527fc1fd41f05b2b4c48a3d96fdf5a48 100644 --- a/zh-cn/application-dev/Readme-CN.md +++ b/zh-cn/application-dev/Readme-CN.md @@ -38,7 +38,7 @@ - 工具 - [DevEco Studio(OpenHarmony)使用指南](quick-start/deveco-studio-user-guide-for-openharmony.md) - 示例教程 - - [示例代码](https://gitee.com/openharmony/app_samples/blob/master/README_zh.md) + - [示例代码](https://gitee.com/openharmony/applications_app_samples/blob/master/README_zh.md) - [Codelabs](https://gitee.com/openharmony/codelabs/blob/master/README.md) - API参考 - [组件参考(基于TS扩展的声明式开发范式)](reference/arkui-ts/Readme-CN.md) diff --git a/zh-cn/application-dev/ability/stage-ability-continuation.md b/zh-cn/application-dev/ability/stage-ability-continuation.md index b50cab8a17cfbcb49e8ff6098e410c76b1c3ae18..2c6045bef7c1eba49c8cf2b7c8f4d26791e6f056 100755 --- a/zh-cn/application-dev/ability/stage-ability-continuation.md +++ b/zh-cn/application-dev/ability/stage-ability-continuation.md @@ -41,7 +41,7 @@ "module": { "abilities": [ { - "continuable": true, + "continuable": true } ] } @@ -62,7 +62,7 @@ "module": { "abilities": [ { - "launchType": "standard", + "launchType": "standard" } ] } @@ -76,7 +76,7 @@ "module": { "abilities": [ { - "launchType": "singleton", + "launchType": "singleton" } ] } diff --git a/zh-cn/application-dev/application-dev-guide-for-gitee.md b/zh-cn/application-dev/application-dev-guide-for-gitee.md index 79371930d291fc6452179a1f11f65c0f83f670c1..9be881921b4c9d7ccefbc2f6b518972030853f1c 100644 --- a/zh-cn/application-dev/application-dev-guide-for-gitee.md +++ b/zh-cn/application-dev/application-dev-guide-for-gitee.md @@ -47,7 +47,7 @@ DevEco Studio工具是OpenHarmony应用开发的推荐IDE工具。 ### 示例教程 -我们提供了[Sample工程](https://gitee.com/openharmony/app_samples/blob/master/README_zh.md)和[Codelab](https://gitee.com/openharmony/codelabs/blob/master/README.md)这两种形式的示例教程,为开发者提供更丰富的开发参考,辅助开发者理解功能逻辑,提升开发效率。 +我们提供了[Sample工程](https://gitee.com/openharmony/applications_app_samples/blob/master/README_zh.md)和[Codelab](https://gitee.com/openharmony/codelabs/blob/master/README.md)这两种形式的示例教程,为开发者提供更丰富的开发参考,辅助开发者理解功能逻辑,提升开发效率。 ### API参考 diff --git a/zh-cn/application-dev/application-dev-guide.md b/zh-cn/application-dev/application-dev-guide.md index b9cef5ddb5958576b70755b6b02fe4cd172fad72..73869033a8be5a1138a21fd56bdd5dbf5c8a3a40 100644 --- a/zh-cn/application-dev/application-dev-guide.md +++ b/zh-cn/application-dev/application-dev-guide.md @@ -48,7 +48,7 @@ DevEco Studio工具是OpenHarmony应用开发的推荐IDE工具。 ### 示例教程 -我们提供了[Sample工程](https://gitee.com/openharmony/app_samples/blob/master/README_zh.md)和[Codelab](https://gitee.com/openharmony/codelabs/blob/master/README.md)这两种形式的示例教程,为开发者提供更丰富的开发参考,辅助开发者理解功能逻辑,提升开发效率。 +我们提供了[Sample工程](https://gitee.com/openharmony/applications_app_samples/blob/master/README_zh.md)和[Codelab](https://gitee.com/openharmony/codelabs/blob/master/README.md)这两种形式的示例教程,为开发者提供更丰富的开发参考,辅助开发者理解功能逻辑,提升开发效率。 ### API参考 diff --git a/zh-cn/application-dev/database/database-preference-guidelines.md b/zh-cn/application-dev/database/database-preference-guidelines.md index d42fda38bc61cd28c6b63d0b530c1a46c14da45b..7714776aa3febdd6a41923b02f6c4bd7ae4a8b19 100644 --- a/zh-cn/application-dev/database/database-preference-guidelines.md +++ b/zh-cn/application-dev/database/database-preference-guidelines.md @@ -88,15 +88,22 @@ 2. 获取Preferences实例。 读取指定文件,将数据加载到Preferences实例,用于数据操作。 - + FA模型示例: ```js // 获取context import featureAbility from '@ohos.ability.featureAbility' - let context = featureAbility.getContext() - + let context = featureAbility.getContext(); + + let preferences = null; let promise = data_preferences.getPreferences(context, 'mystore'); + + promise.then((pref) => { + preferences = pref; + }).catch((err) => { + console.info("Failed to get preferences."); + }) ``` Stage模型示例: @@ -104,14 +111,21 @@ ```ts // 获取context import Ability from '@ohos.application.Ability' - let context = null + let context = null; + let preferences = null; export default class MainAbility extends Ability { onWindowStageCreate(windowStage){ - context = this.context + context = this.context; } } - + let promise = data_preferences.getPreferences(context, 'mystore'); + + promise.then((pref) => { + preferences = pref; + }).catch((err) => { + console.info("Failed to get preferences."); + }) ``` 3. 存入数据。 @@ -119,35 +133,27 @@ 使用put方法保存数据到缓存的实例中。 ```js - promise.then((preferences) => { - let putPromise = preferences.put('startup', 'auto'); - putPromise.then(() => { - console.info("Succeeded in putting the value of 'startup'."); - }).catch((err) => { - console.info("Failed to put the value of 'startup'. Cause: " + err); - }) + let putPromise = preferences.put('startup', 'auto'); + putPromise.then(() => { + console.info("Succeeded in putting the value of 'startup'."); }).catch((err) => { - console.info("Failed to get preferences."); + console.info("Failed to put the value of 'startup'. Cause: " + err); }) ``` - + 4. 读取数据。 使用get方法读取数据。 ```js - promise.then((preferences) => { - let getPromise = preferences.get('startup', 'default'); - getPromise.then((value) => { + let getPromise = preferences.get('startup', 'default'); + getPromise.then((value) => { console.info("The value of 'startup' is " + value); - }).catch((err) => { - console.info("Failed to get the value of 'startup'. Cause: " + err); - }) }).catch((err) => { - console.info("Failed to get preferences.") - }); + console.info("Failed to get the value of 'startup'. Cause: " + err); + }) ``` - + 5. 数据持久化。 应用存入数据到Preferences实例后,可以通过flush方法将Preferences实例回写到文件中。 @@ -165,7 +171,7 @@ console.info("The key" + key + " changed."); } preferences.on('change', observer); - // 数据产生变更,由'auto'变为'manual'。 + // 数据产生变更,由'auto'变为'manual' preferences.put('startup', 'manual', function (err) { if (err) { console.info("Failed to put the value of 'startup'. Cause: " + err); diff --git a/zh-cn/application-dev/database/database-relational-guidelines.md b/zh-cn/application-dev/database/database-relational-guidelines.md index 7ad8f8cc654456ed69a8ee90aa6551db1f7ced72..64398cd48fbdd355d8a40a6f1464b7a553e7333c 100644 --- a/zh-cn/application-dev/database/database-relational-guidelines.md +++ b/zh-cn/application-dev/database/database-relational-guidelines.md @@ -196,17 +196,41 @@ (3) 创建数据库。 - 示例代码如下: + FA模型示例: ```js - import data_rdb from '@ohos.data.rdb' + import data_rdb from '@ohos.data.rdb' + // 获取context + import featureAbility from '@ohos.ability.featureAbility' + let context = featureAbility.getContext() + + const CREATE_TABLE_TEST = "CREATE TABLE IF NOT EXISTS test (" + "id INTEGER PRIMARY KEY AUTOINCREMENT, " + "name TEXT NOT NULL, " + "age INTEGER, " + "salary REAL, " + "blobType BLOB)"; - const CREATE_TABLE_TEST = "CREATE TABLE IF NOT EXISTS test (" + "id INTEGER PRIMARY KEY AUTOINCREMENT, " + "name TEXT NOT NULL, " + "age INTEGER, " + "salary REAL, " + "blobType BLOB)"; - const STORE_CONFIG = { name: "rdbstore.db" } - data_rdb.getRdbStore(this.context, STORE_CONFIG, 1, function (err, rdbStore) { + const STORE_CONFIG = { name: "RdbTest.db" } + data_rdb.getRdbStore(context, STORE_CONFIG, 1, function (err, rdbStore) { rdbStore.executeSql(CREATE_TABLE_TEST) console.info('create table done.') - }) + }) + ``` + Stage模型示例: + ```ts + import data_rdb from '@ohos.data.rdb' + // 获取context + import Ability from '@ohos.application.Ability' + let context = null + class MainAbility extends Ability { + onWindowStageCreate(windowStage) { + context = this.context + } + } + + const CREATE_TABLE_TEST = "CREATE TABLE IF NOT EXISTS test (" + "id INTEGER PRIMARY KEY AUTOINCREMENT, " + "name TEXT NOT NULL, " + "age INTEGER, " + "salary REAL, " + "blobType BLOB)"; + + const STORE_CONFIG = { name: "rdbstore.db" } + data_rdb.getRdbStore(context, STORE_CONFIG, 1, function (err, rdbStore) { + rdbStore.executeSql(CREATE_TABLE_TEST) + console.info('create table done.') + }) ``` 2. 插入数据。 diff --git a/zh-cn/application-dev/device/sample-server-overview.md b/zh-cn/application-dev/device/sample-server-overview.md index 1eabc1e887e7851189ccf518f7f94eff35bd6569..10d74586923c1c740d7709f2ebf6741880659a10 100644 --- a/zh-cn/application-dev/device/sample-server-overview.md +++ b/zh-cn/application-dev/device/sample-server-overview.md @@ -1,6 +1,6 @@ # 示例服务器开发概述 -示例服务器提供一个简易的升级包部署的服务器实例参考,用于升级服务子系统的辅助验证环境搭建。 +示例服务器提供一个简易的升级包部署的服务器实例参考,用于搭建升级服务子系统的辅助验证环境。 ## 基本概念 diff --git a/zh-cn/application-dev/key-features/multi-device-app-dev/faqs.md b/zh-cn/application-dev/key-features/multi-device-app-dev/faqs.md index e23750c33468972110f124d729d4610fabdbae7d..2ec8d05a98a6b9dbf03c151cc47800ad3e1d77dc 100644 --- a/zh-cn/application-dev/key-features/multi-device-app-dev/faqs.md +++ b/zh-cn/application-dev/key-features/multi-device-app-dev/faqs.md @@ -6,10 +6,10 @@ 设备类型分为default(默认设备)、tablet、tv、wearable等,有多种查询设备类型的方式。 1. 通过命令行的方式查询设备类型。 - 通过命令行查询指定系统参数(const.build.characteristics)进而确定设备类型,详见[系统参数介绍](../../../device-dev/subsystems/subsys-boot-syspara.md)。 + 通过命令行查询指定系统参数(const.build.characteristics)进而确定设备类型,详见[系统参数介绍](../../../device-dev/subsystems/subsys-boot-init-sysparam.md)。 - ```ts + ```bash # 方法一 hdc shell param get "const.build.characteristics" # 方法二 diff --git a/zh-cn/application-dev/media/audio-capturer.md b/zh-cn/application-dev/media/audio-capturer.md index 84702dd781f7c2bec186c7b1e5e61ed1333ff5c4..3e91bd1d882e92ada0912066eec69b1df746e528 100644 --- a/zh-cn/application-dev/media/audio-capturer.md +++ b/zh-cn/application-dev/media/audio-capturer.md @@ -8,7 +8,7 @@ AudioCapturer提供了用于获取原始音频文件的方法。开发者可以 在进行应用开发的过程中,建议开发者通过on('stateChange')方法订阅AudioCapturer的状态变更。因为针对AudioCapturer的某些操作,仅在音频采集器在固定状态时才能执行。如果应用在音频采集器处于错误状态时执行操作,系统可能会抛出异常或生成其他未定义的行为。 -详细API含义可参考:[音频管理API文档AudioCapturer](../reference/apis/js-apis-audio.md) +详细API含义可参考:[音频管理API文档AudioCapturer](../reference/apis/js-apis-audio.md#audiocapturer8) **图1** 音频采集状态机 diff --git a/zh-cn/application-dev/media/audio-playback.md b/zh-cn/application-dev/media/audio-playback.md index 0091b8cb7d20ec497cb98a6022f59444726b75f3..5a63c2fc33fab83623b8de9a1b1c8497d5790742 100644 --- a/zh-cn/application-dev/media/audio-playback.md +++ b/zh-cn/application-dev/media/audio-playback.md @@ -18,7 +18,7 @@ ## 开发步骤 -详细API含义可参考:[媒体服务API文档AudioPlayer](../reference/apis/js-apis-media.md) +详细API含义可参考:[媒体服务API文档AudioPlayer](../reference/apis/js-apis-media.md#audioplayer) ### 全流程场景 diff --git a/zh-cn/application-dev/media/audio-recorder.md b/zh-cn/application-dev/media/audio-recorder.md index 739116e193db4ad8f0519ffe6e4784301712d6b7..21fe9c01ad216b331e5c2e708397bfdce4672a4d 100644 --- a/zh-cn/application-dev/media/audio-recorder.md +++ b/zh-cn/application-dev/media/audio-recorder.md @@ -16,7 +16,7 @@ ## 开发步骤 -详细API含义可参考:[媒体服务API文档AudioRecorder](../reference/apis/js-apis-media.md) +详细API含义可参考:[媒体服务API文档AudioRecorder](../reference/apis/js-apis-media.md#audiorecorder) ### 全流程场景 diff --git a/zh-cn/application-dev/media/audio-stream-manager.md b/zh-cn/application-dev/media/audio-stream-manager.md index 19602da3f2b02f21fa29742ac6a7f5425ec386b4..cd23dc2953910c5e7bca59faa64a254c7b76b120 100644 --- a/zh-cn/application-dev/media/audio-stream-manager.md +++ b/zh-cn/application-dev/media/audio-stream-manager.md @@ -6,7 +6,7 @@ AudioStreamManager提供了音频流管理的方法。开发者可以通过本 ### 工作流程 -在进行应用开发的过程中,开发者需要使用getStreamManager()创建一个AudioStreamManager实例,进而通过该实例管理音频流。开发者可通过调用on('audioRendererChange')、on('audioCapturerChange')监听音频播放应用和音频录制应用,在应用状态变化、设备变化、音频属性变化时获得通知。同时可通过off('audioRendererChange')、off('audioCapturerChange')取消相关事件的监听。与此同时,开发者可以通过调用(可选)使用getCurrentAudioRendererInfoArray()获取当前音频播放应用的音频流唯一ID、音频播放客户端的UID、音频状态等信息,同理可调用getCurrentAudioCapturerInfoArray()获取音频录制应用的信息。其具体调用关系可参考音频流管理调用关系图。 +在进行应用开发的过程中,开发者需要使用getStreamManager()创建一个AudioStreamManager实例,进而通过该实例管理音频流。开发者可通过调用on('audioRendererChange')、on('audioCapturerChange')监听音频播放应用和音频录制应用,在应用状态变化、设备变化、音频属性变化时获得通知。同时可通过off('audioRendererChange')、off('audioCapturerChange')取消相关事件的监听。与此同时,开发者可以通过调用(可选)使用getCurrentAudioRendererInfoArray()获取当前音频播放应用的音频流唯一ID、音频播放客户端的UID、音频状态等信息,同理可调用getCurrentAudioCapturerInfoArray()获取音频录制应用的信息。其具体调用关系可参考音频流管理调用关系图。 详细API含义可参考:[音频管理API文档AudioStreamManager](../reference/apis/js-apis-audio.md#audiostreammanager9) diff --git a/zh-cn/application-dev/media/camera.md b/zh-cn/application-dev/media/camera.md index 66877e21c3092aee40ab8df77d2391c091d0dcfb..044535a7ce6c5d80f236b49399c2076108483bc3 100644 --- a/zh-cn/application-dev/media/camera.md +++ b/zh-cn/application-dev/media/camera.md @@ -26,7 +26,7 @@ import image from '@ohos.multimedia.image' import media from '@ohos.multimedia.media' import featureAbility from '@ohos.ability.featureAbility' -//创建CameraManager对象 +// 创建CameraManager对象 let cameraManager await camera.getCameraManager(globalThis.Context, (err, manager) => { if (err) { @@ -37,13 +37,13 @@ await camera.getCameraManager(globalThis.Context, (err, manager) => { cameraManager = manager }) -//注册回调函数监听相机状态变化,获取状态变化的相机信息 +// 注册回调函数监听相机状态变化,获取状态变化的相机信息 cameraManager.on('cameraStatus', (cameraStatusInfo) => { console.log('camera : ' + cameraStatusInfo.camera.cameraId); console.log('status: ' + cameraStatusInfo.status); }) -//获取相机列表 +// 获取相机列表 let cameraArray await cameraManager.getCameras((err, cameras) => { if (err) { @@ -55,20 +55,20 @@ await cameraManager.getCameras((err, cameras) => { }) for(let cameraIndex = 0; cameraIndex < cameraArray.length; cameraIndex++) { - console.log('cameraId : ' + cameraArray[cameraIndex].cameraId) //获取相机ID - console.log('cameraPosition : ' + cameraArray[cameraIndex].cameraPosition) //获取相机位置 - console.log('cameraType : ' + cameraArray[cameraIndex].cameraType) //获取相机类型 - console.log('connectionType : ' + cameraArray[cameraIndex].connectionType) //获取相机连接类型 + console.log('cameraId : ' + cameraArray[cameraIndex].cameraId) // 获取相机ID + console.log('cameraPosition : ' + cameraArray[cameraIndex].cameraPosition) // 获取相机位置 + console.log('cameraType : ' + cameraArray[cameraIndex].cameraType) // 获取相机类型 + console.log('connectionType : ' + cameraArray[cameraIndex].connectionType) // 获取相机连接类型 } -//创建相机输入流 +// 创建相机输入流 let cameraInput await cameraManager.createCameraInput(cameraArray[0].cameraId).then((input) => { console.log('Promise returned with the CameraInput instance'); cameraInput = input }) -//创建预览输出流 +// 创建预览输出流 let previewOutput camera.createPreviewOutput((globalThis.surfaceId), (err, output) => { if (err) { @@ -79,11 +79,11 @@ camera.createPreviewOutput((globalThis.surfaceId), (err, output) => { previewOutput = output }); -//创建ImageReceiver对象,并设置照片参数 +// 创建ImageReceiver对象,并设置照片参数 let imageReceiver = await image.createImageReceiver(1920, 1080, 4, 8) -//获取照片显示SurfaceId +// 获取照片显示SurfaceId let photoSurfaceId = await imageReceiver.getReceivingSurfaceId() -//创建拍照输出流 +// 创建拍照输出流 let photoOutput camera.createPhotoOutput((photoSurfaceId), (err, output) => { if (err) { @@ -94,7 +94,7 @@ camera.createPhotoOutput((photoSurfaceId), (err, output) => { photoOutput = output }); -//创建视频录制的参数 +// 创建视频录制的参数 let videoProfile = { audioBitrate : 48000, audioChannels : 2, @@ -116,13 +116,13 @@ let videoConfig = { location : { latitude : 30, longitude : 130 }, } -//创建录像输出流 +// 创建录像输出流 let videoRecorder await media.createVideoRecorder().then((recorder) => { console.log('createVideoRecorder called') videoRecorder = recorder }) -//设置视频录制的参数 +// 设置视频录制的参数 await videoRecorder.prepare(videoConfig) //获取录像SurfaceId await videoRecorder.getInputSurface().then((id) => { @@ -132,7 +132,7 @@ await videoRecorder.getInputSurface().then((id) => { ``` videoRecorder详细创建方法可参考:[视频录制开发指导](./video-recorder.md) ```js -//创建VideoOutput对象 +// 创建VideoOutput对象 let videoOutput camera.createVideoOutput((surfaceId), (err, output) => { if (err) { @@ -148,14 +148,14 @@ camera.createVideoOutput((surfaceId), (err, output) => { #### 参数设置 ```js -//判断设备是否支持闪光灯 +// 判断设备是否支持闪光灯 let flashStatus await cameraInput.hasFlash().then((status) => { console.log('Promise returned with the flash light support status:' + status); flashStatus = status }) if(flashStatus) { - //判断是否支持自动闪光灯模式 + // 判断是否支持自动闪光灯模式 let flashModeStatus cameraInput.isFlashModeSupported(camera.FlashMode.FLASH_MODE_AUTO, (err, status) => { if (err) { @@ -166,7 +166,7 @@ if(flashStatus) { flashModeStatus = status }) if(flashModeStatus) { - //设置自动闪光灯模式 + // 设置自动闪光灯模式 cameraInput.setFlashMode(camera.FlashMode.FLASH_MODE_AUTO, (err) => { if (err) { console.error('Failed to set the flash mode ${err.message}'); @@ -177,7 +177,7 @@ if(flashStatus) { } } -//判断是否支持连续自动变焦模式 +// 判断是否支持连续自动变焦模式 let focusModeStatus cameraInput.isFocusModeSupported(camera.FocusMode.FOCUS_MODE_CONTINUOUS_AUTO, (err, status) => { if (err) { @@ -188,7 +188,7 @@ cameraInput.isFocusModeSupported(camera.FocusMode.FOCUS_MODE_CONTINUOUS_AUTO, (e focusModeStatus = status }) if(focusModeStatus) { - //设置连续自动变焦模式 + // 设置连续自动变焦模式 cameraInput.setFocusMode(camera.FocusMode.FOCUS_MODE_CONTINUOUS_AUTO, (err) => { if (err) { console.error('Failed to set the focus mode ${err.message}'); @@ -198,7 +198,7 @@ if(focusModeStatus) { }) } -//获取相机支持的可变焦距比范围 +// 获取相机支持的可变焦距比范围 let zoomRatioRange cameraInput.getZoomRatioRange((err, range) => { if (err) { @@ -209,7 +209,7 @@ cameraInput.getZoomRatioRange((err, range) => { zoomRatioRange = range }) -//设置可变焦距比 +// 设置可变焦距比 cameraInput.setZoomRatio(zoomRatioRange[0], (err) => { if (err) { console.error('Failed to set the zoom ratio value ${err.message}'); @@ -224,7 +224,7 @@ cameraInput.setZoomRatio(zoomRatioRange[0], (err) => { ##### 创建会话 ```js -//创建Context对象 +// 创建Context对象 let context = featureAbility.getContext() //创建会话 @@ -238,7 +238,7 @@ await camera.createCaptureSession((context), (err, session) => { captureSession = session }); -//开始配置会话 +// 开始配置会话 await captureSession.beginConfig((err) => { if (err) { console.error('Failed to start the configuration. ${err.message}'); @@ -247,7 +247,7 @@ await captureSession.beginConfig((err) => { console.log('Callback invoked to indicate the begin config success.'); }); -//向会话中添加相机输入流 +// 向会话中添加相机输入流 await captureSession.addInput(cameraInput, (err) => { if (err) { console.error('Failed to add the CameraInput instance. ${err.message}'); @@ -256,7 +256,7 @@ await captureSession.addInput(cameraInput, (err) => { console.log('Callback invoked to indicate that the CameraInput instance is added.'); }); -//向会话中添加预览输入流 +// 向会话中添加预览输入流 await captureSession.addOutput(previewOutput, (err) => { if (err) { console.error('Failed to add the PreviewOutput instance ${err.message}'); @@ -265,7 +265,7 @@ await captureSession.addOutput(previewOutput, (err) => { console.log('Callback invoked to indicate that the PreviewOutput instance is added.'); }); -//向会话中添加拍照输出流 +// 向会话中添加拍照输出流 await captureSession.addOutput(photoOutput, (err) => { if (err) { console.error('Failed to add the PhotoOutput instance ${err.message}'); @@ -274,7 +274,7 @@ await captureSession.addOutput(photoOutput, (err) => { console.log('Callback invoked to indicate that the PhotoOutput instance is added.'); }); -//提交会话配置 +// 提交会话配置 await captureSession.commitConfig((err) => { if (err) { console.error('Failed to commit the configuration. ${err.message}'); @@ -283,7 +283,7 @@ await captureSession.commitConfig((err) => { console.log('Callback invoked to indicate the commit config success.'); }); -//启动会话 +// 启动会话 await captureSession.start().then(() => { console.log('Promise returned to indicate the session start success.'); }) @@ -292,7 +292,7 @@ await captureSession.start().then(() => { ##### 切换会话 ```js -//停止当前会话 +// 停止当前会话 await captureSession.stop((err) => { if (err) { console.error('Failed to stop the session ${err.message}'); @@ -301,7 +301,7 @@ await captureSession.stop((err) => { console.log('Callback invoked to indicate the session stop success.'); }); -//开始配置会话 +// 开始配置会话 await captureSession.beginConfig((err) => { if (err) { console.error('Failed to start the configuration. ${err.message}'); @@ -310,7 +310,7 @@ await captureSession.beginConfig((err) => { console.log('Callback invoked to indicate the begin config success.'); }); -//从会话中移除拍照输出流 +// 从会话中移除拍照输出流 await captureSession.removeOutput(photoOutput, (err) => { if (err) { console.error('Failed to remove the PhotoOutput instance. ${err.message}'); @@ -319,7 +319,7 @@ await captureSession.removeOutput(photoOutput, (err) => { console.log('Callback invoked to indicate that the PhotoOutput instance is removed.'); }); -//向会话中添加录像输出流 +// 向会话中添加录像输出流 await captureSession.addOutput(videoOutput, (err) => { if (err) { console.error('Failed to add the VideoOutput instance ${err.message}'); @@ -328,7 +328,7 @@ await captureSession.addOutput(videoOutput, (err) => { console.log('Callback invoked to indicate that the VideoOutput instance is added.'); }); -//提交会话配置 +// 提交会话配置 await captureSession.commitConfig((err) => { if (err) { console.error('Failed to commit the configuration. ${err.message}'); @@ -337,7 +337,7 @@ await captureSession.commitConfig((err) => { console.log('Callback invoked to indicate the commit config success.'); }); -//启动会话 +// 启动会话 await captureSession.start().then(() => { console.log('Promise returned to indicate the session start success.'); }) @@ -347,10 +347,10 @@ await captureSession.start().then(() => { ```js let settings = { - quality: camera.QualityLevel.QUALITY_LEVEL_HIGH //设置图片质量高 - rotation: camera.ImageRotation.ROTATION_0, //设置图片旋转角度0 + quality: camera.QualityLevel.QUALITY_LEVEL_HIGH, // 设置图片质量高 + rotation: camera.ImageRotation.ROTATION_0 // 设置图片旋转角度0 } -//使用当前拍照设置进行拍照 +// 使用当前拍照设置进行拍照 photoOutput.capture(settings, (err) => { if (err) { console.error('Failed to capture the photo ${err.message}'); @@ -363,7 +363,7 @@ photoOutput.capture(settings, (err) => { #### 录像 ```js -//启动录像输出流 +// 启动录像输出流 videoOutput.start((err) => { if (err) { console.error('Failed to start the video output ${err.message}'); @@ -372,17 +372,17 @@ videoOutput.start((err) => { console.log('Callback invoked to indicate the video output start success.'); }); -//开始录像 +// 开始录像 await videoRecorder.start().then(() => { console.info('videoRecorder start success'); } -//停止录像 +// 停止录像 await videoRecorder.stop().then(() => { console.info('stop success'); } -//停止录像输出流 +// 停止录像输出流 await videoOutput.stop((err) => { if (err) { console.error('Failed to stop the video output ${err.message}'); @@ -395,7 +395,7 @@ await videoOutput.stop((err) => { #### 释放资源 ```js -//停止当前会话 +// 停止当前会话 await captureSession.stop((err) => { if (err) { console.error('Failed to stop the session ${err.message}'); @@ -403,7 +403,7 @@ await captureSession.stop((err) => { } console.log('Callback invoked to indicate the session stop success.'); }); -//释放相机输入流 +// 释放相机输入流 await cameraInput.release((err) => { if (err) { console.error('Failed to release the CameraInput instance ${err.message}'); @@ -411,7 +411,7 @@ await cameraInput.release((err) => { } console.log('Callback invoked to indicate that the CameraInput instance is released successfully.'); }); -//释放预览输出流 +// 释放预览输出流 await previewOutput.release((err) => { if (err) { console.error('Failed to release the PreviewOutput instance ${err.message}'); @@ -419,7 +419,7 @@ await previewOutput.release((err) => { } console.log('Callback invoked to indicate that the PreviewOutput instance is released successfully.'); }); -//释放拍照输出流 +// 释放拍照输出流 await photoOutput.release((err) => { if (err) { console.error('Failed to release the PhotoOutput instance ${err.message}'); @@ -427,7 +427,7 @@ await photoOutput.release((err) => { } console.log('Callback invoked to indicate that the PhotoOutput instance is released successfully.'); }); -//释放录像输出流 +// 释放录像输出流 await videoOutput.release((err) => { if (err) { console.error('Failed to release the VideoOutput instance ${err.message}'); @@ -435,7 +435,7 @@ await videoOutput.release((err) => { } console.log('Callback invoked to indicate that the VideoOutput instance is released successfully.'); }); -//释放会话 +// 释放会话 await captureSession.release((err) => { if (err) { console.error('Failed to release the CaptureSession instance ${err.message}'); @@ -449,24 +449,24 @@ await captureSession.release((err) => { 预览画面显示需要获取SurfaceId ```js -mXComponentController: XComponentController = new XComponentController //创建XComponentController +mXComponentController: XComponentController = new XComponentController // 创建XComponentController build() { Flex() { - XComponent({ //创建XComponent + XComponent({ // 创建XComponent id: '', type: 'surface', libraryname: '', controller: this.mXComponentController }) - .onload(() => { //设置onload回调 - //设置Surface宽高(1920*1080) + .onload(() => { // 设置onload回调 + // 设置Surface宽高(1920*1080) this.mXComponentController.setXComponentSurfaceSize({surfaceWidth:1920,surfaceHeight:1080}) - //获取Surface ID + // 获取Surface ID globalThis.surfaceId = mXComponentController.getXComponentSurfaceId() }) - .width('1920px') //设置XComponent宽度 - .height('1080px') //设置XComponent高度 + .width('1920px') // 设置XComponent宽度 + .height('1080px') // 设置XComponent高度 } } ``` \ No newline at end of file diff --git a/zh-cn/application-dev/media/remote-camera.md b/zh-cn/application-dev/media/remote-camera.md index f1c25013f9366e204b72104eedfcad3a264015a4..5be86b91a20060bf310981751cdaf2879e9c18fc 100644 --- a/zh-cn/application-dev/media/remote-camera.md +++ b/zh-cn/application-dev/media/remote-camera.md @@ -23,7 +23,7 @@ import image from '@ohos.multimedia.image' import media from '@ohos.multimedia.media' import featureAbility from '@ohos.ability.featureAbility' -//创建CameraManager对象 +// 创建CameraManager对象 let cameraManager await camera.getCameraManager(globalThis.Context, (err, manager) => { if (err) { @@ -34,13 +34,13 @@ await camera.getCameraManager(globalThis.Context, (err, manager) => { cameraManager = manager }) -//注册回调函数监听相机状态变化,获取状态变化的相机信息 +// 注册回调函数监听相机状态变化,获取状态变化的相机信息 cameraManager.on('cameraStatus', (cameraStatusInfo) => { console.log('camera : ' + cameraStatusInfo.camera.cameraId); console.log('status: ' + cameraStatusInfo.status); }) -//获取相机列表 +// 获取相机列表 let cameraArray let remoteCamera await cameraManager.getCameras((err, cameras) => { @@ -53,16 +53,16 @@ await cameraManager.getCameras((err, cameras) => { }) for(let cameraIndex = 0; cameraIndex < cameraArray.length; cameraIndex++) { - console.log('cameraId : ' + cameraArray[cameraIndex].cameraId) //获取相机ID - console.log('cameraPosition : ' + cameraArray[cameraIndex].cameraPosition) //获取相机位置 - console.log('cameraType : ' + cameraArray[cameraIndex].cameraType) //获取相机类型 - console.log('connectionType : ' + cameraArray[cameraIndex].connectionType) //获取相机连接类型 + console.log('cameraId : ' + cameraArray[cameraIndex].cameraId) // 获取相机ID + console.log('cameraPosition : ' + cameraArray[cameraIndex].cameraPosition) // 获取相机位置 + console.log('cameraType : ' + cameraArray[cameraIndex].cameraType) // 获取相机类型 + console.log('connectionType : ' + cameraArray[cameraIndex].connectionType) // 获取相机连接类型 if (cameraArray[cameraIndex].connectionType == CAMERA_CONNECTION_REMOTE) { remoteCamera = cameraArray[cameraIndex].cameraId } } -//创建相机输入流 +// 创建相机输入流 let cameraInput await cameraManager.createCameraInput(remoteCamera).then((input) => { console.log('Promise returned with the CameraInput instance'); diff --git a/zh-cn/application-dev/media/video-playback.md b/zh-cn/application-dev/media/video-playback.md index 27279fb3b887efe6f0d62faffbf384e45196ffaf..040b9b479adce001468631ae6920321be06dc894 100644 --- a/zh-cn/application-dev/media/video-playback.md +++ b/zh-cn/application-dev/media/video-playback.md @@ -33,7 +33,7 @@ ## 开发步骤 -详细API含义可参考:[媒体服务API文档VideoPlayer](../reference/apis/js-apis-media.md) +详细API含义可参考:[媒体服务API文档VideoPlayer](../reference/apis/js-apis-media.md#videoplayer8) ### 全流程场景 diff --git a/zh-cn/application-dev/media/video-recorder.md b/zh-cn/application-dev/media/video-recorder.md index 888767e721ad99e71565a1eb5d1607ecc0b303ba..3be9de0cbb47ea787f1861fba9f32aa423fd935a 100644 --- a/zh-cn/application-dev/media/video-recorder.md +++ b/zh-cn/application-dev/media/video-recorder.md @@ -14,7 +14,7 @@ ## 开发步骤 -详细API含义可参考:[媒体服务API文档VideoRecorder](../reference/apis/js-apis-media.md) +详细API含义可参考:[媒体服务API文档VideoRecorder](../reference/apis/js-apis-media.md#videorecorder9) ### 全流程场景 diff --git a/zh-cn/application-dev/quick-start/stage-structure.md b/zh-cn/application-dev/quick-start/stage-structure.md index 8682cf7ffcc0313bb215001c121f5985ffda10b3..13fd166a6eb303f285e99aa77d1ca7e44f8acd90 100755 --- a/zh-cn/application-dev/quick-start/stage-structure.md +++ b/zh-cn/application-dev/quick-start/stage-structure.md @@ -65,7 +65,6 @@ app.json示例: | entityType | 该标签标记该应用的类别,具体有 :游戏类(game),影音类(media)、社交通信类(communication)、新闻类(news)、出行类(travel)、工具类(utility)、购物类(shopping)、教育类(education)、少儿类(kids)、商务类(business)、拍摄类(photography)。 | 字符串 | 该标签可以缺省,缺省为unspecified。 | | singleton | 标识该应用开启单例模式,仅支持系统应用配置,三方应用配置不生效。配置为true时,在多用户场景下,该应用仍然单实例运行,不会随用户切换而变动。采用布尔类型,该字段从API8开始支持。 | 布尔值 | 可缺省,缺省值为false。 | | removable | 标识应用是否可卸载,仅支持系统应用配置,三方应用配置不生效,该字段从API8开始支持。 | 布尔值 | 可缺省,缺省值为true。 | -| process | 标识应用进程名,标签值为字符串类型,最长为127个字节。如果app标签下配置了process,该应用的所有ability都运行在该进程中。 | 字符串 | 可缺省,缺省值为app标签下的bundleName。 | | keepAlive | 标识应用是否始终保持运行状态,仅支持系统应用配置,三方应用配置不生效。标签值为布尔类型,如果为true,应用将始终保持为运行状态,并且在系统启动的时候会被系统启动起来,应用进程退出后,系统也会重新启动该应用进程。 | 布尔值 | 可缺省,缺省值为false。 | | userDataClearable | 标识是否允许应用清除用户数据,仅支持系统应用配置,三方应用配置不生效,该字段从API8开始支持。 | 布尔值 | 可缺省,缺省值为true。 | | accessible | 标识应用的安装目录是否是可访问的,仅支持系统应用配置,三方应用配置不生效。配置为true表示安装目录可以被三方应用访问,false表示不能被三方应用访问。 | 布尔值 | 可缺省,缺省值为false。 | @@ -82,14 +81,13 @@ module.json5示例: "type": "entry|feature|har", "srcEntrance" : "./MyAbilityStage.js", "description" : "$string:description_application", - "process": "string", "mainElement": "MainAbility", "deviceTypes": [ "tablet", "tv", "wearable", "car", - "router", + "router" ], "deliveryWithInstall": true, "installationFree": false, @@ -176,7 +174,7 @@ hap包的配置信息,该标签下的配置只对当前hap包生效。 | type | 该标签标识当前hap的类型。类型有三种,分别是entry、feature和har。 | 字符串 | 该标签不可缺省。 | | srcEntrance | 该标签标识hap所对应的入口js代码路径,标签值为字符串(最长为127字节)。 | 字符串 | 该标签可缺省。 | | description | 该标签标识hap包的描述信息,标签值是是字符串类型或对描述内容的资源索引,以支持多语言。 | 字符串 | 该标签可缺省,缺省值为空。 | -| process | 该标签标识hap的进程名,标签值为字符串类型(最长为31个字节)。如果在hap标签下配置了process,该应用的所有ability都运行在该进程中。 | 字符串 | 可缺省,缺省为app标签下的bundleName。 | +| process | 该标签标识hap的进程名,标签值为字符串类型(最长为31个字节)。如果在hap标签下配置了process,该应用的所有ability都运行在该进程中。该标签只支持系统应用配置。 | 字符串 | 可缺省,缺省为app标签下的bundleName。 | | mainElement | 该标签标识hap的入口ability名称或者extension名称。只有配置为mainElement的ability或者extension才允许在服务中心露出。创建OpenHarmony原子化服务时,该标签不可缺省。 | 字符串 | OpenHarmony应用下,该标签可缺省。 | | deviceTypes | 该标签标识hap可以运行在哪类设备上,标签值采用字符串数组的表示,系统预定义的设备类型见表4。
与syscap不同的是,deviceTypes是以设备类型为粒度,而syscap是以设备能力(例如蓝牙、wifi)为粒度。 | 字符串数组 | 该标签不可缺省,可以为空值。 | | deliveryWithInstall | 该标签标识当前hap是否在用户主动安装的时候安装,true表示主动安装时安装,false表示主动安装时不安装。 | 布尔值 | 该标签不可缺省。 | @@ -403,10 +401,10 @@ skills示例 "pathRegex":"/query/.*", "path":"path", "type": "text/*" - }, + } ] } - ], + ] } ], "extensionAbilities": [ @@ -426,12 +424,12 @@ skills示例 "pathRegex":"/query/.*", "path":"path", "type": "text/*" - }, + } ] } - ], + ] } - ], + ] } ``` diff --git a/zh-cn/application-dev/quick-start/start-with-ets-stage.md b/zh-cn/application-dev/quick-start/start-with-ets-stage.md index 5fd89f64851006558fd94c46d983ce88365fd951..fe0f487bc2b84d2fcf64e0a67f56966da83413b3 100644 --- a/zh-cn/application-dev/quick-start/start-with-ets-stage.md +++ b/zh-cn/application-dev/quick-start/start-with-ets-stage.md @@ -279,7 +279,7 @@ 1. 将搭载OpenHarmony标准系统的开发板与电脑连接。 -2. 点击**File**> **Project Structure...** > **Project**>**SigningConfigs**界面勾选“**Automatically generate signaure**”,等待自动签名完成即可,点击“**OK**”。如下图所示: +2. 点击**File**> **Project Structure...** > **Project**>**SigningConfigs**界面勾选“**Automatically generate signature**”,等待自动签名完成即可,点击“**OK**”。如下图所示: ![06](figures/06.png) diff --git a/zh-cn/application-dev/reference/apis/development-intro.md b/zh-cn/application-dev/reference/apis/development-intro.md index 9f0b6bc59fc735aeeab592fe7593ee853d400500..2bebece5027bee5836d075696cc2ca5e33532c58 100644 --- a/zh-cn/application-dev/reference/apis/development-intro.md +++ b/zh-cn/application-dev/reference/apis/development-intro.md @@ -26,10 +26,12 @@ OpenHarmony中提供的接口,部分是仅供OEM厂商使用的system api, - 如果某个模块的接口均为system api,会在文档开头说明:该模块接口为系统接口。 - 如果某个接口为system api,会在具体的接口描述中说明:此接口为系统接口。 -普通应用即应用APL等级为normal的应用。默认情况下,应用的等级都为normal应用。 +普通应用即应用APL等级为normal的应用。应用等级默认为normal。 APL等级的详细说明及如何将应用的APL等级声明为normal以上,请参考[访问控制开发概述-应用APL等级说明](../../security/accesstoken-overview.md#应用apl等级说明)。 +随DevEco下载的SDK为public-SDK,不包括系统接口。如需使用系统接口,需要将SDK替换为full-SDK,具体参考[full-SDK替换指南](../../quick-start/full-sdk-switch-guide.md)。 + ## 权限说明 默认情况下,应用只能访问有限的系统资源。但某些情况下,应用为了扩展功能的诉求,需要访问额外的系统或其他应用的数据(包括用户个人数据)、功能。具体可参考[访问控制开发概述](../../security/accesstoken-overview.md)。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-Bundle.md b/zh-cn/application-dev/reference/apis/js-apis-Bundle.md index c6d58000ae2a06728fe8fcc463cc3bb558211d04..3428a6cb77e976e52d182a16b05978088cf4497d 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-Bundle.md +++ b/zh-cn/application-dev/reference/apis/js-apis-Bundle.md @@ -158,7 +158,7 @@ SystemCapability.BundleManager.BundleFramework | 名称 | 类型 | 必填 | 描述 | | ----------- | ------ | ---- | ------------------------------------------------------------ | | bundleName | string | 是 | 要查询的包名。 | -| bundleFlags | number | 是 | 用于指定返回的应用信息对象中包含信息的标记。默认值:0,取值范围:参考[BundleFlag说明](#bundleflag)中包信息相关flag。 | +| bundleFlags | number | 是 | 用于指定返回的应用信息对象中包含信息的标记。默认值:0,取值范围:参考[BundleFlag说明](#bundleflag)中应用信息相关flag。 | | userId | number | 是 | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 | **返回值:** @@ -196,7 +196,7 @@ SystemCapability.BundleManager.BundleFramework | 名称 | 类型 | 必填 | 描述 | | ----------- | ------ | ---- | ------------------------------------------------------------ | | bundleName | string | 是 | 要查询的包名。 | -| bundleFlags | number | 是 | 用于指定返回的应用信息对象中包含信息的标记。默认值:0,取值范围:参考[BundleFlag说明](#bundleflag)中包信息相关flag。 | +| bundleFlags | number | 是 | 用于指定返回的应用信息对象中包含信息的标记。默认值:0,取值范围:参考[BundleFlag说明](#bundleflag)中应用信息相关flag。 | **返回值:** @@ -448,7 +448,7 @@ bundle.getBundleInfo(bundleName, bundleFlags, options, (err, data) => { getBundleInfoSync(bundleName: string, bundleFlags: number, options: BundleOptions): BundleInfo; -以同步方法根据给定的包名获取ApplicationInfo,返回BundleInfo对象。 +以同步方法根据给定的包名获取BundleInfo,返回BundleInfo对象。 **需要权限:** @@ -488,7 +488,7 @@ console.info('Operation successful. Name:' + bundleInfo.name); getBundleInfoSync(bundleName: string, bundleFlags: number): BundleInfo; -以同步方法根据给定的包名获取ApplicationInfo,返回BundleInfo对象。 +以同步方法根据给定的包名获取BundleInfo,返回BundleInfo对象。 **需要权限:** @@ -2619,7 +2619,7 @@ ExtensionAbility的类型 此项仅供内部系统使用 -**系统API:**此接口为系统接口,三方应用不支持调用 +**系统API:** 此接口为系统接口,三方应用不支持调用 **系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework @@ -2628,3 +2628,154 @@ ExtensionAbility的类型 | NOT_UPGRADE9+ | 0 | 模块无需升级 | | SINGLE_UPGRADE9+ | 1 | 单个模块需要升级 | | RELATION_UPGRADE9+ | 2 | 关系模块需要升级 | + +## BundlePackFlag + +**系统API:** 此接口为系统接口,三方应用不支持调用 + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework + +| 名称 | 值 | 说明 | +| ------------------ | ---------- | -------------------------------- | +| GET_PACK_INFO_ALL | 0x00000000 | 获取应用包pack.info的所有信息 | +| GET_PACKAGES | 0x00000001 | 获取应用包pack.info的package信息 | +| GET_BUNDLE_SUMMARY | 0x00000002 | 获取应用包pack.info的bundle摘要 | +| GET_MODULE_SUMMARY | 0x00000004 | 获取应用包pack.info的module摘要 | + +## BundlePackInfo + +**系统API:** 此接口为系统接口,三方应用不支持调用 + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework + +| 名称 | 类型 | 可读 | 可写 | 说明 | +| -------- | -------------------- | ---- | ---- | --------------------------- | +| packages | Array | 是 | 否 | 获取pack.info的包信息 | +| summary | PackageSummary | 是 | 否 | 获取pack.info中的包摘要信息 | + +## PackageConfig + +**系统API:** 此接口为系统接口,三方应用不支持调用 + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework + +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ------------------- | ------------- | ---- | ---- | ------------------------------------------------------------ | +| deviceType | Array | 是 | 否 | 包支持的设备类型 | +| name | string | 是 | 否 | 包的名称 | +| moduleType | string | 是 | 否 | 包的module类型 | +| deliveryWithInstall | boolean | 是 | 否 | 是否在用户主动安装的时候安装,true表示主动安装时安装,false表示主动安装时不安装。 | + +## PackageSummary + +**系统API:** 此接口为系统接口,三方应用不支持调用 + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework + +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ------- | ----------------------- | ---- | ---- | ------------------ | +| app | BundleConfigInfo | 是 | 否 | 包的配置信息 | +| modules | Array | 是 | 否 | 包的module配置信息 | + +## BundleConfigInfo + +**系统API:** 此接口为系统接口,三方应用不支持调用 + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework + +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ---------- | ------------------- | ---- | ---- | ---------------------------------- | +| bundleName | string | 是 | 否 | 应用的包名,用于标识应用的唯一性。 | +| version | [Version](#version) | 是 | 否 | 包的版本 | + +## ModuleConfigInfo + +**系统API:** 此接口为系统接口,三方应用不支持调用 + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework + +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ------------------ | ------------------------- | ---- | ---- | -------------------------------- | +| apiVersion | ApiVersion | 是 | 否 | module的api版本 | +| deviceType | Array | 是 | 否 | module的设备类型 | +| distro | ModuleDistroInfo | 是 | 否 | module发行版信息 | +| abilities | Array | 是 | 否 | module的元能力信息 | +| extensionAbilities | Array | 是 | 否 | 描述extensionAbilities的配置信息 | + +## ModuleDistroInfo + +**系统API:** 此接口为系统接口,三方应用不支持调用 + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework + +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ------------------- | ------- | ---- | ---- | ------------------------------------------------------------ | +| mainAbility | string | 是 | 否 | 主要能力的名称 | +| deliveryWithInstall | boolean | 是 | 否 | 是否在用户主动安装的时候安装,true表示主动安装时安装,false表示主动安装时不安装。 | +| installationFree | boolean | 是 | 否 | 表示当前HAP是否支持免安装特性。true表示支持免安装特性,且符合免安装约束,false表示不支持免安装特性。 | +| moduleName | string | 是 | 否 | module名称 | +| moduleType | string | 是 | 否 | module类型 | + +## ModuleAbilityInfo + +**系统API:** 此接口为系统接口,三方应用不支持调用 + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework + +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ------- | ---------------------- | ---- | ---- | ------------------------------------------------------------ | +| name | string | 是 | 否 | 表示当前ability的逻辑名,该名称在整个应用要唯一。 | +| label | string | 是 | 否 | 表示ability对用户显示的名称,标签值配置为该名称的资源索引以支持多语言。 | +| visible | boolean | 是 | 否 | 表示ability是否可以被其它应用调用,true表示可以被其它应用调用,false表示不可以被其它应用调用。 | +| forms | Array | 是 | 否 | 卡片信息 | + +## ExtensionAbilities + +**系统API:** 此接口为系统接口,三方应用不支持调用 + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework + +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ----- | ---------------------- | ---- | ---- | ------------------------------------------------------------ | +| forms | Array | 是 | 否 | 表示form卡片的规格,form卡片是可以嵌入桌面上并接收定时更新的应用简要视图。 | + +## AbilityFormInfo + +**系统API:** 此接口为系统接口,三方应用不支持调用 + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework + +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ------------------- | ------------- | ---- | ---- | ------------------------------------------------------------ | +| name | string | 是 | 否 | 表示forms的名称 | +| type | string | 是 | 否 | 表示forms的类型 | +| updateEnabled | boolean | 是 | 否 | 表示该卡片是否支持定时刷新,true表示卡片支持定时刷新,false表示不支持。 | +| scheduledUpdateTime | string | 是 | 否 | 表示卡片定点刷新的时间,采用24小时计数,精确到分钟。 | +| updateDuration | number | 是 | 否 | 表示卡片定时刷新的更新频率,单位为30分钟,取值为30的倍数值。卡片的最高频率为每30分钟刷新一次,和定点刷新二选一,二者都配置的情况下,定时优先。 | +| supportDimensions | Array | 是 | 否 | 表示卡片外观规格,取值为“1\*2”,“2\*2”,“2\*4”,“4\*4”,定义卡片时至少要指定一个卡片规格。 | +| defaultDimension | number | 是 | 否 | 表示卡片默认外观规格,取值必须在supportDimensions配置的列表中。 | + +## ApiVersion + +**系统API:** 此接口为系统接口,三方应用不支持调用 + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework + +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ----------- | ------ | ---- | ---- | ------------------ | +| releaseType | string | 是 | 否 | 版本的最小兼容代码 | +| compatible | number | 是 | 否 | 版本的名称 | +| target | numbe | 是 | 否 | 目标版本号 | + +## Version + +**系统API:** 此接口为系统接口,三方应用不支持调用 + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework + +| 名称 | 类型 | 可读 | 可写 | 说明 | +| ------------------------ | ------ | ---- | ---- | ------------------------------------------------------------ | +| minCompatibleVersionCode | number | 是 | 否 | 能够兼容的最低历史版本号,用于跨设备兼容性判断。该值为32位整型数值,非负整数。 | +| name | string | 是 | 否 | 标识版本号的文字描述,用于向用户展示。 | +| code | number | 是 | 否 | 标识应用的版本号,值为32位非负整数。此数字仅用于确定某个版本是否比另一个版本更新,数值越大表示版本越高。 | + diff --git a/zh-cn/application-dev/reference/apis/js-apis-audio.md b/zh-cn/application-dev/reference/apis/js-apis-audio.md index 30c2923520bf9494f54082fa8ef00319fa4f5cef..8e4140b0a36a351b4b7f603e6c1650346fe6a8a2 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-audio.md +++ b/zh-cn/application-dev/reference/apis/js-apis-audio.md @@ -774,12 +774,15 @@ getRoutingManager(): Promise<AudioRoutingManager> **示例:** ```js -await audioManager.getRoutingManager().then((value) => { - var routingManager = value; - console.info('getRoutingManager Promise SUCCESS.'); -}).catch((err) => { - console.error(`Result ERROR: ${err}`); -}); +var audioManager = audio.getAudioManager(); +async function getRoutingManager(){ + await audioManager.getRoutingManager().then((value) => { + var routingManager = value; + console.info('getRoutingManager Promise SUCCESS.'); + }).catch((err) => { + console.error(`Result ERROR: ${err}`); + }); +} ``` ### setVolume @@ -2068,13 +2071,14 @@ getGroupManager(groupId: number, callback: AsyncCallback\): | 参数名 | 类型 | 必填 | 说明 | | ---------- | ------------------------------------------------------------ | ---- | -------------------- | -| networkId | string | 是 | 设备的网络id。 | +| groupId | number | 是 | 音量组id。 | | callback | AsyncCallback< [AudioGroupManager](#audiogroupmanager9) > | 是 | 回调,返回一个音量组实例。 | **示例:** ```js var audioManager = audio.getAudioManager(); +var audioGroupManager; async function getGroupManager(){ let value = await audioManager.getVolumeGroups(audio.LOCAL_NETWORK_ID); if (value.length > 0) { @@ -2105,7 +2109,7 @@ getGroupManager(groupId: number\): Promise | 参数名 | 类型 | 必填 | 说明 | | ---------- | ---------------------------------------- | ---- | ---------------- | -| networkId | string | 是 | 设备的网络id。 | +| groupId | number | 是 | 音量组id。 | **返回值:** @@ -2121,7 +2125,7 @@ async function getGroupManager(){ let value = await audioManager.getVolumeGroups(audio.LOCAL_NETWORK_ID); if (value.length > 0) { let groupid = value[0].groupId; - let audioGroupManager = await audioManager.getGroupManager(audio.LOCAL_NETWORK_ID) + let audioGroupManager = await audioManager.getGroupManager(groupid) console.info('Callback invoked to indicate that the volume group infos list is obtained.'); } } @@ -2339,6 +2343,23 @@ setVolume(volumeType: AudioVolumeType, volume: number, callback: AsyncCallback&l **示例:** ```js +var audioManager = audio.getAudioManager(); +var audioGroupManager; +async function getGroupManager(){ + let value = await audioManager.getVolumeGroups(audio.LOCAL_NETWORK_ID); + if (value.length > 0) { + let groupid = value[0].groupId; + audioManager.getGroupManager(groupid, (err, value) => { + if (err) { + console.error(`Failed to obtain the volume group infos list. ${err}`); + return; + } + audioGroupManager = value + console.info('Callback invoked to indicate that the volume group infos list is obtained.'); + }); + } +} + audioGroupManager.setVolume(audio.AudioVolumeType.MEDIA, 10, (err) => { if (err) { console.error(`Failed to set the volume. ${err}`); @@ -2378,6 +2399,24 @@ setVolume(volumeType: AudioVolumeType, volume: number): Promise<void> **示例:** ```js + +var audioManager = audio.getAudioManager(); +var audioGroupManager; +async function getGroupManager(){ + let value = await audioManager.getVolumeGroups(audio.LOCAL_NETWORK_ID); + if (value.length > 0) { + let groupid = value[0].groupId; + audioManager.getGroupManager(groupid, (err, value) => { + if (err) { + console.error(`Failed to obtain the volume group infos list. ${err}`); + return; + } + audioGroupManager = value + console.info('Callback invoked to indicate that the volume group infos list is obtained.'); + }); + } +} + audioGroupManager.setVolume(audio.AudioVolumeType.MEDIA, 10).then(() => { console.info('Promise returned to indicate a successful volume setting.'); }); @@ -2403,6 +2442,23 @@ getVolume(volumeType: AudioVolumeType, callback: AsyncCallback<number>): v **示例:** ```js +var audioManager = audio.getAudioManager(); +var audioGroupManager; +async function getGroupManager(){ + let value = await audioManager.getVolumeGroups(audio.LOCAL_NETWORK_ID); + if (value.length > 0) { + let groupid = value[0].groupId; + audioManager.getGroupManager(groupid, (err, value) => { + if (err) { + console.error(`Failed to obtain the volume group infos list. ${err}`); + return; + } + audioGroupManager = value + console.info('Callback invoked to indicate that the volume group infos list is obtained.'); + }); + } +} + audioGroupManager.getVolume(audio.AudioVolumeType.MEDIA, (err, value) => { if (err) { console.error(`Failed to obtain the volume. ${err}`); @@ -2437,6 +2493,23 @@ getVolume(volumeType: AudioVolumeType): Promise<number> **示例:** ```js +var audioManager = audio.getAudioManager(); +var audioGroupManager; +async function getGroupManager(){ + let value = await audioManager.getVolumeGroups(audio.LOCAL_NETWORK_ID); + if (value.length > 0) { + let groupid = value[0].groupId; + audioManager.getGroupManager(groupid, (err, value) => { + if (err) { + console.error(`Failed to obtain the volume group infos list. ${err}`); + return; + } + audioGroupManager = value + console.info('Callback invoked to indicate that the volume group infos list is obtained.'); + }); + } +} + audioGroupManager.getVolume(audio.AudioVolumeType.MEDIA).then((value) => { console.info(`Promise returned to indicate that the volume is obtained ${value}.`); }); @@ -2462,6 +2535,23 @@ getMinVolume(volumeType: AudioVolumeType, callback: AsyncCallback<number>) **示例:** ```js +var audioManager = audio.getAudioManager(); +var audioGroupManager; +async function getGroupManager(){ + let value = await audioManager.getVolumeGroups(audio.LOCAL_NETWORK_ID); + if (value.length > 0) { + let groupid = value[0].groupId; + audioManager.getGroupManager(groupid, (err, value) => { + if (err) { + console.error(`Failed to obtain the volume group infos list. ${err}`); + return; + } + audioGroupManager = value + console.info('Callback invoked to indicate that the volume group infos list is obtained.'); + }); + } +} + audioGroupManager.getMinVolume(audio.AudioVolumeType.MEDIA, (err, value) => { if (err) { console.error(`Failed to obtain the minimum volume. ${err}`); @@ -2496,6 +2586,23 @@ getMinVolume(volumeType: AudioVolumeType): Promise<number> **示例:** ```js +var audioManager = audio.getAudioManager(); +var audioGroupManager; +async function getGroupManager(){ + let value = await audioManager.getVolumeGroups(audio.LOCAL_NETWORK_ID); + if (value.length > 0) { + let groupid = value[0].groupId; + audioManager.getGroupManager(groupid, (err, value) => { + if (err) { + console.error(`Failed to obtain the volume group infos list. ${err}`); + return; + } + audioGroupManager = value + console.info('Callback invoked to indicate that the volume group infos list is obtained.'); + }); + } +} + audioGroupManager.getMinVolume(audio.AudioVolumeType.MEDIA).then((value) => { console.info(`Promised returned to indicate that the minimum volume is obtained ${value}.`); }); @@ -2521,6 +2628,23 @@ getMaxVolume(volumeType: AudioVolumeType, callback: AsyncCallback<number>) **示例:** ```js +var audioManager = audio.getAudioManager(); +var audioGroupManager; +async function getGroupManager(){ + let value = await audioManager.getVolumeGroups(audio.LOCAL_NETWORK_ID); + if (value.length > 0) { + let groupid = value[0].groupId; + audioManager.getGroupManager(groupid, (err, value) => { + if (err) { + console.error(`Failed to obtain the volume group infos list. ${err}`); + return; + } + audioGroupManager = value + console.info('Callback invoked to indicate that the volume group infos list is obtained.'); + }); + } +} + audioGroupManager.getMaxVolume(audio.AudioVolumeType.MEDIA, (err, value) => { if (err) { console.error(`Failed to obtain the maximum volume. ${err}`); @@ -2555,6 +2679,23 @@ getMaxVolume(volumeType: AudioVolumeType): Promise<number> **示例:** ```js +var audioManager = audio.getAudioManager(); +var audioGroupManager; +async function getGroupManager(){ + let value = await audioManager.getVolumeGroups(audio.LOCAL_NETWORK_ID); + if (value.length > 0) { + let groupid = value[0].groupId; + audioManager.getGroupManager(groupid, (err, value) => { + if (err) { + console.error(`Failed to obtain the volume group infos list. ${err}`); + return; + } + audioGroupManager = value + console.info('Callback invoked to indicate that the volume group infos list is obtained.'); + }); + } +} + audioGroupManager.getMaxVolume(audio.AudioVolumeType.MEDIA).then((data) => { console.info('Promised returned to indicate that the maximum volume is obtained.'); }); @@ -2585,6 +2726,23 @@ mute(volumeType: AudioVolumeType, mute: boolean, callback: AsyncCallback<void **示例:** ```js +var audioManager = audio.getAudioManager(); +var audioGroupManager; +async function getGroupManager(){ + let value = await audioManager.getVolumeGroups(audio.LOCAL_NETWORK_ID); + if (value.length > 0) { + let groupid = value[0].groupId; + audioManager.getGroupManager(groupid, (err, value) => { + if (err) { + console.error(`Failed to obtain the volume group infos list. ${err}`); + return; + } + audioGroupManager = value + console.info('Callback invoked to indicate that the volume group infos list is obtained.'); + }); + } +} + audioGroupManager.mute(audio.AudioVolumeType.MEDIA, true, (err) => { if (err) { console.error(`Failed to mute the stream. ${err}`); @@ -2624,6 +2782,23 @@ mute(volumeType: AudioVolumeType, mute: boolean): Promise<void> **示例:** ```js +var audioManager = audio.getAudioManager(); +var audioGroupManager; +async function getGroupManager(){ + let value = await audioManager.getVolumeGroups(audio.LOCAL_NETWORK_ID); + if (value.length > 0) { + let groupid = value[0].groupId; + audioManager.getGroupManager(groupid, (err, value) => { + if (err) { + console.error(`Failed to obtain the volume group infos list. ${err}`); + return; + } + audioGroupManager = value + console.info('Callback invoked to indicate that the volume group infos list is obtained.'); + }); + } +} + audioGroupManager.mute(audio.AudioVolumeType.MEDIA, true).then(() => { console.info('Promise returned to indicate that the stream is muted.'); }); @@ -2649,6 +2824,23 @@ isMute(volumeType: AudioVolumeType, callback: AsyncCallback<boolean>): voi **示例:** ```js +var audioManager = audio.getAudioManager(); +var audioGroupManager; +async function getGroupManager(){ + let value = await audioManager.getVolumeGroups(audio.LOCAL_NETWORK_ID); + if (value.length > 0) { + let groupid = value[0].groupId; + audioManager.getGroupManager(groupid, (err, value) => { + if (err) { + console.error(`Failed to obtain the volume group infos list. ${err}`); + return; + } + audioGroupManager = value + console.info('Callback invoked to indicate that the volume group infos list is obtained.'); + }); + } +} + audioGroupManager.isMute(audio.AudioVolumeType.MEDIA, (err, value) => { if (err) { console.error(`Failed to obtain the mute status. ${err}`); @@ -2683,6 +2875,23 @@ isMute(volumeType: AudioVolumeType): Promise<boolean> **示例:** ```js +var audioManager = audio.getAudioManager(); +var audioGroupManager; +async function getGroupManager(){ + let value = await audioManager.getVolumeGroups(audio.LOCAL_NETWORK_ID); + if (value.length > 0) { + let groupid = value[0].groupId; + audioManager.getGroupManager(groupid, (err, value) => { + if (err) { + console.error(`Failed to obtain the volume group infos list. ${err}`); + return; + } + audioGroupManager = value + console.info('Callback invoked to indicate that the volume group infos list is obtained.'); + }); + } +} + audioGroupManager.isMute(audio.AudioVolumeType.MEDIA).then((value) => { console.info(`Promise returned to indicate that the mute status of the stream is obtained ${value}.`); }); @@ -2709,8 +2918,9 @@ getCurrentAudioRendererInfoArray(callback: AsyncCallback<AudioRendererChangeI **示例:** ```js +var audioManager = audio.getAudioManager(); let audioStreamManager; -audio.getStreamManager((err, data) => { +audioManager.getStreamManager((err, data) => { if (err) { console.error(`getStreamManager : Error: ${err}`); } else { @@ -2766,8 +2976,9 @@ getCurrentAudioRendererInfoArray(): Promise<AudioRendererChangeInfoArray> **示例:** ```js +var audioManager = audio.getAudioManager(); let audioStreamManager; -audio.getStreamManager((err, data) => { +audioManager.getStreamManager((err, data) => { if (err) { console.error(`getStreamManager : Error: ${err}`); } else { @@ -2821,8 +3032,9 @@ getCurrentAudioCapturerInfoArray(callback: AsyncCallback<AudioCapturerChangeI **示例:** ```js +var audioManager = audio.getAudioManager(); let audioStreamManager; -audio.getStreamManager((err, data) => { +audioManager.getStreamManager((err, data) => { if (err) { console.error(`getStreamManager : Error: ${err}`); } else { @@ -2876,8 +3088,9 @@ getCurrentAudioCapturerInfoArray(): Promise<AudioCapturerChangeInfoArray> **示例:** ```js +var audioManager = audio.getAudioManager(); let audioStreamManager; -audio.getStreamManager((err, data) => { +audioManager.getStreamManager((err, data) => { if (err) { console.error(`getStreamManager : Error: ${err}`); } else { @@ -2930,8 +3143,9 @@ on(type: "audioRendererChange", callback: Callback<AudioRendererChangeInfoArr **示例:** ```js +var audioManager = audio.getAudioManager(); let audioStreamManager; -audio.getStreamManager((err, data) => { +audioManager.getStreamManager((err, data) => { if (err) { console.error(`getStreamManager : Error: ${err}`); } else { @@ -2981,8 +3195,9 @@ off(type: "audioRendererChange"); **示例:** ```js +var audioManager = audio.getAudioManager(); let audioStreamManager; -audio.getStreamManager((err, data) => { +audioManager.getStreamManager((err, data) => { if (err) { console.error(`getStreamManager : Error: ${err}`); } else { @@ -3013,8 +3228,9 @@ on(type: "audioCapturerChange", callback: Callback<AudioCapturerChangeInfoArr **示例:** ```js +var audioManager = audio.getAudioManager(); let audioStreamManager; -audio.getStreamManager((err, data) => { +audioManager.getStreamManager((err, data) => { if (err) { console.error(`getStreamManager : Error: ${err}`); } else { @@ -3063,8 +3279,9 @@ off(type: "audioCapturerChange"); **示例:** ```js +var audioManager = audio.getAudioManager(); let audioStreamManager; -audio.getStreamManager((err, data) => { +audioManager.getStreamManager((err, data) => { if (err) { console.error(`getStreamManager : Error: ${err}`); } else { @@ -3099,11 +3316,11 @@ getDevices(deviceFlag: DeviceFlag, callback: AsyncCallback<AudioDeviceDescrip **示例:** ```js +var audioManager = audio.getAudioManager(); audioManager.getRoutingManager((err,AudioRoutingManager)=>{ if (err) { console.error(`AudioFrameworkTest:Callback:failed to get RoutingManager ${err}`); - } - else { + } else { AudioRoutingManager.getDevices(audio.DeviceFlag.OUTPUT_DEVICES_FLAG, (err, value) => { if (err) { console.error(`Failed to obtain the device list. ${err}`); @@ -3138,6 +3355,7 @@ getDevices(deviceFlag: DeviceFlag): Promise<AudioDeviceDescriptors> **示例:** ```js +var audioManager = audio.getAudioManager(); audioManager.getRoutingManager((err,AudioRoutingManager)=>{ if (err) { console.error(`AudioFrameworkTest:Callback:failed to get RoutingManager ${err}`); @@ -3169,6 +3387,7 @@ on(type: 'deviceChange', deviceFlag: DeviceFlag, callback: Callback{ if (err) { console.error(`AudioFrameworkTest:Callback:failed to get RoutingManager ${err}`); @@ -3203,6 +3422,7 @@ off(type: 'deviceChange', callback?: Callback): void **示例:** ```js +var audioManager = audio.getAudioManager(); audioManager.getRoutingManager((err,AudioRoutingManager)=>{ if (err) { console.error(`AudioFrameworkTest:Callback:failed to get RoutingManager ${err}`); @@ -3234,21 +3454,25 @@ selectOutputDevice(outputAudioDevices: AudioDeviceDescriptors, callback: AsyncCa **示例:** ```js +var audioManager = audio.getAudioManager(); let outputAudioDeviceDescriptor = [{ "deviceRole":audio.DeviceRole.OUTPUT_DEVICE, "networkId":audio.LOCAL_NETWORK_ID, "interruptGroupId":1, "volumeGroupId":1 }]; var audioRoutingManager; -await audioManager.getRoutingManager().then((value) => { - audioRoutingManager = value; - audioRoutingManager.selectOutputDevice(outputAudioDeviceDescriptor, (err) => { - if (err) { - console.error(`Result ERROR: ${err}`); - } else { - console.info('Select output devices result callback: SUCCESS'); } + +async function getRoutingManager(){ + await audioManager.getRoutingManager().then((value) => { + audioRoutingManager = value; + audioRoutingManager.selectOutputDevice(outputAudioDeviceDescriptor, (err) => { + if (err) { + console.error(`Result ERROR: ${err}`); + } else { + console.info('Select output devices result callback: SUCCESS'); } + }); }); -}); +} ``` ### selectOutputDevice9+ @@ -3276,20 +3500,24 @@ selectOutputDevice(outputAudioDevices: AudioDeviceDescriptors): Promise<void& **示例:** ```js +var audioManager = audio.getAudioManager(); let outputAudioDeviceDescriptor =[{ "deviceRole":audio.DeviceRole.OUTPUT_DEVICE, "networkId":audio.LOCAL_NETWORK_ID, "interruptGroupId":1, "volumeGroupId":1 }]; var audioRoutingManager; -await audioManager.getRoutingManager().then((value) => { - audioRoutingManager = value; - audioRoutingManager.selectOutputDevice(outputAudioDeviceDescriptor).then(() => { - console.info('Select output devices result promise: SUCCESS'); - }).catch((err) => { - console.error(`Result ERROR: ${err}`); + +async function getRoutingManager(){ + await audioManager.getRoutingManager().then((value) => { + audioRoutingManager = value; + audioRoutingManager.selectOutputDevice(outputAudioDeviceDescriptor).then(() => { + console.info('Select output devices result promise: SUCCESS'); + }).catch((err) => { + console.error(`Result ERROR: ${err}`); + }); }); -}); +} ``` ### selectOutputDeviceByFilter9+ @@ -3312,6 +3540,7 @@ selectOutputDeviceByFilter(filter: AudioRendererFilter, outputAudioDevices: Audi **示例:** ```js +var audioManager = audio.getAudioManager(); let outputAudioRendererFilter = { "uid":20010041, "rendererInfo": { @@ -3325,15 +3554,18 @@ let outputAudioDeviceDescriptor = [{ "interruptGroupId":1, "volumeGroupId":1 }]; var audioRoutingManager; -await audioManager.getRoutingManager().then((value) => { - audioRoutingManager = value; - audioRoutingManager.selectOutputDeviceByFilter(outputAudioRendererFilter, outputAudioDeviceDescriptor, (err) => { - if (err) { - console.error(`Result ERROR: ${err}`); - } else { - console.info('Select output devices by filter result callback: SUCCESS'); } + +async function getRoutingManager(){ + await audioManager.getRoutingManager().then((value) => { + audioRoutingManager = value; + audioRoutingManager.selectOutputDeviceByFilter(outputAudioRendererFilter, outputAudioDeviceDescriptor, (err) => { + if (err) { + console.error(`Result ERROR: ${err}`); + } else { + console.info('Select output devices by filter result callback: SUCCESS'); } + }); }); -}); +} ``` ### selectOutputDeviceByFilter9+ @@ -3362,6 +3594,7 @@ selectOutputDeviceByFilter(filter: AudioRendererFilter, outputAudioDevices: Audi **示例:** ```js +var audioManager = audio.getAudioManager(); let outputAudioRendererFilter = { "uid":20010041, "rendererInfo": { @@ -3375,14 +3608,17 @@ let outputAudioDeviceDescriptor = [{ "interruptGroupId":1, "volumeGroupId":1 }]; var audioRoutingManager; -await audioManager.getRoutingManager().then((value) => { - audioRoutingManager = value; - audioRoutingManager.selectOutputDeviceByFilter(outputAudioRendererFilter, outputAudioDeviceDescriptor).then(() => { - console.info('Select output devices by filter result promise: SUCCESS'); - }).catch((err) => { - console.error(`Result ERROR: ${err}`); - }) -}); + +async function getRoutingManager(){ + await audioManager.getRoutingManager().then((value) => { + audioRoutingManager = value; + audioRoutingManager.selectOutputDeviceByFilter(outputAudioRendererFilter, outputAudioDeviceDescriptor).then(() => { + console.info('Select output devices by filter result promise: SUCCESS'); + }).catch((err) => { + console.error(`Result ERROR: ${err}`); + }) + }); +} ``` ## AudioRendererChangeInfo9+ @@ -3413,12 +3649,14 @@ var audioStreamManager; var audioStreamManagerCB; var resultFlag = false; -await audioManager.getStreamManager().then(async function (data) { - audioStreamManager = data; - console.info('Get AudioStream Manager : Success'); -}).catch((err) => { - console.error(`Get AudioStream Manager : ERROR : ${err}`); -}); +async function getStreamManager(){ + await audioManager.getStreamManager().then(async function (data) { + audioStreamManager = data; + console.info('Get AudioStream Manager : Success'); + }).catch((err) => { + console.error(`Get AudioStream Manager : ERROR : ${err}`); + }); +} audioManager.getStreamManager((err, data) => { if (err) { @@ -4011,7 +4249,10 @@ audioRenderer.getBufferSize().then((data)=> { }); console.info(`Buffer size: ${bufferSize}`); var context = featureAbility.getContext(); -var path = await context.getCacheDir(); +var path; +async function getCacheDir(){ + path = await context.getCacheDir(); +} var filePath = path + '/StarWars10s-2C-48000-4SW.wav'; let ss = fileio.createStreamSync(filePath, 'r'); let buf = new ArrayBuffer(bufferSize); @@ -4079,7 +4320,9 @@ audioRenderer.getBufferSize().then((data) => { }); console.info(`BufferSize: ${bufferSize}`); var context = featureAbility.getContext(); -var path = await context.getCacheDir(); +async function getCacheDir(){ + path = await context.getCacheDir(); +} var filePath = 'data/StarWars10s-2C-48000-4SW.wav'; let ss = fileio.createStreamSync(filePath, 'r'); let buf = new ArrayBuffer(bufferSize); @@ -4358,7 +4601,11 @@ var audioRendererOptions = { streamInfo: audioStreamInfo, rendererInfo: audioRendererInfo } -let audioRenderer = await audio.createAudioRenderer(audioRendererOptions); +let audioRenderer; +async function createAudioRenderer(){ + audioRenderer = await audio.createAudioRenderer(audioRendererOptions); +} + let mode = 0; audioRenderer.setInterruptMode(mode).then(data=>{ console.info('setInterruptMode Success!'); @@ -4399,7 +4646,12 @@ var audioRendererOptions = { streamInfo: audioStreamInfo, rendererInfo: audioRendererInfo } -let audioRenderer = await audio.createAudioRenderer(audioRendererOptions); + +let audioRenderer; +async function createAudioRenderer(){ + audioRenderer = await audio.createAudioRenderer(audioRendererOptions); +} + let mode = 1; audioRenderer.setInterruptMode(mode, (err, data)=>{ if(err){ @@ -4944,7 +5196,7 @@ audioCapturer.getBufferSize().then((data) => { console.info(`AudioFrameworkRecLog: getBufferSize: SUCCESS ${data}`); bufferSize = data; }).catch((err) => { - console.error(`AudioFrameworkRecLog: getBufferSize: EROOR: ${err}`); + console.error(`AudioFrameworkRecLog: getBufferSize: ERROR: ${err}`); }); audioCapturer.read(bufferSize, true, async(err, buffer) => { if (!err) { @@ -5183,7 +5435,7 @@ off(type: 'periodReach'): void | 参数名 | 类型 | 必填 | 说明 | | :----- | :----- | :--- | :---------------------------------------------- | -| type | string | Yes | 取消事件回调类型,支持的事件为:'periodReach'。 | +| type | string | 是 | 取消事件回调类型,支持的事件为:'periodReach'。 | **示例:** diff --git a/zh-cn/application-dev/reference/apis/js-apis-call.md b/zh-cn/application-dev/reference/apis/js-apis-call.md index b131dbdb738f629f4dead764903335e9ec3ce1cc..e7bad6cac33622c1d7267969e75216f6808e4c7c 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-call.md +++ b/zh-cn/application-dev/reference/apis/js-apis-call.md @@ -319,7 +319,7 @@ isEmergencyPhoneNumber\(phoneNumber: string, options: EmergencyNumberOptions, ca **示例:** ```js -call.isEmergencyPhoneNumber("112", {slotId: 1}, (err, value) => { +call.isEmergencyPhoneNumber("112", {slotId: 1}, (err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); ``` @@ -468,9 +468,7 @@ formatPhoneNumberToE164\(phoneNumber: string, countryCode: string, callback: Asy **示例:** ```js -call.formatPhoneNumberToE164("138xxxxxxxx",{ - countryCode: "CN" -}, (err, data) => { +call.formatPhoneNumberToE164("138xxxxxxxx", "CN", (err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); ``` @@ -504,9 +502,7 @@ formatPhoneNumberToE164\(phoneNumber: string, countryCode: string\): Promise { console.log(`formatPhoneNumberToE164 success, promise: data->${JSON.stringify(data)}`); }).catch(err => { @@ -1703,7 +1699,7 @@ on\(type: 'mmiCodeResult', callback: Callback\): void **示例:** ```js -isNewCallAllowedcall.on('mmiCodeResult', (err, data) => { +call.on('mmiCodeResult', (err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); ``` @@ -2072,10 +2068,7 @@ getCallTransferInfo\(slotId: number, type: CallTransferType, callback: AsyncCall **示例:** ```js -let callTransferTyp={ - CallTransferType: 1 -} -call.getCallTransferInfo(0, callTransferTyp, (err, data) => { +call.getCallTransferInfo(0, call.CallTransferType.TRANSFER_TYPE_BUSY, (err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); ``` @@ -2107,10 +2100,7 @@ getCallTransferInfo\(slotId: number, type: CallTransferType): Promise { console.log(`getCallTransferInfo success, promise: data->${JSON.stringify(data)}`); }).catch(err => { @@ -2399,7 +2389,7 @@ setAudioDevice\(device: AudioDevice, options: AudioDeviceOptions, callback: Asyn let audioDeviceOptions={ bluetoothAddress: "IEEE 802-2014" } -call.setAudioDevice(1, bluetoothAddress, (err, value) => { +call.setAudioDevice(1, audioDeviceOptions, (err, value) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); ``` @@ -2463,7 +2453,10 @@ joinConference(mainCallId: number, callNumberList: Array, callback: Asy **示例:** ```js -call.joinConference(1, "138XXXXXXXX", (err, data) => { +let callNumberList: Array = [ + "138XXXXXXXX" +]; +call.joinConference(1, callNumberList, (err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); ``` @@ -2494,7 +2487,10 @@ joinConference(mainCallId: number, callNumberList: Array): Promise = [ + "138XXXXXXXX" +]; +let promise = call.joinConference(1, callNumberList); promise.then(data => { console.log(`joinConference success, promise: data->${JSON.stringify(data)}`); }).catch(err => { diff --git a/zh-cn/application-dev/reference/apis/js-apis-camera.md b/zh-cn/application-dev/reference/apis/js-apis-camera.md index c5bfbb5b4e0447b82999ce68f678d7c5c3d81d2e..558f36ff7f2bfcbbfb12476545f880fc1ac1cc64 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-camera.md +++ b/zh-cn/application-dev/reference/apis/js-apis-camera.md @@ -631,7 +631,7 @@ createPreviewOutput(profile: Profile, surfaceId: string): Promise { +cameraManager.createPreviewOutput(profile, surfaceId).then((previewoutput) => { console.log('Promise returned with previewOutput created.'); }) ``` @@ -2262,7 +2262,7 @@ cameraInput.isExposureModeSupported(camera.ExposureMode.EXPOSURE_MODE_LOCKEN,(er console.log(`Failed to check exposure mode supported ${err.message}`); return ; } - console.log('Callback returned with the successful excution of isExposureModeSupported'); + console.log('Callback returned with the successful execution of isExposureModeSupported'); }) ``` @@ -2365,7 +2365,7 @@ cameraInput.setExposureMode(camera.ExposureMode.EXPOSURE_MODE_LOCKEN,(err) => { console.log(`Failed to set the exposure mode ${err.message}`); return ; } - console.log('Callback returned with the successful excution of setExposureMode'); + console.log('Callback returned with the successful execution of setExposureMode'); }) ``` @@ -2464,7 +2464,7 @@ cameraInput.setMeteringPoint(Point1,(err) => { console.log(`Failed to set the exposure point ${err.message}`); return ; } - console.log('Callback returned with the successful excution of setMeteringPoint'); + console.log('Callback returned with the successful execution of setMeteringPoint'); }) ``` @@ -2571,7 +2571,7 @@ cameraInput.setExposureBias(-4,(err) => { console.log(`Failed to set the exposure bias ${err.message}`); return ; } - console.log('Callback returned with the successful excution of setExposureBias'); + console.log('Callback returned with the successful execution of setExposureBias'); }) ``` @@ -3545,7 +3545,7 @@ previewOutput.stop((err) => { console.error(`Failed to stop the previewOutput. ${err.message}`); return; } - console.log('Callback returned with previewOutput stoped.'); + console.log('Callback returned with previewOutput stopped.'); }) ``` @@ -3567,7 +3567,7 @@ stop(): Promise ```js previewOutput.stop().then(() => { - console.log('Callback returned with previewOutput stoped.'); + console.log('Callback returned with previewOutput stopped.'); }) ``` @@ -4476,7 +4476,7 @@ metadataOutput.stop((err) => { console.error(`Failed to stop the metadataOutput. ${err.message}`); return; } - console.log('Callback returned with metadataOutput stoped.'); + console.log('Callback returned with metadataOutput stopped.'); }) ``` @@ -4498,7 +4498,7 @@ stop(): Promise ```js metadataOutput.stop().then(() => { - console.log('Callback returned with metadataOutput stoped.'); + console.log('Callback returned with metadataOutput stopped.'); }) ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-contact.md b/zh-cn/application-dev/reference/apis/js-apis-contact.md index 7a5510f3c3047c2a55582f4b45e8222d768833d0..1cc7f540dc1cb54fe0b44cad97081435f9beb013 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-contact.md +++ b/zh-cn/application-dev/reference/apis/js-apis-contact.md @@ -34,7 +34,7 @@ addContact(contact:Contact, callback:AsyncCallback<number>): void ```js contact.addContact({ - fullName: {fullName: 'xxx'}, + name: {fullName: 'xxx'}, phoneNumbers: [{phoneNumber: '138xxxxxxxx'}] }, (err, data) => { if (err) { @@ -202,7 +202,7 @@ updateContact(contact: Contact, attrs: ContactAttributes, callback: AsyncCallbac ```js contact.updateContact({ - fullName: {fullName: 'xxx'}, + name: {fullName: 'xxx'}, phoneNumbers: [{phoneNumber: '138xxxxxxxx'}] },{ attributes:[contact.Attribute.ATTR_EMAIL, contact.Attribute.ATTR_NAME] @@ -242,7 +242,7 @@ updateContact(contact: Contact, attrs?: ContactAttributes): Promise<void> ```js let promise = contact.updateContact({ - fullName: {fullName: 'xxx'}, + name: {fullName: 'xxx'}, phoneNumbers: [{phoneNumber: '138xxxxxxxx'}] }, { attributes: [contact.Attribute.ATTR_EMAIL, contact.Attribute.ATTR_NAME] @@ -487,7 +487,7 @@ selectContact(callback: AsyncCallback<Array<Contact>>): void **需要权限**:ohos.permission.READ_CONTACTS -**系统能力**:SystemCapability.Applications.Contacts、SystemCapability.Applications.ContactsData +**系统能力**:SystemCapability.Applications.ContactsData **参数:** @@ -1450,7 +1450,7 @@ queryKey(id: number, holder: Holder, callback: AsyncCallback<string>): voi **示例:** ```js - contact.queryKey(id, { + contact.queryKey(/*id*/1, { holderId: 0, bundleName: "", displayName: "" @@ -1490,7 +1490,7 @@ queryKey(id: number, holder?: Holder): Promise<string> **示例:** ```js - let promise = contact.queryKey(id, { + let promise = contact.queryKey(/*id*/1, { holderId: 0, bundleName: "", displayName: "" @@ -1605,7 +1605,7 @@ let contactAttributes = { ```js let contactAttributes = new contact.ContactAttributes(); -contactAttributes.attributes = ["ATTR_EMAIL"]; +contactAttributes.attributes = [contact.Attribute.ATTR_EMAIL]; ``` @@ -2242,4 +2242,4 @@ let website = { ```js let website = new contact.Website(); website.website = "website"; -``` \ No newline at end of file +``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-effectKit.md b/zh-cn/application-dev/reference/apis/js-apis-effectKit.md index 0c6f2e1c6d0936f4171997219269628d80faa390..b93ba37d994da644117a8e022b574453014360ef 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-effectKit.md +++ b/zh-cn/application-dev/reference/apis/js-apis-effectKit.md @@ -40,13 +40,14 @@ createEffect(source: image.PixelMap): Filter **示例:** ```js -import image from "@ohos.multimedia.image" +import image from "@ohos.multimedia.image"; + const color = new ArrayBuffer(96); -let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }; -image.createPixelMap(color, opts) - .then((pixelMap) => { - let headFilter = effectKit.createEffect(pixelMap) - }) +let bufferArr = new Uint8Array(color); +let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } } +image.createPixelMap(color, opts).then((pixelMap) => { + let headFilter = effectKit.createEffect(pixelMap); +}) ``` ## effectKit.createColorPicker @@ -72,14 +73,15 @@ createColorPicker(source: image.PixelMap): Promise\ **示例:** ```js -import image from "@ohos.multimedia.image" +import image from "@ohos.multimedia.image"; + const color = new ArrayBuffer(96); -let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }; -image.createPixelMap(color, opts, (pixelMap) => { - effectKit.createColorPicker(pixelMap).then(colorPicker => { - console.info("color picker=" + colorPicker); - }) - .catch(ex => console.error(".error=" + ex.toString())) +let bufferArr = new Uint8Array(color); +let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } } +image.createPixelMap(color, opts).then((pixelMap) => { + effectKit.createColorPicker(pixelMap).then(colorPicker => { + console.info("color picker=" + colorPicker); + }).catch(ex => console.error(".error=" + ex.toString())) }) ``` @@ -101,17 +103,19 @@ createColorPicker(source: image.PixelMap, callback: AsyncCallback\) **示例:** ```js -import image from "@ohos.multimedia.image" +import image from "@ohos.multimedia.image"; + const color = new ArrayBuffer(96); -let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }; -image.createPixelMap(color, opts, (pixelMap) => { - effectKit.createColorPicker(pixelMap, (error, colorPicker) => { - if(error) { - console.log('Failed to create color picker.'); - } else { - console.log('Succeeded in creating color picker.'); - } - }) +let bufferArr = new Uint8Array(color); +let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } } +image.createPixelMap(color, opts).then((pixelMap) => { + effectKit.createColorPicker(pixelMap, (error, colorPicker) => { + if (error) { + console.log('Failed to create color picker.'); + } else { + console.log('Succeeded in creating color picker.'); + } + }) }) ``` @@ -150,7 +154,7 @@ getMainColor(): Promise\ ```js colorPicker.getMainColor().then(color => { - console.log('Succeeded in getting main color.') + console.log('Succeeded in getting main color.'); console.info("color[ARGB]=" + color.alpha + "," + color.red + "," + color.green + "," + color.blue); }).catch(error => { console.log('Failed to get main color.'); @@ -205,17 +209,17 @@ blur(radius: number): Filter **示例:** ```js -import image from "@ohos.multimedia.image" +import image from "@ohos.multimedia.image"; + const color = new ArrayBuffer(96); let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }; -image.createPixelMap(color, opts) - .then((pixelMap) => { - let radius = 5; - let headFilter = effectKit.createEffect(pixelMap) - if (headFilter != null) { - headFilter.blur(radius) - } - }) +image.createPixelMap(color, opts).then((pixelMap) => { + let radius = 5; + let headFilter = effectKit.createEffect(pixelMap); + if (headFilter != null) { + headFilter.blur(radius); + } +}) ``` ### brightness @@ -241,17 +245,17 @@ brightness(bright: number): Filter **示例:** ```js -import image from "@ohos.multimedia.image" +import image from "@ohos.multimedia.image"; + const color = new ArrayBuffer(96); let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }; -image.createPixelMap(color, opts) - .then((pixelMap) => { - let bright = 0.5; - let headFilter = effectKit.createEffect(pixelMap) - if (headFilter != null) { - headFilter.brightness(bright) - } - }) +image.createPixelMap(color, opts).then((pixelMap) => { + let bright = 0.5; + let headFilter = effectKit.createEffect(pixelMap); + if (headFilter != null) { + headFilter.brightness(bright); + } +}) ``` ### grayscale @@ -271,16 +275,16 @@ grayscale(): Filter **示例:** ```js -import image from "@ohos.multimedia.image" +import image from "@ohos.multimedia.image"; + const color = new ArrayBuffer(96); let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }; -image.createPixelMap(color, opts) - .then((pixelMap) => { - let headFilter = effectKit.createEffect(pixelMap) - if (headFilter != null) { - headFilter.grayscale() - } - }) +image.createPixelMap(color, opts).then((pixelMap) => { + let headFilter = effectKit.createEffect(pixelMap); + if (headFilter != null) { + headFilter.grayscale(); + } +}) ``` ### getPixelMap @@ -300,11 +304,11 @@ getPixelMap(): image.PixelMap **示例:** ```js -import image from "@ohos.multimedia.image" +import image from "@ohos.multimedia.image"; + const color = new ArrayBuffer(96); let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }; -image.createPixelMap(color, opts) - .then((pixelMap) => { - let pixel = effectKit.createEffect(pixelMap).grayscale().getPixelMap() - }) +image.createPixelMap(color, opts).then((pixelMap) => { + let pixel = effectKit.createEffect(pixelMap).grayscale().getPixelMap(); +}) ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-hidebug.md b/zh-cn/application-dev/reference/apis/js-apis-hidebug.md index cf4397ba91c2b9080a7fb8dae0be363f0fa6028e..c57ae6c7aac7b28ce9077ed2070611f873004d00 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-hidebug.md +++ b/zh-cn/application-dev/reference/apis/js-apis-hidebug.md @@ -16,7 +16,7 @@ import hidebug from '@ohos.hidebug'; getNativeHeapSize(): bigint -获取native heap内存的总大小。 +获取本应用堆内存的总大小。 本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。 @@ -26,7 +26,7 @@ getNativeHeapSize(): bigint | 类型 | 说明 | | ------ | --------------------------- | -| bigint | 返回native heap内存总大小,单位为kB。 | +| bigint | 返回本应用堆内存总大小,单位为kB。 | **示例:** @@ -39,7 +39,7 @@ getNativeHeapSize(): bigint getNativeHeapAllocatedSize(): bigint -获取native heap内存的已分配内存大小。 +获取本应用堆内存的已分配内存大小。 本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。 @@ -49,7 +49,7 @@ getNativeHeapAllocatedSize(): bigint | 类型 | 说明 | | ------ | --------------------------------- | -| bigint | 返回native heap内存的已分配内存,单位为kB。 | +| bigint | 返回本应用堆内存的已分配内存,单位为kB。 | **示例:** @@ -62,7 +62,7 @@ getNativeHeapAllocatedSize(): bigint getNativeHeapFreeSize(): bigint -获取native heap内存的空闲内存大小。 +获取本应用堆内存的空闲内存大小。 本接口在OpenHarmony 3.1 Release版本仅为接口定义,暂不支持使用。 @@ -72,7 +72,7 @@ getNativeHeapFreeSize(): bigint | 类型 | 说明 | | ------ | ------------------------------- | -| bigint | 返回native heap内存的空闲内存,单位为kB。 | +| bigint | 返回本应用堆内存的空闲内存,单位为kB。 | **示例:** ```js @@ -84,7 +84,7 @@ getNativeHeapFreeSize(): bigint getPss(): bigint -获取应用进程PSS内存大小。 +获取应用进程实际使用的物理内存大小。 **系统能力:** SystemCapability.HiviewDFX.HiProfiler.HiDebug @@ -92,7 +92,7 @@ getPss(): bigint | 类型 | 说明 | | ------ | ------------------------- | -| bigint | 返回应用进程PSS内存大小,单位为kB。 | +| bigint | 返回应用进程实际使用的物理内存大小,单位为kB。 | **示例:** ```js @@ -144,7 +144,7 @@ getPrivateDirty(): bigint getCpuUsage(): number -获取进程的cpu占用率。 +获取进程的cpu使用率。 如占用率为50%,则返回0.5。 @@ -154,7 +154,7 @@ getCpuUsage(): number | 类型 | 说明 | | ------ | -------------------------- | -| number | 获取进程的cpu占用率。 | +| number | 获取进程的cpu使用率。 | **示例:** @@ -166,7 +166,7 @@ getCpuUsage(): number startProfiling(filename : string) : void -启动虚拟机Profiling方法跟踪,`startProfiling()`方法的调用需要与`stopProfiling()`方法的调用一一对应,先开启后关闭,严禁使用`start->start->stop`,`start->stop->stop`,`start->start->stop->stop`等顺序的调用方式。 +启动虚拟机Profiling方法跟踪,`startProfiling()`方法的调用需要与`stopProfiling()`方法的调用一一对应,先开启后关闭,严禁使用`start->start->stop`,`start->stop->stop`,`start->start->stop->stop`等类似的顺序调用。 **系统能力:** SystemCapability.HiviewDFX.HiProfiler.HiDebug @@ -192,7 +192,7 @@ hidebug.stopProfiling(); stopProfiling() : void -停止虚拟机Profiling方法跟踪,`stopProfiling()`方法的调用需要与`startProfiling()`方法的调用一一对应,先开启后关闭,严禁使用`start->start->stop`,`start->stop->stop`,`start->start->stop->stop`等顺序的调用方式。 +停止虚拟机Profiling方法跟踪,`stopProfiling()`方法的调用需要与`startProfiling()`方法的调用一一对应,先开启后关闭,严禁使用`start->start->stop`,`start->stop->stop`,`start->start->stop->stop`等类似的顺序调用。 **系统能力:** SystemCapability.HiviewDFX.HiProfiler.HiDebug diff --git a/zh-cn/application-dev/reference/apis/js-apis-image.md b/zh-cn/application-dev/reference/apis/js-apis-image.md index 95ba48bbb241791d2a51b8418a82ee7e82c775c1..63b3f9d07263b3e5fbfd92b499210c31b9c4929b 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-image.md +++ b/zh-cn/application-dev/reference/apis/js-apis-image.md @@ -169,7 +169,12 @@ readPixels(area: PositionArea): Promise\ **示例:** ```js -const area = new ArrayBuffer(400); +const area = { + pixels: new ArrayBuffer(8), + offset: 0, + stride: 8, + region: { size: { height: 1, width: 2 }, x: 0, y: 0 } +} pixelmap.readPixels(area).then(() => { console.log('Succeeded in reading the image data in the area.'); //符合条件则进入 }).catch(error => { @@ -1449,7 +1454,7 @@ createPixelMap(callback: AsyncCallback\): void ```js imageSourceApi.createPixelMap((err, pixelmap) => { - console.info('Succeeded in creating pixelmap object.'); + console.info('Succeeded in creating pixelmap object.'); }) ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-media.md b/zh-cn/application-dev/reference/apis/js-apis-media.md index feb7845e3f368fef9fe239e5bac5c96ca5517140..7dd7e6ddf623f068d85be5eea9ec2543fc2f1100 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-media.md +++ b/zh-cn/application-dev/reference/apis/js-apis-media.md @@ -189,7 +189,7 @@ media.createVideoRecorder().then((video) => { 媒体服务错误类型枚举。 -**系统能力:** 以下各项对应的系统能力均为 SystemCapability.Multimedia.Media.Core。 +**系统能力:** SystemCapability.Multimedia.Media.Core | 名称 | 值 | 说明 | | -------------------------- | ---- | -------------------------------------- | @@ -208,7 +208,7 @@ media.createVideoRecorder().then((video) => { 媒体类型枚举。 -**系统能力:** 以下各项对应的系统能力均为 SystemCapability.Multimedia.Media.Core。 +**系统能力:** SystemCapability.Multimedia.Media.Core | 名称 | 值 | 说明 | | -------------- | ---- | ---------- | @@ -219,7 +219,7 @@ media.createVideoRecorder().then((video) => { Codec MIME类型枚举。 -**系统能力:** 以下各项对应的系统能力均为 SystemCapability.Multimedia.Media.Core。 +**系统能力:** SystemCapability.Multimedia.Media.Core | 名称 | 值 | 说明 | | ------------ | --------------------- | ------------------------ | @@ -236,7 +236,7 @@ Codec MIME类型枚举。 媒体信息描述枚举。 -**系统能力:** 以下各项对应的系统能力均为 SystemCapability.Multimedia.Media.Core。 +**系统能力:** SystemCapability.Multimedia.Media.Core | 名称 | 值 | 说明 | | ------------------------ | --------------- | ------------------------------------------------------------ | @@ -255,7 +255,7 @@ Codec MIME类型枚举。 缓存事件类型枚举。 -**系统能力:** 以下各项对应的系统能力均为 SystemCapability.Multimedia.Media.Core。 +**系统能力:** SystemCapability.Multimedia.Media.Core | 名称 | 值 | 说明 | | ----------------- | ---- | -------------------------------- | @@ -272,14 +272,14 @@ Codec MIME类型枚举。 ### 属性 -**系统能力:** 以下各项对应的系统能力均为 SystemCapability.Multimedia.Media.AudioPlayer。 +**系统能力:** ystemCapability.Multimedia.Media.AudioPlayer | 名称 | 类型 | 可读 | 可写 | 说明 | | ------------------------------- | ----------------------------------- | ---- | ---- | ------------------------------------------------------------ | -| src | string | 是 | 是 | 音频媒体URI,支持当前主流的音频格式(m4a、aac、mp3、ogg、wav)。
**支持路径示例**:
1. fd类型播放:fd://xx
![](figures/zh-cn_image_url.png)
2. http网络播放: http://xx
3. https网络播放: https://xx
4. hls网络播放路径:http://xx或者https://xx
**需要权限:** ohos.permission.READ_MEDIA;如果需要使用网络素材,还需要申请ohos.permission.INTERNET。 | -| fdSrc9+ | [AVFileDescriptor](#interruptmode9) | 是 | 是 | 音频媒体文件描述,使用场景:应用中的音频资源被连续存储在同一个文件中。
**使用示例**:
假设一个连续存储的音乐文件:
音乐1(地址偏移:0,字节长度:100)
音乐2(地址偏移:101,字节长度:50)
音乐3(地址偏移:151,字节长度:150)
1. 播放音乐1:AVFileDescriptor { fd = 资源句柄; offset = 0; length = 100; }
2. 播放音乐2:AVFileDescriptor { fd = 资源句柄; offset = 101; length = 50; }
3. 播放音乐3:AVFileDescriptor { fd = 资源句柄; offset = 151; length = 150; }
假设是一个独立的音乐文件: 请使用src=fd://xx
**注意事项**:
**需要权限:** ohos.permission.READ_MEDIA | +| src | string | 是 | 是 | 音频媒体URI,支持当前主流的音频格式(m4a、aac、mp3、ogg、wav)。
**支持路径示例**:
1. fd类型播放:fd://xx
![](figures/zh-cn_image_url.png)
2. http网络播放: http://xx
3. https网络播放: https://xx
4. hls网络播放路径:http://xx或者https://xx
**需要权限:** ohos.permission.INTERNET。 | +| fdSrc9+ | [AVFileDescriptor](#avfiledescriptor9) | 是 | 是 | 音频媒体文件描述,使用场景:应用中的音频资源被连续存储在同一个文件中。
**使用示例**:
假设一个连续存储的音乐文件:
音乐1(地址偏移:0,字节长度:100)
音乐2(地址偏移:101,字节长度:50)
音乐3(地址偏移:151,字节长度:150)
1. 播放音乐1:AVFileDescriptor { fd = 资源句柄; offset = 0; length = 100; }
2. 播放音乐2:AVFileDescriptor { fd = 资源句柄; offset = 101; length = 50; }
3. 播放音乐3:AVFileDescriptor { fd = 资源句柄; offset = 151; length = 150; }
假设是一个独立的音乐文件: 请使用src=fd://xx
| | loop | boolean | 是 | 是 | 音频循环播放属性,设置为'true'表示循环播放。 | -| audioInterruptMode9+ | [InterruptMode](#interruptmode9) | 是 | 是 | 音频焦点模型。 | +| audioInterruptMode9+ | [audio.InterruptMode](js-apis-audio.md#interruptmode9) | 是 | 是 | 音频焦点模型。 | | currentTime | number | 是 | 否 | 音频的当前播放位置,单位为毫秒(ms)。 | | duration | number | 是 | 否 | 音频时长,单位为毫秒(ms)。 | | state | [AudioState](#audiostate) | 是 | 否 | 可以查询音频播放的状态,该状态不可作为调用play/pause/stop等状态切换的触发条件。 | @@ -441,7 +441,7 @@ function printfDescription(obj) { } } -audioPlayer.getTrackDescription((error, arrlist) => { +audioPlayer.getTrackDescription((error, ) => { if (arrlist != null) { for (let i = 0; i < arrlist.length; i++) { printfDescription(arrlist[i]); @@ -476,7 +476,7 @@ function printfDescription(obj) { console.info('audio value is ' + property); } } - +let arrayDescription = null audioPlayer.getTrackDescription().then((arrlist) => { if (arrlist != null) { arrayDescription = arrlist; @@ -534,6 +534,8 @@ on(type: 'play' | 'pause' | 'stop' | 'reset' | 'dataLoad' | 'finish' | 'volumeCh **示例:** ```js +import fileio from '@ohos.fileio' + let audioPlayer = media.createAudioPlayer(); //创建一个音频播放实例 audioPlayer.on('dataLoad', () => { //设置'dataLoad'事件回调,src属性设置成功后,触发此回调 console.info('audio set source success'); @@ -573,11 +575,11 @@ audioPlayer.on('error', (error) => { //设置'error'事件回调 }); // 用户选择视频设置fd(本地播放) -let fdPath = 'fd://' +let fdPath = 'fd://'; // path路径的码流可通过"hdc file send D:\xxx\01.mp3 /data/accounts/account_0/appdata" 命令,将其推送到设备上 let path = '/data/accounts/account_0/appdata/ohos.xxx.xxx.xxx/01.mp3'; -fileIO.open(path).then(fdNumber) => { - fdPath = fdPath + '' + fdNumber; +fileio.open(path).then((fdValue) => { + fdPath = fdPath + '' + fdValue; console.info('open fd success fd is' + fdPath); }, (err) => { console.info('open fd failed err is' + err); @@ -643,41 +645,28 @@ audioPlayer.setVolume(3); //设置volume为无效值,触发'error'事件 音频播放的状态机。可通过state属性获取当前状态。 -**系统能力:** 以下各项对应的系统能力均为 SystemCapability.Multimedia.Media.AudioPlayer。 +**系统能力:** SystemCapability.Multimedia.Media.AudioPlayer -| 名称 | 类型 | 描述 | -| ------------------ | ------ | ---------------------------------------------- | -| idle | string | 音频播放空闲,dataload/reset成功后处于此状态。 | -| playing | string | 音频正在播放,play成功后处于此状态。 | -| paused | string | 音频暂停播放,pause成功后处于此状态。 | -| stopped | string | 音频播放停止,stop/播放结束后处于此状态。 | -| error8+ | string | 错误状态。 | +| 名称 | 类型 | 描述 | +| ------- | ------ | ---------------------------------------------- | +| idle | string | 音频播放空闲,dataload/reset成功后处于此状态。 | +| playing | string | 音频正在播放,play成功后处于此状态。 | +| paused | string | 音频暂停播放,pause成功后处于此状态。 | +| stopped | string | 音频播放停止,stop/播放结束后处于此状态。 | +| error | string | 错误状态。 | ## AVFileDescriptor9+ 音视频文件资源描述,一种特殊资源的播放方式,使用场景:应用中的音频资源被连续存储在同一个文件中,需要根据偏移量和长度进行播放。 -**系统能力:** SystemCapability.Multimedia.Media.AudioPlayer - -**参数:** +**系统能力:** SystemCapability.Multimedia.Media.Core -| 参数名 | 类型 | 必填 | 说明 | +| 名称 | 类型 | 必填 | 说明 | | ------ | ------ | ---- | ------------------------------------------------------------ | | fd | number | 是 | 资源句柄,通过resourceManager.getRawFileDescriptor获取 | | offset | number | 是 | 资源偏移量,需要基于预置资源的信息输入,非法值会造成音视频资源解析错误 | | length | number | 是 | 资源长度,需要基于预置资源的信息输入,非法值会造成音视频资源解析错误 | -## InterruptMode9+ - -音频焦点模式。 - -**系统能力:** SystemCapability.Multimedia.Media.AudioPlayer - -| 名称 | 默认值 | 描述 | -| ---------------------------- | ------ | ---------- | -| SHARE_MODE | 0 | 共享焦点模式。 | -| INDEPENDENT_MODE| 1 | 独立焦点模式。 | - ## VideoPlayer8+ 视频播放管理类,用于管理和播放视频媒体。在调用VideoPlayer的方法前,需要先通过[createVideoPlayer()](#mediacreatevideoplayer8)构建一个[VideoPlayer](#videoplayer8)实例。 @@ -686,15 +675,15 @@ audioPlayer.setVolume(3); //设置volume为无效值,触发'error'事件 ### 属性 -**系统能力:** 以下各项对应的系统能力均为 SystemCapability.Multimedia.Media.VideoPlayer。 +**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer | 名称 | 类型 | 可读 | 可写 | 说明 | | ------------------------ | ---------------------------------- | ---- | ---- | ------------------------------------------------------------ | -| url8+ | string | 是 | 是 | 视频媒体URL,支持当前主流的视频格式(mp4、mpeg-ts、webm、mkv)。
**支持路径示例**:
1. fd类型播放:fd://xx
![](figures/zh-cn_image_url.png)
2. http网络播放: http://xx
3. https网络播放: https://xx
4. hls网络播放路径:http://xx或者https://xx
**需要权限:** ohos.permission.READ_MEDIA;如果需要使用网络素材,还需要申请ohos.permission.INTERNET。 | -| fdSrc9+ | [AVFileDescriptor](#interruptmode9) | 是 | 是 | 视频媒体文件描述,使用场景:应用中的视频资源被连续存储在同一个文件中。
**使用示例**:
假设一个连续存储的音乐文件:
视频1(地址偏移:0,字节长度:100)
视频2(地址偏移:101,字节长度:50)
视频3(地址偏移:151,字节长度:150)
1. 播放视频1:AVFileDescriptor { fd = 资源句柄; offset = 0; length = 100; }
2. 播放视频2:AVFileDescriptor { fd = 资源句柄; offset = 101; length = 50; }
3. 播放视频3:AVFileDescriptor { fd = 资源句柄; offset = 151; length = 150; }
假设是一个独立的视频文件: 请使用src=fd://xx
**注意事项**:
**需要权限:** ohos.permission.READ_MEDIA | +| url8+ | string | 是 | 是 | 视频媒体URL,支持当前主流的视频格式(mp4、mpeg-ts、webm、mkv)。
**支持路径示例**:
1. fd类型播放:fd://xx
![](figures/zh-cn_image_url.png)
2. http网络播放: http://xx
3. https网络播放: https://xx
4. hls网络播放路径:http://xx或者https://xx
**需要权限:** ohos.permission.INTERNET。 | +| fdSrc9+ | [AVFileDescriptor](#avfiledescriptor9) | 是 | 是 | 视频媒体文件描述,使用场景:应用中的视频资源被连续存储在同一个文件中。
**使用示例**:
假设一个连续存储的音乐文件:
视频1(地址偏移:0,字节长度:100)
视频2(地址偏移:101,字节长度:50)
视频3(地址偏移:151,字节长度:150)
1. 播放视频1:AVFileDescriptor { fd = 资源句柄; offset = 0; length = 100; }
2. 播放视频2:AVFileDescriptor { fd = 资源句柄; offset = 101; length = 50; }
3. 播放视频3:AVFileDescriptor { fd = 资源句柄; offset = 151; length = 150; }
假设是一个独立的视频文件: 请使用src=fd://xx
| | loop8+ | boolean | 是 | 是 | 视频循环播放属性,设置为'true'表示循环播放。 | | videoScaleType9+ | [VideoScaleType](#videoscaletype9) | 是 | 是 | 视频缩放模式。 | -| audioInterruptMode9+ | [InterruptMode](#interruptmode9) | 是 | 是 | 音频焦点模型。 | +| audioInterruptMode9+ | [audio.InterruptMode](js-apis-audio.md#interruptmode9) | 是 | 是 | 音频焦点模型。 | | currentTime8+ | number | 是 | 否 | 视频的当前播放位置,单位为毫秒(ms)。 | | duration8+ | number | 是 | 否 | 视频时长,单位为毫秒(ms),返回-1表示直播模式。 | | state8+ | [VideoPlayState](#videoplaystate8) | 是 | 否 | 视频播放的状态。 | @@ -721,6 +710,7 @@ setDisplaySurface(surfaceId: string, callback: AsyncCallback\): void **示例:** ```js +let surfaceId = null; videoPlayer.setDisplaySurface(surfaceId, (err) => { if (err == null) { console.info('setDisplaySurface success!'); @@ -755,6 +745,7 @@ setDisplaySurface(surfaceId: string): Promise\ **示例:** ```js +let surfaceId = null; videoPlayer.setDisplaySurface(surfaceId).then(() => { console.info('setDisplaySurface success'); }).catch((error) => { @@ -1061,8 +1052,7 @@ seek(timeMs: number, mode:SeekMode, callback: AsyncCallback\): void ```js import media from '@ohos.multimedia.media' let seekTime = 5000; -let seekMode = media.SeekMode.SEEK_NEXT_SYNC; -videoPlayer.seek(seekTime, seekMode, (err, result) => { +videoPlayer.seek(seekTime, media.SeekMode.SEEK_NEXT_SYNC, (err, result) => { if (err == null) { console.info('seek success!'); } else { @@ -1095,6 +1085,7 @@ seek(timeMs: number, mode?:SeekMode): Promise\ **示例:** ```js +import media from '@ohos.multimedia.media' let seekTime = 5000; videoPlayer.seek(seekTime).then((seekDoneTime) => { // seekDoneTime表示seek完成后的时间点 console.info('seek success'); @@ -1102,7 +1093,7 @@ videoPlayer.seek(seekTime).then((seekDoneTime) => { // seekDoneTime表示seek完 console.info(`video catchCallback, error:${error}`); }); -videoPlayer.seek(seekTime, seekMode).then((seekDoneTime) => { +videoPlayer.seek(seekTime, media.SeekMode.SEEK_NEXT_SYNC).then((seekDoneTime) => { console.info('seek success'); }).catch((error) => { console.info(`video catchCallback, error:${error}`); @@ -1161,7 +1152,7 @@ setVolume(vol: number): Promise\ ```js let vol = 0.5; -videoPlayer.setVolume(vol).then() => { +videoPlayer.setVolume(vol).then(() => { console.info('setVolume success'); }).catch((error) => { console.info(`video catchCallback, error:${error}`); @@ -1211,7 +1202,7 @@ release(): Promise\ **示例:** ```js -videoPlayer.release().then() => { +videoPlayer.release().then(() => { console.info('release success'); }).catch((error) => { console.info(`video catchCallback, error:${error}`); @@ -1244,7 +1235,7 @@ function printfDescription(obj) { } videoPlayer.getTrackDescription((error, arrlist) => { - if (arrlist) != null) { + if ((arrlist) != null) { for (let i = 0; i < arrlist.length; i++) { printfDescription(arrlist[i]); } @@ -1350,7 +1341,7 @@ setSpeed(speed:number): Promise\ import media from '@ohos.multimedia.media' let speed = media.PlaybackSpeed.SPEED_FORWARD_2_00_X; -videoPlayer.setSpeed(speed).then() => { +videoPlayer.setSpeed(speed).then(() => { console.info('setSpeed success'); }).catch((error) => { console.info(`video catchCallback, error:${error}`); @@ -1409,7 +1400,7 @@ selectBitrate(bitrate:number): Promise\ ```js let bitrate = 1024000; -videoPlayer.selectBitrate(bitrate).then() => { +videoPlayer.selectBitrate(bitrate).then(() => { console.info('selectBitrate success'); }).catch((error) => { console.info(`video catchCallback, error:${error}`); @@ -1563,7 +1554,7 @@ videoPlayer.on('availableBitratesCollect', (bitrates) => { 视频播放的状态机,可通过state属性获取当前状态。 -**系统能力:** 以下各项对应的系统能力均为 SystemCapability.Multimedia.Media.VideoPlayer。 +**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer | 名称 | 类型 | 描述 | | -------- | ------ | -------------- | @@ -1578,7 +1569,7 @@ videoPlayer.on('availableBitratesCollect', (bitrates) => { 视频播放的Seek模式枚举,可通过seek方法作为参数传递下去。 -**系统能力:** 以下各项对应的系统能力均为 SystemCapability.Multimedia.Media.Core。 +**系统能力:** SystemCapability.Multimedia.Media.Core | 名称 | 值 | 描述 | | -------------- | ---- | ------------------------------------------------------------ | @@ -1589,7 +1580,7 @@ videoPlayer.on('availableBitratesCollect', (bitrates) => { 视频播放的倍速枚举,可通过setSpeed方法作为参数传递下去。 -**系统能力:** 以下各项对应的系统能力均为 SystemCapability.Multimedia.Media.VideoPlayer。 +**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer | 名称 | 值 | 描述 | | -------------------- | ---- | ------------------------------ | @@ -1603,7 +1594,7 @@ videoPlayer.on('availableBitratesCollect', (bitrates) => { 枚举,视频缩放模式。 -**系统能力:** 以下各项对应的系统能力均为 SystemCapability.Multimedia.Media.VideoPlayer。 +**系统能力:** SystemCapability.Multimedia.Media.VideoPlayer | 名称 | 默认值 | 描述 | | ---------------------------- | ------ | ---------- | @@ -1612,30 +1603,24 @@ videoPlayer.on('availableBitratesCollect', (bitrates) => { ## MediaDescription8+ -### [key : string] : Object - 通过key-value方式获取媒体信息。 -**系统能力:** 以下各项对应的系统能力均为 SystemCapability.Multimedia.Media.Core。 - -| 名称 | 类型 | 说明 | -| ----- | ------ | ------------------------------------------------------------ | -| key | string | 通过key值获取对应的value。key值具体可见[MediaDescriptionKey](#mediadescriptionkey8)。 | -| value | any | 对应key值得value。其类型可为任意类型,具体key对应value的类型可参考[MediaDescriptionKey](#mediadescriptionkey8)的描述信息。 | +**系统能力:** SystemCapability.Multimedia.Media.Core **示例:** ```js +import media from '@ohos.multimedia.media' function printfItemDescription(obj, key) { let property = obj[key]; - console.info('audio key is ' + key); - console.info('audio value is ' + property); + console.info('audio key is ' + key); // 通过key值获取对应的value。key值具体可见[MediaDescriptionKey] + console.info('audio value is ' + property); //对应key值得value。其类型可为任意类型,具体key对应value的类型可参考[MediaDescriptionKey] } - +let audioPlayer = media.createAudioPlayer(); audioPlayer.getTrackDescription((error, arrlist) => { if (arrlist != null) { for (let i = 0; i < arrlist.length; i++) { - printfItemDescription(arrlist[i], MD_KEY_TRACK_TYPE); //打印出每条轨道MD_KEY_TRACK_TYPE的值 + printfItemDescription(arrlist[i], media.MediaDescriptionKey.MD_KEY_TRACK_TYPE); //打印出每条轨道MD_KEY_TRACK_TYPE的值 } } else { console.log(`audio getTrackDescription fail, error:${error}`); @@ -1807,7 +1792,7 @@ on(type: 'prepare' | 'start' | 'pause' | 'resume' | 'stop' | 'release' | 'reset' **示例:** ```js -let audiorecorder = media.createAudioRecorder(); // 创建一个音频录制实例 +let audioRecorder = media.createAudioRecorder(); // 创建一个音频录制实例 let audioRecorderConfig = { audioEncoder : media.AudioEncoder.AAC_LC, , audioEncodeBitRate : 22050, @@ -1863,17 +1848,26 @@ on(type: 'error', callback: ErrorCallback): void **示例:** ```js +let audioRecorderConfig = { + audioEncoder : media.AudioEncoder.AAC_LC, , + audioEncodeBitRate : 22050, + audioSampleRate : 22050, + numberOfChannels : 2, + format : media.AudioOutputFormat.AAC_ADTS, + uri : 'fd://xx', // 文件需先由调用者创建,并给予适当的权限 + location : { latitude : 30, longitude : 130}, +} audioRecorder.on('error', (error) => { // 设置'error'事件回调 console.info(`audio error called, error: ${error}`); }); -audioRecorder.prepare(); // prepare不设置参数,触发'error'事件 +audioRecorder.prepare(audioRecorderConfig); // prepare不设置参数,触发'error'事件 ``` ## AudioRecorderConfig 表示音频的录音配置。 -**系统能力:** 以下各项对应的系统能力均为 SystemCapability.Multimedia.Media.AudioRecorder。 +**系统能力:** SystemCapability.Multimedia.Media.AudioRecorder | 名称 | 参数类型 | 必填 | 说明 | | --------------------- | --------------------------------------- | ---- | ------------------------------------------------------------ | @@ -1894,7 +1888,7 @@ audioRecorder.prepare(); // pre 表示音频编码格式的枚举。 -**系统能力:** 以下各项对应的系统能力均为 SystemCapability.Multimedia.Media.AudioRecorder。 +**系统能力:** SystemCapability.Multimedia.Media.AudioRecorder | 名称 | 默认值 | 说明 | | ------- | ------ | ------------------------------------------------------------ | @@ -1912,7 +1906,7 @@ audioRecorder.prepare(); // pre 表示音频封装格式的枚举。 -**系统能力:** 以下各项对应的系统能力均为 SystemCapability.Multimedia.Media.AudioRecorder。 +**系统能力:** SystemCapability.Multimedia.Media.AudioRecorder | 名称 | 默认值 | 说明 | | -------- | ------ | ------------------------------------------------------------ | @@ -1930,7 +1924,7 @@ audioRecorder.prepare(); // pre ### 属性 -**系统能力:** 以下各项对应的系统能力均为 SystemCapability.Multimedia.Media.VideoRecorder。 +**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder | 名称 | 类型 | 可读 | 可写 | 说明 | | ------------------ | -------------------------------------- | ---- | ---- | ---------------- | @@ -2057,18 +2051,17 @@ media.createVideoRecorder().then((recorder) => { if (recorder != null) { videoRecorder = recorder; console.info('createVideoRecorder success'); + videoRecorder.prepare(videoConfig).then(() => { + console.info('prepare success'); + }).catch((err) => { + console.info('prepare failed and catch error is ' + err.message); + }); } else { console.info('createVideoRecorder failed'); } }).catch((err) => { console.info('catch err error message is ' + err.message); }); - -videoRecorder.prepare(videoConfig).then(() => { - console.info('prepare success'); -}).catch((err) => { - console.info('prepare failed and catch error is ' + err.message); -}); ``` ### getInputSurface9+ @@ -2483,14 +2476,16 @@ on(type: 'error', callback: ErrorCallback): void ```js videoRecorder.on('error', (error) => { // 设置'error'事件回调 console.info(`audio error called, error: ${error}`); +} // 当获取videoRecordState接口出错时通过此订阅事件上报 +}); ``` ## VideoRecordState9+ 视频录制的状态机。可通过state属性获取当前状态。 -**系统能力:** 以下各项对应的系统能力均为 SystemCapability.Multimedia.Media.VideoRecorder。 +**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder | 名称 | 类型 | 描述 | | -------- | ------ | ---------------------- | @@ -2505,7 +2500,7 @@ videoRecorder.on('error', (error) => { // 设 表示视频录制的参数设置。 -**系统能力:** 以下各项对应的系统能力均为 SystemCapability.Multimedia.Media.VideoRecorder。 +**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder | 名称 | 参数类型 | 必填 | 说明 | | --------------- | ---------------------------------------------- | ---- | ------------------------------------------------------------ | @@ -2514,13 +2509,13 @@ videoRecorder.on('error', (error) => { // 设 | profile | [VideoRecorderProfile](#videorecorderprofile9) | 是 | 视频录制的profile。 | | rotation | number | 否 | 录制视频的旋转角度。 | | location | [Location](#location) | 否 | 录制视频的地理位置。 | -| url | string | 是 | 视频输出URL:fd://xx (fd number)
![](figures/zh-cn_image_url.png)
**需要权限:** ohos.permission.READ_MEDIA; | +| url | string | 是 | 视频输出URL:fd://xx (fd number)
![](figures/zh-cn_image_url.png)| ## AudioSourceType9+ 表示视频录制中音频源类型的枚举。 -**系统能力:** 以下各项对应的系统能力均为 SystemCapability.Multimedia.Media.VideoRecorder。 +**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder | 名称 | 值 | 说明 | | ------------------------- | ---- | ---------------------- | @@ -2531,7 +2526,7 @@ videoRecorder.on('error', (error) => { // 设 表示视频录制中视频源类型的枚举。 -**系统能力:** 以下各项对应的系统能力均为 SystemCapability.Multimedia.Media.VideoRecorder。 +**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder | 名称 | 值 | 说明 | | ----------------------------- | ---- | ------------------------------- | @@ -2542,7 +2537,7 @@ videoRecorder.on('error', (error) => { // 设 视频录制的配置文件。 -**系统能力:** 以下各项对应的系统能力均为 SystemCapability.Multimedia.Media.VideoRecorder。 +**系统能力:** SystemCapability.Multimedia.Media.VideoRecorder | 名称 | 参数类型 | 必填 | 说明 | | ---------------- | -------------------------------------------- | ---- | ---------------- | @@ -2561,7 +2556,7 @@ videoRecorder.on('error', (error) => { // 设 表示容器格式类型的枚举,缩写为CFT。 -**系统能力:** 以下各项对应的系统能力均为 SystemCapability.Multimedia.Media.Core。 +**系统能力:** SystemCapability.Multimedia.Media.Core | 名称 | 值 | 说明 | | ----------- | ----- | --------------------- | @@ -2572,7 +2567,7 @@ videoRecorder.on('error', (error) => { // 设 视频录制的地理位置。 -**系统能力:** 以下各项对应的系统能力均为 SystemCapability.Multimedia.Media.Core。 +**系统能力:** SystemCapability.Multimedia.Media.Core | 名称 | 参数类型 | 必填 | 说明 | | --------- | -------- | ---- | ---------------- | diff --git a/zh-cn/application-dev/reference/apis/js-apis-medialibrary.md b/zh-cn/application-dev/reference/apis/js-apis-medialibrary.md index 1d6db241ef0070ab2f48b4890b5b708314bce895..2fdcde2330a51f4feb1d8ca0041e5c2d300b6da2 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-medialibrary.md +++ b/zh-cn/application-dev/reference/apis/js-apis-medialibrary.md @@ -94,23 +94,42 @@ getFileAssets(options: MediaFetchOptions, callback: AsyncCallback<FetchFileRe ```js let fileKeyObj = mediaLibrary.FileKey; let imageType = mediaLibrary.MediaType.IMAGE; -let imagesfetchOp = { +let imagesFetchOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', selectionArgs: [imageType.toString()], }; -media.getFileAssets(imagesfetchOp, (error, fetchFileResult) => { - if (fetchFileResult != undefined) { - console.info('mediaLibraryTest : ASSET_CALLBACK fetchFileResult success'); - for (let i = 0; i < fetchFileResult.getCount(); i++) { +media.getFileAssets(imagesFetchOp, (error, fetchFileResult) => { + if (fetchFileResult == undefined) { + console.error('Failed to get fetchFileResult: ' + error); + return; + } + const count = fetchFileResult.getCount(); + if (count < 0) { + console.error('Failed to get count from fetchFileResult: count: ' + count); + return; + } + if (count == 0) { + console.info('The count of fetchFileResult is zero'); + return; + } + + console.info('Get fetchFileResult success, count: ' + count); + fetchFileResult.getFirstObject((err, fileAsset) => { + if (fileAsset == undefined) { + console.error('Failed to get first object: ' + err); + return; + } + console.log('fileAsset.displayName ' + ': ' + fileAsset.displayName); + for (let i = 1; i < count; i++) { fetchFileResult.getNextObject((err, fileAsset) => { - if (err) { - console.error('Failed '); - return; - } - console.log('fileAsset.displayName ' + i + ': ' + fileAsset.displayName); + if (fileAsset == undefined) { + console.error('Failed to get next object: ' + err); + return; + } + console.log('fileAsset.displayName ' + i + ': ' + fileAsset.displayName); }) - } - } + } + }); }); ``` ### getFileAssets7+ @@ -140,14 +159,35 @@ getFileAssets(options: MediaFetchOptions): Promise<FetchFileResult> ```js let fileKeyObj = mediaLibrary.FileKey; let imageType = mediaLibrary.MediaType.IMAGE; -let imagesfetchOp = { +let imagesFetchOp = { selections: fileKeyObj.MEDIA_TYPE + '= ?', selectionArgs: [imageType.toString()], }; -media.getFileAssets(imagesfetchOp).then(function(fetchFileResult){ - console.info("getFileAssets successfully: image number is "+ fetchFileResult.getCount()); +media.getFileAssets(imagesFetchOp).then(function(fetchFileResult) { + const count = fetchFileResult.getCount(); + if (count < 0) { + console.error('Failed to get count from fetchFileResult: count: ' + count); + return; + } + if (count == 0) { + console.info('The count of fetchFileResult is zero'); + return; + } + console.info('Get fetchFileResult success, count: ' + count); + fetchFileResult.getFirstObject().then(function(fileAsset) { + console.log('fileAsset.displayName ' + ': ' + fileAsset.displayName); + for (let i = 1; i < count; i++) { + fetchFileResult.getNextObject().then(function(fileAsset) { + console.log('fileAsset.displayName ' + ': ' + fileAsset.displayName); + }).catch(function(err) { + console.error('Failed to get next object: ' + err); + }) + } + }).catch(function(err) { + console.error('Failed to get first object: ' + err); + }); }).catch(function(err){ - console.info("getFileAssets failed with error:"+ err); + console.error("Failed to get file assets: " + err); }); ``` @@ -763,13 +803,11 @@ startMediaSelect(option: MediaSelectOption, callback: AsyncCallback<Array< **示例:** ```js -let fileKeyObj = mediaLibrary.FileKey; -let imageType = mediaLibrary.MediaType.IMAGE; -let imagesfetchOp = { - selections: fileKeyObj.MEDIA_TYPE + '= ?', - selectionArgs: [imageType.toString()], +let option : mediaLibrary.MediaSelectOption = { + type : "media", + count : 2 }; -mediaLibrary.getMediaLibrary().startMediaSelect(imagesfetchOp, (err, value) => { +mediaLibrary.getMediaLibrary().startMediaSelect(option, (err, value) => { if (err) { console.log("An error occurred when selecting media resources."); return; @@ -805,13 +843,11 @@ startMediaSelect(option: MediaSelectOption): Promise<Array<string>> **示例:** ```js -let fileKeyObj = mediaLibrary.FileKey; -let imageType = mediaLibrary.MediaType.IMAGE; -let imagesfetchOp = { - selections: fileKeyObj.MEDIA_TYPE + '= ?', - selectionArgs: [imageType.toString()], +let option : mediaLibrary.MediaSelectOption = { + type : "media", + count : 2 }; -mediaLibrary.getMediaLibrary().startMediaSelect(imagesfetchOp).then((value) => { +mediaLibrary.getMediaLibrary().startMediaSelect(option).then((value) => { console.log("Media resources selected."); // Obtain the media selection value. }).catch((err) => { @@ -1724,18 +1760,13 @@ async function example() { }; const fetchFileResult = await media.getFileAssets(getImageOp); const asset = await fetchFileResult.getFirstObject(); - asset.isTrash(isTrashCallBack); - function isTrashCallBack(err, isTrash) { - if (isTrash == true) { - console.info('mediaLibraryTest : ASSET_CALLBACK ASSET_CALLBACK isTrash = ' + isTrash); - asset.trash(true, isTrashCallBack); - - } else { - console.info('mediaLibraryTest : ASSET_CALLBACK isTrash Unsuccessfull = ' + err); - console.info('mediaLibraryTest : ASSET_CALLBACK isTrash : FAIL'); - - } - } + asset.isTrash((err, isTrash) => { + if (isTrash == undefined) { + console.error('Failed to get trash state: ' + err); + return; + } + console.info('Get trash state success: ' + isTrash); + }); } ``` @@ -1765,14 +1796,13 @@ async function example() { selections: fileKeyObj.MEDIA_TYPE + '= ?', selectionArgs: [imageType.toString()], order: fileKeyObj.DATE_ADDED + " DESC", - extendArgs: "", }; const fetchFileResult = await media.getFileAssets(getImageOp); const asset = await fetchFileResult.getFirstObject(); asset.isTrash().then(function(isTrash){ - console.info("isTrash result:"+ isTrash); + console.info("isTrash result: " + isTrash); }).catch(function(err){ - console.info("isTrash failed with error:"+ err); + console.error("isTrash failed with error: " + err); }); } ``` @@ -2557,4 +2587,3 @@ async function example() { | type | string | 是 | 媒体类型,包括:image, video, media,当前仅支持media类型 | | count | number | 是 | 媒体选择,count = 1表示单选,count大于1表示多选。 | - diff --git a/zh-cn/application-dev/reference/apis/js-apis-process.md b/zh-cn/application-dev/reference/apis/js-apis-process.md index 2027c27caf16a6162c1d20cd0696ee08bb246160..ad7b968f48c81dc0bff95a88cf6f57127b188f0d 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-process.md +++ b/zh-cn/application-dev/reference/apis/js-apis-process.md @@ -63,8 +63,8 @@ wait(): Promise<number> **示例:** ```js -var child = process.runCmd('ls'); -var result = child.wait(); +let child = process.runCmd('ls'); +let result = child.wait(); result.then(val=>{ console.log("result = " + val); }) @@ -90,8 +90,8 @@ getOutput(): Promise<Uint8Array> **示例:** ```js -var child = process.runCmd('ls'); -var result = child.wait(); +let child = process.runCmd('ls'); +let result = child.wait(); child.getOutput().then(val=>{ console.log("child.getOutput = " + val); }) @@ -117,8 +117,8 @@ getErrorOutput(): Promise<Uint8Array> **示例:** ```js -var child = process.runCmd('madir test.text'); -var result = child.wait(); +let child = process.runCmd('madir test.text'); +let result = child.wait(); child.getErrorOutput().then(val=>{ console.log("child.getErrorOutput= " + val); }) @@ -138,7 +138,7 @@ close(): void **示例:** ```js -var child = process.runCmd('sleep 5; ls'); +let child = process.runCmd('sleep 5; ls'); child.close(); ``` @@ -162,7 +162,7 @@ kill(signal: number | string): void **示例:** ```js -var child = process.runCmd('sleep 5; ls'); +let child = process.runCmd('sleep 5; ls'); child.kill(9); ``` @@ -184,7 +184,7 @@ isIsolatedProcess(): boolean **示例:** ```js -var result = process.isIsolatedProcess(); +let result = process.isIsolatedProcess(); ``` @@ -211,7 +211,7 @@ isAppUid(v: number): boolean **示例:** ```js -var result = process.isAppUid(688); +let result = process.isAppUid(688); ``` @@ -232,7 +232,7 @@ is64Bit(): boolean **示例:** ```js -var result = process.is64Bit(); +let result = process.is64Bit(); ``` @@ -259,7 +259,7 @@ getUidForName(v: string): number **示例:** ```js -var pres = process.getUidForName("tool") +let pres = process.getUidForName("tool") ``` @@ -286,8 +286,8 @@ getThreadPriority(v: number): number **示例:** ```js -var tid = process.tid; -var pres = process.getThreadPriority(tid); +let tid = process.tid; +let pres = process.getThreadPriority(tid); ``` @@ -308,7 +308,7 @@ getStartRealtime(): number **示例:** ```js -var realtime = process.getStartRealtime(); +let realtime = process.getStartRealtime(); ``` ## process.getPastCpuTime8+ @@ -328,7 +328,7 @@ getPastCpuTime(): number **示例:** ```js -var result = process.getPastCpuTime() ; +let result = process.getPastCpuTime() ; ``` @@ -355,8 +355,8 @@ getSystemConfig(name: number): number **示例:** ```js -var _SC_ARG_MAX = 0 -var pres = process.getSystemConfig(_SC_ARG_MAX) +let _SC_ARG_MAX = 0 +let pres = process.getSystemConfig(_SC_ARG_MAX) ``` @@ -383,7 +383,7 @@ getEnvironmentVar(name: string): string **示例:** ```js -var pres = process.getEnvironmentVar("PATH") +let pres = process.getEnvironmentVar("PATH") ``` @@ -421,8 +421,8 @@ runCmd(command: string, options?: { timeout?: number, killSignal?: number | stri **示例:** ```js -var child = process.runCmd('ls', { maxBuffer : 2 }); -var result = child.wait(); +let child = process.runCmd('ls', { maxBuffer : 2 }); +let result = child.wait(); child.getOutput.then(val=>{ console.log("child.getOutput = " + val); }) @@ -504,7 +504,7 @@ off(type: string): boolean process.on("data", (e)=>{ console.log("data callback"); }) -var result = process.off("data"); +let result = process.off("data"); ``` @@ -544,7 +544,7 @@ cwd(): string **示例:** ```js -var path = process.cwd(); +let path = process.cwd(); ``` @@ -588,7 +588,7 @@ uptime(): number **示例:** ```js -var time = process.uptime(); +let time = process.uptime(); ``` @@ -616,6 +616,6 @@ kill(signal: number, pid: number): boolean **示例:** ```js -var pres = process.pid -var result = process.kill(28, pres) +let pres = process.pid +let result = process.kill(28, pres) ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-radio.md b/zh-cn/application-dev/reference/apis/js-apis-radio.md index dbcbb5dd2ca98ff217f9cfb8c2519f81ab4819db..eaf6b2c9e65f464a949e83352af4e17987eaf5a9 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-radio.md +++ b/zh-cn/application-dev/reference/apis/js-apis-radio.md @@ -1100,12 +1100,12 @@ setNetworkSelectionMode\(options: NetworkSelectionModeOptions, callback: AsyncCa let networkInformation={ operatorName: "中国移动", operatorNumeric: "898600", - state: 1, + state: radio.NetworkInformationState.NETWORK_AVAILABLE, radioTech: "CS" } let networkSelectionModeOptions={ - slotid: 0, - selectMode: 1, + slotId: 0, + selectMode: radio.NetworkSelectionMode.NETWORK_SELECTION_AUTOMATIC, networkInformation: networkInformation, resumeSelection: true } @@ -1144,12 +1144,12 @@ setNetworkSelectionMode\(options: NetworkSelectionModeOptions\): Promise let networkInformation={ operatorName: "中国移动", operatorNumeric: "898600", - state: 1, + state: radio.NetworkInformationState.NETWORK_AVAILABLE, radioTech: "CS" } let networkSelectionModeOptions={ - slotid: 0, - selectMode: 1, + slotId: 0, + selectMode: radio.NetworkSelectionMode.NETWORK_SELECTION_AUTOMATIC, networkInformation: networkInformation, resumeSelection: true } @@ -1190,7 +1190,7 @@ radio.getNetworkSearchInformation(0, (err, data) => { ## radio.getNetworkSearchInformation -getNetworkSearchInformation\(slotId: number\): Promise +getNetworkSearchInformation\(slotId: number\): Promise 获取网络搜索信息。使用Promise异步回调。 @@ -1586,7 +1586,7 @@ radio.getPreferredNetwork(0, (err, data) => { ## radio.getPreferredNetwork8+ -getPreferredNetwork(slotId: number): Promise +getPreferredNetwork(slotId: number): Promise 获取首选网络。使用Promise异步回调。 @@ -1642,7 +1642,7 @@ getImsRegInfo(slotId: number, imsType: ImsServiceType, callback: AsyncCallback { +radio.getImsRegInfo(0, radio.ImsServiceType.TYPE_VIDEO, (err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); ``` @@ -1675,7 +1675,7 @@ getImsRegInfo(slotId: number, imsType: ImsServiceType): Promise **示例:** ```js -let promise = radio.getImsRegInfo(0, 1); +let promise = radio.getImsRegInfo(0, radio.ImsServiceType.TYPE_VIDEO); promise.then(data => { console.log(`getImsRegInfo success, promise: data->${JSON.stringify(data)}`); }).catch(err => { @@ -1707,7 +1707,7 @@ on(type: 'imsRegStateChange', slotId: number, imsType: ImsServiceType, callback: **示例:** ```js -radio.on('imsRegStateChange', 0, 1, (err, data) => { +radio.on('imsRegStateChange', 0, radio.ImsServiceType.TYPE_VIDEO, (err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); ``` @@ -1736,7 +1736,7 @@ off(type: 'imsRegStateChange', slotId: number, imsType: ImsServiceType, callback **示例:** ```js -radio.off('imsRegStateChange', 0, 1, (err, data) => { +radio.off('imsRegStateChange', 0, radio.ImsServiceType.TYPE_VIDEO, (err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); ``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-sensor.md b/zh-cn/application-dev/reference/apis/js-apis-sensor.md index 196ec53e12a2835eaca2dc4cfc7fed1371765c50..dff972822aeab4d1c436f6c13af2ef77d9dc946d 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-sensor.md +++ b/zh-cn/application-dev/reference/apis/js-apis-sensor.md @@ -58,7 +58,7 @@ on(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION,callback:Callback<Line 监听线性加速度传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。 -从API Version9开始该接口不再维护,推荐使用sensor.on.LINEAR_ACCELEROMETER9+ +从API Version9开始该接口不再维护,请使用[sensor.on.LINEAR_ACCELEROMETER](#linear_accelerometer9) **需要权限**:ohos.permission.ACCELEROMETER,该权限为系统权限 @@ -71,17 +71,6 @@ on(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION,callback:Callback<Line | callback | Callback<[LinearAccelerometerResponse](#linearaccelerometerresponse)> | 是 | 注册线性加速度传感器的回调函数,上报的数据类型为LinearAccelerometerResponse。 | | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | -**示例:** - ```js - sensor.on(sensor.SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION,function(data){ - console.info('X-coordinate component: ' + data.x); - console.info('Y-coordinate component: ' + data.y); - console.info('Z-coordinate component: ' + data.z); - }, - {interval: 10000000} - ); - ``` - ### LINEAR_ACCELEROMETER9+ on(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELEROMETER,callback:Callback<LinearAccelerometerResponse>, options?: Options): void @@ -539,28 +528,18 @@ on(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback: Callback<HeartRateRe 监听心率传感器数据变化一次。 -从API Version9开始该接口不再维护,推荐使用sensor.on.HEART_BEAT_RATE9+ +从API Version9开始该接口不再维护,请使用[sensor.on.HEART_BEAT_RATE](#heart_beat_rate9) -**需要权限**:ohos.permission.READ_HEALTH_DATA +**需要权限**:ohos.permission.HEALTH_DATA **系统能力**:SystemCapability.Sensors.Sensor **参数:** -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ---------------------------------------- | ---- | ---------------------------------------- | -| type | [SensorType](#sensortype) | 是 | 要订阅的心率传感器类型为SENSOR_TYPE_ID_HEART_RATE。 | -| callback | Callback<[HeartRateResponse](#heartrateresponse)> | 是 | 注册一次心率传感器的回调函数,上报的数据类型为HeartRateResponse。 | - -**示例:** - -```js -sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HEART_RATE,function(data){ - console.info("Heart rate: " + data.heartRate); -}, - {interval: 10000000} -); -``` +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | [SensorType](#sensortype) | 是 | 要订阅的心率传感器类型为SENSOR_TYPE_ID_HEART_RATE。 | +| callback | Callback<[HeartRateResponse](#heartrateresponse)> | 是 | 注册一次心率传感器的回调函数,上报的数据类型为HeartRateResponse。 | ### HEART_BEAT_RATE9+ @@ -675,28 +654,19 @@ once(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION,callback:Callback<Li 监听线性加速度传感器数据变化一次。 -从API Version9开始该接口不再维护,推荐使用sensor.once.LINEAR_ACCELEROMETER9+ +从API Version9开始该接口不再维护,请用[sensor.once.LINEAR_ACCELEROMETER](#linear_accelerometer9) -**需要权限**:ohos.permission.ACCELEROMETER,该权限为系统权限 +**需要权限**:ohos.permission.ACCELERATION,该权限为系统权限 **系统能力**:SystemCapability.Sensors.Sensor **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------------------------- | ---- | ---------------------------------------- | | type | [SensorType](#sensortype) | 是 | 线性加速度传感器类型为SENSOR_TYPE_ID_LINEAR_ACCELERATION。 | | callback | Callback<[LinearAccelerometerResponse](#linearaccelerometerresponse)> | 是 | 注册一次线性加速度传感器的回调函数,上报的数据类型为LinearAccelerometerResponse。 | -**示例:** - ```js - sensor.once(sensor.SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION, function(data) { - console.info('X-coordinate component: ' + data.x); - console.info('Y-coordinate component: ' + data.y); - console.info('Z-coordinate component: ' + data.z); - } - ); - ``` - ### LINEAR_ACCELEROMETER9+ once(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELEROMETER,callback:Callback<LinearAccelerometerResponse>): void @@ -1143,26 +1113,19 @@ once(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback: Callback<HeartRate 监听心率传感器数据变化一次。 -从API Version9开始该接口不再维护,推荐使用sensor.once.HEART_BEAT_RATE9+ +从API Version9开始该接口不再维护,请使用[sensor.once.HEART_BEAT_RATE](#heart_beat_rate9) -**需要权限**:ohos.permission.READ_HEALTH_DATA +**需要权限**:ohos.permission.HEART_RATE **系统能力**:SystemCapability.Sensors.Sensor **参数:** + | 参数名 | 类型 | 必填 | 说明 | | -------- | ---------------------------------------- | ---- | ---------------------------------------- | | type | [SensorType](#sensortype) | 是 | 心率传感器类型为SENSOR_TYPE_ID_HEART_RATE。 | | callback | Callback<[HeartRateResponse](#heartrateresponse)> | 是 | 注册一次心率传感器的回调函数,上报的数据类型为HeartRateResponse。 | -**示例:** - ```js - sensor.once(sensor.SensorType.SENSOR_TYPE_ID_HEART_RATE, function(data) { - console.info("Heart rate: " + data.heartRate); - } - ); - ``` - ### HEART_BEAT_RATE9+ once(type: SensorType.SENSOR_TYPE_ID_HEART_BEAT_RATE, callback: Callback<HeartRateResponse>): void @@ -1217,7 +1180,7 @@ off(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback?: Callback<Accele 取消订阅传感器数据。 -**需要权限**:ohos.permission.ACCELEROMETER, 该权限为系统权限 +**需要权限**:ohos.permission.ACCELEROMETER,该权限为系统权限 **系统能力**:SystemCapability.Sensors.Sensor @@ -1245,7 +1208,7 @@ off(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED, callback?: Callb 取消订阅传感器数据。 -**需要权限**:ohos.permission.ACCELEROMETER, 该权限为系统权限 +**需要权限**:ohos.permission.ACCELEROMETER,该权限为系统权限 **系统能力**:SystemCapability.Sensors.Sensor @@ -1374,7 +1337,7 @@ off(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback?: Callback<GyroscopeR 取消订阅传感器数据。 -**需要权限**:ohos.permission.GYROSCOPE, 该权限为系统权限 +**需要权限**:ohos.permission.GYROSCOPE,该权限为系统权限 **系统能力**:SystemCapability.Sensors.Sensor @@ -1402,7 +1365,7 @@ off(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, callback?: Callback& 取消订阅传感器数据。 -**需要权限**:ohos.permission.GYROSCOPE, 该权限为系统权限 +**需要权限**:ohos.permission.GYROSCOPE,该权限为系统权限 **系统能力**:SystemCapability.Sensors.Sensor @@ -1454,9 +1417,9 @@ off(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback?: Callback<HeartRate 取消订阅传感器数据。 -从API Version9开始该接口不再维护,推荐使用sensor.off.HEART_BEAT_RATE9+ +从API Version9开始该接口不再维护,请使用[sensor.off.HEART_BEAT_RATE](#heart_beat_rate9) -**需要权限**:ohos.permission.READ_HEALTH_DATA +**需要权限**:ohos.permission.HEALTH_DATA **系统能力**:SystemCapability.Sensors.Sensor @@ -1467,15 +1430,6 @@ off(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback?: Callback<HeartRate | type | [SensorType](#sensortype)[SensorType](#sensortype) | 是 | 要取消订阅的心率传感器类型为SENSOR_TYPE_ID_HEART_RATE。 | | callback | Callback<[HeartRateResponse](#heartrateresponse)> | 是 | 取消注册一次心率传感器的回调函数,上报的数据类型为HeartRateResponse。 | -**示例:** - -```js -function callback(data) { - console.info("Heart rate: " + data.heartRate); -} -sensor.off(sensor.SensorType.SENSOR_TYPE_ID_HEART_RATE, callback); -``` - ### HEART_BEAT_RATE9+ off(type: SensorType.SENSOR_TYPE_ID_HEART_BEAT_RATE, callback?: Callback<HeartRateResponse>): void @@ -1532,7 +1486,7 @@ off(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION, callback?: Callback< 取消订阅传感器数据。 -从API Version9开始该接口不再维护,推荐使用sensor.off.LINEAR_ACCELEROMETER9+ +从API Version9开始该接口不再维护,请使用[sensor.off.LINEAR_ACCELEROMETER](#linear_accelerometer9) **需要权限**:ohos.permission.ACCELEROMETER,该权限为系统权限 @@ -1545,17 +1499,6 @@ off(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION, callback?: Callback< | type | [SensorType](#sensortype) | 是 | 要取消订阅的线性加速度传感器类型为SENSOR_TYPE_ID_LINEAR_ACCELERATION。 | | callback | Callback<[LinearAccelerometerResponse](#linearaccelerometerresponse)> | 是 | 取消注册性加速度传感器的回调函数,上报的数据类型为LinearAccelerometerResponse。 | -**示例:** - -```js -function callback(data) { - console.info('X-coordinate component: ' + data.x); - console.info('Y-coordinate component: ' + data.y); - console.info('Z-coordinate component: ' + data.z); -} -sensor.off(sensor.SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION, callback); -``` - ### LINEAR_ACCELEROMETER9+ off(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELEROMETER, callback?: Callback<LinearAccelerometerResponse>): void diff --git a/zh-cn/application-dev/reference/apis/js-apis-sim.md b/zh-cn/application-dev/reference/apis/js-apis-sim.md index 97f2f399c452ff1414fcbfa6b7fe57cce7f14558..7ffd2749b7cac24295d7c50186a75e95c244ac4c 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-sim.md +++ b/zh-cn/application-dev/reference/apis/js-apis-sim.md @@ -589,7 +589,7 @@ getActiveSimAccountInfoList(callback: AsyncCallback>): vo **示例:** ```js -sim.getActiveSimAccountInfoList(0, (err, data) => { +sim.getActiveSimAccountInfoList((err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); ``` @@ -710,7 +710,7 @@ setShowName\(slotId: number, name: string,callback: AsyncCallback\): void **示例:** ```js -const name = '中国移动'; +let name = '中国移动'; sim.setShowName(0, name, (err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); @@ -744,7 +744,7 @@ setShowName\(slotId: number, name: string\): Promise\ **示例:** ```js -const name = '中国移动'; +let name = '中国移动'; let promise = sim.setShowName(0, name); promise.then(data => { console.log(`setShowName success, promise: data->${JSON.stringify(data)}`); @@ -1096,9 +1096,9 @@ setLockState(slotId: number, options: LockInfo, callback: AsyncCallback { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); @@ -1135,9 +1135,9 @@ setLockState(slotId: number, options: LockInfo): Promise ```js let lockInfo = { - lockType = 1, + lockType: sim.LockType.PIN_LOCK, password = "1234", - state = 0 + state: sim.LockState.LOCK_OFF }; let promise = sim.setLockState(0, lockInfo); promise.then(data => { @@ -2236,12 +2236,12 @@ addIccDiallingNumbers(slotId: number, type: ContactType, diallingNumbers: Dialli ```js let diallingNumbersInof = { - alphaTag = "alpha", - number = "138xxxxxxxx", - recordNumber = 123, - pin2 = "1234" + alphaTag: "alpha", + number: "138xxxxxxxx", + recordNumber: 123, + pin2: "1234" }; -sim.addIccDiallingNumbers(0, 1, diallingNumbersInof, (err, data) => { +sim.addIccDiallingNumbers(0, sim.ContactType.GENERAL_CONTACT, diallingNumbersInof, (err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); ``` @@ -2277,12 +2277,12 @@ addIccDiallingNumbers(slotId: number, type: ContactType, diallingNumbers: Dialli ```js let diallingNumbersInof = { - alphaTag = "alpha", - number = "138xxxxxxxx", - recordNumber = 123, - pin2 = "1234" + alphaTag: "alpha", + number: "138xxxxxxxx", + recordNumber: 123, + pin2: "1234" }; -let promise = sim.addIccDiallingNumbers(0, 1, diallingNumbersInof); +let promise = sim.addIccDiallingNumbers(0, sim.ContactType.GENERAL_CONTACT, diallingNumbersInof); promise.then(data => { console.log(`addIccDiallingNumbers success, promise: data->${JSON.stringify(data)}`); }).catch(err => { @@ -2315,12 +2315,12 @@ delIccDiallingNumbers(slotId: number, type: ContactType, diallingNumbers: Dialli ```js let diallingNumbersInof = { - alphaTag = "alpha", - number = "138xxxxxxxx", - recordNumber = 123, - pin2 = "1234" + alphaTag: "alpha", + number: "138xxxxxxxx", + recordNumber: 123, + pin2: "1234" }; -sim.delIccDiallingNumbers(0, 1, diallingNumbersInof, (err, data) => { +sim.delIccDiallingNumbers(0, sim.ContactType.GENERAL_CONTACT, diallingNumbersInof, (err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); ``` @@ -2356,12 +2356,12 @@ delIccDiallingNumbers(slotId: number, type: ContactType, diallingNumbers: Dialli ```js let diallingNumbersInof = { - alphaTag = "alpha", - number = "138xxxxxxxx", - recordNumber = 123, - pin2 = "1234" + alphaTag: "alpha", + number: "138xxxxxxxx", + recordNumber: 123, + pin2: "1234" }; -let promise = sim.delIccDiallingNumbers(0, 1, diallingNumbersInof); +let promise = sim.delIccDiallingNumbers(0, sim.ContactType.GENERAL_CONTACT, diallingNumbersInof); promise.then(data => { console.log(`delIccDiallingNumbers success, promise: data->${JSON.stringify(data)}`); }).catch(err => { @@ -2394,12 +2394,12 @@ updateIccDiallingNumbers(slotId: number, type: ContactType, diallingNumbers: Dia ```js let diallingNumbersInof = { - alphaTag = "alpha", - number = "138xxxxxxxx", - recordNumber = 123, - pin2 = "1234" + alphaTag: "alpha", + number: "138xxxxxxxx", + recordNumber: 123, + pin2: "1234" }; -sim.updateIccDiallingNumbers(0, 1, diallingNumbersInof, (err, data) => { +sim.updateIccDiallingNumbers(0, sim.ContactType.GENERAL_CONTACT, diallingNumbersInof, (err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); ``` @@ -2435,12 +2435,12 @@ updateIccDiallingNumbers(slotId: number, type: ContactType, diallingNumbers: Dia ```js let diallingNumbersInof = { - alphaTag = "alpha", - number = "138xxxxxxxx", - recordNumber = 123, - pin2 = "1234" + alphaTag: "alpha", + number: "138xxxxxxxx", + recordNumber: 123, + pin2: "1234" }; -let promise = sim.updateIccDiallingNumbers(0, 1, diallingNumbersInof); +let promise = sim.updateIccDiallingNumbers(0, sim.ContactType.GENERAL_CONTACT, diallingNumbersInof); promise.then(data => { console.log(`updateIccDiallingNumbers success, promise: data->${JSON.stringify(data)}`); }).catch(err => { @@ -2602,7 +2602,7 @@ unlockSimLock(slotId: number, lockInfo: PersoLockInfo, callback: AsyncCallback { @@ -2640,7 +2640,7 @@ unlockSimLock(slotId: number, lockInfo: PersoLockInfo): Promise>): void **示例:** ```js -string content= "long message"; +let content = "long message"; sms.splitMessage(content, (err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); @@ -431,7 +431,7 @@ splitMessage(content: string): Promise> **示例:** ```js -string content = "long message"; +let content = "long message"; let promise = sms.splitMessage(content); promise.then(data => { console.log(`splitMessage success, promise: data->${JSON.stringify(data)}`); @@ -463,10 +463,10 @@ addSimMessage(options: SimMessageOptions, callback: AsyncCallback): void ```js let simMessageOptions = { - slotId = 0, - smsc = "test", - pdu = "xxxxxx", - status = 0 + slotId: 0, + smsc: "test", + pdu: "xxxxxx", + status: sms.SimMessageStatus.SIM_MESSAGE_STATUS_READ }; sms.addSimMessage(simMessageOptions, (err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); @@ -502,10 +502,10 @@ addSimMessage(options: SimMessageOptions): Promise ```js let simMessageOptions = { - slotId = 0, - smsc = "test", - pdu = "xxxxxx", - status = 0 + slotId: 0, + smsc: "test", + pdu: "xxxxxx", + status: sms.SimMessageStatus.SIM_MESSAGE_STATUS_READ }; let promise = sms.addSimMessage(simMessageOptions); promise.then(data => { @@ -607,9 +607,9 @@ updateSimMessage(options: UpdateSimMessageOptions, callback: AsyncCallback ```js let updateSimMessageOptions = { - slotId = 0, - msgIndex = 1, - newStatus = 0, + slotId: 0, + msgIndex: 1, + newStatus: sms.SimMessageStatus.SIM_MESSAGE_STATUS_FREE, pdu = "xxxxxxx", smsc = "test" }; @@ -749,10 +749,11 @@ setCBConfig(options: CBConfigOptions, callback: AsyncCallback): void ```js let cbConfigOptions = { - slotId = 0, - smsc = "test", - pdu = "xxxxxxxx", - status = 0 + slotId: 0, + enable: true, + startMessageId: 100, + endMessageId: 200, + ranType: sms.RanType.TYPE_GSM }; sms.setCBConfig(cbConfigOptions, (err, data) => { console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); @@ -788,13 +789,14 @@ setCBConfig(options: CBConfigOptions): Promise ```js let cbConfigOptions = { - slotId = 0, - smsc = "test", - pdu = "xxxxxxxx", - status = 0 + slotId: 0, + enable: true, + startMessageId: 100, + endMessageId: 200, + ranType: sms.RanType.TYPE_GSM }; let promise = sms.setCBConfig(cbConfigOptions); -promise.then(data => +promise.then(data => { console.log(`setCBConfig success, promise: data->${JSON.stringify(data)}`); }).catch(err => { console.error(`setCBConfig failed, promise: err->${JSON.stringify(err)}`); @@ -859,7 +861,7 @@ getSmsSegmentsInfo(slotId: number, message: string, force7bit: boolean): Promise ```js let slotId = 0; let promise = sms.getSmsSegmentsInfo(slotId, "message", false); -promise.then(data => +promise.then(data => { console.log(`getSmsSegmentsInfo success, promise: data->${JSON.stringify(data)}`); }).catch(err => { console.error(`getSmsSegmentsInfo failed, promise: err->${JSON.stringify(err)}`); @@ -886,7 +888,7 @@ isImsSmsSupported(callback: AsyncCallback): void ```js sms.isImsSmsSupported((err, data) => { - console.log(`callback: err->${JSON.(err)}, data->${JSON.stringify(data)}`); + console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); }); ``` @@ -1023,7 +1025,7 @@ decodeMms(mmsFilePathName: string | Array): Promise ```js let mmsFilePathName = "filename"; -let promise = sms.getSmscAddr(mmsFilePathName); +let promise = sms.decodeMms(mmsFilePathName); promise.then(data => { console.log(`decodeMms success, promise: data->${JSON.stringify(data)}`); }).catch(err => { @@ -1092,13 +1094,13 @@ encodeMms(mms: MmsInformation): Promise> ```js let mmsAcknowledgeInd = { - transactionId = "100", - version = 0x10, - reportAllowed = 128 + transactionId: "100", + version: sms.MmsVersionType.MMS_VERSION_1_0, + reportAllowed = sms.ReportType.MMS_YES }; let mmsInformation = { - messageType = 133, - mmsType = mmsAcknowledgeInd + messageType: sms.MessageType.TYPE_MMS_ACKNOWLEDGE_IND, + mmsType: mmsAcknowledgeInd }; let promise = sms.encodeMms(mmsInformation); promise.then(data => { diff --git a/zh-cn/application-dev/reference/apis/js-apis-uri.md b/zh-cn/application-dev/reference/apis/js-apis-uri.md index b5a432841036c20a98e6cc6f160320847a7165fc..f14cab80f246d22f68b0012e9c3026447f92e776 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-uri.md +++ b/zh-cn/application-dev/reference/apis/js-apis-uri.md @@ -46,7 +46,7 @@ constructor是URI的构造函数。 **示例:** ```js -var mm = 'http://username:password@host:8080/directory/file?foo=1&bar=2#fragment'; +let mm = 'http://username:password@host:8080/directory/file?foo=1&bar=2#fragment'; new uri.URI(mm); // Output 'http://username:password@host:8080/directory/file?foo=1&bar=2#fragment'; ``` ```js diff --git a/zh-cn/application-dev/reference/apis/js-apis-url.md b/zh-cn/application-dev/reference/apis/js-apis-url.md index f7a30ab9b74c73fc034b9d8f37d69ff1337a21f2..98ab0ef71610ee027b01ba22207150685b31e313 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-url.md +++ b/zh-cn/application-dev/reference/apis/js-apis-url.md @@ -30,11 +30,11 @@ URLSearchParams的构造函数。 **示例:** ```js -var objectParams = new Url.URLSearchParams([ ['user1', 'abc1'], ['query2', 'first2'], ['query3', 'second3'] ]); -var objectParams1 = new Url.URLSearchParams({"fod" : '1' , "bard" : '2'}); -var objectParams2 = new Url.URLSearchParams('?fod=1&bard=2'); -var urlObject = new Url.URL('https://developer.mozilla.org/?fod=1&bard=2'); -var params = new Url.URLSearchParams(urlObject.search); +let objectParams = new Url.URLSearchParams([ ['user1', 'abc1'], ['query2', 'first2'], ['query3', 'second3'] ]); +let objectParams1 = new Url.URLSearchParams({"fod" : '1' , "bard" : '2'}); +let objectParams2 = new Url.URLSearchParams('?fod=1&bard=2'); +let urlObject = new Url.URL('https://developer.mozilla.org/?fod=1&bard=2'); +let params = new Url.URLSearchParams(urlObject.search); ``` @@ -132,7 +132,7 @@ entries(): IterableIterator<[string, string]> **示例:** ```js -var searchParamsObject = new Url.URLSearchParams("keyName1=valueName1&keyName2=valueName2"); +let searchParamsObject = new Url.URLSearchParams("keyName1=valueName1&keyName2=valueName2"); for (var pair of searchParamsObject .entries()) { // Show keyName/valueName pairs console.log(pair[0]+ ', '+ pair[1]); } @@ -196,9 +196,9 @@ get(name: string): string | null **示例:** ```js -var paramsOject = new Url.URLSearchParams('name=Jonathan&age=18'); -var name = paramsOject.get("name"); // is the string "Jonathan" -var age = parseInt(paramsOject.get("age"), 10); // is the number 18 +let paramsOject = new Url.URLSearchParams('name=Jonathan&age=18'); +let name = paramsOject.get("name"); // is the string "Jonathan" +let age = parseInt(paramsOject.get("age"), 10); // is the number 18 ``` @@ -266,7 +266,7 @@ sort(): void **示例:** ```js -var searchParamsObject = new Url.URLSearchParams("c=3&a=9&b=4&d=2"); // Create a test URLSearchParams object +let searchParamsObject = new Url.URLSearchParams("c=3&a=9&b=4&d=2"); // Create a test URLSearchParams object searchParamsObject.sort(); // Sort the key/value pairs console.log(searchParamsObject.toString()); // Display the sorted query string // Output a=9&b=2&c=3&d=4 ``` @@ -289,7 +289,7 @@ keys(): IterableIterator<string> **示例:** ```js -var searchParamsObject = new Url.URLSearchParams("key1=value1&key2=value2"); // Create a URLSearchParamsObject object for testing +let searchParamsObject = new Url.URLSearchParams("key1=value1&key2=value2"); // Create a URLSearchParamsObject object for testing for (var key of searchParamsObject .keys()) { // Output key-value pairs console.log(key); } @@ -313,8 +313,8 @@ values(): IterableIterator<string> **示例:** ```js -var searchParams = new Url.URLSearchParams("key1=value1&key2=value2"); // Create a URLSearchParamsObject object for testing -for (var value of searchParams.values()) { +let searchParams = new Url.URLSearchParams("key1=value1&key2=value2"); // Create a URLSearchParamsObject object for testing +for (var value of searchParams.values()) { console.log(value); } ``` @@ -338,7 +338,7 @@ for (var value of searchParams.values()) { ```js const paramsObject = new Url.URLSearchParams('fod=bay&edg=bap'); -for (const [name, value] of paramsObject) { +for (const [name, value] of paramsObject) { console.log(name, value); } ``` @@ -408,11 +408,11 @@ URL的构造函数。 **示例:** ```js -var mm = 'http://username:password@host:8080'; -var a = new Url.URL("/", mm); // Output 'http://username:password@host:8080/'; -var b = new Url.URL(mm); // Output 'http://username:password@host:8080/'; +let mm = 'http://username:password@host:8080'; +let a = new Url.URL("/", mm); // Output 'http://username:password@host:8080/'; +let b = new Url.URL(mm); // Output 'http://username:password@host:8080/'; new Url.URL('path/path1', b); // Output 'http://username:password@host:8080/path/path1'; -var c = new Url.URL('/path/path1', b); // Output 'http://username:password@host:8080/path/path1'; +let c = new Url.URL('/path/path1', b); // Output 'http://username:password@host:8080/path/path1'; new Url.URL('/path/path1', c); // Output 'http://username:password@host:8080/path/path1'; new Url.URL('/path/path1', a); // Output 'http://username:password@host:8080/path/path1'; new Url.URL('/path/path1', "https://www.exampleUrl/fr-FR/toto"); // Output https://www.exampleUrl/path/path1 diff --git a/zh-cn/application-dev/reference/apis/js-apis-util.md b/zh-cn/application-dev/reference/apis/js-apis-util.md index 365ec57f81c410e79a2ab56b57fcb692f758f501..2cf3ccd9b48d2be1e88edb0455dd904f0ce655a2 100755 --- a/zh-cn/application-dev/reference/apis/js-apis-util.md +++ b/zh-cn/application-dev/reference/apis/js-apis-util.md @@ -37,7 +37,7 @@ printf(format: string, ...args: Object[]): string **示例:** ```js - var res = util.printf("%s", "hello world!"); + let res = util.printf("%s", "hello world!"); console.log(res); ``` @@ -64,8 +64,8 @@ getErrorString(errno: number): string **示例:** ```js - var errnum = 10; // 10 : a system error number - var result = util.getErrorString(errnum); + let errnum = 10; // 10 : a system error number + let result = util.getErrorString(errnum); console.log("result = " + result); ``` @@ -95,8 +95,8 @@ callbackWrapper(original: Function): (err: Object, value: Object )=>void async function promiseFn() { return Promise.reject('value'); } - var err = "type err"; - var cb = util.callbackWrapper(promiseFn); + let err = "type err"; + let cb = util.callbackWrapper(promiseFn); cb((err, ret) => { console.log(err); console.log(ret); @@ -283,7 +283,7 @@ TextDecoder的构造函数。 **示例:** ```js - var textDecoder = new util.TextDecoder("utf-8",{ignoreBOM: true}); + let textDecoder = new util.TextDecoder("utf-8",{ignoreBOM: true}); ``` @@ -316,8 +316,8 @@ decode(input: Uint8Array, options?: { stream?: false }): string **示例:** ```js - var textDecoder = new util.TextDecoder("utf-8",{ignoreBOM: true}); - var result = new Uint8Array(6); + let textDecoder = new util.TextDecoder("utf-8",{ignoreBOM: true}); + let result = new Uint8Array(6); result[0] = 0xEF; result[1] = 0xBB; result[2] = 0xBF; @@ -325,7 +325,7 @@ decode(input: Uint8Array, options?: { stream?: false }): string result[4] = 0x62; result[5] = 0x63; console.log("input num:"); - var retStr = textDecoder.decode( result , {stream: false}); + let retStr = textDecoder.decode( result , {stream: false}); console.log("retStr = " + retStr); ``` @@ -359,8 +359,8 @@ decodeWithStream(input: Uint8Array, options?: { stream?: boolean }): string **示例:** ```js - var textDecoder = new util.TextDecoder("utf-8",{ignoreBOM: true}); - var result = new Uint8Array(6); + let textDecoder = new util.TextDecoder("utf-8",{ignoreBOM: true}); + let result = new Uint8Array(6); result[0] = 0xEF; result[1] = 0xBB; result[2] = 0xBF; @@ -368,7 +368,7 @@ decodeWithStream(input: Uint8Array, options?: { stream?: boolean }): string result[4] = 0x62; result[5] = 0x63; console.log("input num:"); - var retStr = textDecoder.decodeWithStream( result , {stream: false}); + let retStr = textDecoder.decodeWithStream( result , {stream: false}); console.log("retStr = " + retStr); ``` @@ -394,7 +394,7 @@ TextEncoder的构造函数。 **示例:** ```js - var textEncoder = new util.TextEncoder(); + let textEncoder = new util.TextEncoder(); ``` @@ -420,9 +420,9 @@ encode(input?: string): Uint8Array **示例:** ```js - var textEncoder = new util.TextEncoder(); - var buffer = new ArrayBuffer(20); - var result = new Uint8Array(buffer); + let textEncoder = new util.TextEncoder(); + let buffer = new ArrayBuffer(20); + let result = new Uint8Array(buffer); result = textEncoder.encode("\uD800¥¥"); ``` @@ -450,10 +450,10 @@ encodeInto(input: string, dest: Uint8Array, ): { read: number; written: number } **示例:** ```js - var that = new util.TextEncoder() - var buffer = new ArrayBuffer(4) - var dest = new Uint8Array(buffer) - var result = new Object() + let that = new util.TextEncoder() + let buffer = new ArrayBuffer(4) + let dest = new Uint8Array(buffer) + let result = new Object() result = that.encodeInto('abcd', dest) ``` @@ -477,7 +477,7 @@ RationalNumber的构造函数。 **示例:** ```js - var rationalNumber = new util.RationalNumber(1,2); + let rationalNumber = new util.RationalNumber(1,2); ``` @@ -503,8 +503,8 @@ static createRationalFromString​(rationalString: string): RationalNumber​ **示例:** ```js - var rationalNumber = new util.RationalNumber(1,2); - var rational = util.RationalNumber.createRationalFromString("3/4"); + let rationalNumber = new util.RationalNumber(1,2); + let rational = util.RationalNumber.createRationalFromString("3/4"); ``` @@ -530,9 +530,9 @@ compareTo​(another: RationalNumber): number​ **示例:** ```js - var rationalNumber = new util.RationalNumber(1,2); - var rational = util.RationalNumber.createRationalFromString("3/4"); - var result = rationalNumber.compareTo(rational); + let rationalNumber = new util.RationalNumber(1,2); + let rational = util.RationalNumber.createRationalFromString("3/4"); + let result = rationalNumber.compareTo(rational); ``` @@ -552,8 +552,8 @@ valueOf(): number **示例:** ```js - var rationalNumber = new util.RationalNumber(1,2); - var result = rationalNumber.valueOf(); + let rationalNumber = new util.RationalNumber(1,2); + let result = rationalNumber.valueOf(); ``` @@ -579,9 +579,9 @@ equals​(obj: Object): boolean **示例:** ```js - var rationalNumber = new util.RationalNumber(1,2); - var rational = util.RationalNumber.createRationalFromString("3/4"); - var result = rationalNumber.equals(rational); + let rationalNumber = new util.RationalNumber(1,2); + let rational = util.RationalNumber.createRationalFromString("3/4"); + let result = rationalNumber.equals(rational); ``` @@ -608,8 +608,8 @@ static getCommonDivisor​(number1: number,number2: number): number **示例:** ```js - var rationalNumber = new util.RationalNumber(1,2); - var result = util.RationalNumber.getCommonDivisor(4,6); + let rationalNumber = new util.RationalNumber(1,2); + let result = util.RationalNumber.getCommonDivisor(4,6); ``` @@ -629,8 +629,8 @@ getNumerator​(): number **示例:** ```js - var rationalNumber = new util.RationalNumber(1,2); - var result = rationalNumber.getNumerator(); + let rationalNumber = new util.RationalNumber(1,2); + let result = rationalNumber.getNumerator(); ``` @@ -650,8 +650,8 @@ getDenominator​(): number **示例:** ```js - var rationalNumber = new util.RationalNumber(1,2); - var result = rationalNumber.getDenominator(); + let rationalNumber = new util.RationalNumber(1,2); + let result = rationalNumber.getDenominator(); ``` @@ -671,8 +671,8 @@ isZero​():boolean **示例:** ```js - var rationalNumber = new util.RationalNumber(1,2); - var result = rationalNumber.isZero(); + let rationalNumber = new util.RationalNumber(1,2); + let result = rationalNumber.isZero(); ``` @@ -692,8 +692,8 @@ isNaN​(): boolean **示例:** ```js - var rationalNumber = new util.RationalNumber(1,2); - var result = rationalNumber.isNaN(); + let rationalNumber = new util.RationalNumber(1,2); + let result = rationalNumber.isNaN(); ``` @@ -713,8 +713,8 @@ isFinite​():boolean **示例:** ```js - var rationalNumber = new util.RationalNumber(1,2); - var result = rationalNumber.isFinite(); + let rationalNumber = new util.RationalNumber(1,2); + let result = rationalNumber.isFinite(); ``` @@ -734,8 +734,8 @@ toString​(): string **示例:** ```js - var rationalNumber = new util.RationalNumber(1,2); - var result = rationalNumber.toString(); + let rationalNumber = new util.RationalNumber(1,2); + let result = rationalNumber.toString(); ``` ## LruBuffer8+ @@ -750,10 +750,10 @@ toString​(): string **示例:** ```js - var pro = new util.LruBuffer(); + let pro = new util.LruBuffer(); pro.put(2,10); pro.put(1,8); - var result = pro.length; + let result = pro.length; ``` @@ -773,7 +773,7 @@ constructor(capacity?: number) **示例:** ```js - var lrubuffer= new util.LruBuffer(); + let lrubuffer= new util.LruBuffer(); ``` @@ -793,8 +793,8 @@ updateCapacity(newCapacity: number): void **示例:** ```js - var pro = new util.LruBuffer(); - var result = pro.updateCapacity(100); + let pro = new util.LruBuffer(); + let result = pro.updateCapacity(100); ``` @@ -814,11 +814,11 @@ toString(): string **示例:** ```js - var pro = new util.LruBuffer(); + let pro = new util.LruBuffer(); pro.put(2,10); pro.get(2); pro.remove(20); - var result = pro.toString(); + let result = pro.toString(); ``` @@ -838,8 +838,8 @@ getCapacity(): number **示例:** ```js - var pro = new util.LruBuffer(); - var result = pro.getCapacity(); + let pro = new util.LruBuffer(); + let result = pro.getCapacity(); ``` @@ -853,9 +853,9 @@ clear(): void **示例:** ```js - var pro = new util.LruBuffer(); + let pro = new util.LruBuffer(); pro.put(2,10); - var result = pro.length; + let result = pro.length; pro.clear(); ``` @@ -876,9 +876,9 @@ getCreateCount(): number **示例:** ```js - var pro = new util.LruBuffer(); + let pro = new util.LruBuffer(); pro.put(1,8); - var result = pro.getCreateCount(); + let result = pro.getCreateCount(); ``` @@ -898,10 +898,10 @@ getMissCount(): number **示例:** ```js - var pro = new util.LruBuffer(); + let pro = new util.LruBuffer(); pro.put(2,10); pro.get(2); - var result = pro.getMissCount(); + let result = pro.getMissCount(); ``` @@ -921,11 +921,11 @@ getRemovalCount(): number **示例:** ```js - var pro = new util.LruBuffer(); + let pro = new util.LruBuffer(); pro.put(2,10); pro.updateCapacity(2); pro.put(50,22); - var result = pro.getRemovalCount(); + let result = pro.getRemovalCount(); ``` @@ -945,10 +945,10 @@ getMatchCount(): number **示例:** ```js - var pro = new util.LruBuffer(); + let pro = new util.LruBuffer(); pro.put(2,10); pro.get(2); - var result = pro.getMatchCount(); + let result = pro.getMatchCount(); ``` @@ -968,9 +968,9 @@ getPutCount(): number **示例:** ```js - var pro = new util.LruBuffer(); + let pro = new util.LruBuffer(); pro.put(2,10); - var result = pro.getPutCount(); + let result = pro.getPutCount(); ``` @@ -990,9 +990,9 @@ isEmpty(): boolean **示例:** ```js - var pro = new util.LruBuffer(); + let pro = new util.LruBuffer(); pro.put(2,10); - var result = pro.isEmpty(); + let result = pro.isEmpty(); ``` @@ -1018,9 +1018,9 @@ get(key: K): V | undefined **示例:** ```js - var pro = new util.LruBuffer(); + let pro = new util.LruBuffer(); pro.put(2,10); - var result = pro.get(2); + let result = pro.get(2); ``` @@ -1047,8 +1047,8 @@ put(key: K,value: V): V **示例:** ```js - var pro = new util.LruBuffer(); - var result = pro.put(2,10); + let pro = new util.LruBuffer(); + let result = pro.put(2,10); ``` ### values8+ @@ -1067,11 +1067,11 @@ values(): V[] **示例:** ```js - var pro = new util.LruBuffer(); + let pro = new util.LruBuffer(); pro.put(2,10); pro.put(2,"anhu"); pro.put("afaf","grfb"); - var result = pro.values(); + let result = pro.values(); ``` @@ -1091,9 +1091,9 @@ keys(): K[] **示例:** ```js - var pro = new util.LruBuffer(); + let pro = new util.LruBuffer(); pro.put(2,10); - var result = pro.keys(); + let result = pro.keys(); ``` @@ -1119,9 +1119,9 @@ remove(key: K): V | undefined **示例:** ```js - var pro = new util.LruBuffer(); + let pro = new util.LruBuffer(); pro.put(2,10); - var result = pro.remove(20); + let result = pro.remove(20); ``` @@ -1144,7 +1144,7 @@ afterRemoval(isEvict: boolean,key: K,value: V,newValue: V): void **示例:** ```js - var arr = []; + let arr = []; class ChildLruBuffer extends util.LruBuffer { constructor() @@ -1159,7 +1159,7 @@ afterRemoval(isEvict: boolean,key: K,value: V,newValue: V): void } } } - var lru = new ChildLruBuffer(); + let lru = new ChildLruBuffer(); lru.afterRemoval(false,10,30,null); ``` @@ -1186,9 +1186,9 @@ contains(key: K): boolean **示例:** ```js - var pro = new util.LruBuffer(); + let pro = new util.LruBuffer(); pro.put(2,10); - var result = pro.contains(20); + let result = pro.contains(20); ``` @@ -1214,8 +1214,8 @@ createDefault(key: K): V **示例:** ```js - var pro = new util.LruBuffer(); - var result = pro.createDefault(50); + let pro = new util.LruBuffer(); + let result = pro.createDefault(50); ``` @@ -1235,9 +1235,9 @@ entries(): IterableIterator<[K,V]> **示例:** ```js - var pro = new util.LruBuffer(); + let pro = new util.LruBuffer(); pro.put(2,10); - var result = pro.entries(); + let result = pro.entries(); ``` @@ -1257,9 +1257,9 @@ entries(): IterableIterator<[K,V]> **示例:** ```js - var pro = new util.LruBuffer(); + let pro = new util.LruBuffer(); pro.put(2,10); - var result = pro[Symbol.iterator](); + let result = pro[Symbol.iterator](); ``` @@ -1320,9 +1320,9 @@ constructor(lowerObj: ScopeType, upperObj: ScopeType) **示例:** ```js - var tempLower = new Temperature(30); - var tempUpper = new Temperature(40); - var range = new util.Scope(tempLower, tempUpper); + let tempLower = new Temperature(30); + let tempUpper = new Temperature(40); + let range = new util.Scope(tempLower, tempUpper); ``` @@ -1342,10 +1342,10 @@ toString(): string **示例:** ```js - var tempLower = new Temperature(30); - var tempUpper = new Temperature(40); - var range = new util.Scope(tempLower, tempUpper); - var result = range.toString(); + let tempLower = new Temperature(30); + let tempUpper = new Temperature(40); + let range = new util.Scope(tempLower, tempUpper); + let result = range.toString(); ``` @@ -1371,12 +1371,12 @@ intersect(range: Scope): Scope **示例:** ```js - var tempLower = new Temperature(30); - var tempUpper = new Temperature(40); - var range = new util.Scope(tempLower, tempUpper); - var tempMiDF = new Temperature(35); - var tempMidS = new Temperature(39); - var rangeFir = new util.Scope(tempMiDF, tempMidS); + let tempLower = new Temperature(30); + let tempUpper = new Temperature(40); + let range = new util.Scope(tempLower, tempUpper); + let tempMiDF = new Temperature(35); + let tempMidS = new Temperature(39); + let rangeFir = new util.Scope(tempMiDF, tempMidS); range.intersect(rangeFir ); ``` @@ -1404,12 +1404,12 @@ intersect(lowerObj:ScopeType,upperObj:ScopeType):Scope **示例:** ```js - var tempLower = new Temperature(30); - var tempUpper = new Temperature(40); - var tempMiDF = new Temperature(35); - var tempMidS = new Temperature(39); - var range = new util.Scope(tempLower, tempUpper); - var result = range.intersect(tempMiDF, tempMidS); + let tempLower = new Temperature(30); + let tempUpper = new Temperature(40); + let tempMiDF = new Temperature(35); + let tempMidS = new Temperature(39); + let range = new util.Scope(tempLower, tempUpper); + let result = range.intersect(tempMiDF, tempMidS); ``` @@ -1429,10 +1429,10 @@ getUpper(): ScopeType **示例:** ```js - var tempLower = new Temperature(30); - var tempUpper = new Temperature(40); - var range = new util.Scope(tempLower, tempUpper); - var result = range.getUpper(); + let tempLower = new Temperature(30); + let tempUpper = new Temperature(40); + let range = new util.Scope(tempLower, tempUpper); + let result = range.getUpper(); ``` @@ -1452,10 +1452,10 @@ getLower(): ScopeType **示例:** ```js - var tempLower = new Temperature(30); - var tempUpper = new Temperature(40); - var range = new util.Scope(tempLower, tempUpper); - var result = range.getLower(); + let tempLower = new Temperature(30); + let tempUpper = new Temperature(40); + let range = new util.Scope(tempLower, tempUpper); + let result = range.getLower(); ``` @@ -1483,12 +1483,12 @@ expand(lowerObj: ScopeType,upperObj: ScopeType): Scope **示例:** ```js - var tempLower = new Temperature(30); - var tempUpper = new Temperature(40); - var tempMiDF = new Temperature(35); - var tempMidS = new Temperature(39); - var range = new util.Scope(tempLower, tempUpper); - var result = range.expand(tempMiDF, tempMidS); + let tempLower = new Temperature(30); + let tempUpper = new Temperature(40); + let tempMiDF = new Temperature(35); + let tempMidS = new Temperature(39); + let range = new util.Scope(tempLower, tempUpper); + let result = range.expand(tempMiDF, tempMidS); ``` @@ -1514,13 +1514,13 @@ expand(range: Scope): Scope **示例:** ```js - var tempLower = new Temperature(30); - var tempUpper = new Temperature(40); - var tempMiDF = new Temperature(35); - var tempMidS = new Temperature(39); - var range = new util.Scope(tempLower, tempUpper); - var rangeFir = new util.Scope(tempMiDF, tempMidS); - var result = range.expand(rangeFir); + let tempLower = new Temperature(30); + let tempUpper = new Temperature(40); + let tempMiDF = new Temperature(35); + let tempMidS = new Temperature(39); + let range = new util.Scope(tempLower, tempUpper); + let rangeFir = new util.Scope(tempMiDF, tempMidS); + let result = range.expand(rangeFir); ``` @@ -1546,11 +1546,11 @@ expand(value: ScopeType): Scope **示例:** ```js - var tempLower = new Temperature(30); - var tempUpper = new Temperature(40); - var tempMiDF = new Temperature(35); - var range = new util.Scope(tempLower, tempUpper); - var result = range.expand(tempMiDF); + let tempLower = new Temperature(30); + let tempUpper = new Temperature(40); + let tempMiDF = new Temperature(35); + let range = new util.Scope(tempLower, tempUpper); + let result = range.expand(tempMiDF); ``` @@ -1576,10 +1576,10 @@ contains(value: ScopeType): boolean **示例:** ```js - var tempLower = new Temperature(30); - var tempUpper = new Temperature(40); - var tempMiDF = new Temperature(35); - var range = new util.Scope(tempLower, tempUpper); + let tempLower = new Temperature(30); + let tempUpper = new Temperature(40); + let tempMiDF = new Temperature(35); + let range = new util.Scope(tempLower, tempUpper); range.contains(tempMiDF); ``` @@ -1606,13 +1606,13 @@ contains(range: Scope): boolean **示例:** ```js - var tempLower = new Temperature(30); - var tempUpper = new Temperature(40); - var range = new util.Scope(tempLower, tempUpper); - var tempLess = new Temperature(20); - var tempMore = new Temperature(45); - var rangeSec = new util.Scope(tempLess, tempMore); - var result = range.contains(rangeSec); + let tempLower = new Temperature(30); + let tempUpper = new Temperature(40); + let range = new util.Scope(tempLower, tempUpper); + let tempLess = new Temperature(20); + let tempMore = new Temperature(45); + let rangeSec = new util.Scope(tempLess, tempMore); + let result = range.contains(rangeSec); ``` @@ -1638,11 +1638,11 @@ clamp(value: ScopeType): ScopeType **示例:** ```js - var tempLower = new Temperature(30); - var tempUpper = new Temperature(40); - var tempMiDF = new Temperature(35); - var range = new util.Scope(tempLower, tempUpper); - var result = range.clamp(tempMiDF); + let tempLower = new Temperature(30); + let tempUpper = new Temperature(40); + let tempMiDF = new Temperature(35); + let range = new util.Scope(tempLower, tempUpper); + let result = range.clamp(tempMiDF); ``` @@ -1659,7 +1659,7 @@ Base64的构造函数。 **示例:** ```js - var base64 = new util.Base64(); + let base64 = new util.Base64(); ``` @@ -1685,9 +1685,9 @@ encodeSync(src: Uint8Array): Uint8Array **示例:** ```js - var that = new util.Base64(); - var array = new Uint8Array([115,49,51]); - var result = that.encodeSync(array); + let that = new util.Base64(); + let array = new Uint8Array([115,49,51]); + let result = that.encodeSync(array); ``` @@ -1713,9 +1713,9 @@ encodeToStringSync(src: Uint8Array): string **示例:** ```js - var that = new util.Base64(); - var array = new Uint8Array([115,49,51]); - var result = that.encodeToStringSync(array); + let that = new util.Base64(); + let array = new Uint8Array([115,49,51]); + let result = that.encodeToStringSync(array); ``` @@ -1741,9 +1741,9 @@ decodeSync(src: Uint8Array | string): Uint8Array **示例:** ```js - var that = new util.Base64(); - var buff = 'czEz'; - var result = that.decodeSync(buff); + let that = new util.Base64(); + let buff = 'czEz'; + let result = that.decodeSync(buff); ``` @@ -1769,9 +1769,9 @@ encode(src: Uint8Array): Promise<Uint8Array> **示例:** ```js - var that = new util.Base64(); - var array = new Uint8Array([115,49,51]); - var rarray = new Uint8Array([99,122,69,122]); + let that = new util.Base64(); + let array = new Uint8Array([115,49,51]); + let rarray = new Uint8Array([99,122,69,122]); that.encode(array).then(val=>{ for (var i = 0; i < rarray.length; i++) { console.log(val[i].toString()) @@ -1802,8 +1802,8 @@ encodeToString(src: Uint8Array): Promise<string> **示例:** ```js - var that = new util.Base64(); - var array = new Uint8Array([115,49,51]); + let that = new util.Base64(); + let array = new Uint8Array([115,49,51]); that.encodeToString(array).then(val=>{ console.log(val) }) @@ -1832,9 +1832,9 @@ decode(src: Uint8Array | string): Promise<Uint8Array> **示例:** ```js - var that = new util.Base64(); - var array = new Uint8Array([99,122,69,122]); - var rarray = new Uint8Array([115,49,51]); + let that = new util.Base64(); + let array = new Uint8Array([99,122,69,122]); + let rarray = new Uint8Array([115,49,51]); that.decode(array).then(val=>{ for (var i = 0; i < rarray.length; i++) { console.log(val[i].toString()) @@ -1856,7 +1856,7 @@ Types的构造函数。 **示例:** ```js - var type = new util.types(); + let type = new util.types(); ``` @@ -1882,8 +1882,8 @@ isAnyArrayBuffer(value: Object): boolean **示例:** ```js - var that = new util.types(); - var result = that.isAnyArrayBuffer(new ArrayBuffer(0)); + let that = new util.types(); + let result = that.isAnyArrayBuffer(new ArrayBuffer(0)); ``` @@ -1911,8 +1911,8 @@ ArrayBufferView辅助类型包括:Int8Array、Int16Array、Int32Array、Uint8A **示例:** ```js - var that = new util.types(); - var result = that.isArrayBufferView(new Int8Array([])); + let that = new util.types(); + let result = that.isArrayBufferView(new Int8Array([])); ``` @@ -1938,11 +1938,11 @@ isArgumentsObject(value: Object): boolean **示例:** ```js - var that = new util.types(); + let that = new util.types(); function foo() { var result = that.isArgumentsObject(arguments); } - var f = foo(); + let f = foo(); ``` @@ -1968,8 +1968,8 @@ isArrayBuffer(value: Object): boolean **示例:** ```js - var that = new util.types(); - var result = that.isArrayBuffer(new ArrayBuffer(0)); + let that = new util.types(); + let result = that.isArrayBuffer(new ArrayBuffer(0)); ``` @@ -1995,8 +1995,8 @@ isAsyncFunction(value: Object): boolean **示例:** ```js - var that = new util.types(); - var result = that.isAsyncFunction(async function foo() {}); + let that = new util.types(); + let result = that.isAsyncFunction(async function foo() {}); ``` @@ -2022,8 +2022,8 @@ isBooleanObject(value: Object): boolean **示例:** ```js - var that = new util.types(); - var result = that.isBooleanObject(new Boolean(true)); + let that = new util.types(); + let result = that.isBooleanObject(new Boolean(true)); ``` @@ -2049,8 +2049,8 @@ isBoxedPrimitive(value: Object): boolean **示例:** ```js - var that = new util.types(); - var result = that.isBoxedPrimitive(new Boolean(false)); + let that = new util.types(); + let result = that.isBoxedPrimitive(new Boolean(false)); ``` @@ -2076,9 +2076,9 @@ isDataView(value: Object): boolean **示例:** ```js - var that = new util.types(); + let that = new util.types(); const ab = new ArrayBuffer(20); - var result = that.isDataView(new DataView(ab)); + let result = that.isDataView(new DataView(ab)); ``` @@ -2104,8 +2104,8 @@ isDate(value: Object): boolean **示例:** ```js - var that = new util.types(); - var result = that.isDate(new Date()); + let that = new util.types(); + let result = that.isDate(new Date()); ``` @@ -2131,8 +2131,8 @@ isExternal(value: Object): boolean **示例:** ```js - var that = new util.types(); - var result = that.isExternal(true); + let that = new util.types(); + let result = that.isExternal(true); ``` @@ -2158,8 +2158,8 @@ isFloat32Array(value: Object): boolean **示例:** ```js - var that = new util.types(); - var result = that.isFloat32Array(new Float32Array()); + let that = new util.types(); + let result = that.isFloat32Array(new Float32Array()); ``` @@ -2185,8 +2185,8 @@ isFloat64Array(value: Object): boolean **示例:** ```js - var that = new util.types(); - var result = that.isFloat64Array(new Float64Array()); + let that = new util.types(); + let result = that.isFloat64Array(new Float64Array()); ``` @@ -2212,8 +2212,8 @@ isGeneratorFunction(value: Object): boolean **示例:** ```js - var that = new util.types(); - var result = that.isGeneratorFunction(function* foo() {}); + let that = new util.types(); + let result = that.isGeneratorFunction(function* foo() {}); ``` @@ -2239,10 +2239,10 @@ isGeneratorObject(value: Object): boolean **示例:** ```js - var that = new util.types(); + let that = new util.types(); function* foo() {} const generator = foo(); - var result = that.isGeneratorObject(generator); + let result = that.isGeneratorObject(generator); ``` @@ -2268,8 +2268,8 @@ isInt8Array(value: Object): boolean **示例:** ```js - var that = new util.types(); - var result = that.isInt8Array(new Int8Array([])); + let that = new util.types(); + let result = that.isInt8Array(new Int8Array([])); ``` @@ -2295,8 +2295,8 @@ isInt16Array(value: Object): boolean **示例:** ```js - var that = new util.types(); - var result = that.isInt16Array(new Int16Array([])); + let that = new util.types(); + let result = that.isInt16Array(new Int16Array([])); ``` @@ -2322,8 +2322,8 @@ isInt32Array(value: Object): boolean **示例:** ```js - var that = new util.types(); - var result = that.isInt32Array(new Int32Array([])); + let that = new util.types(); + let result = that.isInt32Array(new Int32Array([])); ``` @@ -2349,8 +2349,8 @@ isMap(value: Object): boolean **示例:** ```js - var that = new util.types(); - var result = that.isMap(new Map()); + let that = new util.types(); + let result = that.isMap(new Map()); ``` @@ -2376,9 +2376,9 @@ isMapIterator(value: Object): boolean **示例:** ```js - var that = new util.types(); + let that = new util.types(); const map = new Map(); - var result = that.isMapIterator(map.keys()); + let result = that.isMapIterator(map.keys()); ``` @@ -2404,8 +2404,8 @@ isNativeError(value: Object): boolean **示例:** ```js - var that = new util.types(); - var result = that.isNativeError(new TypeError()); + let that = new util.types(); + let result = that.isNativeError(new TypeError()); ``` @@ -2431,8 +2431,8 @@ isNumberObject(value: Object): boolean **示例:** ```js - var that = new util.types(); - var result = that.isNumberObject(new Number(0)); + let that = new util.types(); + let result = that.isNumberObject(new Number(0)); ``` @@ -2458,8 +2458,8 @@ isPromise(value: Object): boolean **示例:** ```js - var that = new util.types(); - var result = that.isPromise(Promise.resolve(1)); + let that = new util.types(); + let result = that.isPromise(Promise.resolve(1)); ``` @@ -2485,10 +2485,10 @@ isProxy(value: Object): boolean **示例:** ```js - var that = new util.types(); + let that = new util.types(); const target = {}; const proxy = new Proxy(target, {}); - var result = that.isProxy(proxy); + let result = that.isProxy(proxy); ``` @@ -2514,8 +2514,8 @@ isRegExp(value: Object): boolean **示例:** ```js - var that = new util.types(); - var result = that.isRegExp(new RegExp('abc')); + let that = new util.types(); + let result = that.isRegExp(new RegExp('abc')); ``` @@ -2541,8 +2541,8 @@ isSet(value: Object): boolean **示例:** ```js - var that = new util.types(); - var result = that.isSet(new Set()); + let that = new util.types(); + let result = that.isSet(new Set()); ``` @@ -2568,9 +2568,9 @@ isSetIterator(value: Object): boolean **示例:** ```js - var that = new util.types(); + let that = new util.types(); const set = new Set(); - var result = that.isSetIterator(set.keys()); + let result = that.isSetIterator(set.keys()); ``` @@ -2596,8 +2596,8 @@ isStringObject(value: Object): boolean **示例:** ```js - var that = new util.types(); - var result = that.isStringObject(new String('foo')); + let that = new util.types(); + let result = that.isStringObject(new String('foo')); ``` @@ -2623,9 +2623,9 @@ isSymbolObject(value: Object): boolean **示例:** ```js - var that = new util.types(); + let that = new util.types(); const symbols = Symbol('foo'); - var result = that.isSymbolObject(Object(symbols)); + let result = that.isSymbolObject(Object(symbols)); ``` @@ -2653,8 +2653,8 @@ TypedArray类型的辅助类型,包括Int8Array、Int16Array、Int32Array、Ui **示例:** ```js - var that = new util.types(); - var result = that.isTypedArray(new Float64Array([])); + let that = new util.types(); + let result = that.isTypedArray(new Float64Array([])); ``` @@ -2680,8 +2680,8 @@ isUint8Array(value: Object): boolean **示例:** ```js - var that = new util.types(); - var result = that.isUint8Array(new Uint8Array([])); + let that = new util.types(); + let result = that.isUint8Array(new Uint8Array([])); ``` @@ -2707,8 +2707,8 @@ isUint8ClampedArray(value: Object): boolean **示例:** ```js - var that = new util.types(); - var result = that.isUint8ClampedArray(new Uint8ClampedArray([])); + let that = new util.types(); + let result = that.isUint8ClampedArray(new Uint8ClampedArray([])); ``` @@ -2734,8 +2734,8 @@ isUint16Array(value: Object): boolean **示例:** ```js - var that = new util.types(); - var result = that.isUint16Array(new Uint16Array([])); + let that = new util.types(); + let result = that.isUint16Array(new Uint16Array([])); ``` @@ -2761,8 +2761,8 @@ isUint32Array(value: Object): boolean **示例:** ```js - var that = new util.types(); - var result = that.isUint32Array(new Uint32Array([])); + let that = new util.types(); + let result = that.isUint32Array(new Uint32Array([])); ``` @@ -2788,8 +2788,8 @@ isWeakMap(value: Object): boolean **示例:** ```js - var that = new util.types(); - var result = that.isWeakMap(new WeakMap()); + let that = new util.types(); + let result = that.isWeakMap(new WeakMap()); ``` @@ -2815,8 +2815,8 @@ isWeakSet(value: Object): boolean **示例:** ```js - var that = new util.types(); - var result = that.isWeakSet(new WeakSet()); + let that = new util.types(); + let result = that.isWeakSet(new WeakSet()); ``` @@ -2842,8 +2842,8 @@ isBigInt64Array(value: Object): boolean **示例:** ```js - var that = new util.types(); - var result = that.isBigInt64Array(new BigInt64Array([])); + let that = new util.types(); + let result = that.isBigInt64Array(new BigInt64Array([])); ``` @@ -2869,8 +2869,8 @@ isBigUint64Array(value: Object): boolean **示例:** ```js - var that = new util.types(); - var result = that.isBigUint64Array(new BigUint64Array([])); + let that = new util.types(); + let result = that.isBigUint64Array(new BigUint64Array([])); ``` @@ -2897,8 +2897,8 @@ isModuleNamespaceObject(value: Object): boolean **示例:** ```js import url from '@ohos.url' - var that = new util.types(); - var result = that.isModuleNamespaceObject(url); + let that = new util.types(); + let result = that.isModuleNamespaceObject(url); ``` @@ -2924,6 +2924,6 @@ isSharedArrayBuffer(value: Object): boolean **示例:** ```js - var that = new util.types(); - var result = that.isSharedArrayBuffer(new SharedArrayBuffer(0)); + let that = new util.types(); + let result = that.isSharedArrayBuffer(new SharedArrayBuffer(0)); ``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-xml.md b/zh-cn/application-dev/reference/apis/js-apis-xml.md index 7d573cf82dd1203054dc4aaec9465ebfd003971f..1e17a2ecff74754a1ef1a086777d7118b7161175 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-xml.md +++ b/zh-cn/application-dev/reference/apis/js-apis-xml.md @@ -31,9 +31,9 @@ XmlSerializer的构造函数。 **示例:** ```js -var arrayBuffer = new ArrayBuffer(1024); -var bufView = new DataView(arrayBuffer); -var thatSer = new xml.XmlSerializer(bufView); +let arrayBuffer = new ArrayBuffer(1024); +let bufView = new DataView(arrayBuffer); +let thatSer = new xml.XmlSerializer(bufView); ``` @@ -55,9 +55,9 @@ setAttributes(name: string, value: string): void **示例:** ```js -var arrayBuffer = new ArrayBuffer(1024); -var bufView = new DataView(arrayBuffer); -var thatSer = new xml.XmlSerializer(bufView); +let arrayBuffer = new ArrayBuffer(1024); +let bufView = new DataView(arrayBuffer); +let thatSer = new xml.XmlSerializer(bufView); thatSer.setAttributes("importance", "high"); ``` @@ -79,9 +79,9 @@ addEmptyElement(name: string): void **示例:** ```js -var arrayBuffer = new ArrayBuffer(1024); -var bufView = new DataView(arrayBuffer); -var thatSer = new xml.XmlSerializer(bufView); +let arrayBuffer = new ArrayBuffer(1024); +let bufView = new DataView(arrayBuffer); +let thatSer = new xml.XmlSerializer(bufView); thatSer.addEmptyElement("b"); // => ``` @@ -97,9 +97,9 @@ setDeclaration(): void **示例:** ```js -var arrayBuffer = new ArrayBuffer(1024); -var bufView = new DataView(arrayBuffer); -var thatSer = new xml.XmlSerializer(bufView); +let arrayBuffer = new ArrayBuffer(1024); +let bufView = new DataView(arrayBuffer); +let thatSer = new xml.XmlSerializer(bufView); thatSer.setDeclaration() // => ; ``` @@ -121,8 +121,8 @@ startElement(name: string): void **示例:** ```js -var arrayBuffer = new ArrayBuffer(1024); -var thatSer = new xml.XmlSerializer(arrayBuffer); +let arrayBuffer = new ArrayBuffer(1024); +let thatSer = new xml.XmlSerializer(arrayBuffer); thatSer.startElement("notel"); thatSer.endElement();// => ''; ``` @@ -139,9 +139,9 @@ endElement(): void **示例:** ```js -var arrayBuffer = new ArrayBuffer(1024); -var bufView = new DataView(arrayBuffer); -var thatSer = new xml.XmlSerializer(bufView); +let arrayBuffer = new ArrayBuffer(1024); +let bufView = new DataView(arrayBuffer); +let thatSer = new xml.XmlSerializer(bufView); thatSer.setNamespace("h", "http://www.w3.org/TR/html4/"); thatSer.startElement("table"); thatSer.setAttributes("importance", "high"); @@ -168,8 +168,8 @@ setNamespace(prefix: string, namespace: string): void **示例:** ```js -var arrayBuffer = new ArrayBuffer(1024); -var thatSer = new xml.XmlSerializer(arrayBuffer); +let arrayBuffer = new ArrayBuffer(1024); +let thatSer = new xml.XmlSerializer(arrayBuffer); thatSer.setDeclaration(); thatSer.setNamespace("h", "http://www.w3.org/TR/html4/"); thatSer.startElement("note"); @@ -193,8 +193,8 @@ setComment(text: string): void **示例:** ```js -var arrayBuffer = new ArrayBuffer(1024); -var thatSer = new xml.XmlSerializer(arrayBuffer); +let arrayBuffer = new ArrayBuffer(1024); +let thatSer = new xml.XmlSerializer(arrayBuffer); thatSer.startElement("note"); thatSer.setComment("Hi!"); thatSer.endElement(); // => '\r\n \r\n'; @@ -218,8 +218,8 @@ setCDATA(text: string): void **示例:** ```js -var arrayBuffer = new ArrayBuffer(1028); -var thatSer = new xml.XmlSerializer(arrayBuffer); +let arrayBuffer = new ArrayBuffer(1028); +let thatSer = new xml.XmlSerializer(arrayBuffer); thatSer.setCDATA('root SYSTEM') // => ''; ``` @@ -241,8 +241,8 @@ setText(text: string): void **示例:** ```js -var arrayBuffer = new ArrayBuffer(1024); -var thatSer = new xml.XmlSerializer(arrayBuffer); +let arrayBuffer = new ArrayBuffer(1024); +let thatSer = new xml.XmlSerializer(arrayBuffer); thatSer.startElement("note"); thatSer.setAttributes("importance", "high"); thatSer.setText("Happy1"); @@ -267,8 +267,8 @@ setDocType(text: string): void **示例:** ```js -var arrayBuffer = new ArrayBuffer(1024); -var thatSer = new xml.XmlSerializer(arrayBuffer); +let arrayBuffer = new ArrayBuffer(1024); +let thatSer = new xml.XmlSerializer(arrayBuffer); thatSer.setDocType('root SYSTEM'); // => ''; ``` @@ -294,20 +294,20 @@ constructor(buffer: ArrayBuffer | DataView, encoding?: string) **示例:** ```js -var strXml = +let strXml = '' + '' + ' Happy' + ' Work' + ' Play' + ''; -var arrayBuffer = new ArrayBuffer(strXml.length); -var bufView = new Uint8Array(arrayBuffer); -var strLen = strXml.length; +let arrayBuffer = new ArrayBuffer(strXml.length); +let bufView = new Uint8Array(arrayBuffer); +let strLen = strXml.length; for (var i = 0; i < strLen; ++i) { bufView[i] = strXml.charCodeAt(i);//设置arraybuffer方式 } -var that = new xml.XmlPullParser(arrayBuffer); +let that = new xml.XmlPullParser(arrayBuffer); ``` @@ -328,30 +328,30 @@ parse(option: ParseOptions): void **示例:** ```js -var strXml = +let strXml = '' + '' + ' Happy' + ' Work' + ' Play' + ''; -var arrayBuffer = new ArrayBuffer(strXml.length); -var bufView = new Uint8Array(arrayBuffer); -var strLen = strXml.length; +let arrayBuffer = new ArrayBuffer(strXml.length); +let bufView = new Uint8Array(arrayBuffer); +let strLen = strXml.length; for (var i = 0; i < strLen; ++i) { bufView[i] = strXml.charCodeAt(i); } -var that = new xml.XmlPullParser(arrayBuffer); -var arrTag = {}; -var str = ""; -var i = 0; +let that = new xml.XmlPullParser(arrayBuffer); +let arrTag = {}; +let str = ""; +let i = 0; function func(key, value){ arrTag[i] = 'key:'+key+' value:'+ value.getDepth(); str += arrTag[i]; i++; return true; // Determines whether to continuely parse, which is used to continue or terminate parsing. } -var options = {supportDoctype:true, ignoreNameSpace:true, tokenValueCallbackFunction:func} +let options = {supportDoctype:true, ignoreNameSpace:true, tokenValueCallbackFunction:func} that.parse(options); console.log(str); // 输出: diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-canvas-canvasrenderingcontext2d.md b/zh-cn/application-dev/reference/arkui-js/js-components-canvas-canvasrenderingcontext2d.md index f94a20bf5991f7dc4c8066278d687ee022540103..639d952b396a54ea009ec293b03053db53ea904f 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-canvas-canvasrenderingcontext2d.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-canvas-canvasrenderingcontext2d.md @@ -47,25 +47,25 @@ ## 属性 -| 名称 | 类型 | 默认值 | 描述 | -| ---------------------------------------- | ---------------------------------------- | ---------------------------------------- | ---------------------------------------- | -| [fillStyle](#fillstyle) | <color> \| [CanvasGradient](../arkui-js/js-components-canvas-canvasgradient.md) \| CanvasPattern | - | 指定绘制的填充色。
- 类型为<color>时,表示设置填充区域的颜色。
- 类型为CanvasGradient时,表示渐变对象,使用 createLinearGradient()方法创建。
- 类型为CanvasPattern时,使用 createPattern()方法创建。 | -| [lineWidth](#linewidth) | number | - | 设置绘制线条的宽度。 | -| [strokeStyle](#strokestyle) | <color> \| [CanvasGradient](../arkui-js/js-components-canvas-canvasgradient.md) \| CanvasPattern | - | 设置描边的颜色。
- 类型为<color>时,表示设置描边使用的颜色。
- 类型为CanvasGradient时,表示渐变对象,使用 createLinearGradient()方法创建。
- 类型为CanvasPattern时,使用 createPattern()方法创建。 | -| [lineCap](#linecap) | string | butt | 指定线端点的样式,可选值为:
- butt:线端点以方形结束。
- round:线端点以圆形结束。
- square:线端点以方形结束,该样式下会增加一个长度和线段厚度相同,宽度是线段厚度一半的矩形。 | -| [lineJoin](#linejoin) | string | miter | 指定线段间相交的交点样式,可选值为:
- round:在线段相连处绘制一个扇形,扇形的圆角半径是线段的宽度。
- bevel:在线段相连处使用三角形为底填充, 每个部分矩形拐角独立。
- miter:在相连部分的外边缘处进行延伸,使其相交于一点,形成一个菱形区域,该属性可以通过设置miterLimit属性展现效果。 | -| [miterLimit](#miterlimit) | number | 10 | 设置斜接面限制值,该值指定了线条相交处内角和外角的距离。 | -| [font](#font) | string | "normal normal 14px sans-serif" | 设置文本绘制中的字体样式。
语法:ctx.font="font-style font-weight font-size font-family"5+
- font-style(可选),用于指定字体样式,支持如下几种样式:normal, italic。
- font-weight(可选),用于指定字体的粗细,支持如下几种类型:normal, bold, bolder, lighter, 100, 200, 300, 400, 500, 600, 700, 800, 900。
- font-size(可选),指定字号和行高,单位只支持px。
- font-family(可选),指定字体系列,支持如下几种类型:sans-serif, serif, monospace。 | -| [textAlign](#textalign) | string | left | 设置文本绘制中的文本对齐方式,可选值为:
- left:文本左对齐。
- right:文本右对齐。
- center:文本居中对齐。
- start:文本对齐界线开始的地方。
- end:文本对齐界线结束的地方。
ltr布局模式下start和left一致,rtl布局模式下start和right一致·。 | -| [textBaseline](#textbaseline) | string | alphabetic | 设置文本绘制中的水平对齐方式,可选值为:
- alphabetic:文本基线是标准的字母基线。
- top:文本基线在文本块的顶部。
- hanging:文本基线是悬挂基线。
- middle:文本基线在文本块的中间。
- ideographic:文字基线是表意字基线;如果字符本身超出了alphabetic 基线,那么ideographic基线位置在字符本身的底部。
- bottom:文本基线在文本块的底部。 与 ideographic 基线的区别在于 ideographic 基线不需要考虑下行字母。 | -| [globalAlpha](#globalalpha) | number | - | 设置透明度,0.0为完全透明,1.0为完全不透明。 | -| [lineDashOffset](#linedashoffset) | number | 0.0 | 设置画布的虚线偏移量,精度为float。 | -| [globalCompositeOperation](#globalcompositeoperation) | string | source-over | 设置合成操作的方式。类型字段可选值有source-over,source-atop,source-in,source-out,destination-over,destination-atop,destination-in,destination-out,lighter,copy,xor。具体请参考[表 类型字段说明](#globalcompositeoperation)。 | -| [shadowBlur](#shadowblur) | number | 0.0 | 设置绘制阴影时的模糊级别,值越大越模糊,精度为float。 | -| [shadowColor](#shadowcolor) | <color> | - | 设置绘制阴影时的阴影颜色。 | -| [shadowOffsetX](#shadowoffsetx) | number | - | 设置绘制阴影时和原有对象的水平偏移值。 | -| [shadowOffsetY](#shadowoffsety) | number | - | 设置绘制阴影时和原有对象的垂直偏移值。 | -| [imageSmoothingEnabled](#imagesmoothingenabled6)6+ | boolean | true | 用于设置绘制图片时是否进行图像平滑度调整,true为启用,false为不启用。 | +| 名称 | 类型 | 描述 | +| ---------------------------------------- | ---------------------------------------- | ---------------------------------------- | +| [fillStyle](#fillstyle) | <color> \| [CanvasGradient](../arkui-js/js-components-canvas-canvasgradient.md) \| CanvasPattern | 指定绘制的填充色。
- 类型为<color>时,表示设置填充区域的颜色。
- 类型为CanvasGradient时,表示渐变对象,使用 createLinearGradient()方法创建。
- 类型为CanvasPattern时,使用 createPattern()方法创建。 | +| [lineWidth](#linewidth) | number | 设置绘制线条的宽度。 | +| [strokeStyle](#strokestyle) | <color> \| [CanvasGradient](../arkui-js/js-components-canvas-canvasgradient.md) \| CanvasPattern | 设置描边的颜色。
- 类型为<color>时,表示设置描边使用的颜色。
- 类型为CanvasGradient时,表示渐变对象,使用 createLinearGradient()方法创建。
- 类型为CanvasPattern时,使用 createPattern()方法创建。 | +| [lineCap](#linecap) | string | 指定线端点的样式,可选值为:
- butt:线端点以方形结束。
- round:线端点以圆形结束。
- square:线端点以方形结束,该样式下会增加一个长度和线段厚度相同,宽度是线段厚度一半的矩形。
默认值:butt | +| [lineJoin](#linejoin) | string | 指定线段间相交的交点样式,可选值为:
- round:在线段相连处绘制一个扇形,扇形的圆角半径是线段的宽度。
- bevel:在线段相连处使用三角形为底填充, 每个部分矩形拐角独立。
- miter:在相连部分的外边缘处进行延伸,使其相交于一点,形成一个菱形区域,该属性可以通过设置miterLimit属性展现效果。
默认值:miter | +| [miterLimit](#miterlimit) | number | 设置斜接面限制值,该值指定了线条相交处内角和外角的距离。
默认值:10 | +| [font](#font) | string | 设置文本绘制中的字体样式。
语法:ctx.font="font-style font-weight font-size font-family"5+
- font-style(可选),用于指定字体样式,支持如下几种样式:normal, italic。
- font-weight(可选),用于指定字体的粗细,支持如下几种类型:normal, bold, bolder, lighter, 100, 200, 300, 400, 500, 600, 700, 800, 900。
- font-size(可选),指定字号和行高,单位只支持px。
- font-family(可选),指定字体系列,支持如下几种类型:sans-serif, serif, monospace。
默认值:"normal normal 14px sans-serif" | +| [textAlign](#textalign) | string | 设置文本绘制中的文本对齐方式,可选值为:
- left:文本左对齐。
- right:文本右对齐。
- center:文本居中对齐。
- start:文本对齐界线开始的地方。
- end:文本对齐界线结束的地方。
ltr布局模式下start和left一致,rtl布局模式下start和right一致。
默认值:left | +| [textBaseline](#textbaseline) | string | 设置文本绘制中的水平对齐方式,可选值为:
- alphabetic:文本基线是标准的字母基线。
- top:文本基线在文本块的顶部。
- hanging:文本基线是悬挂基线。
- middle:文本基线在文本块的中间。
- ideographic:文字基线是表意字基线;如果字符本身超出了alphabetic 基线,那么ideographic基线位置在字符本身的底部。
- bottom:文本基线在文本块的底部。 与 ideographic 基线的区别在于 ideographic 基线不需要考虑下行字母。
默认值: alphabetic | +| [globalAlpha](#globalalpha) | number | 设置透明度,0.0为完全透明,1.0为完全不透明。 | +| [lineDashOffset](#linedashoffset) | number | 设置画布的虚线偏移量,精度为float。
默认值:0.0 | +| [globalCompositeOperation](#globalcompositeoperation) | string | 设置合成操作的方式。类型字段可选值有source-over,source-atop,source-in,source-out,destination-over,destination-atop,destination-in,destination-out,lighter,copy,xor。具体请参考[表 类型字段说明](#globalcompositeoperation)。
默认值:ource-over | +| [shadowBlur](#shadowblur) | number | 设置绘制阴影时的模糊级别,值越大越模糊,精度为float。
默认值:0.0 | +| [shadowColor](#shadowcolor) | <color> | 设置绘制阴影时的阴影颜色。 | +| [shadowOffsetX](#shadowoffsetx) | number | 设置绘制阴影时和原有对象的水平偏移值。 | +| [shadowOffsetY](#shadowoffsety) | number | 设置绘制阴影时和原有对象的垂直偏移值。 | +| [imageSmoothingEnabled](#imagesmoothingenabled6)6+ | boolean | 用于设置绘制图片时是否进行图像平滑度调整,true为启用,false为不启用。
默认值:true | ### fillStyle diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-common-animation.md b/zh-cn/application-dev/reference/arkui-js/js-components-common-animation.md index d0b3d57916df702b6229c17a072e2f37fb991d9f..b7c71d2d19e6132320224368e41cc6c975ebf7ed 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-common-animation.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-common-animation.md @@ -7,20 +7,20 @@ 组件支持动态的旋转、平移、缩放效果,可在style或css中设置。 -| 名称 | 类型 | 默认值 | 描述 | -| --------------------------------- | ---------------------------------------- | ---------------------------------------- | ---------------------------------------- | -| transform-origin | string6+ \| <percentage> \| <length> string6+ \| <percentage> \| <length> | center center | 变换对象的原点位置,支持px和百分比(相对于动画目标组件),如果仅设置一个值,另一个值为50%,第一个string的可选值为:left \| center \| right ,第二个string的可选值为:top \| center \| bottom。
示例:
transform-origin: 200px 30%。
transform-origin: 100px top。
transform-origin: center center。 | -| transform | string | - | 支持同时设置平移/旋转/缩放的属性。
详见表 transform操作说明。 | -| animation6+ | string | 0s ease 0s 1 normal none running none | 格式:duration \| timing-function \| delay \| iteration-count \| direction \| fill-mode \| play-state \| name,每个字段不区分先后,但是 duration / delay 按照出现的先后顺序解析。 | -| animation-name | string | - | 指定\@keyframes,详见表 @keyframes属性说明。 | -| animation-delay | <time> | 0 | 定义动画播放的延迟时间。支持的单位为[s(秒)\|ms(毫秒) ],默认单位为ms,格式为:1000ms或1s。 | -| animation-duration | <time> | 0 | 定义一个动画周期。支持的单位为[s(秒)\|ms(毫秒) ],默认单位为ms,格式为:1000ms或1s。
必须设置animation-duration 样式,否则时长为 0将不会播放动画。 | -| animation-iteration-count | number \| infinite | 1 | 定义动画播放的次数,默认播放一次,可通过设置为infinite无限次播放。 | -| animation-timing-function | string | ease
| 描述动画执行的速度曲线,用于使动画更为平滑。
可选项有:
- linear:表示动画从头到尾的速度都是相同的。
- ease:表示动画以低速开始,然后加快,在结束前变慢,cubic-bezier(0.25, 0.1, 0.25, 1.0)。
- ease-in:表示动画以低速开始,cubic-bezier(0.42, 0.0, 1.0, 1.0)。
- ease-out:表示动画以低速结束,cubic-bezier(0.0, 0.0, 0.58, 1.0)。
- ease-in-out:表示动画以低速开始和结束,cubic-bezier(0.42, 0.0, 0.58, 1.0)。
- friction:阻尼曲线,cubic-bezier(0.2, 0.0, 0.2, 1.0)。
- extreme-deceleration:急缓曲线,cubic-bezier(0.0, 0.0, 0.0, 1.0)。
- sharp:锐利曲线,cubic-bezier(0.33, 0.0, 0.67, 1.0)。
- rhythm:节奏曲线,cubic-bezier(0.7, 0.0, 0.2, 1.0)。
- smooth:平滑曲线,cubic-bezier(0.4, 0.0, 0.4, 1.0)。
- cubic-bezier:在三次贝塞尔函数中定义动画变化过程,入参的x和y值必须处于0-1之间。
- steps: 阶梯曲线6+。语法:steps(number[, end\|start]);number必须设置,支持的类型为正整数。第二个参数可选,表示在每个间隔的起点或是终点发生阶跃变化,支持设置end或start,默认值为end。 | -| animation-direction6+ | string | normal | 指定动画的播放模式:
- normal: 动画正向循环播放。
- reverse: 动画反向循环播放。
- alternate:动画交替循环播放,奇数次正向播放,偶数次反向播放。
- alternate-reverse:动画反向交替循环播放,奇数次反向播放,偶数次正向播放。 | -| animation-fill-mode | string | none | 指定动画开始和结束的状态:
- none:在动画执行之前和之后都不会应用任何样式到目标上。
- forwards:在动画结束后,目标将保留动画结束时的状态(在最后一个关键帧中定义)。
- backwards6+:动画将在animation-delay期间应用第一个关键帧中定义的值。当animation-direction为"normal"或"alternate"时应用from关键帧中的值,当animation-direction为"reverse"或"alternate-reverse"时应用to关键帧中的值。
- both6+:动画将遵循forwards和backwards的规则,从而在两个方向上扩展动画属性。 | -| animation-play-state6+ | string | running | 指定动画的当前状态:
- paused:动画状态为暂停。
- running:动画状态为播放。 | -| transition6+ | string | all 0 ease 0 | 指定组件状态切换时的过渡效果,可以通过transition属性设置如下四个属性:
- transition-property:规定设置过渡效果的 CSS 属性的名称,目前支持宽、高、背景色。
- transition-duration:规定完成过渡效果需要的时间,单位秒。
- transition-timing-function:规定过渡效果的时间曲线,支持样式动画提供的曲线。
- transition-delay:规定过渡效果延时启动时间,单位秒。 | +| 名称 | 类型 | 描述 | +| --------------------------------- | ---------------------------------------- | ---------------------------------------- | +| transform-origin | string6+ \|
 <percentage> \|
 <length> string6+ \|
 <percentage> \| <length> | 变换对象的原点位置,支持px和百分比(相对于动画目标组件),如果仅设置一个值,另一个值为50%,第一个string的可选值为:left \| center \| right ,第二个string的可选值为:top \| center \| bottom。
示例:
transform-origin: 200px 30%。
transform-origin: 100px top。
transform-origin: center center。
默认值:center center | +| transform | string | 支持同时设置平移/旋转/缩放的属性。
详见表 transform操作说明。 | +| animation6+ | string | 格式:duration \| timing-function \| delay \| iteration-count \| direction \| fill-mode \| play-state \| name,每个字段不区分先后,但是 duration / delay 按照出现的先后顺序解析。
默认值:0s ease 0s 1 normal none running none | +| animation-name | string | 指定\@keyframes,详见表 @keyframes属性说明。 | +| animation-delay | <time> | 定义动画播放的延迟时间。支持的单位为[s(秒)\|ms(毫秒) ],默认单位为ms,格式为:1000ms或1s。
默认值:0 | +| animation-duration | <time> | 定义一个动画周期。支持的单位为[s(秒)\|ms(毫秒) ],默认单位为ms,格式为:1000ms或1s。
必须设置animation-duration 样式,否则时长为 0将不会播放动画。
默认值:0 | +| animation-iteration-count | number \| infinite | 定义动画播放的次数,默认播放一次,可通过设置为infinite无限次播放。
默认值:1 | +| animation-timing-function | string | 描述动画执行的速度曲线,用于使动画更为平滑。
可选项有:
- linear:表示动画从头到尾的速度都是相同的。
- ease:表示动画以低速开始,然后加快,在结束前变慢,cubic-bezier(0.25, 0.1, 0.25, 1.0)。
- ease-in:表示动画以低速开始,cubic-bezier(0.42, 0.0, 1.0, 1.0)。
- ease-out:表示动画以低速结束,cubic-bezier(0.0, 0.0, 0.58, 1.0)。
- ease-in-out:表示动画以低速开始和结束,cubic-bezier(0.42, 0.0, 0.58, 1.0)。
- friction:阻尼曲线,cubic-bezier(0.2, 0.0, 0.2, 1.0)。
- extreme-deceleration:急缓曲线,cubic-bezier(0.0, 0.0, 0.0, 1.0)。
- sharp:锐利曲线,cubic-bezier(0.33, 0.0, 0.67, 1.0)。
- rhythm:节奏曲线,cubic-bezier(0.7, 0.0, 0.2, 1.0)。
- smooth:平滑曲线,cubic-bezier(0.4, 0.0, 0.4, 1.0)。
- cubic-bezier:在三次贝塞尔函数中定义动画变化过程,入参的x和y值必须处于0-1之间。
- steps: 阶梯曲线6+。语法:steps(number[, end\|start]);number必须设置,支持的类型为正整数。第二个参数可选,表示在每个间隔的起点或是终点发生阶跃变化,支持设置end或start,默认值为end。
默认值:ease | +| animation-direction6+ | string | 指定动画的播放模式:
- normal: 动画正向循环播放。
- reverse: 动画反向循环播放。
- alternate:动画交替循环播放,奇数次正向播放,偶数次反向播放。
- alternate-reverse:动画反向交替循环播放,奇数次反向播放,偶数次正向播放。
默认值:normal | +| animation-fill-mode | string | 指定动画开始和结束的状态:
- none:在动画执行之前和之后都不会应用任何样式到目标上。
- forwards:在动画结束后,目标将保留动画结束时的状态(在最后一个关键帧中定义)。
- backwards6+:动画将在animation-delay期间应用第一个关键帧中定义的值。当animation-direction为"normal"或"alternate"时应用from关键帧中的值,当animation-direction为"reverse"或"alternate-reverse"时应用to关键帧中的值。
- both6+:动画将遵循forwards和backwards的规则,从而在两个方向上扩展动画属性。
默认值:none | +| animation-play-state6+ | string | 指定动画的当前状态:
- paused:动画状态为暂停。
- running:动画状态为播放。
默认值:running | +| transition6+ | string | 指定组件状态切换时的过渡效果,可以通过transition属性设置如下四个属性:
- transition-property:规定设置过渡效果的 CSS 属性的名称,目前支持宽、高、背景色。
- transition-duration:规定完成过渡效果需要的时间,单位秒。
- transition-timing-function:规定过渡效果的时间曲线,支持样式动画提供的曲线。
- transition-delay:规定过渡效果延时启动时间,单位秒。
默认值:all 0 ease 0 | **表1** transform操作说明 @@ -30,11 +30,11 @@ | none6+ | - | 不进行任何转换。 | | matrix6+ | <number> | 入参为六个值的矩阵,6个值分别代表:scaleX, skewY, skewX, scaleY, translateX, translateY。 | | matrix3d6+ | <number> | 入参为十六个值的4X4矩阵。 | -| translate | <length> \| <percent> | 平移动画属性,支持设置x轴和y轴两个维度的平移参数。 | -| translate3d6+ | <length> \| <percent> | 三个入参,分别代表X轴、Y轴、Z轴的平移距离。 | -| translateX | <length> \| <percent> | X轴方向平移动画属性。 | -| translateY | <length> \| <percent> | Y轴方向平移动画属性。 | -| translateZ6+ | <length> \| <percent> | Z轴的平移距离。 | +| translate | <length> \| <percent> | 平移动画属性,支持设置x轴和y轴两个维度的平移参数。 | +| translate3d6+ | <length> \| <percent> | 三个入参,分别代表X轴、Y轴、Z轴的平移距离。 | +| translateX | <length> \| <percent> | X轴方向平移动画属性。 | +| translateY | <length> \| <percent> | Y轴方向平移动画属性。 | +| translateZ6+ | <length> \| <percent> | Z轴的平移距离。 | | scale | <number> | 缩放动画属性,支持设置x轴和y轴两个维度的缩放参数。 | | scale3d6+ | <number> | 三个入参,分别代表X轴、Y轴、Z轴的缩放参数。 | | scaleX | <number> | X轴方向缩放动画属性。 | @@ -59,7 +59,7 @@ | width | <length> | - | 动画执行后应用到组件上的宽度值。 | | height | <length> | - | 动画执行后应用到组件上的高度值。 | | transform | string | - | 定义应用在组件上的变换类型,见表 transform操作说明。 | -| background-position6+ | string \| <percentage> \| <length> string \| <percentage> \| <length> | 50% 50% | 背景图位置。单位支持百分比和px,第一个值是水平位置,第二个值是垂直位置。如果仅设置一个值,另一个值为50%。第一个string的可选值为:left \| center \| right ,第二个string的可选值为:top \| center \| bottom。
示例:
- background-position: 200px 30%
- background-position: 100px top
- background-position: center center | +| background-position6+ | string \| <percentage> \| <length> string \|
 <percentage> \| <length> | 50% 50% | 背景图位置。单位支持百分比和px,第一个值是水平位置,第二个值是垂直位置。如果仅设置一个值,另一个值为50%。第一个string的可选值为:left \| center \| right ,第二个string的可选值为:top \| center \| bottom。
示例:
- background-position: 200px 30%
- background-position: 100px top
- background-position: center center | 对于不支持起始值或终止值缺省的情况,可以通过from和to显示指定起始和结束。可以通过百分比指定动画运行的中间状态6+。示例: diff --git a/zh-cn/application-dev/reference/arkui-js/js-components-container-stepper.md b/zh-cn/application-dev/reference/arkui-js/js-components-container-stepper.md index b665bb83e62f1bda1ae1a3369b0ef7d9e94f9f3a..817e33cf5f0ae34156f8546e1ffc7ec52c04a399 100644 --- a/zh-cn/application-dev/reference/arkui-js/js-components-container-stepper.md +++ b/zh-cn/application-dev/reference/arkui-js/js-components-container-stepper.md @@ -45,8 +45,8 @@ | finish | 无 | 当步骤导航器最后一个步骤完成时触发该事件。 | | skip | 无 | 当通过setNextButtonStatus方法设置当前步骤导航器可跳过时,点击右侧跳过按钮触发该事件。 | | change | { prevIndex:prevIndex, index: index} | 当步骤导航器点击左边或者右边文本按钮进行步骤切换时触发该事件,prevIndex表示老步骤的序号,index表示新步骤的序号。 | -| next | { index:index, pendingIndex: pendingIndex } | 当用户点击下一步按钮时触发该事件,index表示当前步骤序号,pendingIndex表示将于跳转的序号,该事件有返回值,返回值格式为:{ pendingIndex:pendingIndex },可以通过指定pendingIndex来修改下一个步骤使用哪个stepper-item子组件。 | -| back | { index:index, pendingIndex: pendingIndex } | 当用户点击上一步按钮时触发该事件,index表示当前步骤序号,pendingIndex表示将于跳转的序号,该事件有返回值,返回值格式为Object:{ pendingIndex:pendingIndex },可以通过指定pendingIndex来修改上一个步骤使用哪个stepper-item子组件。 | +| next | { index:index, pendingIndex: pendingIndex } | 当用户点击下一步按钮时触发该事件,index表示当前步骤序号,pendingIndex表示将要跳转的序号,该事件有返回值,返回值格式为:{ pendingIndex:pendingIndex },可以通过指定pendingIndex来修改下一个步骤使用哪个stepper-item子组件。 | +| back | { index:index, pendingIndex: pendingIndex } | 当用户点击上一步按钮时触发该事件,index表示当前步骤序号,pendingIndex表示将要跳转的序号,该事件有返回值,返回值格式为Object:{ pendingIndex:pendingIndex },可以通过指定pendingIndex来修改上一个步骤使用哪个stepper-item子组件。 | ## 方法 diff --git a/zh-cn/application-dev/reference/arkui-ts/Readme-CN.md b/zh-cn/application-dev/reference/arkui-ts/Readme-CN.md index 5eb5a49955b47df7d72293fc49453e17775ab632..12c658c75628e84883cdecf837d2a290a79d4d20 100644 --- a/zh-cn/application-dev/reference/arkui-ts/Readme-CN.md +++ b/zh-cn/application-dev/reference/arkui-ts/Readme-CN.md @@ -159,4 +159,5 @@ - [时间选择弹窗](ts-methods-timepicker-dialog.md) - [文本选择弹窗](ts-methods-textpicker-dialog.md) - [菜单](ts-methods-menu.md) -- [文档中涉及到的内置枚举值](ts-appendix-enums.md) +- [枚举说明](ts-appendix-enums.md) +- [类型说明](ts-types.md) diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-blank.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-blank.md index badc57b479c59ac82b35e9261e779213b905b530..6a7dcbaac67bf9a854829a86f02062de6dd929ec 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-blank.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-blank.md @@ -28,7 +28,7 @@ Blank(min?: number | string) | 名称 | 参数类型 | 描述 | | -------- | -------- | -------- | -| color | [ResourceColor](../../ui/ts-types.md) | 设置空白填充的填充颜色。 | +| color | [ResourceColor](ts-types.md) | 设置空白填充的填充颜色。 | ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-button.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-button.md index 68ebd224a1dc3347fc4c098c4139be0836e820fe..5b16c09ec99f6f311f830af1f7ecb59c68d9c2c9 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-button.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-button.md @@ -36,7 +36,7 @@ | 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | | ------- | ----------------------------------- | ---- | ---- | ------------- | - | label | [ResourceStr](../../ui/ts-types.md) | 否 | - | 按钮文本内容。 | + | label | [ResourceStr](ts-types.md) | 否 | - | 按钮文本内容。 | | options | Object | 否 | - | 见options参数说明。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-checkbox.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-checkbox.md index b16f9057e8ea6513b64cdf3ade64563dba03216b..1885dab05ed103598e3c30f82e8e6543061ac339 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-checkbox.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-checkbox.md @@ -29,7 +29,7 @@ Checkbox( option?: {name?: string, group?: string }) | 名称 | 参数类型 | 描述 | | ------------- | ------- | -------- | | select | boolean | 设置多选框是否选中。
默认值:false | -| selectedColor | [ResourceColor](../../ui/ts-types.md) | 设置多选框选中状态颜色。 | +| selectedColor | [ResourceColor](ts-types.md) | 设置多选框选中状态颜色。 | ## 事件 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-checkboxgroup.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-checkboxgroup.md index 2645b7bc25d0c920c27b7f69b051763640892b2a..2a43aa72f4f1466edae2e7c349f76fb9df815d12 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-checkboxgroup.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-checkboxgroup.md @@ -31,7 +31,7 @@ CheckboxGroup( group?: string ) | 名称 | 参数类型 | 描述 | | -------- | -------- | -------- | | selectAll | boolean | 设置是否全选。
默认值:false | -| selectedColor | [ResourceColor](../../ui/ts-types.md) | 设置被选中或部分选中状态的颜色。 | +| selectedColor | [ResourceColor](ts-types.md) | 设置被选中或部分选中状态的颜色。 | ## 事件 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-divider.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-divider.md index 51a10ae1059e5c0912a6aaf10b90299aeddb49a3..53ad72fc1f7253302d29ccef2bab74476ed92501 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-divider.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-divider.md @@ -23,7 +23,7 @@ Divider() | 名称 | 参数类型 | 描述 | | -------- | -------- | -------- | | vertical | boolean | 使用水平分割线还是垂直分割线。false:水平分割线;true:垂直分割线。
默认值:false | -| color | [ResourceColor](../../ui/ts-types.md) | 分割线颜色。 | +| color | [ResourceColor](ts-types.md) | 分割线颜色。 | | strokeWidth | number \| string | 分割线宽度。
默认值:1 | | lineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | 分割线的端点样式。
默认值:LineCapStyle.Butt | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-gauge.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-gauge.md index 6a6311e3c54bde20e87acceccce6bde6236c59f3..3bcc593769d261fe4f55595829239fbb91fdc512 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-gauge.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-gauge.md @@ -43,7 +43,7 @@ Gauge(options:{value: number, min?: number, max?: number}) | 名称 | 类型定义 | 描述 | | --------- | -------------------- | ------------------------------------------------------------ | -| ColorStop | [[ResourceColor](../../ui/ts-types.md#resourcecolor8), number] | 描述渐进色颜色断点类型,第一个参数为颜色值,第二个参数为0~1之间的比例值。 | +| ColorStop | [[ResourceColor](ts-types.md#resourcecolor8), number] | 描述渐进色颜色断点类型,第一个参数为颜色值,第二个参数为0~1之间的比例值。 | ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-image.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-image.md index 630e8164c1bd7ab796bafcfc8d01e7b9306261a6..76ed9ceb424cd77b08f7118d0359794b04db62ee 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-image.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-image.md @@ -27,7 +27,7 @@ Image(src: string | PixelMap | Resource) | 参数名 | 参数类型 | 必填 | 参数描述 | | ------ | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| src | string\| [PixelMap](../apis/js-apis-image.md#pixelmap7) \| [Resource](../../ui/ts-types.md#resource类型) | 是 | 图片的数据源,支持本地图片和网络图片。
当使用相对路径引用图片资源时,例如`Image("common/test.jpg")`,不支持跨包/跨模块调用该Image组件,建议使用`$r`方式来管理需全局使用的图片资源。
\- 支持的图片格式包括png、jpg、bmp、svg和gif。
\- 支持`Base64`字符串。格式`data:image/[png\|jpeg\|bmp\|webp];base64,[base64 data]`, 其中`[base64 data]`为`Base64`字符串数据。
\- 支持`dataability://`路径前缀的字符串,用于访问通过data ability提供的图片路径。 | +| src | string\| [PixelMap](../apis/js-apis-image.md#pixelmap7) \| [Resource](ts-types.md#resource类型) | 是 | 图片的数据源,支持本地图片和网络图片。
当使用相对路径引用图片资源时,例如`Image("common/test.jpg")`,不支持跨包/跨模块调用该Image组件,建议使用`$r`方式来管理需全局使用的图片资源。
\- 支持的图片格式包括png、jpg、bmp、svg和gif。
\- 支持`Base64`字符串。格式`data:image/[png\|jpeg\|bmp\|webp];base64,[base64 data]`, 其中`[base64 data]`为`Base64`字符串数据。
\- 支持`dataability://`路径前缀的字符串,用于访问通过data ability提供的图片路径。 | ## 属性 @@ -35,7 +35,7 @@ Image(src: string | PixelMap | Resource) | 名称 | 参数类型 | 描述 | | --------------------- | ------------------------------------------------------- | ------------------------------------------------------------ | -| alt | string \| [Resource](../../ui/ts-types.md#resource类型) | 加载时显示的占位图,支持本地图片和网络图片。 | +| alt | string \| [Resource](ts-types.md#resource类型) | 加载时显示的占位图,支持本地图片和网络图片。 | | objectFit | [ImageFit](ts-appendix-enums.md#imagefit) | 设置图片的缩放类型。
默认值:ImageFit.Cover | | objectRepeat | [ImageRepeat](ts-appendix-enums.md#imagerepeat) | 设置图片的重复样式。
默认值:NoRepeat
**说明:**
svg类型图源不支持该属性。 | | interpolation | [ImageInterpolation](#imageinterpolation) | 设置图片的插值效果,即减轻低清晰度图片在放大显示的时候出现的锯齿问题,仅针对图片放大插值。
默认值:ImageInterpolation.None
**说明:**
svg类型图源不支持该属性。
PixelMap资源不支持该属性。 | @@ -43,11 +43,11 @@ Image(src: string | PixelMap | Resource) | sourceSize | {
width: number,
height: number
} | 设置图片裁剪尺寸,将原始图片解码成pixelMap,指定尺寸的图片,单位为px。
**说明:**
PixelMap资源不支持该属性。 | | matchTextDirection | boolean | 设置图片是否跟随系统语言方向,在RTL语言环境下显示镜像翻转显示效果。
默认值:false | | fitOriginalSize | boolean | 图片组件尺寸未设置时,其显示尺寸是否跟随图源尺寸。
默认值:true | -| fillColor | [ResourceColor](../../ui/ts-types.md#resourcecolor8) | 填充颜色。设置的填充颜色会覆盖在图片上。仅对svg图源生效,设置后会替换svg图片的fill颜色。 | +| fillColor | [ResourceColor](ts-types.md#resourcecolor8) | 填充颜色。设置的填充颜色会覆盖在图片上。仅对svg图源生效,设置后会替换svg图片的fill颜色。 | | autoResize | boolean | 是否需要在图片解码过程中对图源做resize操作,该操作会根据显示区域的尺寸决定用于绘制的图源尺寸,有利于减少内存占用。
默认值:true | | syncLoad8+ | boolean | 设置是否同步加载图片,默认是异步加载。同步加载时阻塞UI线程,不会显示占位图。
默认值:false | | copyOption9+ | [CopyOptions](ts-appendix-enums.md#copyoptions9) | 设置图片是否可复制(SVG图片不支持复制)。
当copyOption设置为非CopyOptions.None时,支持使用长按、鼠标右击、快捷组合键'CTRL+C'等方式进行复制。
默认值:CopyOptions.None | -| colorFilter9+ | [ColorFilter](../../ui/ts-types.md#colorfilter9) | 给图像设置颜色滤镜效果。 | +| colorFilter9+ | [ColorFilter](ts-types.md#colorfilter9) | 给图像设置颜色滤镜效果。 | > **说明:** > diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-imageanimator.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-imageanimator.md index e24457c1753d5b4381941387adda9fc10f10a866..97635bb4f1871858501418826e24633ee7376411 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-imageanimator.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-imageanimator.md @@ -38,11 +38,11 @@ ImageAnimator() - ImageFrameInfo属性说明 | 参数名称 | 参数类型 | 默认值 | 必填 | 参数描述 | | -------- | -------- | -------- | -------- | -------- | - | src | string \| [Resource](../../ui/ts-types.md#resource类型)9+ | "" | 是 | 图片路径,图片格式为svg,png和jpg,从API Version9开始支持[Resource](../../ui/ts-types.md#resource类型)类型的路径 | - | width | [Length](../../ui/ts-types.md#长度类型) | 0 | 否 | 图片宽度 | - | height | [Length](../../ui/ts-types.md#长度类型) | 0 | 否 | 图片高度 | - | top | [Length](../../ui/ts-types.md#长度类型) | 0 | 否 | 图片相对于组件左上角的纵向坐标 | - | left | [Length](../../ui/ts-types.md#长度类型) | 0 | 否 | 图片相对于组件左上角的横向坐标 | + | src | string \| [Resource](ts-types.md#resource类型)9+ | "" | 是 | 图片路径,图片格式为svg,png和jpg,从API Version9开始支持[Resource](ts-types.md#resource类型)类型的路径 | + | width | [Length](ts-types.md#长度类型) | 0 | 否 | 图片宽度 | + | height | [Length](ts-types.md#长度类型) | 0 | 否 | 图片高度 | + | top | [Length](ts-types.md#长度类型) | 0 | 否 | 图片相对于组件左上角的纵向坐标 | + | left | [Length](ts-types.md#长度类型) | 0 | 否 | 图片相对于组件左上角的横向坐标 | | duration | number | 0 | 否 | 每一帧图片的播放时长,单位毫秒 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-loadingprogress.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-loadingprogress.md index db994a3d8e0f9316526ecde92224dd91e62b5226..506ff40553df13f2a9d58ba40a4df7763574b61e 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-loadingprogress.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-loadingprogress.md @@ -21,7 +21,7 @@ LoadingProgress() | 名称 | 参数类型 | 描述 | | -------- | -------- | -------- | -| color | [ResourceColor](../../ui/ts-types.md) | 设置加载进度条前景色。 | +| color | [ResourceColor](ts-types.md) | 设置加载进度条前景色。 | ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-marquee.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-marquee.md index eae2b01713e67271edcb927b13e7c00ae770e0a0..e1bb411247a8294c28d38942e88233195671fbab 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-marquee.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-marquee.md @@ -22,7 +22,7 @@ Marquee(value: { start: boolean, step?: number, loop?: number, fromStart?: boole | 参数名 | 参数类型 | 必填 | 参数描述 | | -------- | -------- | -------- | -------- | | start | boolean | 是 | 控制跑马灯是否进入播放状态。 | -| step | number | 否 | 滚动动画文本滚动步长。
默认值:6vp | +| step | number | 否 | 滚动动画文本滚动步长。
默认值:6,单位vp | | loop | number | 否 | 设置重复滚动的次数,小于等于零时无限循环。
默认值:-1 | | fromStart | boolean | 否 | 设置文本从头开始滚动或反向滚动。
默认值:true | | src | string | 是 | 需要滚动的文本。 | @@ -84,7 +84,7 @@ struct MarqueeExample { Button('start') .onClick(() => { this.start = true - }) + }) .width(200) .height(60) .margin({bottom:20}) diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-navigation.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-navigation.md index c2804ee0d0a49aff0cf6f331d1b05f5fda9c139f..78a7eb4ceb78f46a50b31e1fbe9d4125d59525e9 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-navigation.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-navigation.md @@ -24,11 +24,11 @@ Navigation() | 名称 | 参数类型 | 描述 | | -------------- | ---------------------------------------- | ---------------------------------------- | -| title | string \| [CustomBuilder](../../ui/ts-types.md) | 页面标题。 | +| title | string \| [CustomBuilder](ts-types.md) | 页面标题。 | | subTitle | string | 页面副标题。 | -| menus | Array8+ | 页面右上角菜单。 | +| menus | Array8+ | 页面右上角菜单。 | | titleMode | NavigationTitleMode | 页面标题栏显示模式。
默认值:NavigationTitleMode.Free | -| toolBar | object \| [CustomBuilder](../../ui/ts-types.md#custombuilder8)8+ | 设置工具栏内容。
items: 工具栏所有项。 | +| toolBar | object \| [CustomBuilder](ts-types.md#custombuilder8)8+ | 设置工具栏内容。
items: 工具栏所有项。 | | hideToolBar | boolean | 设置隐藏/显示工具栏:
默认值:false
true: 隐藏工具栏。
false: 显示工具栏。 | | hideTitleBar | boolean | 隐藏标题栏。
默认值:false | | hideBackButton | boolean | 隐藏返回键。
默认值:false | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-patternlock.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-patternlock.md index 95099d70d17963958d6d4dd65c2505cc34bde389..27ba28ae074f78a265e1fec5d95fdcd47413d3b0 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-patternlock.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-patternlock.md @@ -26,12 +26,12 @@ PatternLock(controller?: PatternLockController) | 名称 | 参数类型 | 描述 | | --------------- | ------------------------------------- | ------------------------------------------------------------ | -| sideLength | [Length](../../ui/ts-types.md) | 设置组件的宽度和高度(相同值)。最小可以设置为0。
默认值:300vp | -| circleRadius | [Length](../../ui/ts-types.md) | 设置宫格圆点的半径。
默认值:14vp | -| regularColor | [ResourceColor](../../ui/ts-types.md) | 设置宫格圆点在“未选中”状态的填充颜色。
默认值:Color.Black | -| selectedColor | [ResourceColor](../../ui/ts-types.md) | 设置宫格圆点在“选中”状态的填充颜色。
默认值:Color.Black | -| activeColor | [ResourceColor](../../ui/ts-types.md) | 设置宫格圆点在“激活”状态的填充颜色。
默认值:Color.Black | -| pathColor | [ResourceColor](../../ui/ts-types.md) | 设置连线的颜色。
默认值:Color.Blue | +| sideLength | [Length](ts-types.md) | 设置组件的宽度和高度(相同值)。最小可以设置为0。
默认值:300vp | +| circleRadius | [Length](ts-types.md) | 设置宫格圆点的半径。
默认值:14vp | +| regularColor | [ResourceColor](ts-types.md) | 设置宫格圆点在“未选中”状态的填充颜色。
默认值:Color.Black | +| selectedColor | [ResourceColor](ts-types.md) | 设置宫格圆点在“选中”状态的填充颜色。
默认值:Color.Black | +| activeColor | [ResourceColor](ts-types.md) | 设置宫格圆点在“激活”状态的填充颜色。
默认值:Color.Black | +| pathColor | [ResourceColor](ts-types.md) | 设置连线的颜色。
默认值:Color.Blue | | pathStrokeWidth | number \| string | 设置连线的宽度。最小可以设置为0。
默认值:34vp | | autoReset | boolean | 设置是否支持用户在完成输入后再次触屏重置组件状态。如果设置为true,用户可以通过触摸图案密码锁重置组件状态(清除之前的输入效果);如果设置为false,用户手指离开屏幕完成输入后,再次触摸图案密码锁(包括圆点)不能改变之前的输入状态。
默认值:true | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-progress.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-progress.md index 5248b2902f2888429f4510a141a3ba8b2eb22846..2e46582a93b5178bbae473ffb59976ee6127b103 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-progress.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-progress.md @@ -52,8 +52,8 @@ Progress(options: {value: number, total?: number, type?: ProgressType}) | 名称 | 参数类型 | 描述 | | -------- | -------- | -------- | | value | number | 设置当前进度值。 | -| color | [ResourceColor](../../ui/ts-types.md) | 设置进度条前景色。 | -| style8+ | {
strokeWidth?: [Length](../../ui/ts-types.md#length),
scaleCount?: number,
scaleWidth?: [Length](../../ui/ts-types.md#length)
} | 定义组件的样式。
- strokeWidth: 设置进度条宽度。
- scaleCount: 设置环形进度条总刻度数。
- scaleWidth: 设置环形进度条刻度粗细,刻度粗细大于进度条宽度时,为系统默认粗细。 | +| color | [ResourceColor](ts-types.md) | 设置进度条前景色。 | +| style8+ | {
strokeWidth?: [Length](ts-types.md#length),
scaleCount?: number,
scaleWidth?: [Length](ts-types.md#length)
} | 定义组件的样式。
- strokeWidth: 设置进度条宽度。
- scaleCount: 设置环形进度条总刻度数。
- scaleWidth: 设置环形进度条刻度粗细,刻度粗细大于进度条宽度时,为系统默认粗细。 | ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-qrcode.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-qrcode.md index b988fa3483cdcd60f07edfa57da9e55dec6579db..6fce76e8855930628d2cb05cd18d6ecd693e7be1 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-qrcode.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-qrcode.md @@ -27,8 +27,8 @@ QRCode(value: string) | 名称 | 参数类型 | 描述 | | -------- | -------- | -------- | -| color | [ResourceColor](../../ui/ts-types.md) | 设置二维码颜色。
默认值:Color.Black | -| backgroundColor | [ResourceColor](../../ui/ts-types.md) | 设置二维码背景颜色。
默认值:Color.White | +| color | [ResourceColor](ts-types.md) | 设置二维码颜色。
默认值:Color.Black | +| backgroundColor | [ResourceColor](ts-types.md) | 设置二维码背景颜色。
默认值:Color.White | ## 事件 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-search.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-search.md index d4d84906cfa565b8ab0d68c46feab435ec241385..b0154381cbe100c4620b015fe1b3d35bcecea563 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-search.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-search.md @@ -30,9 +30,9 @@ Search(options?: { value?: string; placeholder?: string; icon?: string; controll | 名称 | 参数类型 | 描述 | | ----------------------- | ------------------------------------------------ | ---------------------------------------------- | | searchButton | string | 搜索框末尾搜索按钮文本值,默认无搜索按钮。 | -| placeholderColor | [ResourceColor](../../ui/ts-types.md) | 设置placeholder颜色。 | -| placeholderFont | [Font](../../ui/ts-types.md) | 设置placeholder文本样式。 | -| textFont | [Font](../../ui/ts-types.md) | 设置搜索框内文本样式。 | +| placeholderColor | [ResourceColor](ts-types.md) | 设置placeholder颜色。 | +| placeholderFont | [Font](ts-types.md) | 设置placeholder文本样式。 | +| textFont | [Font](ts-types.md) | 设置搜索框内文本样式。 | | copyOption9+ | [CopyOptions](ts-appendix-enums.md#copyoptions9) | 设置文本是否可复制。 | | textAlign | [TextAlign](ts-appendix-enums.md#textalign) | 设置文本对齐方式。
默认值:TextAlign.Start | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-select.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-select.md index d6b6e0cdbba6d7e2a1aaf23310525225a5eeaec8..f16df1e5379ffe226a169f75b24657ce83e06d43 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-select.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-select.md @@ -18,8 +18,8 @@ Select(options: Array\) | 参数名 | 参数类型 | 必填 | 参数描述 | | ------ | ----------------------------------- | ---- | -------------- | -| value | [ResourceStr](../../ui/ts-types.md) | 是 | 下拉选项内容。 | -| icon | [ResourceStr](../../ui/ts-types.md) | 否 | 下拉选项图片。 | +| value | [ResourceStr](ts-types.md) | 是 | 下拉选项内容。 | +| icon | [ResourceStr](ts-types.md) | 否 | 下拉选项图片。 | ## 属性 @@ -27,14 +27,14 @@ Select(options: Array\) | ----------------------- | ------------------------------------- | --------------------------------------------- | | selected | number | 设置下拉菜单初始选项的索引,第一项的索引为0。 | | value | string | 设置下拉按钮本身的文本显示。 | -| font | [Font](../../ui/ts-types.md) | 设置下拉按钮本身的文本样式。 | -| fontColor | [ResourceColor](../../ui/ts-types.md) | 设置下拉按钮本身的文本颜色。 | -| selectedOptionBgColor | [ResourceColor](../../ui/ts-types.md) | 设置下拉菜单选中项的背景色。 | -| selectedOptionFont | [Font](../../ui/ts-types.md) | 设置下拉菜单选中项的文本样式。 | -| selectedOptionFontColor | [ResourceColor](../../ui/ts-types.md) | 设置下拉菜单选中项的文本颜色。 | -| optionBgColor | [ResourceColor](../../ui/ts-types.md) | 设置下拉菜单项的背景色。 | -| optionFont | [Font](../../ui/ts-types.md) | 设置下拉菜单项的文本样式。 | -| optionFontColor | [ResourceColor](../../ui/ts-types.md) | 设置下拉菜单项的文本颜色。 | +| font | [Font](ts-types.md) | 设置下拉按钮本身的文本样式。 | +| fontColor | [ResourceColor](ts-types.md) | 设置下拉按钮本身的文本颜色。 | +| selectedOptionBgColor | [ResourceColor](ts-types.md) | 设置下拉菜单选中项的背景色。 | +| selectedOptionFont | [Font](ts-types.md) | 设置下拉菜单选中项的文本样式。 | +| selectedOptionFontColor | [ResourceColor](ts-types.md) | 设置下拉菜单选中项的文本颜色。 | +| optionBgColor | [ResourceColor](ts-types.md) | 设置下拉菜单项的背景色。 | +| optionFont | [Font](ts-types.md) | 设置下拉菜单项的文本样式。 | +| optionFontColor | [ResourceColor](ts-types.md) | 设置下拉菜单项的文本颜色。 | ## 事件 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-slider.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-slider.md index 3d41ae214cbc157aa119be3b6785236634e0055f..ed79c007dc9860285f67a96718cb748cb046eec2 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-slider.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-slider.md @@ -42,12 +42,12 @@ Slider(options?: {value?: number, min?: number, max?: number, step?: number, sty | 名称 | 参数类型 | 描述 | | -------- | -------- | -------- | -| blockColor | [ResourceColor](../../ui/ts-types.md#resourcecolor8) | 设置滑块的颜色。 | -| trackColor | [ResourceColor](../../ui/ts-types.md#resourcecolor8) | 设置滑轨的背景颜色。 | -| selectedColor | [ResourceColor](../../ui/ts-types.md#resourcecolor8) | 设置滑轨的已滑动颜色。 | +| blockColor | [ResourceColor](ts-types.md#resourcecolor8) | 设置滑块的颜色。 | +| trackColor | [ResourceColor](ts-types.md#resourcecolor8) | 设置滑轨的背景颜色。 | +| selectedColor | [ResourceColor](ts-types.md#resourcecolor8) | 设置滑轨的已滑动颜色。 | | showSteps | boolean | 设置当前是否显示步长刻度值。
默认值:false | | showTips | boolean | 设置滑动时是否显示气泡提示百分比。
默认值:false | -| trackThickness | [Length](../../ui/ts-types.md#length) | 设置滑轨的粗细。 | +| trackThickness | [Length](ts-types.md#length) | 设置滑轨的粗细。 | ## 事件 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-span.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-span.md index 2e37770e82c0906e66a08a6c7fde2fd8fbeb9076..c017aaf3bdd3cf9f60da6026fb520430f443881b 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-span.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-span.md @@ -20,7 +20,7 @@ Span(content: string | Resource) | 参数名 | 参数类型 | 必填 | 参数描述 | | -------- | -------- | -------- | -------- | -| content | string \| [Resource](../../ui/ts-types.md#resource) | 是 | 文本内容。 | +| content | string \| [Resource](ts-types.md#resource) | 是 | 文本内容。 | ## 属性 @@ -29,7 +29,7 @@ Span(content: string | Resource) | 名称 | 参数类型 | 描述 | | -------- | -------- | -------- | -| decoration | {
type: [TextDecorationType](ts-appendix-enums.md#textdecorationtype),
color?: [ResourceColor](../../ui/ts-types.md#resourcecolor8)
} | 设置文本装饰线样式及其颜色。
默认值:{
type: TextDecorationType.None
color:Color.Black
} | +| decoration | {
type: [TextDecorationType](ts-appendix-enums.md#textdecorationtype),
color?: [ResourceColor](ts-types.md#resourcecolor8)
} | 设置文本装饰线样式及其颜色。
默认值:{
type: TextDecorationType.None
color:Color.Black
} | | letterSpacing | number \| string | 设置文本字符间距。 | | textCase | [TextCase](ts-appendix-enums.md#textcase) | 设置文本大小写。
默认值:TextCase.Normal | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-text.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-text.md index 1b114d66e82b9c703760d45802d58b78327aa168..a8f3a429ea6841fb79c9118dc5274ef048438a3a 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-text.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-text.md @@ -20,7 +20,7 @@ Text(content?: string | Resource) | 参数名 | 参数类型 | 必填 | 参数描述 | | -------- | -------- | -------- | -------- | -| content | string \| [Resource](../../ui/ts-types.md#resource) | 否 | 文本内容。包含子组件Span时不生效,显示Span内容,并且此时text组件的样式不生效。
默认值:' ' | +| content | string \| [Resource](ts-types.md#resource) | 否 | 文本内容。包含子组件Span时不生效,显示Span内容,并且此时text组件的样式不生效。
默认值:' ' | ## 属性 @@ -31,12 +31,12 @@ Text(content?: string | Resource) | textAlign | [TextAlign](ts-appendix-enums.md#textalign) | 设置多行文本的文本对齐方式。
默认值:TextAlign.Start | | textOverflow | {overflow: [TextOverflow](ts-appendix-enums.md#textoverflow)} | 设置文本超长时的显示方式。
默认值:{overflow: TextOverflow.Clip}
**说明:**
文本截断是按字截断。例如,英文以单词为最小单位进行截断,若需要以字母为单位进行截断,可在字母间添加零宽空格:\u200B。
需配合`maxLines`使用,单独设置不生效。 | | maxLines | number | 设置文本的最大行数。
默认值:Infinity
**说明:**
默认情况下,文本是自动折行的,如果指定此参数,则文本最多不会超过指定的行。如果有多余的文本,可以通过 `textOverflow`来指定截断方式。 | -| lineHeight | string \| number \| [Resource](../../ui/ts-types.md) | 设置文本的文本行高,设置值不大于0时,不限制文本行高,自适应字体大小,Length为number类型时单位为fp。 | -| decoration | {
type: TextDecorationType,
color?: [ResourceColor](../../ui/ts-types.md)
} | 设置文本装饰线样式及其颜色。
默认值:{
type: TextDecorationType.None,
color:Color.Black
} | +| lineHeight | string \| number \| [Resource](ts-types.md) | 设置文本的文本行高,设置值不大于0时,不限制文本行高,自适应字体大小,Length为number类型时单位为fp。 | +| decoration | {
type: TextDecorationType,
color?: [ResourceColor](ts-types.md)
} | 设置文本装饰线样式及其颜色。
默认值:{
type: TextDecorationType.None,
color:Color.Black
} | | baselineOffset | number \| string | 设置文本基线的偏移量。 | | letterSpacing | number \| string | 设置文本字符间距。 | -| minFontSize | number \| string \| [Resource](../../ui/ts-types.md) | 设置文本最小显示字号。 | -| maxFontSize | number \| string \| [Resource](../../ui/ts-types.md) | 设置文本最大显示字号。 | +| minFontSize | number \| string \| [Resource](ts-types.md) | 设置文本最小显示字号。 | +| maxFontSize | number \| string \| [Resource](ts-types.md) | 设置文本最大显示字号。 | | textCase | [TextCase](ts-appendix-enums.md#textcase) | 设置文本大小写。
默认值:TextCase.Normal | | copyOption9+ | [CopyOptions](ts-appendix-enums.md#copyoptions9) | 组件支持设置文本是否可复制粘贴。
默认值:CopyOptions.None | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-textarea.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-textarea.md index f9cf5c685b59792f5fa0f3b18599f4f55d54e524..a82812ec6012d65ccc72be0f43de19bc008cef9b 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-textarea.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-textarea.md @@ -20,8 +20,8 @@ TextArea(value?:{placeholder?: ResourceStr, text?: ResourceStr, controller?: Tex | 参数名 | 参数类型 | 必填 | 参数描述 | | ----------------------- | ---------------------------------------- | ---- | -------------- | -| placeholder | [ResourceStr](../../ui/ts-types.md) | 否 | 无输入时的提示文本。 | -| text | [ResourceStr](../../ui/ts-types.md) | 否 | 设置输入框当前的文本内容。 | +| placeholder | [ResourceStr](ts-types.md) | 否 | 无输入时的提示文本。 | +| text | [ResourceStr](ts-types.md) | 否 | 设置输入框当前的文本内容。 | | controller8+ | [TextAreaController](#textareacontroller8) | 否 | 设置TextArea控制器。 | @@ -31,11 +31,11 @@ TextArea(value?:{placeholder?: ResourceStr, text?: ResourceStr, controller?: Tex | 名称 | 参数类型 | 描述 | | ------------------------ | ---------------------------------------- | ---------------------------------------- | -| placeholderColor | [ResourceColor](../../ui/ts-types.md#resourcecolor8) | 设置placeholder文本颜色。 | -| placeholderFont | [Font](../../ui/ts-types.md#font) | 设置placeholder文本样式。 | +| placeholderColor | [ResourceColor](ts-types.md#resourcecolor8) | 设置placeholder文本颜色。 | +| placeholderFont | [Font](ts-types.md#font) | 设置placeholder文本样式。 | | textAlign | [TextAlign](ts-appendix-enums.md#textalign) | 设置文本水平对齐式。
默认值:TextAlign.Start | -| caretColor | [ResourceColor](../../ui/ts-types.md#resourcecolor8) | 设置输入框光标颜色。 | -| inputFilter8+ | {
value: [ResourceStr](../../ui/ts-types.md)8+,
error?: (value: string) => void
} | 通过正则表达式设置输入过滤器。满足表达式的输入允许显示,不满足的输入被忽略。仅支持单个字符匹配,不支持字符串匹配。例如:^(?=.\*\d)(?=.\*[a-z])(?=.\*[A-Z]).{8,10}$,不支持过滤8到10位的强密码。
- value:设置正则表达式。
- error:正则匹配失败时,返回被忽略的内容。 | +| caretColor | [ResourceColor](ts-types.md#resourcecolor8) | 设置输入框光标颜色。 | +| inputFilter8+ | {
value: [ResourceStr](ts-types.md)8+,
error?: (value: string) => void
} | 通过正则表达式设置输入过滤器。满足表达式的输入允许显示,不满足的输入被忽略。仅支持单个字符匹配,不支持字符串匹配。例如:^(?=.\*\d)(?=.\*[a-z])(?=.\*[A-Z]).{8,10}$,不支持过滤8到10位的强密码。
- value:设置正则表达式。
- error:正则匹配失败时,返回被忽略的内容。 | | copyOption9+ | [CopyOptions](ts-appendix-enums.md#copyoptions9) | 设置文本是否可复制。 | ## 事件 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-textinput.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-textinput.md index 7738ea1728fc319ceb35acfe575b1e9d11cd652f..e2e90e8c7b66220f57ef12136663289f333497e5 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-textinput.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-textinput.md @@ -20,8 +20,8 @@ TextInput(value?:{placeholder?: ResourceStr, text?: ResourceStr, controller?: Te | 参数名 | 参数类型 | 必填 | 参数描述 | | ----------------------- | ---------------------------------------- | ---- | --------------- | -| placeholder | [ResourceStr](../../ui/ts-types.md) | 否 | 无输入时的提示文本。 | -| text | [ResourceStr](../../ui/ts-types.md) | 否 | 设置输入框当前的文本内容。 | +| placeholder | [ResourceStr](ts-types.md) | 否 | 无输入时的提示文本。 | +| text | [ResourceStr](ts-types.md) | 否 | 设置输入框当前的文本内容。 | | controller8+ | [TextInputController](#textinputcontroller8) | 否 | 设置TextInput控制器。 | @@ -32,12 +32,12 @@ TextInput(value?:{placeholder?: ResourceStr, text?: ResourceStr, controller?: Te | 名称 | 参数类型 | 描述 | | ------------------------ | ---------------------------------------- | ---------------------------------------- | | type | InputType | 设置输入框类型。
默认值:InputType.Normal | -| placeholderColor | [ResourceColor](../../ui/ts-types.md) | 设置placeholder颜色。| -| placeholderFont | [Font](../../ui/ts-types.md#font) | 设置placeholder文本样式。 | +| placeholderColor | [ResourceColor](ts-types.md) | 设置placeholder颜色。| +| placeholderFont | [Font](ts-types.md#font) | 设置placeholder文本样式。 | | enterKeyType | EnterKeyType | 设置输入法回车键类型。
默认值:EnterKeyType.Done | -| caretColor | [ResourceColor](../../ui/ts-types.md) | 设置输入框光标颜色。 | +| caretColor | [ResourceColor](ts-types.md) | 设置输入框光标颜色。 | | maxLength | number | 设置文本的最大输入字符数。 | -| inputFilter8+ | {
value: [ResourceStr](../../ui/ts-types.md)8+,
error?: (value: string) => void
} | 正则表达式,满足表达式的输入允许显示,不满足正则表达式的输入被忽略。仅支持单个字符匹配,不支持字符串匹配。例如:^(?=.\*\d)(?=.\*[a-z])(?=.\*[A-Z]).{8,10}$,8到10位的强密码不支持过滤。
- value:设置正则表达式。
- error:正则匹配失败时,返回被忽略的内容。 | +| inputFilter8+ | {
value: [ResourceStr](ts-types.md)8+,
error?: (value: string) => void
} | 正则表达式,满足表达式的输入允许显示,不满足正则表达式的输入被忽略。仅支持单个字符匹配,不支持字符串匹配。例如:^(?=.\*\d)(?=.\*[a-z])(?=.\*[A-Z]).{8,10}$,8到10位的强密码不支持过滤。
- value:设置正则表达式。
- error:正则匹配失败时,返回被忽略的内容。 | | copyOption9+ | [CopyOptions](ts-appendix-enums.md#copyoptions9) | 设置文本是否可复制。 | | showPasswordIcon9+ | boolean | 密码输入模式时,密码框末尾的图标是否显示。
默认值:true | | style9+ | TextInputStyle | TextInput风格。
默认值:TextInputStyle.Default | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-textpicker.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-textpicker.md index d038685ddd81c123d9dded2a8da4b745fc5646d3..0f20ae9ed4d76f5c16e5842f027d3dfe316a6360 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-textpicker.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-textpicker.md @@ -22,7 +22,7 @@ TextPicker(options?: {range: string[]|Resource, selected?: number, value?: strin | 参数名 | 参数类型 | 必填 | 参数描述 | | -------- | -------- | -------- | -------- | -| range | string[] \| [Resource](../../ui/ts-types.md#resource类型) | 是 | 选择器的数据选择范围。 | +| range | string[] \| [Resource](ts-types.md#resource类型) | 是 | 选择器的数据选择范围。 | | selected | number | 否 | 选中项在数组中的index值。
默认值:0 | | value | string | 否 | 选中项的值,优先级低于selected。
默认值:第一个元素值 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-toggle.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-toggle.md index 8bca323f30a2569a7a781b462191cc17666d36cf..a892b4533c55cce6e2a8a229d5f0b2d0bdcdad0b 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-toggle.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-toggle.md @@ -39,8 +39,8 @@ Toggle(options: { type: ToggleType, isOn?: boolean }) | 名称 | 参数 | 默认值 | 参数描述 | | -------- | -------- | -------- | -------- | -| selectedColor | [ResourceColor](../../ui/ts-types.md) | - | 设置组件打开状态的背景颜色。 | -| switchPointColor | [ResourceColor](../../ui/ts-types.md) | - | 设置Switch类型的圆形滑块颜色。
> **说明:**
> 仅对type为ToggleType.Switch生效。 | +| selectedColor | [ResourceColor](ts-types.md) | - | 设置组件打开状态的背景颜色。 | +| switchPointColor | [ResourceColor](ts-types.md) | - | 设置Switch类型的圆形滑块颜色。
> **说明:**
> 仅对type为ToggleType.Switch生效。 | ## 事件 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-web.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-web.md index c9dc3bdf1c6bd48799bde4a4bd980eca42dd2957..8dd92b4bab6ec93821d1a11adbd93dc8a167043d 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-web.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-web.md @@ -26,7 +26,7 @@ Web(options: { src: ResourceStr, controller: WebController }) | 参数名 | 参数类型 | 必填 | 参数描述 | | ---------- | ------------------------------- | ---- | ------- | -| src | [ResourceStr](../../ui/ts-types.md) | 是 | 网页资源地址。 | +| src | [ResourceStr](ts-types.md) | 是 | 网页资源地址。 | | controller | [WebController](#webcontroller) | 否 | 控制器。 | **示例:** diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-basic-gestures-tapgesture.md b/zh-cn/application-dev/reference/arkui-ts/ts-basic-gestures-tapgesture.md index 83f769f07188777f1a2f0775cb40f07ef7a53394..68b27342c2b9fcc3cd267988c9b9fb6f601c05cf 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-basic-gestures-tapgesture.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-basic-gestures-tapgesture.md @@ -23,7 +23,7 @@ TapGesture(value?: { count?: number, fingers?: number }) | 名称 | 功能描述 | | -------- | -------- | -| onAction(event: (event?: GestureEvent) => void) | Tap手势识别成功回调。 | +| onAction(event: (event?: [GestureEvent](ts-gesture-settings.md)) => void) | Tap手势识别成功回调。 | ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-alphabet-indexer.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-alphabet-indexer.md index b5c763ced54c42266450d001877d930aea03bf28..360c035961184598a4aed2e8419f96c7e6dbd1e0 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-alphabet-indexer.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-alphabet-indexer.md @@ -29,19 +29,19 @@ AlphabetIndexer(value: {arrayValue: Array<string>, selected: number}) | 名称 | 参数类型 | 描述 | | ----------------------- | --------------- | ----------------------------------------------------------- | -| color | [ResourceColor](../../ui/ts-types.md#resourcecolor8) | 设置文字颜色。 | -| selectedColor | [ResourceColor](../../ui/ts-types.md#resourcecolor8) | 设置选中项文字颜色。 | -| popupColor | [ResourceColor](../../ui/ts-types.md#resourcecolor8) | 设置提示弹窗文字颜色。 | -| selectedBackgroundColor | [ResourceColor](../../ui/ts-types.md#resourcecolor8) | 设置选中项背景颜色。 | -| popupBackground | [ResourceColor](../../ui/ts-types.md#resourcecolor8) | 设置提示弹窗背景色。 | +| color | [ResourceColor](ts-types.md#resourcecolor8) | 设置文字颜色。 | +| selectedColor | [ResourceColor](ts-types.md#resourcecolor8) | 设置选中项文字颜色。 | +| popupColor | [ResourceColor](ts-types.md#resourcecolor8) | 设置提示弹窗文字颜色。 | +| selectedBackgroundColor | [ResourceColor](ts-types.md#resourcecolor8) | 设置选中项背景颜色。 | +| popupBackground | [ResourceColor](ts-types.md#resourcecolor8) | 设置提示弹窗背景色。 | | usingPopup | boolean | 设置是否使用提示弹窗。 | -| selectedFont | [Font](../../ui/ts-types.md#font) | 设置选中项文字样式。 | -| popupFont | [Font](../../ui/ts-types.md#font) | 设置提示弹窗字体样式。 | -| font | [Font](../../ui/ts-types.md#font) | 设置字母索引条默认字体样式。 | +| selectedFont | [Font](ts-types.md#font) | 设置选中项文字样式。 | +| popupFont | [Font](ts-types.md#font) | 设置提示弹窗字体样式。 | +| font | [Font](ts-types.md#font) | 设置字母索引条默认字体样式。 | | itemSize | string \| number | 设置字母索引条字母区域大小,字母区域为正方形,即正方形边长。 | | alignStyle | IndexerAlign | 设置字母索引条弹框的对齐样式,支持弹窗显示在索引条右侧和左侧。
默认值:IndexerAlign.Right | | selected | number | 设置选中项索引值。 | -| popupPosition | [Position](../../ui/ts-types.md#position8) | 设置弹出窗口相对于索引器条上边框中点的位置。 | +| popupPosition | [Position](ts-types.md#position8) | 设置弹出窗口相对于索引器条上边框中点的位置。 | ## IndexerAlign枚举说明 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-badge.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-badge.md index 6990d3d93cd24b5db073a41604b31943ad14fd9e..1e68ee635c0ec903f556bbf68342ca5a57438b07 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-badge.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-badge.md @@ -23,12 +23,12 @@ 创建数字标记组件。 **参数:** - | 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | - | -------- | -------- | -------- | -------- | -------- | - | count | number | 是 | - | 设置提醒消息数。 | - | position | BadgePosition | 否 | BadgePosition.RightTop | 设置提示点显示位置。 | - | maxCount | number | 否 | 99 | 最大消息数,超过最大消息时仅显示maxCount+。 | - | style | BadgeStyle | 是 | - | Badge组件可设置样式,支持设置文本颜色、尺寸、圆点颜色和尺寸。 | +| 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | +| -------- | -------- | -------- | -------- | -------- | +| count | number | 是 | - | 设置提醒消息数。 | +| position | BadgePosition | 否 | BadgePosition.RightTop | 设置提示点显示位置。 | +| maxCount | number | 否 | 99 | 最大消息数,超过最大消息时仅显示maxCount+。 | +| style | BadgeStyle | 是 | - | Badge组件可设置样式,支持设置文本颜色、尺寸、圆点颜色和尺寸。 | 方法2: Badge(value: {value: string, position?: BadgePosition, style: BadgeStyle}) @@ -44,10 +44,10 @@ - BadgeStyle对象说明 | 名称 | 类型 | 必填 | 默认值 | 描述 | | -------- | -------- | -------- | -------- | -------- | - | color | [ResourceColor](../../ui/ts-types.md) | 否 | Color.White | 文本颜色。 | + | color | [ResourceColor](ts-types.md) | 否 | Color.White | 文本颜色。 | | fontSize | number \| string | 否 | 10 | 文本大小。 | | badgeSize | number \| string | 是 | - | badge的大小。 | - | badgeColor | [ResourceColor](../../ui/ts-types.md) | 否 | Color.Red | badge的颜色。 | + | badgeColor | [ResourceColor](ts-types.md) | 否 | Color.Red | badge的颜色。 | - BadgePosition枚举说明 | 名称 | 描述 | @@ -92,7 +92,7 @@ struct BadgeExample { Badge({ value: ' ', - position: 1, + position: BadgePosition.Right, style: { badgeSize: 6, badgeColor: Color.Red } }) { Text('message') diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-list.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-list.md index 2806c868038b50b986ec5e9eb68e1e64bf5ce253..f4334a9399cbedf07f2048981eeb5a857fc870d9 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-list.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-list.md @@ -32,14 +32,14 @@ List(value?:{space?: number | string, initialIndex?: number, scroller? | 名称 | 参数类型 | 描述 | | -------- | -------- | -------- | | listDirection | [Axis](ts-appendix-enums.md#axis) | 设置List组件排列方向。
默认值:Axis.Vertical | -| divider | {
strokeWidth: [Length](../../ui/ts-types.md#length),
color?:[ResourceColor](../../ui/ts-types.md),
startMargin?: Length,
endMargin?: Length
} \| null | 设置ListItem分割线样式,默认无分割线。
- strokeWidth: 分割线的线宽。
- color: 分割线的颜色。
- startMargin: 分割线与列表侧边起始端的距离。
- endMargin: 分割线与列表侧边结束端的距离。 | +| divider | {
strokeWidth: [Length](ts-types.md#length),
color?:[ResourceColor](ts-types.md),
startMargin?: Length,
endMargin?: Length
} \| null | 设置ListItem分割线样式,默认无分割线。
- strokeWidth: 分割线的线宽。
- color: 分割线的颜色。
- startMargin: 分割线与列表侧边起始端的距离。
- endMargin: 分割线与列表侧边结束端的距离。 | | scrollBar | [BarState](ts-appendix-enums.md#barstate) | 设置滚动条状态。
默认值:BarState.Off | | cachedCount | number | 设置预加载的ListItem数量。具体使用可参考[减少应用白块说明](../../ui/ts-performance-improvement-recommendation.md#减少应用滑动白块)。
默认值:1 | | editMode | boolean | 声明当前List组件是否处于可编辑模式。
默认值:false | | edgeEffect | [EdgeEffect](ts-appendix-enums.md#edgeeffect) | 设置组件的滑动效果。
默认值:EdgeEffect.Spring | | chainAnimation | boolean | 设置当前List是否启用链式联动动效,开启后列表滑动以及顶部和底部拖拽时会有链式联动的效果。链式联动效果:List内的list-item间隔一定距离,在基本的滑动交互行为下,主动对象驱动从动对象进行联动,驱动效果遵循弹簧物理动效。
默认值:false
- false:不启用链式联动。
- true:启用链式联动。 | | multiSelectable8+ | boolean | 是否开启鼠标框选。
默认值:false
- false:关闭框选。
- true:开启框选。 | -| lanes9+ | number \| [LengthConstrain](../../ui/ts-types.md#lengthconstrain) | 以列模式为例(listDirection为Axis.Vertical):
lanes用于决定List组件在交叉轴方向按几列布局。
默认值:1
规则如下:
- lanes为指定的数量时,根据指定的数量与List组件的交叉轴宽度来决定每列的宽度;
- lane设置了{minLength,maxLength}时,根据List组件的宽度自适应决定lanes数量(即列数),保证缩放过程中lane的宽度符合{minLength,maxLength}的限制。其中,minLength条件会被优先满足,即优先保证符合ListItem的宽度符合最小宽度限制。例如在列模式下,设置了{minLength: 40vp,maxLength: 60vp},则当List组件宽度为70vp时,ListItem为一列,并且根据alignListItem属性做靠左、居中或者靠右布局;当List组件宽度变化至80vp时,符合两倍的minLength,则ListItem自适应为两列。 | +| lanes9+ | number \| [LengthConstrain](ts-types.md#lengthconstrain) | 以列模式为例(listDirection为Axis.Vertical):
lanes用于决定List组件在交叉轴方向按几列布局。
默认值:1
规则如下:
- lanes为指定的数量时,根据指定的数量与List组件的交叉轴宽度来决定每列的宽度;
- lane设置了{minLength,maxLength}时,根据List组件的宽度自适应决定lanes数量(即列数),保证缩放过程中lane的宽度符合{minLength,maxLength}的限制。其中,minLength条件会被优先满足,即优先保证符合ListItem的宽度符合最小宽度限制。例如在列模式下,设置了{minLength: 40vp,maxLength: 60vp},则当List组件宽度为70vp时,ListItem为一列,并且根据alignListItem属性做靠左、居中或者靠右布局;当List组件宽度变化至80vp时,符合两倍的minLength,则ListItem自适应为两列。 | | alignListItem9+ | ListItemAlign | List交叉轴方向宽度大于ListItem交叉轴宽度 * lanes时,ListItem在List交叉轴方向的布局方式,默认为首部对齐。
默认值:ListItemAlign.Start | | sticky9+ | StickyStyle | 配合[ListItemGroup](ts-container-listitemgroup.md)组件使用,设置ListItemGroup中header和footer是否要吸顶或吸底。
默认值:StickyStyle.None
**说明:**
sticky属性可以设置为 StickyStyle.Header \| StickyStyle.Footer 以同时支持header吸顶和footer吸底。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-listitemgroup.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-listitemgroup.md index fe5ab429da78b43674881cccc976ef768092b188..d9c1b34bf09f77b677ba7dfb9d7e9f137d3661da 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-listitemgroup.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-listitemgroup.md @@ -23,15 +23,15 @@ ListItemGroup(options?: {header?: CustomBuilder, footer?: CustomBuilder, space?: | 参数名 | 参数类型 | 必填 | 参数描述 | | -------- | -------- | -------- | -------- | - | header | [CustomBuilder](../../ui/ts-types.md#custombuilder8) | 否 | 设置ListItemGroup头部组件。 | - | footer | [CustomBuilder](../../ui/ts-types.md#custombuilder8) | 否 | 设置ListItemGroup尾部组件。 | + | header | [CustomBuilder](ts-types.md#custombuilder8) | 否 | 设置ListItemGroup头部组件。 | + | footer | [CustomBuilder](ts-types.md#custombuilder8) | 否 | 设置ListItemGroup尾部组件。 | | space | number \| string | 否 | 列表项间距。只作用于ListItem与ListItem之间,不作用于header与ListItem、footer与ListItem之间。 | ## 属性 | 名称 | 参数类型 | 描述 | | -------- | -------- | -------- | -| divider | {
strokeWidth: [Length](../../ui/ts-types.md#length),
color?: [ResourceColor](../../ui/ts-types.md#resourcecolor8),
startMargin?: [Length](../../ui/ts-types.md#length),
endMargin?: [Length](../../ui/ts-types.md#length)
} \| null | 用于设置ListItem分割线样式,默认无分割线。
strokeWidth: 分割线的线宽。
color: 分割线的颜色。
startMargin: 分割线距离列表侧边起始端的距离。
endMargin: 分割线距离列表侧边结束端的距离。 | +| divider | {
strokeWidth: [Length](ts-types.md#length),
color?: [ResourceColor](ts-types.md#resourcecolor8),
startMargin?: [Length](ts-types.md#length),
endMargin?: [Length](ts-types.md#length)
} \| null | 用于设置ListItem分割线样式,默认无分割线。
strokeWidth: 分割线的线宽。
color: 分割线的颜色。
startMargin: 分割线距离列表侧边起始端的距离。
endMargin: 分割线距离列表侧边结束端的距离。 | ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-panel.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-panel.md index cebd4995112ee15c038b72e4e1e08bbcb595b408..2ec1c332acda20a888d6687962b2ff377e8a6a8d 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-panel.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-panel.md @@ -34,7 +34,7 @@ Panel(show:boolean) | halfHeight | string \| number | 指定PanelMode.Half状态下的高度,默认为屏幕尺寸的一半。 | | miniHeight | string \| number | 指定PanelMode.Mini状态下的高度。 | | show | boolean | 当滑动面板弹出时调用。 | -| backgroundMask9+|[ResourceColor](../../ui/ts-types.md#resourcecolor8)|指定Panel的背景蒙层。| +| backgroundMask9+|[ResourceColor](ts-types.md#resourcecolor8)|指定Panel的背景蒙层。| ## PanelType枚举说明 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-sidebarcontainer.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-sidebarcontainer.md index 7032115bf6cf45431ce8ba64d6c151fb426ad787..c1744c1b1ecb5b053877232fed1a29dd882dade3 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-sidebarcontainer.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-sidebarcontainer.md @@ -50,7 +50,7 @@ SideBarContainer( type?: SideBarContainerType ) | top | number | 否 | 设置侧边栏控制按钮距离容器上界限的间距。
默认值:48,单位vp | | width | number | 否 | 设置侧边栏控制按钮的宽度。
默认值:32,单位vp | | height | number | 否 | 设置侧边栏控制按钮的高度。
默认值:32,单位vp | -| icons | {
shown: string \| PixelMap \| [Resource](../../ui/ts-types.md) ,
hidden: string \| PixelMap \| [Resource](../../ui/ts-types.md) ,
switching?: string \| PixelMap \| [Resource](../../ui/ts-types.md)
} | 否 | 设置侧边栏控制按钮的图标:

- shown: 设置侧边栏显示时控制按钮的图标。
- hidden: 设置侧边栏隐藏时控制按钮的图标。
- switching:设置侧边栏显示和隐藏状态切换时控制按钮的图标。 | +| icons | {
shown: string \| PixelMap \| [Resource](ts-types.md) ,
hidden: string \| PixelMap \| [Resource](ts-types.md) ,
switching?: string \| PixelMap \| [Resource](ts-types.md)
} | 否 | 设置侧边栏控制按钮的图标:

- shown: 设置侧边栏显示时控制按钮的图标。
- hidden: 设置侧边栏隐藏时控制按钮的图标。
- switching:设置侧边栏显示和隐藏状态切换时控制按钮的图标。 | ## SideBarPosition9+枚举说明 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-swiper.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-swiper.md index 5a523dd57d9a658b14a3dd6050d9cedd4123613a..30949d64161ba76be0f24cc4da25309ccdfa10f0 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-swiper.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-swiper.md @@ -41,7 +41,7 @@ Swiper(value:{controller?: SwiperController}) | cachedCount8+ | number | 设置预加载子组件个数。
默认值:1 | | disableSwipe8+ | boolean | 禁用组件滑动切换功能。
默认值:false | | curve8+ | [Curve](ts-appendix-enums.md#curve) \| string | 设置Swiper的动画曲线,默认为淡入淡出曲线,常用曲线参考[Curve枚举说明](ts-appendix-enums.md#curve),也可以通过插值计算模块提供的接口创建自定义的Curves([插值曲线对象](ts-interpolation-calculation.md))。
默认值:Curve.Ease | -| indicatorStyle8+ | {
left?: [Length](../../ui/ts-types.md#length),
top?: [Length](../../ui/ts-types.md#length),
right?: [Length](../../ui/ts-types.md#length),
bottom?: [Length](../../ui/ts-types.md#length),
size?: [Length](../../ui/ts-types.md#length),
mask?: boolean,
color?: [ResourceColor](../../ui/ts-types.md),
selectedColor?: [ResourceColor](../../ui/ts-types.md)
} | 设置导航点样式:
\- left: 设置导航点距离Swiper组件左边的距离。
\- top: 设置导航点距离Swiper组件顶部的距离。
\- right: 设置导航点距离Swiper组件右边的距离。
\- bottom: 设置导航点距离Swiper组件底部的距离。
\- size: 设置导航点的直径。
\- mask: 设置是否显示导航点蒙层样式。
\- color: 设置导航点的颜色。
\- selectedColor: 设置选中的导航点的颜色。 | +| indicatorStyle8+ | {
left?: [Length](ts-types.md#length),
top?: [Length](ts-types.md#length),
right?: [Length](ts-types.md#length),
bottom?: [Length](ts-types.md#length),
size?: [Length](ts-types.md#length),
mask?: boolean,
color?: [ResourceColor](ts-types.md),
selectedColor?: [ResourceColor](ts-types.md)
} | 设置导航点样式:
\- left: 设置导航点距离Swiper组件左边的距离。
\- top: 设置导航点距离Swiper组件顶部的距离。
\- right: 设置导航点距离Swiper组件右边的距离。
\- bottom: 设置导航点距离Swiper组件底部的距离。
\- size: 设置导航点的直径。
\- mask: 设置是否显示导航点蒙层样式。
\- color: 设置导航点的颜色。
\- selectedColor: 设置选中的导航点的颜色。 | | displayCount8+ | number\|string | 设置元素显示个数。
默认值:1 | | effectMode8+ | [EdgeEffect](ts-appendix-enums.md#edgeeffect) | 滑动效果,目前支持的滑动效果参见EdgeEffect的枚举说明。
默认值:EdgeEffect.Spring | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-container-tabcontent.md b/zh-cn/application-dev/reference/arkui-ts/ts-container-tabcontent.md index a23c17552d46553a65d1e95b9002cdb75ab345e3..d2e6c7f80e18c245d0b8e913c97e9ea330f3352f 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-container-tabcontent.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-container-tabcontent.md @@ -23,7 +23,7 @@ TabContent() | 名称 | 参数类型 | 描述 | | -------- | -------- | -------- | -| tabBar | string \| Resource \| {
icon?: string \| Resource,
text?: string \| Resource
}
\| [CustomBuilder](../../ui/ts-types.md)8+ | 设置TabBar上显示内容。
CustomBuilder: 构造器,内部可以传入组件(API8版本以上适用)。
>  **说明:**
> 如果icon采用svg格式图源,则要求svg图源删除其自有宽高属性值。如采用带有自有宽高属性的svg图源,icon大小则是svg本身内置的宽高属性值大小。 | +| tabBar | string \| Resource \| {
icon?: string \| Resource,
text?: string \| Resource
}
\| [CustomBuilder](ts-types.md)8+ | 设置TabBar上显示内容。
CustomBuilder: 构造器,内部可以传入组件(API8版本以上适用)。
>  **说明:**
> 如果icon采用svg格式图源,则要求svg图源删除其自有宽高属性值。如采用带有自有宽高属性的svg图源,icon大小则是svg本身内置的宽高属性值大小。 | > **说明:** > - TabContent组件不支持设置通用宽度属性,其宽度默认撑满Tabs父组件。 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-circle.md b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-circle.md index c641e7932e0d6362d5dabae55aff65c61698ba3f..a3f690f5f5e7a8fa685b33d0906939d319d1501c 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-circle.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-circle.md @@ -28,15 +28,15 @@ Circle(options?: {width?: string | number, height?: string | number}) | 参数名称 | 参数类型 | 默认值 | 必填 | 参数描述 | | -------- | -------- | -------- | -------- | -------- | -| fill | [ResourceColor](../../ui/ts-types.md) | Color.Black | 否 | 设置填充区域颜色。 | -| fillOpacity | number \| string \| [Resource](../../ui/ts-types.md#resource类型) | 1 | 否 | 设置填充区域透明度。 | -| stroke | [ResourceColor](../../ui/ts-types.md) | Color.Black | 否 | 设置线条颜色。 | +| fill | [ResourceColor](ts-types.md) | Color.Black | 否 | 设置填充区域颜色。 | +| fillOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 否 | 设置填充区域透明度。 | +| stroke | [ResourceColor](ts-types.md) | Color.Black | 否 | 设置线条颜色。 | | strokeDashArray | Array<Length> | [] | 否 | 设置线条间隙。 | | strokeDashOffset | number \| string | 0 | 否 | 线条绘制起点的偏移量。 | | strokeLineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | LineCapStyle.Butt | 否 | 设置线条端点绘制样式。 | | strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | LineJoinStyle.Miter | 否 | 设置线条拐角绘制样式。 | | strokeMiterLimit | number \| string | 4 | 否 | 设置锐角绘制成斜角的极限值。 | -| strokeOpacity | number \| string \| [Resource](../../ui/ts-types.md#resource类型) | 1 | 否 | 设置线条透明度。 | +| strokeOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 否 | 设置线条透明度。 | | strokeWidth | Length | 1 | 否 | 设置线条宽度。 | | antiAlias | boolean | true | 否 | 是否开启抗锯齿效果。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-ellipse.md b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-ellipse.md index 64040cc7ef99db510cb0877be8f110b083461ff3..6558f3733f669d7a05500e802d68d35c0715cacc 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-ellipse.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-ellipse.md @@ -29,15 +29,15 @@ ellipse(options?: {width?: string | number, height?: string | number}) | 参数名称 | 参数类型 | 默认值 | 必填 | 参数描述 | | -------- | -------- | -------- | -------- | -------- | -| fill | [ResourceColor](../../ui/ts-types.md) | Color.Black | 否 | 设置填充区域颜色。 | -| fillOpacity | number \| string \| [Resource](../../ui/ts-types.md#resource类型) | 1 | 否 | 设置填充区域透明度。 | -| stroke | [ResourceColor](../../ui/ts-types.md) | Color.Black | 否 |设置线条颜色。 | +| fill | [ResourceColor](ts-types.md) | Color.Black | 否 | 设置填充区域颜色。 | +| fillOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 否 | 设置填充区域透明度。 | +| stroke | [ResourceColor](ts-types.md) | Color.Black | 否 |设置线条颜色。 | | strokeDashArray | Array<Length> | [] | 否 | 设置线条间隙。 | | strokeDashOffset | number \| string | 0 | 否 | 线条绘制起点的偏移量。 | | strokeLineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | LineCapStyle.Butt | 否 | 设置线条端点绘制样式。 | | strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | LineJoinStyle.Miter | 否 | 设置线条拐角绘制样式。 | | strokeMiterLimit | number \| string | 4 | 否 | 设置锐角绘制成斜角的极限值。 | -| strokeOpacity | number \| string \| [Resource](../../ui/ts-types.md#resource类型) | 1 | 否 | 设置线条透明度。 | +| strokeOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 否 | 设置线条透明度。 | | strokeWidth | Length | 1 | 否 | 设置线条宽度。 | | antiAlias | boolean | true | 否 | 是否开启抗锯齿效果。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-line.md b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-line.md index b2b3785ce0ca51bba69401f9dec96793275cf2f7..3e51c861165a58651c57dae9c344177217e14a18 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-line.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-line.md @@ -36,15 +36,15 @@ Line(options?: {width?: string | number, height?: string | number}) | -------- | -------- | -------- | -------- | -------- | | startPoint | Array | [0, 0] | 是 | 直线起点坐标点(相对坐标)。 | | endPoint | Array | [0, 0] | 是 | 直线终点坐标点(相对坐标)。 | -| fill | [ResourceColor](../../ui/ts-types.md) | Color.Black | 否 | 设置填充区域颜色。 | -| fillOpacity | number \| string \| [Resource](../../ui/ts-types.md#resource类型) | 1 | 否 | 设置填充区域透明度。 | -| stroke | [ResourceColor](../../ui/ts-types.md) | Color.Black | 否 | 设置线条颜色。 | +| fill | [ResourceColor](ts-types.md) | Color.Black | 否 | 设置填充区域颜色。 | +| fillOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 否 | 设置填充区域透明度。 | +| stroke | [ResourceColor](ts-types.md) | Color.Black | 否 | 设置线条颜色。 | | strokeDashArray | Array<Length> | [] | 否 | 设置线条间隙。 | | strokeDashOffset | number \| string | 0 | 否 | 线条绘制起点的偏移量。 | | strokeLineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | LineCapStyle.Butt | 否 | 设置线条端点绘制样式。 | | strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | LineJoinStyle.Miter | 否 | 设置线条拐角绘制样式。 | | strokeMiterLimit | number \| string | 4 | 否 | 设置锐角绘制成斜角的极限值。 | -| strokeOpacity | number \| string \| [Resource](../../ui/ts-types.md#resource类型) | 1 | 否 | 设置线条透明度。 | +| strokeOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 否 | 设置线条透明度。 | | strokeWidth | Length | 1 | 否 | 设置线条宽度。 | | antiAlias | boolean | true | 否 | 是否开启抗锯齿效果。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-path.md b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-path.md index eadf46951de6851dd445b39db72b0516bb8f7e74..372b056e1951d565b0bf50f566526cebcd26cf4e 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-path.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-path.md @@ -30,15 +30,15 @@ Path(value?: { width?: number | string; height?: number | string; commands?: str | 参数名称 | 参数类型 | 默认值 | 必填 | 参数描述 | | -------- | ----------------------------------- | ---- | ---- | ---------------------------------------- | | commands | string | '' | 否 | 路径绘制的命令字符串,单位为px。像素单位转换方法请参考[像素单位转换](../../ui/ts-pixel-units.md)。 | -| fill | [ResourceColor](../../ui/ts-types.md) | Color.Black | 否 | 设置填充区域颜色。 | -| fillOpacity | number \| string \| [Resource](../../ui/ts-types.md#resource类型) | 1 | 否 | 设置填充区域透明度。 | -| stroke | [ResourceColor](../../ui/ts-types.md) | Color.Black | 否 | 设置线条颜色。 | +| fill | [ResourceColor](ts-types.md) | Color.Black | 否 | 设置填充区域颜色。 | +| fillOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 否 | 设置填充区域透明度。 | +| stroke | [ResourceColor](ts-types.md) | Color.Black | 否 | 设置线条颜色。 | | strokeDashArray | Array<Length> | [] | 否 | 设置线条间隙。 | | strokeDashOffset | number \| string | 0 | 否 | 线条绘制起点的偏移量。 | | strokeLineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | LineCapStyle.Butt | 否 | 设置线条端点绘制样式。 | | strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | LineJoinStyle.Miter | 否 | 设置线条拐角绘制样式。 | | strokeMiterLimit | number \| string | 4 | 否 | 设置锐角绘制成斜角的极限值。 | -| strokeOpacity | number \| string \| [Resource](../../ui/ts-types.md#resource类型) | 1 | 否 | 设置线条透明度。 | +| strokeOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 否 | 设置线条透明度。 | | strokeWidth | Length | 1 | 否 | 设置线条宽度。 | | antiAlias | boolean | true | 否 | 是否开启抗锯齿效果。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-polygon.md b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-polygon.md index f9f2674cbe0892bd983de4bd2b45a7f28ab76907..640d8cff9a544e495ede82b1dedf500af2e79fb3 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-polygon.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-polygon.md @@ -30,15 +30,15 @@ Polygon(options?: {width?: string | number, height?: string | number}) | 参数名称 | 参数类型 | 默认值 | 必填 | 参数描述 | | -------- | -------- | -------- | -------- | -------- | | points | Array<Point> | [] | 否 | 多边形的顶点坐标列表。 | -| fill | [ResourceColor](../../ui/ts-types.md) | Color.Black | 否 | 设置填充区域颜色。 | -| fillOpacity | number \| string \| [Resource](../../ui/ts-types.md#resource类型) | 1 | 否 | 设置填充区域透明度。 | -| stroke | [ResourceColor](../../ui/ts-types.md) | Color.Black | 否 | 设置线条颜色。 | +| fill | [ResourceColor](ts-types.md) | Color.Black | 否 | 设置填充区域颜色。 | +| fillOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 否 | 设置填充区域透明度。 | +| stroke | [ResourceColor](ts-types.md) | Color.Black | 否 | 设置线条颜色。 | | strokeDashArray | Array<Length> | [] | 否 | 设置线条间隙。 | | strokeDashOffset | number \| string | 0 | 否 | 线条绘制起点的偏移量。 | | strokeLineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | LineCapStyle.Butt | 否 | 设置线条端点绘制样式。 | | strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | LineJoinStyle.Miter | 否 | 设置线条拐角绘制样式。 | | strokeMiterLimit | number \| string | 4 | 否 | 设置锐角绘制成斜角的极限值。 | -| strokeOpacity | number \| string \| [Resource](../../ui/ts-types.md#resource类型) | 1 | 否 | 设置线条透明度。 | +| strokeOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 否 | 设置线条透明度。 | | strokeWidth | Length | 1 | 否 | 设置线条宽度。 | | antiAlias | boolean | true | 否 | 是否开启抗锯齿效果。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-polyline.md b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-polyline.md index cf2d0ea085fb49e14aaa9d59ac909af218ef2ba9..d650c783667355475a221b892064b728978b1492 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-polyline.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-polyline.md @@ -30,15 +30,15 @@ Polyline(options?: {width?: string | number, height?: string | number}) | 参数名称 | 参数类型 | 默认值 | 必填 | 参数描述 | | -------- | -------- | -------- | -------- | -------- | | points | Array<Point> | [] | 否 | 折线经过坐标点列表。 | -| fill | [ResourceColor](../../ui/ts-types.md) | Color.Black | 否 | 设置填充区域颜色。 | -| fillOpacity | number \| string \| [Resource](../../ui/ts-types.md#resource类型) | 1 | 否 | 设置填充区域透明度。 | -| stroke | [ResourceColor](../../ui/ts-types.md) | Color.Black | 否 | 设置线条颜色。 | +| fill | [ResourceColor](ts-types.md) | Color.Black | 否 | 设置填充区域颜色。 | +| fillOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 否 | 设置填充区域透明度。 | +| stroke | [ResourceColor](ts-types.md) | Color.Black | 否 | 设置线条颜色。 | | strokeDashArray | Array<Length> | [] | 否 | 设置线条间隙。 | | strokeDashOffset | number \| string | 0 | 否 | 线条绘制起点的偏移量。 | | strokeLineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | LineCapStyle.Butt | 否 | 设置线条端点绘制样式。 | | strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | LineJoinStyle.Miter | 否 | 设置线条拐角绘制样式。 | | strokeMiterLimit | number \| string | 4 | 否 | 设置锐角绘制成斜角的极限值。 | -| strokeOpacity | number \| string \| [Resource](../../ui/ts-types.md#resource类型) | 1 | 否 | 设置线条透明度。 | +| strokeOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 否 | 设置线条透明度。 | | strokeWidth | Length | 1 | 否 | 设置线条宽度。 | | antiAlias | boolean | true | 否 | 是否开启抗锯齿效果。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-rect.md b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-rect.md index 53ff413ddd1793b97d0fec303564b28aa85fa857..0b3477c98e16a53b88e09519b453cb92dea57cea 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-rect.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-rect.md @@ -36,15 +36,15 @@ Rect(options?: {width?: string | number,height?: string | number,radius?: string | radiusWidth | string \| number | 0 | 否 | 圆角的宽度,仅设置宽时宽高一致。 | | radiusHeight | string \| number | 0 | 否 | 圆角的高度,仅设置高时宽高一致。 | | radius | string \| number \| Array<string \| number> | 0 | 否 | 圆角半径大小。 | -| fill | [ResourceColor](../../ui/ts-types.md) | Color.Black | 否 | 设置填充区域颜色。 | -| fillOpacity | number \| string \| [Resource](../../ui/ts-types.md#resource类型) | 1 | 否 | 设置填充区域透明度。 | -| stroke | [ResourceColor](../../ui/ts-types.md) | Color.Black | 否 | 设置线条颜色。 | +| fill | [ResourceColor](ts-types.md) | Color.Black | 否 | 设置填充区域颜色。 | +| fillOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 否 | 设置填充区域透明度。 | +| stroke | [ResourceColor](ts-types.md) | Color.Black | 否 | 设置线条颜色。 | | strokeDashArray | Array<Length> | [] | 否 | 设置线条间隙。 | | strokeDashOffset | number \| string | 0 | 否 | 线条绘制起点的偏移量。 | | strokeLineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | LineCapStyle.Butt | 否 | 设置线条端点绘制样式。 | | strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | LineJoinStyle.Miter | 否 | 设置线条拐角绘制样式。 | | strokeMiterLimit | number \| string | 4 | 否 | 设置锐角绘制成斜角的极限值。 | -| strokeOpacity | number \| string \| [Resource](../../ui/ts-types.md#resource类型) | 1 | 否 | 设置线条透明度。 | +| strokeOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 否 | 设置线条透明度。 | | strokeWidth | Length | 1 | 否 | 设置线条宽度。 | | antiAlias | boolean | true | 否 | 是否开启抗锯齿效果。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-shape.md b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-shape.md index 0d75477d8c16d9f8a7bc077977a849f874e93ff1..2c912ca38081d058f5467cd0efb5cf01e8cd9ba8 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-shape.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-drawing-components-shape.md @@ -34,15 +34,15 @@ Shape(value?: PixelMap) | 参数名称 | 参数类型 | 默认值 | 必填 | 参数描述 | | -------- | -------- | -------- | -------- | -------- | | viewPort | {
x?: number \| string,
y?: number \| string,
width?: number \| string,
height?: number \| string
} | { x:0, y:0, width:0, height:0 } | 否 | 形状的视口。 | -| fill | [ResourceColor](../../ui/ts-types.md) | Color.Black | 否 | 设置填充区域颜色。 | -| fillOpacity | number \| string \| [Resource](../../ui/ts-types.md#resource类型) | 1 | 否 | 设置填充区域透明度。 | -| stroke | [ResourceColor](../../ui/ts-types.md) | Color.Black | 否 | 设置线条颜色。 | +| fill | [ResourceColor](ts-types.md) | Color.Black | 否 | 设置填充区域颜色。 | +| fillOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 否 | 设置填充区域透明度。 | +| stroke | [ResourceColor](ts-types.md) | Color.Black | 否 | 设置线条颜色。 | | strokeDashArray | Array<Length> | [] | 否 | 设置线条间隙。 | | strokeDashOffset | number \| string | 0 | 否 | 线条绘制起点的偏移量。 | | strokeLineCap | [LineCapStyle](ts-appendix-enums.md#linecapstyle) | LineCapStyle.Butt | 否 | 设置线条端点绘制样式。 | | strokeLineJoin | [LineJoinStyle](ts-appendix-enums.md#linejoinstyle) | LineJoinStyle.Miter | 否 | 设置线条拐角绘制样式。 | | strokeMiterLimit | number \| string | 4 | 否 | 设置锐角绘制成斜角的极限值。 | -| strokeOpacity | number \| string \| [Resource](../../ui/ts-types.md#resource类型) | 1 | 否 | 设置线条透明度。 | +| strokeOpacity | number \| string \| [Resource](ts-types.md#resource类型) | 1 | 否 | 设置线条透明度。 | | strokeWidth | number \| string | 1 | 否 | 设置线条宽度。 | | antiAlias | boolean | true | 否 | 是否开启抗锯齿效果。 | | mesh8+ | Array<number>,number,number | [],0,0 | 否 | 设置mesh效果。第一个参数为长度(column + 1)* (row + 1)* 2的数组,它记录了扭曲后的位图各个顶点位置,第二个参数为mesh矩阵列数column,第三个参数为mesh矩阵行数row。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-media-components-video.md b/zh-cn/application-dev/reference/arkui-ts/ts-media-components-video.md index 05591aaf496e148eb2f9d950d42eb69842fe2368..b504929e733dbc57385d8bcf492d605603587bf3 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-media-components-video.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-media-components-video.md @@ -24,9 +24,9 @@ Video(value: {src?: string | Resource, currentProgressRate?: number | string | P | 参数名 | 参数类型 | 必填 | 参数描述 | | ------------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | -| src | string \| [Resource](../../ui/ts-types.md) | 否 | 视频播放源的路径,支持本地视频路径和网络路径。
支持在resources下面的video或rawfile文件夹里放置媒体资源。
支持dataability://的路径前缀,用于访问通过Data Ability提供的视频路径,具体路径信息详见[Data Ability说明](../../ability/fa-dataability.md)。
**说明:**
视频支持的规格是:mp4、mkv、webm、TS。 | +| src | string \| [Resource](ts-types.md) | 否 | 视频播放源的路径,支持本地视频路径和网络路径。
支持在resources下面的video或rawfile文件夹里放置媒体资源。
支持dataability://的路径前缀,用于访问通过Data Ability提供的视频路径,具体路径信息详见[Data Ability说明](../../ability/fa-dataability.md)。
**说明:**
视频支持的规格是:mp4、mkv、webm、TS。 | | currentProgressRate | number \| string \| PlaybackSpeed8+ | 否 | 视频播放倍速。
**说明:**
number取值仅支持:0.75,1.0,1.25,1.75,2.0。
默认值:1.0 \| PlaybackSpeed.Speed_Forward_1_00_X | -| previewUri | string \| PixelMap8+ \| [Resource](../../ui/ts-types.md) | 否 | 预览图片的路径。 | +| previewUri | string \| PixelMap8+ \| [Resource](ts-types.md) | 否 | 预览图片的路径。 | | controller | [VideoController](#videocontroller) | 否 | 控制器。 | ## PlaybackSpeed8+枚举说明 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-methods-action-sheet.md b/zh-cn/application-dev/reference/arkui-ts/ts-methods-action-sheet.md index c4f236ec93bb4b595cd0b9ab33e6abc2c94205d7..f03fcd0d0f1256be6992e1b18ee1c5ec3904822b 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-methods-action-sheet.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-methods-action-sheet.md @@ -21,10 +21,10 @@ show(value: { title: string | Resource, message: string  | 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | | -------- | -------- | -------- | -------- | -------- | - | title | string \| [Resource](../../ui/ts-types.md#resource) | 是 | - | 弹窗标题。 | - | message | string \| [Resource](../../ui/ts-types.md#resource) | 是 | - | 弹窗内容。 | + | title | string \| [Resource](ts-types.md#resource) | 是 | - | 弹窗标题。 | + | message | string \| [Resource](ts-types.md#resource) | 是 | - | 弹窗内容。 | | autoCancel | boolean | 否 | true | 点击遮障层时,是否关闭弹窗。 | - | confirm | {
value: string \| [Resource](../../ui/ts-types.md#resource),
action: () => void
} | 否 | - | 确认按钮的文本内容和点击回调。
value:按钮文本内容。
action: 按钮选中时的回调。 | + | confirm | {
value: string \| [Resource](ts-types.md#resource),
action: () => void
} | 否 | - | 确认按钮的文本内容和点击回调。
value:按钮文本内容。
action: 按钮选中时的回调。 | | cancel | () => void | 否 | - | 点击遮障层关闭dialog时的回调。 | | alignment | [DialogAlignment](ts-methods-custom-dialog-box.md) | 否 | DialogAlignment.Default | 弹窗在竖直方向上的对齐方式。 | | offset | {
dx: Length,
dy: Length
} | 否 | {
dx: 0,
dy: 0
} | 弹窗相对alignment所在位置的偏移量。 | @@ -34,8 +34,8 @@ show(value: { title: string | Resource, message: string  | 参数名 | 参数类型 | 必填 | 参数描述 | | ------ | ------------------------------------------------------------ | ---- | ----------------- | - | title | string \| [Resource](../../ui/ts-types.md#resource) | 是 | 选项的文本内容。 | - | icon | string \| [Resource](../../ui/ts-types.md#resource) | 否 | 选项的图标,默认无图标显示。 | + | title | string \| [Resource](ts-types.md#resource) | 是 | 选项的文本内容。 | + | icon | string \| [Resource](ts-types.md#resource) | 否 | 选项的图标,默认无图标显示。 | | action | ()=>void | 是 | 选项选中的回调。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-methods-alert-dialog-box.md b/zh-cn/application-dev/reference/arkui-ts/ts-methods-alert-dialog-box.md index 12d8a07c2993170cd7da94157628fb3f607f58fd..b323eb9378415d28933e2eb8d126d84088e92df7 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-methods-alert-dialog-box.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-methods-alert-dialog-box.md @@ -15,26 +15,26 @@ ## AlertDialogParamWithConfirm对象说明 | 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | | -------- | -------- | -------- | -------- | -------- | - | title | string \| [Resource](../../ui/ts-types.md#resource类型) | 否 | - | 弹窗标题。 | - | message | string \| [Resource](../../ui/ts-types.md#resource类型) | 是 | - | 弹窗内容。 | + | title | string \| [Resource](ts-types.md#resource类型) | 否 | - | 弹窗标题。 | + | message | string \| [Resource](ts-types.md#resource类型) | 是 | - | 弹窗内容。 | | autoCancel | boolean | 否 | true | 点击遮障层时,是否关闭弹窗。 | - | confirm | {
value: string \| [Resource](../../ui/ts-types.md#resource类型),
fontColor?: Color \| number \| string \| [Resource](../../ui/ts-types.md#resource类型),
backgroundColor?: Color \| number \| string \| [Resource](../../ui/ts-types.md#resource类型),
action: () => void
} | 否 | - | 确认按钮的文本内容、文本色、按钮背景色和点击回调。 | + | confirm | {
value: string \| [Resource](ts-types.md#resource类型),
fontColor?: Color \| number \| string \| [Resource](ts-types.md#resource类型),
backgroundColor?: Color \| number \| string \| [Resource](ts-types.md#resource类型),
action: () => void
} | 否 | - | 确认按钮的文本内容、文本色、按钮背景色和点击回调。 | | cancel | () => void | 否 | - | 点击遮障层关闭dialog时的回调。 | | alignment | [DialogAlignment](ts-methods-custom-dialog-box.md) | 否 | DialogAlignment.Default | 弹窗在竖直方向上的对齐方式。 | - | offset | {
dx: Length \| [Resource](../../ui/ts-types.md#resource类型),
dy: Length  \| [Resource](../../ui/ts-types.md#resource类型)
} | 否 | - | 弹窗相对alignment所在位置的偏移量。 | + | offset | {
dx: Length \| [Resource](ts-types.md#resource类型),
dy: Length  \| [Resource](ts-types.md#resource类型)
} | 否 | - | 弹窗相对alignment所在位置的偏移量。 | | gridCount | number | 否 | - | 弹窗容器宽度所占用栅格数。 | ## AlertDialogParamWithButtons对象说明 | 参数名 | 参数类型 | 必填 | 默认值 | 参数描述 | | -------- | -------- | -------- | -------- | -------- | - | title | string \| [Resource](../../ui/ts-types.md#resource类型) | 否 | - | 弹窗标题。 | - | message | string \| [Resource](../../ui/ts-types.md#resource类型) | 是 | - | 弹窗内容。 | + | title | string \| [Resource](ts-types.md#resource类型) | 否 | - | 弹窗标题。 | + | message | string \| [Resource](ts-types.md#resource类型) | 是 | - | 弹窗内容。 | | autoCancel | boolean | 否 | true | 点击遮障层时,是否关闭弹窗。 | - | primaryButton | {
value: string \| [Resource](../../ui/ts-types.md#resource类型),
fontColor?: Color \| number \| string \| [Resource](../../ui/ts-types.md#resource类型),
backgroundColor?: Color \| number \| string \| [Resource](../../ui/ts-types.md#resource类型),
action: () => void;
} | 否 | - | 按钮的文本内容、文本色、按钮背景色和点击回调。 | - | secondaryButton | {
value: string \| [Resource](../../ui/ts-types.md#resource类型),
fontColor?: Color \| number \| string \| [Resource](../../ui/ts-types.md#resource类型),
backgroundColor?: Color \| number \| string \| [Resource](../../ui/ts-types.md#resource类型),
action: () => void;
} | 否 | - | 按钮的文本内容、文本色、按钮背景色和点击回调。 | + | primaryButton | {
value: string \| [Resource](ts-types.md#resource类型),
fontColor?: Color \| number \| string \| [Resource](ts-types.md#resource类型),
backgroundColor?: Color \| number \| string \| [Resource](ts-types.md#resource类型),
action: () => void;
} | 否 | - | 按钮的文本内容、文本色、按钮背景色和点击回调。 | + | secondaryButton | {
value: string \| [Resource](ts-types.md#resource类型),
fontColor?: Color \| number \| string \| [Resource](ts-types.md#resource类型),
backgroundColor?: Color \| number \| string \| [Resource](ts-types.md#resource类型),
action: () => void;
} | 否 | - | 按钮的文本内容、文本色、按钮背景色和点击回调。 | | cancel | () => void | 否 | - | 点击遮障层关闭dialog时的回调。 | | alignment | [DialogAlignment](ts-methods-custom-dialog-box.md) | 否 | DialogAlignment.Default | 弹窗在竖直方向上的对齐方式。 | - | offset | {
dx: Length \| [Resource](../../ui/ts-types.md#resource类型),
dy: Length  \| [Resource](../../ui/ts-types.md#resource类型)
} | 否 | - | 弹窗相对alignment所在位置的偏移量。 | + | offset | {
dx: Length \| [Resource](ts-types.md#resource类型),
dy: Length  \| [Resource](ts-types.md#resource类型)
} | 否 | - | 弹窗相对alignment所在位置的偏移量。 | | gridCount | number | 否 | - | 弹窗容器宽度所占用栅格数。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-methods-custom-dialog-box.md b/zh-cn/application-dev/reference/arkui-ts/ts-methods-custom-dialog-box.md index da83aa7d4459f4fe9fffefe6dc2a248ada8c2e7b..be90e66cc0ab2da4beec22f2ebac93dc24c49683 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-methods-custom-dialog-box.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-methods-custom-dialog-box.md @@ -21,7 +21,7 @@ CustomDialogController(value:{builder: CustomDialog, cancel?: () => void, aut | cancel | () => void | 否 | - | 点击遮障层退出时的回调。 | | autoCancel | boolean | 否 | true | 是否允许点击遮障层退出。 | | alignment | DialogAlignment | 否 | DialogAlignment.Default | 弹窗在竖直方向上的对齐方式。 | - | offset | {
dx: Length \| [Resource](../../ui/ts-types.md#resource类型),
dy: Length  \| [Resource](../../ui/ts-types.md#resource类型)
} | 否 | - | 弹窗相对alignment所在位置的偏移量。 | + | offset | {
dx: Length \| [Resource](ts-types.md#resource类型),
dy: Length  \| [Resource](ts-types.md#resource类型)
} | 否 | - | 弹窗相对alignment所在位置的偏移量。 | | customStyle | boolean | 否 | false | 弹窗容器样式是否自定义。 | | gridCount8+ | number | 否 | - | 弹窗宽度占栅格宽度的个数。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-types.md b/zh-cn/application-dev/reference/arkui-ts/ts-types.md new file mode 100644 index 0000000000000000000000000000000000000000..acb841ae60212c012f084123f4c37e279e91b398 --- /dev/null +++ b/zh-cn/application-dev/reference/arkui-ts/ts-types.md @@ -0,0 +1,217 @@ +# 类型定义 + +## Resource + +资源引用类型,用于设置组件属性的值。 + +可以通过`$r`或者`$rawfile`创建Resource类型对象,不可以修改Resource中的各属性的值。 + +- `$r('belonging.type.name')` + + belonging:系统资源或者应用资源,相应的取值为'sys'和'app'; + + type:资源类型,支持'color'、'float'、'string'、'media'等; + + name:资源名称,在资源定义时确定。 + +- `$rawfile('filename')` + + filename:工程中resources/rawfile目录下的文件名称。 + +## Length + +长度类型,用于描述尺寸单位。 + +| 类型 | 说明 | +| -------- | -------------------------------------- | +| string | 需要显式指定像素单位,如'10px',也可设置百分比字符串,如'100%'。 | +| number | 默认单位vp。 | +| Resource | 使用引入资源的方式,引入系统资源或者应用资源中的尺寸。 | + +## ResourceStr8+ + +字符串类型,用于描述字符串入参可以使用的类型。 + +| 类型 | 说明 | +| -------- | ---------------------------- | +| string | 字符串类型。 | +| Resource | 使用引入资源的方式,引入系统资源或者应用资源中的字符串。 | + +## Padding + +内边距类型,用于描述组件不同方向的内边距。 + +| 名称 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | --------------- | +| top | Length | 否 | 组件内元素距组件顶部的尺寸。 | +| right | Length | 否 | 组件内元素距组件右边界的尺寸。 | +| bottom | Length | 否 | 组件内元素距组件底部的尺寸。 | +| left | Length | 否 | 组件内元素距组件左边界的尺寸。 | + +## Margin + +外边距类型,用于描述组件不同方向的外边距。 + +| 名称 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | --------------- | +| top | Length | 否 | 组件外元素距组件顶部的尺寸。 | +| right | Length | 否 | 组件外元素距组件右边界的尺寸。 | +| bottom | Length | 否 | 组件外元素距组件底部的尺寸。 | +| left | Length | 否 | 组件外元素距组件左边界的尺寸。 | + +## EdgeWidths9+ + +边框宽度类型,用于描述组件边框不同方向的宽度。 + +| 名称 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | -------- | +| top | Length | 否 | 组件上边框宽度。 | +| right | Length | 否 | 组件右边框宽度。 | +| bottom | Length | 否 | 组件下边框宽度。 | +| left | Length | 否 | 组件左边框宽度。 | + +## BorderRadiuses9+ + +圆角类型,用于描述组件边框圆角半径。 + +| 名称 | 类型 | 必填 | 说明 | +| ----------- | ------ | ---- | ---------- | +| topLeft | Length | 否 | 组件左上角圆角半径。 | +| topRight | Length | 否 | 组件右上角圆角半径。 | +| bottomLeft | Length | 否 | 组件左下角圆角半径。 | +| bottomRight | Length | 否 | 组件右下角圆角半径。 | + +## EdgeColors9+ + +边框颜色,用于描述组件边框四条边的颜色。 + +| 名称 | 类型 | 必填 | 说明 | +| ------ | ------------- | ---- | -------- | +| top | ResourceColor | 否 | 组件上边框颜色。 | +| right | ResourceColor | 否 | 组件右边框颜色。 | +| bottom | ResourceColor | 否 | 组件下边框颜色。 | +| left | ResourceColor | 否 | 组件左边框颜色。 | + +## EdgeStyles9+ + +边框样式,用于描述组件边框四条边的样式。 + +| 名称 | 类型 | 必填 | 说明 | +| ------ | ----------- | ---- | -------- | +| top | BorderStyle | 否 | 组件上边框样式。 | +| right | BorderStyle | 否 | 组件右边框样式。 | +| bottom | BorderStyle | 否 | 组件下边框样式。 | +| left | BorderStyle | 否 | 组件左边框样式。 | + + +## Offset + +相对布局完成位置坐标偏移量。 + +| 名称 | 类型 | 必填 | 说明 | +| ---- | ------ | ---- | -------- | +| dx | Length | 是 | 水平方向偏移量。 | +| dy | Length | 是 | 竖直方向偏移量。 | + +## ResourceColor8+ + +颜色类型,用于描述资源颜色类型。 + +| 类型 | 说明 | +| ---------------------------------------- | --------------------------- | +| [Color](../reference/arkui-ts/ts-appendix-enums.md#color) | 颜色枚举值。 | +| number | HEX格式颜色。 | +| string | rgb或者rgba格式颜色。 | +| Resource | 使用引入资源的方式,引入系统资源或者应用资源中的颜色。 | + +## LengthConstrain + +长度约束,用于对组件最大、最小长度做限制。 + +| 名称 | 类型 | 必填 | 说明 | +| --------- | ------ | ---- | ------- | +| minLength | Length | 是 | 组件最小长度。 | +| maxLength | Length | 是 | 组件最大长度。 | + + +## Font + +设置文本样式。 + +| 名称 | 类型 | 必填 | 说明 | +| ------ | ---------------------------------------- | ---- | ---------------------------------------- | +| size | [Length](#length) | 否 | 设置文本尺寸,Length为number类型时,使用fp单位。 | +| weight | [FontWeight](../reference/arkui-ts/ts-appendix-enums.md#fontweight) \| number \| string | 否 | 设置文本的字体粗细,number类型取值[100, 900],取值间隔为100,默认为400,取值越大,字体越粗。 | +| family | string \| [Resource](#resource) | 否 | 设置文本的字体列表。使用多个字体,使用','进行分割,优先级按顺序生效。例如:'Arial, sans-serif'。 | +| style | [FontStyle](../reference/arkui-ts/ts-appendix-enums.md#fontstyle) | 否 | 设置文本的字体样式。 | + +## Area8+ + +区域类型,用于存储元素所占区域信息 + +| 名称 | 类型 | 说明 | +| -------------- | ---------------------- | ------------------------------ | +| width | [Length](#length) | 目标元素的宽度,作为返回值时,类型为number,单位vp。 | +| height | [Length](#length) | 目标元素的高度,作为返回值时,类型为number,单位vp。 | +| position | [Position](#position8) | 目标元素左上角相对父元素左上角的位置。 | +| globalPosition | [Position](#position8) | 目标元素左上角相对页面左上角的位置。 | + + +## Position8+ + +位置类型,用于表示一个坐标点。 + +| 名称 | 类型 | 必填 | 说明 | +| ---- | ------ | ---- | --------------------------- | +| x | Length | 否 | x轴坐标,作为返回值时,类型为number,单位vp。 | +| y | Length | 否 | y轴坐标,作为返回值时,类型为number,单位vp。 | + +## ConstraintSizeOptions + +设置约束尺寸,组件布局时,进行尺寸范围限制。 + +| 名称 | 类型 | 必填 | 说明 | +| --------- | ------ | ---- | ------- | +| minWidth | Length | 否 | 元素最小宽度。 | +| maxWidth | Length | 否 | 元素最大宽度。 | +| minHeight | Length | 否 | 元素最小高度。 | +| maxHeight | Length | 否 | 元素最大高度。 | + +## SizeOptions + +设置宽高尺寸。 + +| 名称 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ----- | +| width | Length | 否 | 元素宽度。 | +| height | Length | 否 | 元素高度。 | + + +## BorderOptions + +边框属性集合,用于描述边框相关信息。 + +| 名称 | 类型 | 必填 | 说明 | +| ------ | ---------------------------------------- | ---- | ------- | +| width | Length \| EdgeWidths9+ | 否 | 边框宽度。 | +| color | ResourceColor \| EdgeColors9+ | 否 | 边框颜色。 | +| radius | Length \| BorderRadiuses9+ | 否 | 边框圆角半径。 | +| style | [BorderStyle](../reference/arkui-ts/ts-appendix-enums.md#borderstyle) \| EdgeStyles9+ | 否 | 边框样式。 | + +## ColorFilter9+ + +创建具有4*5矩阵的颜色过滤器。 + +| 名称 | 类型 | 必填 | 描述 | +| ----------- | -------- | ---- | ---------------------------------------- | +| constructor | number[] | 是 | 创建具有4*5矩阵的颜色过滤器, 入参为[m*n]位于m行和n列中矩阵值, 矩阵是行优先的。 | + + +## CustomBuilder8+ + +组件属性方法参数可使用CustomBuilder类型来自定义UI描述。 + +| 名称 | 类型定义 | 描述 | +| ------------- | ---------------------- | ---------------------------------------- | +| CustomBuilder | () => any | 该方法类型必须使用@Builder装饰器修饰。具体用法见[@Builder](../../ui/ts-component-based-builder.md)。 | + diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-background.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-background.md index 0986e03f2b635f689bd5a699c095e34079edefb3..16adaa56c33207d1a2eba09c6664785fb2dc0d28 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-background.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-background.md @@ -12,10 +12,10 @@ | 名称 | 参数类型 | 描述 | | -------- | -------- | -------- | -| backgroundColor | [ResourceColor](../../ui/ts-types.md) | 设置组件的背景色。 | -| backgroundImage | - src: [ResourceStr](../../ui/ts-types.md),
- repeat?: [ImageRepeat](ts-appendix-enums.md#imagerepeat) | src:图片地址,支持网络图片资源和本地图片资源地址(不支持svg类型的图片)。
repeat:设置背景图片的重复样式,默认不重复。 | -| backgroundImageSize | {
width?: [Length](../../ui/ts-types.md#length),
height?: [Length](../../ui/ts-types.md#length)
} \| [ImageSize](ts-appendix-enums.md#imagesize) | 设置背景图像的高度和宽度。当输入为{width: Length, height: Length}对象时,如果只设置一个属性,则第二个属性保持图片原始宽高比进行调整。默认保持原图的比例不变。
默认值:ImageSize.Auto | -| backgroundImagePosition | {
x?: [Length](../../ui/ts-types.md#length),
y?: [Length](../../ui/ts-types.md#length)
} \| [Alignment](ts-appendix-enums.md#alignment) | 设置背景图在组件中显示位置。
默认值:
{
x: 0,
y: 0
} | +| backgroundColor | [ResourceColor](ts-types.md) | 设置组件的背景色。 | +| backgroundImage | - src: [ResourceStr](ts-types.md),
- repeat?: [ImageRepeat](ts-appendix-enums.md#imagerepeat) | src:图片地址,支持网络图片资源和本地图片资源地址(不支持svg类型的图片)。
repeat:设置背景图片的重复样式,默认不重复。 | +| backgroundImageSize | {
width?: [Length](ts-types.md#length),
height?: [Length](ts-types.md#length)
} \| [ImageSize](ts-appendix-enums.md#imagesize) | 设置背景图像的高度和宽度。当输入为{width: Length, height: Length}对象时,如果只设置一个属性,则第二个属性保持图片原始宽高比进行调整。默认保持原图的比例不变。
默认值:ImageSize.Auto | +| backgroundImagePosition | {
x?: [Length](ts-types.md#length),
y?: [Length](ts-types.md#length)
} \| [Alignment](ts-appendix-enums.md#alignment) | 设置背景图在组件中显示位置。
默认值:
{
x: 0,
y: 0
} | ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-border-image.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-border-image.md index 9d79e66d36821a40aeb9d9b7126808c9c99998fc..3292fda02a1f7e839a281339f23bf08cc62cc688 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-border-image.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-border-image.md @@ -12,10 +12,10 @@ | 名称 | 参数类型 | 描述 | | -------- | -------- | -------- | -| source | string \| [Resource](../../ui/ts-types.md#resource类型) \| [linearGradient](ts-universal-attributes-gradient-color.md) | 边框图源或者渐变色设置。 | -| slice | [Length](../../ui/ts-types.md#length)\| EdgeWidth | 设置图片边框切割宽度。
默认值:0 | -| width | [Length](../../ui/ts-types.md#length)\| EdgeWidth | 设置图片边框宽度。
默认值:0 | -| outset | [Length](../../ui/ts-types.md#length)\| EdgeWidth | 设置边框图片向外延伸距离。
默认值:0 | +| source | string \| [Resource](ts-types.md#resource类型) \| [linearGradient](ts-universal-attributes-gradient-color.md) | 边框图源或者渐变色设置。 | +| slice | [Length](ts-types.md#length)\| EdgeWidth | 设置图片边框切割宽度。
默认值:0 | +| width | [Length](ts-types.md#length)\| EdgeWidth | 设置图片边框宽度。
默认值:0 | +| outset | [Length](ts-types.md#length)\| EdgeWidth | 设置边框图片向外延伸距离。
默认值:0 | | RepeatMode | RepeatMode | 设置边框图片的重复方式。
默认值:RepeatMode.Stretch | | fill | boolean | 设置边框图片中心填充。
默认值:false | ## EdgeWidth枚举说明 @@ -26,10 +26,10 @@ | 名称 | 参数类型 | 必填 |描述 | | -------- | -------- |-------- |-------- | -| left | [Length](../../ui/ts-types.md#length) | 否 | 左侧距离参数。 | -| right | [Length](../../ui/ts-types.md#length) | 否 | 右侧距离参数。 | -| top | [Length](../../ui/ts-types.md#length) | 否 | 上侧距离参数。 | -| bottom | [Length](../../ui/ts-types.md#length) | 否 | 下侧距离参数。 | +| left | [Length](ts-types.md#length) | 否 | 左侧距离参数。 | +| right | [Length](ts-types.md#length) | 否 | 右侧距离参数。 | +| top | [Length](ts-types.md#length) | 否 | 上侧距离参数。 | +| bottom | [Length](ts-types.md#length) | 否 | 下侧距离参数。 | ## RepeatMode枚举说明 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-border.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-border.md index 3c830ec6f320f179419359787d4b42137d492fff..39f476affafdd2f261bec91dd4b26287cb74f6dc 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-border.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-border.md @@ -14,11 +14,11 @@ | 名称 | 参数类型 | 描述 | | ------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | -| border | {
width?: [Length](../../ui/ts-types.md#长度类型) \| EdgeWidth9+,
color?:  [ResourceColor](../../ui/ts-types.md) \| EdgeColor9+,
radius?:  [Length](../../ui/ts-types.md#长度类型) \| BorderRadiuses9+,
style?: [BorderStyle](ts-appendix-enums.md#borderstyle) \| EdgeStyle9+
} | 统一边框样式设置接口。
- width:设置边框宽度。
- color:设置边框颜色。
- radius:设置边框圆角半径。
- style:设置边框样式。 | +| border | {
width?: [Length](ts-types.md#长度类型) \| EdgeWidth9+,
color?:  [ResourceColor](ts-types.md) \| EdgeColor9+,
radius?:  [Length](ts-types.md#长度类型) \| BorderRadiuses9+,
style?: [BorderStyle](ts-appendix-enums.md#borderstyle) \| EdgeStyle9+
} | 统一边框样式设置接口。
- width:设置边框宽度。
- color:设置边框颜色。
- radius:设置边框圆角半径。
- style:设置边框样式。 | | borderStyle | [BorderStyle](ts-appendix-enums.md#borderstyle) \| EdgeStyle9+ | 设置元素的边框样式。
默认值:BorderStyle.Solid | -| borderWidth | [Length](../../ui/ts-types.md) \| EdgeWidth9+ | 设置元素的边框宽度。 | -| borderColor | [ResourceColor](../../ui/ts-types.md) \| EdgeColor9+ | 设置元素的边框颜色。 | -| borderRadius | [Length](../../ui/ts-types.md) \| BorderRadiuses9+ | 设置元素的边框圆角半径。 | +| borderWidth | [Length](ts-types.md) \| EdgeWidth9+ | 设置元素的边框宽度。 | +| borderColor | [ResourceColor](ts-types.md) \| EdgeColor9+ | 设置元素的边框颜色。 | +| borderRadius | [Length](ts-types.md) \| BorderRadiuses9+ | 设置元素的边框圆角半径。 | ## EdgeWidth9+对象说明 @@ -26,10 +26,10 @@ | 名称 | 参数类型 | 必填 | 描述 | | ------ | ------------------------------------- | ---- | -------------- | -| left | [Length](../../ui/ts-types.md#length) | 否 | 左侧边框宽度。 | -| right | [Length](../../ui/ts-types.md#length) | 否 | 右侧边框宽度。 | -| top | [Length](../../ui/ts-types.md#length) | 否 | 上侧边框宽度。 | -| bottom | [Length](../../ui/ts-types.md#length) | 否 | 下侧边框宽度。 | +| left | [Length](ts-types.md#length) | 否 | 左侧边框宽度。 | +| right | [Length](ts-types.md#length) | 否 | 右侧边框宽度。 | +| top | [Length](ts-types.md#length) | 否 | 上侧边框宽度。 | +| bottom | [Length](ts-types.md#length) | 否 | 下侧边框宽度。 | ## EdgeColor9+对象说明 @@ -37,10 +37,10 @@ | 名称 | 参数类型 | 必填 | 描述 | | ------ | ------------------------------------- | ---- | -------------- | -| left | [ResourceColor](../../ui/ts-types.md) | 否 | 左侧边框颜色。 | -| right | [ResourceColor](../../ui/ts-types.md) | 否 | 右侧边框颜色。 | -| top | [ResourceColor](../../ui/ts-types.md) | 否 | 上侧边框颜色。 | -| bottom | [ResourceColor](../../ui/ts-types.md) | 否 | 下侧边框颜色。 | +| left | [ResourceColor](ts-types.md) | 否 | 左侧边框颜色。 | +| right | [ResourceColor](ts-types.md) | 否 | 右侧边框颜色。 | +| top | [ResourceColor](ts-types.md) | 否 | 上侧边框颜色。 | +| bottom | [ResourceColor](ts-types.md) | 否 | 下侧边框颜色。 | ## BorderRadiuses9+对象说明 @@ -48,10 +48,10 @@ | 名称 | 参数类型 | 必填 | 描述 | | ----------- | ------------------------------------- | ---- | ---------------- | -| topLeft | [Length](../../ui/ts-types.md#length) | 否 | 左上角圆角半径。 | -| topRight | [Length](../../ui/ts-types.md#length) | 否 | 右上角圆角半径。 | -| bottomLeft | [Length](../../ui/ts-types.md#length) | 否 | 左下角圆角半径。 | -| bottomRight | [Length](../../ui/ts-types.md#length) | 否 | 右下角圆角半径。 | +| topLeft | [Length](ts-types.md#length) | 否 | 左上角圆角半径。 | +| topRight | [Length](ts-types.md#length) | 否 | 右上角圆角半径。 | +| bottomLeft | [Length](ts-types.md#length) | 否 | 左下角圆角半径。 | +| bottomRight | [Length](ts-types.md#length) | 否 | 右下角圆角半径。 | ## EdgeStyle9+对象说明 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-gradient-color.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-gradient-color.md index 564c3a50b6047ab2443719de2045030ed1513e45..abc458e88813ddd0fe6fa2f68364c765d00f5cf7 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-gradient-color.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-gradient-color.md @@ -17,9 +17,9 @@ | 名称 | 参数类型 | 默认值 | 描述 | | -------- | -------- | -------- | -------- | -| linearGradient | {
angle?: number \| string,
direction?: [GradientDirection](ts-appendix-enums.md#gradientdirection),
colors: Array<[ColorStop](../../ui/ts-types.md)>
, repeating?: boolean
} | - | 线性渐变。
angle: 线性渐变的角度。
direction: 线性渐变的方向,设置angle后不生效。
colors: 为渐变的颜色描述。
repeating: 为渐变的颜色重复着色。 | -| sweepGradient | {
center: Point,
start?: number \| string,
end?: number \| string,
colors: Array<[ColorStop](../../ui/ts-types.md)>
, repeating?: boolean
} | - | 角度渐变。
center:为角度渐变的中心点。
start:角度渐变的起点。
end:角度渐变的终点。
colors: 为渐变的颜色描述。
repeating: 为渐变的颜色重复着色。 | -| radialGradient | {
center: Point,
radius: number \| string,
colors: Array<[ColorStop](../../ui/ts-types.md)>
, repeating: boolean
} | - | 径向渐变。
center:径向渐变的中心点。
radius:径向渐变的半径。
colors: 为渐变的颜色描述。
repeating: 为渐变的颜色重复着色。 | +| linearGradient | {
angle?: number \| string,
direction?: [GradientDirection](ts-appendix-enums.md#gradientdirection),
colors: Array<[ColorStop](ts-basic-components-gauge.md#colorstop)>,
repeating?: boolean
} | - | 线性渐变。
angle: 线性渐变的角度。
direction: 线性渐变的方向,设置angle后不生效。
colors: 为渐变的颜色描述。
repeating: 为渐变的颜色重复着色。 | +| sweepGradient | {
center: Point,
start?: number \| string,
end?: number \| string,
rotation?: number\|string,
colors: Array<[ColorStop](ts-basic-components-gauge.md#colorstop)>,
repeating?: boolean
} | - | 角度渐变。
center:为角度渐变的中心点。
start:角度渐变的起点。
end:角度渐变的终点。
rotation: 角度渐变的旋转角度。
colors: 为渐变的颜色描述。
repeating: 为渐变的颜色重复着色。 | +| radialGradient | {
center: Point,
radius: number \| string,
colors: Array<[ColorStop](ts-basic-components-gauge.md#colorstop)>,
repeating?: boolean
} | - | 径向渐变。
center:径向渐变的中心点。
radius:径向渐变的半径。
colors: 为渐变的颜色描述。
repeating: 为渐变的颜色重复着色。 | ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-image-effect.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-image-effect.md index b301bcb2f3dda328ceb909b2d70bfe1f3e14f636..a58be16636b4a4f0e005b43b5ce32ff6129c9a0b 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-image-effect.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-image-effect.md @@ -18,13 +18,13 @@ | ----------------------------- | ------------------------------------------------------------ | ------ | ------------------------------------------------------------ | | blur | number | - | 为当前组件添加内容模糊效果,入参为模糊半径,模糊半径越大越模糊,为0时不模糊。 | | backdropBlur | number | - | 为当前组件添加背景模糊效果,入参为模糊半径,模糊半径越大越模糊,为0时不模糊。 | -| shadow | {
radius: number \| [Resource](../../ui/ts-types.md#resource),
color?: Color \| string \| Resource,
offsetX?: number \| Resource,
offsetY?: number \| Resource
} | - | 为当前组件添加阴影效果,入参为模糊半径(必填)、阴影的颜色(可选,默认为灰色)、X轴的偏移量(可选,默认为0),Y轴的偏移量(可选,默认为0),偏移量单位为px。 | +| shadow | {
radius: number \| [Resource](ts-types.md#resource),
color?: Color \| string \| Resource,
offsetX?: number \| Resource,
offsetY?: number \| Resource
} | - | 为当前组件添加阴影效果,入参为模糊半径(必填)、阴影的颜色(可选,默认为灰色)、X轴的偏移量(可选,默认为0),Y轴的偏移量(可选,默认为0),偏移量单位为px。 | | grayscale | number | 0.0 | 为当前组件添加灰度效果。值定义为灰度转换的比例,入参1.0则完全转为灰度图像,入参则0.0图像无变化,入参在0.0和1.0之间时,效果呈线性变化。(百分比) | | brightness | number | 1.0 | 为当前组件添加高光效果,入参为高光比例,值为1时没有效果,小于1时亮度变暗,0为全黑;大于1时亮度增加,数值越大亮度越大。 | | saturate | number | 1.0 | 为当前组件添加饱和度效果,饱和度为颜色中的含色成分和消色成分(灰)的比例,入参为1时,显示原图像,大于1时含色成分越大,饱和度越大;小于1时消色成分越大,饱和度越小。(百分比) | | contrast | number | 1.0 | 为当前组件添加对比度效果,入参为对比度的值,值为1时,显示原图;大于1时,值越大对比度越高,图像越清晰醒目;小于1时,值越小对比度越低;当对比度为0时,图像变为全灰。(百分比) | | invert | number | 0 | 反转输入的图像。入参为图像反转的比例。值为1时完全反转。值为0则图像无变化。(百分比) | -| colorBlend 8+ | Color \| string \| [Resource](../../ui/ts-types.md#resource) | - | 为当前组件添加颜色叠加效果,入参为叠加的颜色。 | +| colorBlend 8+ | Color \| string \| [Resource](ts-types.md#resource) | - | 为当前组件添加颜色叠加效果,入参为叠加的颜色。 | | sepia | number | 0 | 将图像转换为深褐色。入参为图像反转的比例。值为1则完全是深褐色的,值为0图像无变化。 (百分比) | | hueRotate | number\|string | '0deg' | 色相旋转效果,输入参数为旋转角度。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-location.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-location.md index 739ce3e872594c160bd0aee9f52da360cb9960ad..f071d455be691b5bf006f8641a5e33507202e45d 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-location.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-location.md @@ -14,9 +14,9 @@ | -------- | -------- | -------- | | align | [Alignment](ts-appendix-enums.md#alignment) | 设置元素内容的对齐方式,只有当设置的width和height大小超过元素本身内容大小时生效。
默认值:Alignment.Center | | direction | [Direction](ts-appendix-enums.md#direction) | 设置元素水平方向的布局。
默认值:Direction.Auto | -| position | {
x: [Length](../../ui/ts-types.md#length),
y: [Length](../../ui/ts-types.md#length)
} | 使用绝对定位,设置元素锚点相对于父容器顶部起点偏移位置。在布局容器中,设置该属性不影响父容器布局,仅在绘制时进行位置调整。 | -| markAnchor | {
x: [Length](../../ui/ts-types.md#length),
y: [Length](../../ui/ts-types.md#length)
} | 设置元素在位置定位时的锚点,以元素顶部起点作为基准点进行偏移。
默认值:
{
x: 0,
y: 1
} | -| offset | {
x: [Length](../../ui/ts-types.md#length),
y: [Length](../../ui/ts-types.md#length)
} | 相对布局完成位置坐标偏移量,设置该属性,不影响父容器布局,仅在绘制时进行位置调整。
默认值:
{
x: 0,
y: 1
} | +| position | {
x: [Length](ts-types.md#length),
y: [Length](ts-types.md#length)
} | 使用绝对定位,设置元素锚点相对于父容器顶部起点偏移位置。在布局容器中,设置该属性不影响父容器布局,仅在绘制时进行位置调整。 | +| markAnchor | {
x: [Length](ts-types.md#length),
y: [Length](ts-types.md#length)
} | 设置元素在位置定位时的锚点,以元素顶部起点作为基准点进行偏移。
默认值:
{
x: 0,
y: 1
} | +| offset | {
x: [Length](ts-types.md#length),
y: [Length](ts-types.md#length)
} | 相对布局完成位置坐标偏移量,设置该属性,不影响父容器布局,仅在绘制时进行位置调整。
默认值:
{
x: 0,
y: 1
} | | alignRules9+ | {
left?: { anchor: string, align: [HorizontalAlign](ts-appendix-enums.md#horizontalalign) };
right?: { anchor: string, align: [HorizontalAlign](ts-appendix-enums.md#horizontalalign) };
middle?: { anchor: string, align: [HorizontalAlign](ts-appendix-enums.md#horizontalalign) };
top?: { anchor: string, align: [VerticalAlign](ts-appendix-enums.md#verticalalign) };
bottom?: { anchor: string, align: [VerticalAlign](ts-appendix-enums.md#verticalalign) };
center?: { anchor: string, align: [VerticalAlign](ts-appendix-enums.md#verticalalign) }
} | 指定相对容器的对齐规则。
- left:设置左对齐参数。
- right:设置右对齐参数。
- middle:设置中间对齐的参数。
- top:设置顶部对齐的参数。
- bottom:设置底部对齐的参数。
- center:设置中心对齐的参数。
**说明:**
- anchor:设置作为锚点的组件的id值。
- align:设置相对于锚点组件的对齐方式。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-menu.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-menu.md index a9e87d40133f5cf24eb3768d15ff7c584654f01a..1b46ee5137f7aec507f18951bb6a12963135066a 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-menu.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-menu.md @@ -12,8 +12,8 @@ | 名称 | 参数类型 | 描述 | | ---------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | -| bindMenu | Array8+ | content: [CustomBuilder](../../ui/ts-types.md),
responseType: [ResponseType](ts-appendix-enums.md#responsetype8) | 给组件绑定菜单,触发方式为长按或者右键点击,弹出菜单项需要自定义。 | +| bindMenu | Array8+ | content: [CustomBuilder](ts-types.md),
responseType: [ResponseType](ts-appendix-enums.md#responsetype8) | 给组件绑定菜单,触发方式为长按或者右键点击,弹出菜单项需要自定义。 | ## MenuItem diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-opacity.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-opacity.md index aa285f3ccb765adc4c27712a8182b1838a6f2d8b..6fb486dcd3a95a4a09db971c42981e1509593844 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-opacity.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-opacity.md @@ -17,7 +17,7 @@ | 名称 | 参数类型 | 默认值 | 描述 | | -------- | -------- | -------- | -------- | -| opacity | number \| [Resource](../../ui/ts-types.md#resource类型) | 1 | 元素的不透明度,取值范围为0到1,1表示为不透明,0表示为完全透明。 | +| opacity | number \| [Resource](ts-types.md#resource类型) | 1 | 元素的不透明度,取值范围为0到1,1表示为不透明,0表示为完全透明。 | ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-popup.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-popup.md index ba9251977c5df751622a77ea68a74cf015cf12e3..bb707e9be1b7e5b3d8aeedaf19ca344e5ad7f231 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-popup.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-popup.md @@ -20,7 +20,7 @@ | -------- | -------- | -------- | -------- | | message | string | 是 | 弹窗信息内容。 | | placementOnTop | boolean | 否 | 是否在组件上方显示,默认值为false。 | -| arrowOffset9+ | [Length](../../ui/ts-types.md#length) | 否 | popup箭头在弹窗处的偏移。箭头在气泡上下方时,默认居左;箭头在气泡左右侧时,默认居上。 | +| arrowOffset9+ | [Length](ts-types.md#length) | 否 | popup箭头在弹窗处的偏移。箭头在气泡上下方时,默认居左;箭头在气泡左右侧时,默认居上。 | | primaryButton | {
value: string,
action: () => void
} | 否 | 第一个按钮。
value: 弹窗里主按钮的文本。
action: 点击主按钮的回调函数。 | | secondaryButton | {
value: string,
action: () => void
} | 否 | 第二个按钮。
value: 弹窗里辅助按钮的文本。
action: 点击辅助按钮的回调函数。 | | onStateChange | (event: { isVisible: boolean }) => void | 否 | 弹窗状态变化事件回调,参数isVisible为弹窗当前的显示状态。 | @@ -29,11 +29,11 @@ | 名称 | 类型 | 必填 | 描述 | | -------- | -------- | -------- | -------- | -| builder | [CustomBuilder](../../ui/ts-types.md) | 是 | 提示气泡内容的构造器。 | +| builder | [CustomBuilder](ts-types.md) | 是 | 提示气泡内容的构造器。 | | placement | [Placement](ts-appendix-enums.md#placement8) | 否 | 气泡组件优先显示的位置,当前位置显示不下时,会自动调整位置。
默认值:Placement.Bottom | -| arrowOffset9+ | [Length](../../ui/ts-types.md#length) | 否 | popup箭头在弹窗处的偏移。箭头在气泡上下方时,默认居左;箭头在气泡左右侧时,默认居上。 | -| maskColor | [ResourceColor](../../ui/ts-types.md) | 否 | 提示气泡遮障层的颜色。 | -| popupColor | [ResourceColor](../../ui/ts-types.md) | 否 | 提示气泡的颜色。 | +| arrowOffset9+ | [Length](ts-types.md#length) | 否 | popup箭头在弹窗处的偏移。箭头在气泡上下方时,默认居左;箭头在气泡左右侧时,默认居上。 | +| maskColor | [ResourceColor](ts-types.md) | 否 | 提示气泡遮障层的颜色。 | +| popupColor | [ResourceColor](ts-types.md) | 否 | 提示气泡的颜色。 | | enableArrow | boolean | 否 | 是否显示箭头。
从API Version 9开始,如果箭头所在方位侧的气泡长度不足以显示下箭头,则会默认不显示箭头。比如:placement设置为Left,但气泡高度小于箭头的宽度(32vp),则实际不会显示箭头。
默认值:true | | autoCancel | boolean | 否 | 页面有操作时,是否自动关闭气泡
默认值:true | | onStateChange | (event: { isVisible: boolean }) => void | 否 | 弹窗状态变化事件回调,参数为弹窗当前的显示状态。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-text-style.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-text-style.md index 900ed973ab009749201d7b351eef5e4c58a04008..94a531a62ffe5fcd59ce30cb6d0dc4b63f79bb40 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-text-style.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-text-style.md @@ -18,11 +18,11 @@ | 名称 | 参数类型 | 默认值 | 描述 | | -------- | -------- | -------- | -------- | -| fontColor | [ResourceColor](../../ui/ts-types.md) | - | 设置文本颜色。 | -| fontSize | Length \| [Resource](../../ui/ts-types.md#resource类型) | - | 设置文本尺寸,Length为number类型时,使用fp单位。 | +| fontColor | [ResourceColor](ts-types.md) | - | 设置文本颜色。 | +| fontSize | Length \| [Resource](ts-types.md#resource类型) | - | 设置文本尺寸,Length为number类型时,使用fp单位。 | | fontStyle | [FontStyle](ts-appendix-enums.md#fontstyle) | FontStyle.Normal | 设置文本的字体样式。 | | fontWeight | number \| [FontWeight](ts-appendix-enums.md#fontweight) \| string | FontWeight.FontWeightNormal | 设置文本的字体粗细,number类型取值[100, 900],取值间隔为100,默认为400,取值越大,字体越粗。
提供常用枚举值,参考:FontWeight枚举说明。 | -| fontFamily | string \| [Resource](../../ui/ts-types.md#resource类型) | - | 设置文本的字体列表。使用多个字体,使用','进行分割,优先级按顺序生效。例如:'Arial, sans-serif'。 | +| fontFamily | string \| [Resource](ts-types.md#resource类型) | - | 设置文本的字体列表。使用多个字体,使用','进行分割,优先级按顺序生效。例如:'Arial, sans-serif'。 | ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-touch-target.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-touch-target.md index 5b585a65b09b163afc25758c9fa33cf10edc933d..c8121960143866c9ff82d6395778e91fc4e38c27 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-touch-target.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-touch-target.md @@ -18,10 +18,10 @@ ### Rectangle对象说明 | 名称 | 类型 | 必填 | 描述 | | -------- | -------- | -------- | -------- | -| x | [Length](../../ui/ts-types.md) | 否 | 触摸点相对于组件本身左边沿的X坐标。
默认值:0vp | -| y | [Length](../../ui/ts-types.md) | 否 | 触摸点相对于组件本身左边沿的Y坐标。
默认值:0vp | -| width | [Length](../../ui/ts-types.md) | 否 | 触摸热区范围的宽度。
默认值:100% | -| height | [Length](../../ui/ts-types.md) | 否 | 触摸热区范围的高度。
默认值:100% | +| x | [Length](ts-types.md) | 否 | 触摸点相对于组件本身左边沿的X坐标。
默认值:0vp | +| y | [Length](ts-types.md) | 否 | 触摸点相对于组件本身左边沿的Y坐标。
默认值:0vp | +| width | [Length](ts-types.md) | 否 | 触摸热区范围的宽度。
默认值:100% | +| height | [Length](ts-types.md) | 否 | 触摸热区范围的高度。
默认值:100% | > **说明:** > diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-component-area-change-event.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-component-area-change-event.md index 361699d2968608ae2aef7dc3eb9a9831145d3a8c..fd3bdbfd3487b506731ebf1327c8aaf901cc6acd 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-component-area-change-event.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-component-area-change-event.md @@ -15,7 +15,7 @@ | 名称 | 支持冒泡 | 功能描述 | | ---------------------------------------- | ---- | ---------------------------------------- | -| onAreaChange(event: (oldValue: Area, newValue: Area) => void) | 否 | 组件区域变化时触发该回调,Area类型描述见[Area](../../ui/ts-types.md#area8)。 | +| onAreaChange(event: (oldValue: Area, newValue: Area) => void) | 否 | 组件区域变化时触发该回调,Area类型描述见[Area](ts-types.md#area8)。 | ## 示例 diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-click.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-click.md index 25e644f73d8a6523b051bea972a7aeff328c7f82..e6ad83abb7786c64549103654b6848754654b878 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-click.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-click.md @@ -26,7 +26,7 @@ ## EventTarget8+对象说明 | 名称 | 参数类型 | 描述 | | ---- | ----------------- | ---------- | -| area | [Area](../../ui/ts-types.md#area8) | 目标元素的区域信息。 | +| area | [Area](ts-types.md#area8) | 目标元素的区域信息。 | diff --git a/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-drag-drop.md b/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-drag-drop.md index 4d6b2525e46f9cf5f1b716cfbb645a2cab61867d..646fee2de66c7cb9a00ebe2b08437e4ede77b088 100644 --- a/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-drag-drop.md +++ b/zh-cn/application-dev/reference/arkui-ts/ts-universal-events-drag-drop.md @@ -9,7 +9,7 @@ | 名称 | 支持冒泡 | 功能描述 | | ---------------------------------------- | ---- | ---------------------------------------- | -| onDragStart(event: (event?: DragEvent, extraParams?: string) =>  [CustomBuilder](../../ui/ts-types.md#custombuilder8)) \| DragItemInfo | 否 | 第一次拖拽此事件绑定的组件时,触发回调。
- event:拖拽事件信息,包括拖拽点坐标。
- extraParams:拖拽事件额外信息,详见extraParam类型描述。
返回值:当前跟手效果所拖拽的对象,用于显示拖拽时的提示组件。
长按150毫秒(ms)可触发拖拽事件。优先级:长按手势配置时间小于等于150毫秒(ms)时,长按手势优先触发,否则拖拽事件优先触发。 | +| onDragStart(event: (event?: DragEvent, extraParams?: string) =>  [CustomBuilder](ts-types.md#custombuilder8)) \| DragItemInfo | 否 | 第一次拖拽此事件绑定的组件时,触发回调。
- event:拖拽事件信息,包括拖拽点坐标。
- extraParams:拖拽事件额外信息,详见extraParam类型描述。
返回值:当前跟手效果所拖拽的对象,用于显示拖拽时的提示组件。
长按150毫秒(ms)可触发拖拽事件。优先级:长按手势配置时间小于等于150毫秒(ms)时,长按手势优先触发,否则拖拽事件优先触发。 | | onDragEnter(event: (event?: DragEvent, extraParams?: string) => void) | 否 | 拖拽进入组件范围内时,触发回调。
- event:拖拽事件信息,包括拖拽点坐标。
- extraParams:拖拽事件额外信息,详见extraParam类型描述。
当监听了onDrop事件时,此事件才有效。 | | onDragMove(event: (event?: DragEvent, extraParams?: string) => void) | 否 | 拖拽在组件范围内移动时,触发回调。
- event:拖拽事件信息,包括拖拽点坐标。
- extraParams:拖拽事件额外信息,详见extraParam类型描述。
当监听了onDrop事件时,此事件才有效。 | | onDragLeave(event: (event?: DragEvent, extraParams?: string) => void) | 否 | 拖拽离开组件范围内时,触发回调。
- event:拖拽事件信息,包括拖拽点坐标。
- extraParams:拖拽事件额外信息,详见extraParam类型描述。
当监听了onDrop事件时,此事件才有效。 | @@ -19,7 +19,7 @@ | 属性名称 | 属性类型 | 必填 | 描述 | | ------------- | ------ | ------- |--------------------------------- | | pixelMap | [PixelMap](../apis/js-apis-image.md#pixelmap7) | 否 | 设置拖拽过程中显示的图片。 | - | builder | [CustomBuilder](../../ui/ts-types.md#custombuilder8) | 否 | 使用自定义生成器进行绘图,如果设置了pixelMap,则忽略此值。 | + | builder | [CustomBuilder](ts-types.md#custombuilder8) | 否 | 使用自定义生成器进行绘图,如果设置了pixelMap,则忽略此值。 | | extraInfo | string | 否 | 拖拽项的描述。 | diff --git a/zh-cn/application-dev/reference/js-service-widget-ui/js-service-widget-common-atomic-layout.md b/zh-cn/application-dev/reference/js-service-widget-ui/js-service-widget-common-atomic-layout.md index 81d672704b3ea750ae1e07e67f8baa9903e0c996..87aef492b94a58c47ab36426b5fa502f9eb0134d 100644 --- a/zh-cn/application-dev/reference/js-service-widget-ui/js-service-widget-common-atomic-layout.md +++ b/zh-cn/application-dev/reference/js-service-widget-ui/js-service-widget-common-atomic-layout.md @@ -1,6 +1,6 @@ # 原子布局 -在屏幕形态和规格不同等情况下,布局效果需要实现自适应,因此系统提供了面向不同屏幕尺寸界面自适应适配的布局能力,称为原子布局。设计师可以考虑使用原子能力,定义元素在不同形态的尺寸界面上体现的自适应规则。开发者可以使用原子布局能力,快速实现让应用在多形态屏幕上有与设计效果相匹配的自适应效果。 +在屏幕形态和规格不同等情况下,布局效果需要实现自适应,因此系统提供了面向不同屏幕尺寸的自适应布局能力,称为原子布局。设计师可以考虑使用原子能力,定义元素在不同形态的尺寸界面上体现的自适应规则。开发者可以使用原子布局能力,快速实现让应用在多形态屏幕上有与设计效果相匹配的自适应效果。 > **说明:** @@ -12,24 +12,24 @@ 在非折行flex布局基础上,增加了显示优先级标记,可以调整组件内元素水平/垂直方向的显示优先级,根据当前组件容器的可用空间来显示内容。 -| 样式 | 类型 | 默认值 | 说明 | -| -------- | -------- | -------- | -------- | -| display-index | number | 0 | 适用于div等支持flex布局的容器组件中的子组件上,当容器组件在flex主轴上尺寸不足以显示全部内容时,按照display-index值从小到大的顺序进行隐藏,具有相同display-index值的组件同时隐藏,默认值为0,表示隐藏。 | +| 样式 | 类型 | 默认值 | 说明 | +| ------------- | ------ | ---- | ---------------------------------------- | +| display-index | number | 0 | 适用于div等支持flex布局的容器组件中的子组件上,当容器组件在flex主轴上尺寸不足以显示全部内容时,按照display-index值从小到大的顺序进行隐藏,具有相同display-index值的组件同时隐藏,默认值为0,表示隐藏。 | ## 占比能力 在非折行的flex布局中,定义了占比能力的组件,保证指定元素始终在容器的某一个比例空间中进行布局。 -| 样式 | 类型 | 默认值 | 说明 | -| -------- | -------- | -------- | -------- | -| flex-weight | number | - | 指明当前元素在flex主轴方向上尺寸权值,当且仅当容器组件中所有节点均设置此属性时生效,当前元素尺寸为: 容器主轴尺寸 \* 当前权值 / 所有子元素权值和。 | +| 样式 | 类型 | 默认值 | 说明 | +| ----------- | ------ | ---- | ---------------------------------------- | +| flex-weight | number | - | 指明当前元素在flex主轴方向上尺寸权值,当且仅当容器组件中所有节点均设置此属性时生效,当前元素尺寸为: 容器主轴尺寸 \* 当前权值 / 所有子元素权值和。 | ## 固定比例 定义了组件固定比例调整尺寸的能力。 -| 样式 | 类型 | 默认值 | 说明 | -| -------- | -------- | -------- | -------- | -| aspect-ratio | number | - |  接受任意大于0的浮点值,定义为该节点的宽度与高度比,设置该属性后,该元素尺寸宽高比按照此属性值进行调整。
 遵守最大值与最小值的限制。
 在flex布局中,主轴尺寸先进行调整,后根据该尺寸调整交叉轴。 | +| 样式 | 类型 | 默认值 | 说明 | +| ------------ | ------ | ---- | ---------------------------------------- | +| aspect-ratio | number | - |  接受任意大于0的浮点值,定义为该节点的宽度与高度比,设置该属性后,该元素尺寸宽高比按照此属性值进行调整。
 遵守最大值与最小值的限制。
 在flex布局中,主轴尺寸先进行调整,后根据该尺寸调整交叉轴。 | diff --git a/zh-cn/application-dev/security/accesstoken-guidelines.md b/zh-cn/application-dev/security/accesstoken-guidelines.md index cbb6e712bf1daab57612a278749cf57b71742f7a..4f6ff8eb4951782e77c4b334d5c1bfab305d077b 100644 --- a/zh-cn/application-dev/security/accesstoken-guidelines.md +++ b/zh-cn/application-dev/security/accesstoken-guidelines.md @@ -88,10 +88,10 @@ "name" : "ohos.permission.PERMISSION1", "reason": "$string:reason", "usedScene": { - "abilities": [ - "FormAbility" - ], - "when":"inuse" + "abilities": [ + "FormAbility" + ], + "when":"inuse" } }, { @@ -101,7 +101,7 @@ "abilities": [ "FormAbility" ], - "when":"always" + "when":"always" } } ] diff --git a/zh-cn/application-dev/security/huks-guidelines.md b/zh-cn/application-dev/security/huks-guidelines.md index def1398ca152a1b273f00943778863fa55565e7e..43bd962a534a2197c58c8df71631d7ec8e044b48 100644 --- a/zh-cn/application-dev/security/huks-guidelines.md +++ b/zh-cn/application-dev/security/huks-guidelines.md @@ -163,7 +163,7 @@ RSA512, RSA768, RSA1024, RSA2048, RSA3072, RSA4096, ECC224, ECC256, ECC384, ECC5 | huksOptions | HuksOptions | 是 | 用于存放生成key所需TAG。 | | encryptOptions | HuksOptions | 是 | 用于存放导入key所需TAG。 | -关于接口的具体信息,可在[API参考文档](..\reference\apis\js-apis-huks.md)中查看。 +关于接口的具体信息,可在[API参考文档](../reference/apis/js-apis-huks.md)中查看。 **示例:** @@ -294,7 +294,7 @@ AES128, AES192, AES256, RSA512, RSA768, RSA1024, RSA2048, RSA3072, RSA4096, Hmac | genWrapOptions | HuksOptions | 是 | 用于存放生成加密协商key所需TAG。 | | importOptions | HuksOptions | 是 | 用于存放导入加密key所需TAG。 | -关于接口的具体信息,可在[API参考文档](..\reference\apis\js-apis-huks.md)中查看。 +关于接口的具体信息,可在[API参考文档](../reference/apis/js-apis-huks.md)中查看。 **示例:** @@ -544,7 +544,7 @@ function huksImportWrappedKey() { | encryptOptions | HuksOptions | 是 | 用于存放加密key所需TAG。 | | decryptOptions | HuksOptions | 是 | 用于存放解密key所需TAG。 | -关于接口的具体信息,可在[API参考文档](..\reference\apis\js-apis-huks.md)中查看。 +关于接口的具体信息,可在[API参考文档](../reference/apis/js-apis-huks.md)中查看。 **示例1:** @@ -946,7 +946,7 @@ Update过程只将inData发送到Core中记录在ctx中,不进行Hash计算, | rsaSignOptionsSecond | HuksOptions | 是 | 用于存放签名key所需TAG。 | | rsaVerifyOptions | HuksOptions | 是 | 用于存放验签key所需TAG。 | -关于接口的具体信息,可在[API参考文档](..\reference\apis\js-apis-huks.md)中查看。 +关于接口的具体信息,可在[API参考文档](../reference/apis/js-apis-huks.md)中查看。 **示例:** @@ -1176,7 +1176,7 @@ HksFinish对paramSet中参数的要求: | finishOptionsFrist | HuksOptions | 是 | 用于存放协商key所需TAG。 | | finishOptionsSecond | HuksOptions | 是 | 用于存放协商key所需TAG,用于结果对比。 | -关于接口的具体信息,可在[API参考文档](..\reference\apis\js-apis-huks.md)中查看。 +关于接口的具体信息,可在[API参考文档](../reference/apis/js-apis-huks.md)中查看。 **示例:** @@ -1407,7 +1407,7 @@ HksFinish对paramSet中参数的要求: | huksOptions | HuksOptions | 是 | 生成密钥参数集。 | | finishOptions | HuksOptions | 是 | 派生密钥参数集。 | -关于接口的具体信息,可在[API参考文档](..\reference\apis\js-apis-huks.md)中查看。 +关于接口的具体信息,可在[API参考文档](../reference/apis/js-apis-huks.md)中查看。 **示例:** @@ -1579,7 +1579,7 @@ HksInit对paramSet中参数的要求,其他三段式接口对paramSet无要求 | srcKeyAlias | string | 是 | 生成密钥别名。 | | huksOptions | HuksOptions | 是 | 密钥参数集。 | -关于接口的具体信息,可在[API参考文档](..\reference\apis\js-apis-huks.md)中查看。 +关于接口的具体信息,可在[API参考文档](../reference/apis/js-apis-huks.md)中查看。 **示例:** @@ -1693,7 +1693,7 @@ RSA512, RSA768, RSA1024, RSA2048, RSA3072, RSA4096, ECC224, ECC256, ECC384, ECC5 | keyAlias | string | 是 | 密钥别名,存放待获取证书密钥的别名。 | | options | HuksOptions | 是 | 用于获取证书时指定所需参数与数据。 | -关于接口的具体信息,可在[API参考文档](..\reference\apis\js-apis-huks.md)中查看。 +关于接口的具体信息,可在[API参考文档](../reference/apis/js-apis-huks.md)中查看。 **示例:** @@ -1832,7 +1832,7 @@ RSA512, RSA768, RSA1024, RSA2048, RSA3072, RSA4096, ECC224, ECC256, ECC384, ECC5 | keyAlias | string | 是 | 密钥别名,存放待获取证书密钥的别名。 | | options | HuksOptions | 是 | 用于获取证书时指定所需参数与数据。 | -关于接口的具体信息,可在[API参考文档](..\reference\apis\js-apis-huks.md)中查看。 +关于接口的具体信息,可在[API参考文档](../reference/apis/js-apis-huks.md)中查看。 **示例:** diff --git a/zh-cn/application-dev/ui/Readme-CN.md b/zh-cn/application-dev/ui/Readme-CN.md index f4876392b3cbd07103959dd697762a9bcf32df44..7bc13823db69b4e6281a09cd09e433ff997ef734 100755 --- a/zh-cn/application-dev/ui/Readme-CN.md +++ b/zh-cn/application-dev/ui/Readme-CN.md @@ -12,7 +12,6 @@ - [资源文件的分类](ui-ts-basic-resource-file-categories.md) - [资源访问](ts-resource-access.md) - [像素单位](ts-pixel-units.md) - - [类型定义](ts-types.md) - 声明式语法 - [描述规范使用说明](ts-syntax-intro.md) - 通用UI描述规范 diff --git a/zh-cn/application-dev/ui/ts-types.md b/zh-cn/application-dev/ui/ts-types.md deleted file mode 100644 index 39b84c43e101fed069a02a52519bb72813043a71..0000000000000000000000000000000000000000 --- a/zh-cn/application-dev/ui/ts-types.md +++ /dev/null @@ -1,217 +0,0 @@ -# 类型定义 - -## Resource - -资源引用类型,用于设置组件属性的值。 - -可以通过`$r`或者`$rawfile`创建Resource类型对象,不可以修改Resource中的各属性的值。 - -- `$r('belonging.type.name')` - - belonging:系统资源或者应用资源,相应的取值为'sys'和'app'; - - type:资源类型,支持'color'、'float'、'string'、'media'等; - - name:资源名称,在资源定义时确定。 - -- `$rawfile('filename')` - - filename:工程中resources/rawfile目录下的文件名称。 - -## Length - -长度类型,用于描述尺寸单位。 - -| 类型 | 说明 | -| -------- | ------------------------------------------------------------ | -| string | 需要显式指定像素单位,如'10px',也可设置百分比字符串,如'100%'。 | -| number | 默认单位vp。 | -| Resource | 使用引入资源的方式,引入系统资源或者应用资源中的尺寸。 | - -## ResourceStr8+ - -字符串类型,用于描述字符串入参可以使用的类型。 - -| 类型 | 说明 | -| -------- | --------------------------------------------------- | -| string | 字符串类型。 | -| Resource | 使用引入资源的方式,引入系统资源或者应用资源中的字符串。 | - -## Padding - -内边距类型,用于描述组件不同方向的内边距。 - - | 名称 | 类型 | 必填 | 说明 | - | ------- | ------ | ---- |------------------------ | - | top | Length | 否 | 组件内元素距组件顶部的尺寸。 | - | right | Length | 否 | 组件内元素距组件右边界的尺寸。 | - | bottom | Length | 否 | 组件内元素距组件底部的尺寸。 | - | left | Length | 否 | 组件内元素距组件左边界的尺寸。 | - -## Margin - -外边距类型,用于描述组件不同方向的外边距。 - - | 名称 | 类型 | 必填 | 说明 | - | ------- | ------ | ---- |------------------------ | - | top | Length | 否 | 组件外元素距组件顶部的尺寸。 | - | right | Length | 否 | 组件外元素距组件右边界的尺寸。 | - | bottom | Length | 否 | 组件外元素距组件底部的尺寸。 | - | left | Length | 否 | 组件外元素距组件左边界的尺寸。 | - -## EdgeWidths9+ - -边框宽度类型,用于描述组件边框不同方向的宽度。 - - | 名称 | 类型 | 必填 | 说明 | - | ------- | ------ | ---- |--------------------- | - | top | Length | 否 | 组件上边框宽度。 | - | right | Length | 否 | 组件右边框宽度。 | - | bottom | Length | 否 | 组件下边框宽度。 | - | left | Length | 否 | 组件左边框宽度。 | - -## BorderRadiuses9+ - -圆角类型,用于描述组件边框圆角半径。 - - | 名称 | 类型 | 必填 | 说明 | - | ----------- | ------ | ---- |--------------------- | - | topLeft | Length | 否 | 组件左上角圆角半径。 | - | topRight | Length | 否 | 组件右上角圆角半径。 | - | bottomLeft | Length | 否 | 组件左下角圆角半径。 | - | bottomRight | Length | 否 | 组件右下角圆角半径。 | - -## EdgeColors9+ - -边框颜色,用于描述组件边框四条边的颜色。 - - | 名称 | 类型 | 必填 | 说明 | - | ------- | --------------- | ---- |--------------------- | - | top | ResourceColor | 否 | 组件上边框颜色。 | - | right | ResourceColor | 否 | 组件右边框颜色。 | - | bottom | ResourceColor | 否 | 组件下边框颜色。 | - | left | ResourceColor | 否 | 组件左边框颜色。 | - -## EdgeStyles9+ - -边框样式,用于描述组件边框四条边的样式。 - - | 名称 | 类型 | 必填 | 说明 | - | ------- | ------------- | ---- |--------------------- | - | top | BorderStyle | 否 | 组件上边框样式。 | - | right | BorderStyle | 否 | 组件右边框样式。 | - | bottom | BorderStyle | 否 | 组件下边框样式。 | - | left | BorderStyle | 否 | 组件左边框样式。 | - - -## Offset - -相对布局完成位置坐标偏移量。 - - | 名称 | 类型 | 必填 | 说明 | - | -------- | ------ | ---- |--------------------- | - | dx | Length | 是 | 水平方向偏移量。 | - | dy | Length | 是 | 竖直方向偏移量。 | - -## ResourceColor8+ - -颜色类型,用于描述资源颜色类型。 - -| 类型 | 说明 | -| -------- | ----------------------- | -| [Color](../reference/arkui-ts/ts-appendix-enums.md#color) | 颜色枚举值。 | -| number | HEX格式颜色。 | -| string | rgb或者rgba格式颜色。 | -| Resource | 使用引入资源的方式,引入系统资源或者应用资源中的颜色。 | - -## LengthConstrain - -长度约束,用于对组件最大、最小长度做限制。 - - | 名称 | 类型 | 必填 | 说明 | - | --------- | ------ | ---- |---------------- | - | minLength | Length | 是 | 组件最小长度。 | - | maxLength | Length | 是 | 组件最大长度。 | - - -## Font - -设置文本样式。 - -| 名称 | 类型 | 必填 | 说明 | -| ------ | ------------------------------ | ---- | ------------------------------------------------------------ | -| size | [Length](#length) | 否 | 设置文本尺寸,Length为number类型时,使用fp单位。 | -| weight | [FontWeight](../reference/arkui-ts/ts-appendix-enums.md#fontweight) \| number \| string | 否 | 设置文本的字体粗细,number类型取值[100, 900],取值间隔为100,默认为400,取值越大,字体越粗。 | -| family | string \| [Resource](#resource) | 否 | 设置文本的字体列表。使用多个字体,使用','进行分割,优先级按顺序生效。例如:'Arial, sans-serif'。 | -| style | [FontStyle](../reference/arkui-ts/ts-appendix-enums.md#fontstyle) | 否 | 设置文本的字体样式。 | - -## Area8+ - -区域类型,用于存储元素所占区域信息 - -| 名称 | 类型 | 说明 | -| -------------- | -------- | ------------------------------------------------- | -| width | [Length](#length) | 目标元素的宽度,作为返回值时,类型为number,单位vp。 | -| height | [Length](#length) | 目标元素的高度,作为返回值时,类型为number,单位vp。 | -| position | [Position](#position8) | 目标元素左上角相对父元素左上角的位置。 | -| globalPosition | [Position](#position8) | 目标元素左上角相对页面左上角的位置。 | - - -## Position8+ - -位置类型,用于表示一个坐标点。 - -| 名称 | 类型 | 必填 | 说明 | -| ----- | ------- | ---- | ------------------------------------------- | -| x | Length | 否 | x轴坐标,作为返回值时,类型为number,单位vp。 | -| y | Length | 否 | y轴坐标,作为返回值时,类型为number,单位vp。 | - -## ConstraintSizeOptions - -设置约束尺寸,组件布局时,进行尺寸范围限制。 - -| 名称 | 类型 | 必填 | 说明 | -| --------- | -------- | ---- | -------------- | -| minWidth | Length | 否 | 元素最小宽度。 | -| maxWidth | Length | 否 | 元素最大宽度。 | -| minHeight | Length | 否 | 元素最小高度。 | -| maxHeight | Length | 否 | 元素最大高度。 | - -## SizeOptions - -设置宽高尺寸。 - -| 名称 | 类型 | 必填 | 说明 | -| ------- | -------- | ---- | -------------- | -| width | Length | 否 | 元素宽度。 | -| height | Length | 否 | 元素高度。 | - - -## BorderOptions - -边框属性集合,用于描述边框相关信息。 - -| 名称 | 类型 | 必填 | 说明 | -| ------ | ----------------------- | ---- | ----------- | -| width | Length \| EdgeWidths9+ | 否 | 边框宽度。 | -| color | ResourceColor \| EdgeColors9+ | 否 | 边框颜色。 | -| radius | Length \| BorderRadiuses9+ | 否 | 边框圆角半径。 | -| style | [BorderStyle](../reference/arkui-ts/ts-appendix-enums.md#borderstyle) \| EdgeStyles9+ | 否 | 边框样式。 | - -## ColorFilter9+ - -创建具有4*5矩阵的颜色过滤器。 - -| 名称 | 类型 | 必填 | 描述 | -| ----------- | -------- | ------ | --------------------------------------------------------------- | -| constructor | number[] | 是 | 创建具有4*5矩阵的颜色过滤器, 入参为[m*n]位于m行和n列中矩阵值, 矩阵是行优先的。 | - - -## CustomBuilder8+ - -组件属性方法参数可使用CustomBuilder类型来自定义UI描述。 - -| 名称 | 类型定义 | 描述 | -| ------------- | ---------------------- | ------------------------------------------------------------ | -| CustomBuilder | () => any | 这种方法类型必须使用@Builder装饰器修饰。具体用法见[@Builder](ts-component-based-builder.md)。 | - diff --git a/zh-cn/application-dev/ui/ui-js-components-stepper.md b/zh-cn/application-dev/ui/ui-js-components-stepper.md index 6efaf995e06f4f94cce553c980f226c8ff9460ca..e85191d8534b7b53bb41d52c0593380ac8a9ee9d 100644 --- a/zh-cn/application-dev/ui/ui-js-components-stepper.md +++ b/zh-cn/application-dev/ui/ui-js-components-stepper.md @@ -268,12 +268,14 @@ export default { stepperChange(e){ console.log("stepperChange"+e.index) prompt.showToast({ + // index表示当前步骤的序号 message: 'Previous step: '+e.prevIndex+"-------Current step:"+e.index }) }, stepperNext(e){ console.log("stepperNext"+e.index) prompt.showToast({ + // pendingIndex表示将要跳转的序号 message: 'Current step:'+e.index+"-------Next step:"+e.pendingIndex }) var index = {pendingIndex:e.pendingIndex } diff --git a/zh-cn/application-dev/ui/ui-ts-layout-grid-container.md b/zh-cn/application-dev/ui/ui-ts-layout-grid-container.md index f704864a0d06017cd72fd67752caa776ef2145f6..e2cb433592b7c5e3c6240bcce1dbae9d4c6564bf 100644 --- a/zh-cn/application-dev/ui/ui-ts-layout-grid-container.md +++ b/zh-cn/application-dev/ui/ui-ts-layout-grid-container.md @@ -70,7 +70,7 @@ Text('1') .useSizeType({ xs: { span: 2, offset: 0 }, - sm: { span: 2, offset: 0 }, + sm: { span: 3, offset: 0 }, md: { span: 6, offset: 2 }, lg: { span: 8, offset: 2 }, }) @@ -90,7 +90,7 @@ GridContainer() { Text('1') .useSizeType({ xs: { span: 2, offset: 0 }, - sm: { span: 0, offset: 0 }, + sm: { span: 2, offset: 0 }, md: { span: 6, offset: 2 }, lg: { span: 8, offset: 2 }, }) diff --git a/zh-cn/application-dev/website.md b/zh-cn/application-dev/website.md index 08c82d3c8d3f22143657f4d193f9dec9b826c045..97ebf08af66d0804d5ccad14879cc62e5120adcd 100644 --- a/zh-cn/application-dev/website.md +++ b/zh-cn/application-dev/website.md @@ -370,7 +370,7 @@ - 工具 - [DevEco Studio(OpenHarmony)使用指南](quick-start/deveco-studio-user-guide-for-openharmony.md) - 示例教程 - - [示例代码](https://gitee.com/openharmony/app_samples/blob/master/README_zh.md) + - [示例代码](https://gitee.com/openharmony/applications_app_samples/blob/master/README_zh.md) - [Codelabs](https://gitee.com/openharmony/codelabs/blob/master/README.md) - API参考 - 组件参考(基于TS扩展的声明式开发范式) diff --git a/zh-cn/contribute/template/ts-template.md b/zh-cn/contribute/template/ts-template.md index 0eb2d04107f5c2ce0d250cc2cc2866b232d6f8df..bd2076bc45b2f23fc98729df97c4a9415099ddc4 100644 --- a/zh-cn/contribute/template/ts-template.md +++ b/zh-cn/contribute/template/ts-template.md @@ -15,9 +15,9 @@ | 9 | 权限说明 | 以二级标题的形式,标题名为“需要权限”
1. 如果仅系统应用可申请,格式:
ohos.permission.xxxx,仅系统应用可用。
2. 如果该权限所有应用可申请,格式:
ohos.permission.xxxx
3. 如果该接口涉及多个权限,则采用“和、或”进行分割,格式:
ohos.permission.A 和 ohos.permission.B
ohos.permission.A 或 ohos.permission.B | | 10 | @system api | 1. 如果某个模块全部接口均为system api,则在模块开头的版本说明下一行,增加:
- 本模块接口为系统接口。
2. 如果某个接口为system api,仅供OEM厂商使用,则需要在描述中增加:
**系统接口:** 此接口为系统接口。 | | 11 | 示例代码语言 | 所有的示例代码采用代码块的样式,并标记开发语言为ts,且在示例代码最开始添加注释`// xxx.ets` | -| 12 | 链接写法 | 格式:[链接文字]\(链接内容)
跨文件夹链接:[指南]\(\.\./../xxx/xxx.md),一个`../`表示上移一层文件夹。
页面内链接:[接口A7+]\(#xxxa7),页面内链接和需要链接到的标题保持一致,全小写无特殊符号无标签。 | +| 12 | 链接写法 | 格式:[链接文字]\(链接内容)
跨文件夹链接:[指南]\(\.\./../xxx/xxx.md),一个`../`表示上移一层文件夹。
页面内链接:[接口A7+]\(#xxxa7),页面内链接和需要链接到的标题保持一致,全小写无特殊符号(-除外)无标签。 | -下面进入具体每个API的写作。 +下面进入具体每个组件接口的写作。 *** @@ -25,7 +25,7 @@ > *写作说明* > -> 1. **文档标题**:作为文档标题,要求使用中文短语概括本组件功能;但如果部分概念使用英文更便于开发者理解,可以直接使用。如Button、Silder等。 +> 1. **文档标题**:作为文档标题,要求使用中文短语概括本组件功能;但如果部分概念使用英文更便于开发者理解,可以直接使用。如Button、Slider等。 > 2. **标题层级**:文档标题为一级标题,使用`# `;其他字段如function、class、interface、enum、type为二级标题,使用`## `;class下的属性、function为三级标题,使用`### `。 > 3. **起始版本说明**:使用markdown的引用语法“>”对接口的起始版本进行说明,说明后需要换行。
版本说明统一放在模块描述之后。一个模块只会有一个起始版本。
采用标准句式:“本模块首批接口从API version x开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。”x需要修改为对应的版本号。 @@ -43,7 +43,7 @@ **举例1**:Marquee -跑马灯组件,用于滚动展示一段单行文本,仅当文本内容宽度朝国跑马灯组件宽度时滚动。 +跑马灯组件,用于滚动展示一段单行文本,仅当文本内容宽度超过跑马灯组件宽度时滚动。 **举例2**:SideBarContainer diff --git a/zh-cn/design/hdi-design-specifications.md b/zh-cn/design/hdi-design-specifications.md index 03d9969594a2482bbb2e4c44fb7608309e4f6c51..5b20dd0799214d46a45197f8a4eb3b87b6628c3c 100644 --- a/zh-cn/design/hdi-design-specifications.md +++ b/zh-cn/design/hdi-design-specifications.md @@ -14,11 +14,11 @@ **用词约定:** -规则:必须遵守的约定 +规则:必须遵守的约定。 -建议:需要加以考虑的约定 +建议:需要加以考虑的约定。 -说明:对此规则或建议进行相应的解释 +说明:对此规则或建议进行相应的解释。 **文档变更说明:** | 版本 | 变更说明 | @@ -132,7 +132,7 @@ Table 1 接口评审&管控角色 - 对废弃接口增加标识废弃标记。 - - 废弃HDI至少保留4个OpenHarmony API版本 + - 废弃HDI至少保留4个OpenHarmony API版本。 ## 接口设计约束 @@ -158,7 +158,7 @@ Table 1 接口评审&管控角色 int (*OpenLayer)(uint32_t devId, const LayerInfo *layerInfo, uint32_t *layerId); ``` -在调用OpenLayer接口时,根据入参layerInfo创建图层数据内存,并返回layerId +在调用OpenLayer接口时,根据入参layerInfo创建图层数据内存,并返回layerId; ```cpp int (*CloseLayer)(uint32_t devId, uint32_t layerId); @@ -216,14 +216,14 @@ void WriteReady(); #### 【规则】类、结构体、接口方法、参数等采用驼峰命名风格 __驼峰风格(CamelCase)__ 大小写字母混用,单词连在一起,不同单词间通过单词首字母大写来分开。 -按连接后的首字母是否大写,又分: 大驼峰(UpperCamelCase)和小驼峰(lowerCamelCase) +按连接后的首字母是否大写,又分: 大驼峰(UpperCamelCase)和小驼峰(lowerCamelCase)。 | 类型 | 命名风格 | | ---------------------------------------- | --------- | | 接口类型,接口方法,结构体类型,枚举类型,联合体类型等类型定义 | 大驼峰 | | 函数参数,结构体和联合体中的成员变量 | 小驼峰 | -| 常量,枚举值 | 全大写,下划线分割 | +| 常量,枚举值 | 全大写,以下划线分割 | #### 【规则】接口文件应与接口类同名且使用'.idl'文件后缀 - 每个接口类应定义在独立的接口文件中,并使文件命名与接口类保持一致(大驼峰命名),并以`.idl`后缀结尾。 diff --git a/zh-cn/device-dev/hpm-part/hpm-part-development.md b/zh-cn/device-dev/hpm-part/hpm-part-development.md index 9abf5536b8282f1708710c04cd1402d1c992bdf4..a9de88a60b859cb6b544920ba0a1c8b51d5bc8b6 100644 --- a/zh-cn/device-dev/hpm-part/hpm-part-development.md +++ b/zh-cn/device-dev/hpm-part/hpm-part-development.md @@ -180,36 +180,36 @@ hpm init ``` { -"name": "@your/dist_name", -"version": "2.2.0", -"publishAs": "distribution", -"description": "describe it", -"scripts": { -"config_hb": "hb set -root $DEP_BUNDLE_BASE", -"dist": "PATH=/root/.local/bin:${DEP_OHOS_gn}:${DEP_OHOS_ninja}/ninja:${DEP_OHOS_llvm}/llvm/bin:${DEP_OHOS_hc_gen}/hc-gen:${PATH} && ./scripts/dist.sh" -}, -"envs": { -"debug": false -}, -"dirs": { -"scripts": "scripts/*" -}, -"dependencies": { -"@ohos/build_lite": "2.2.0", -"@ohos/gn": "1.1.1", -"@ohos/llvm": "1.1.1", -"@ohos/hc_gen": "1.1.0", -"@ohos/ninja": "1.1.0", -...... -}, -"ohos": { -"os": "2.2-Beta", -"board": "hi3516", -"kernel": "liteos-a" -}, -"keywords": [ "hispark", "hi3516" ], -"repository": "https://gitee.com/openharmony/your-project", -"license": "Apache V2" + "name": "@your/dist_name", + "version": "2.2.0", + "publishAs": "distribution", + "description": "describe it", + "scripts": { + "config_hb": "hb set -root $DEP_BUNDLE_BASE", + "dist": "PATH=/root/.local/bin:${DEP_OHOS_gn}:${DEP_OHOS_ninja}/ninja:${DEP_OHOS_llvm}/llvm/bin:${DEP_OHOS_hc_gen}/hc-gen:${PATH} && ./scripts/dist.sh" + }, + "envs": { + "debug": false + }, + "dirs": { + "scripts": "scripts/*" + }, + "dependencies": { + "@ohos/build_lite": "2.2.0", + "@ohos/gn": "1.1.1", + "@ohos/llvm": "1.1.1", + "@ohos/hc_gen": "1.1.0", + "@ohos/ninja": "1.1.0", + ...... + }, + "ohos": { + "os": "2.2-Beta", + "board": "hi3516", + "kernel": "liteos-a" + }, + "keywords": ["hispark", "hi3516"], + "repository": "https://gitee.com/openharmony/your-project", + "license": "Apache V2" } ``` @@ -371,7 +371,7 @@ project ``` { -"dependencies": { + "dependencies": { "@scope/the_bundle": "^1.0.0" } } @@ -382,7 +382,7 @@ project ``` { -"dependencies": { + "dependencies": { "@scope/the_bundle1": "^1.0.0", "@scope/the_bundle2": "^2.0.0", "@scope/the_bundle3": "^3.0.0", diff --git a/zh-cn/device-dev/porting/porting-dayu200-on_standard-demo.md b/zh-cn/device-dev/porting/porting-dayu200-on_standard-demo.md index 6bdd613d31f4ec4b58aa8713a047c227b79afb05..e7257b14a34f48719f7bf5146d3118d97e2e5568 100755 --- a/zh-cn/device-dev/porting/porting-dayu200-on_standard-demo.md +++ b/zh-cn/device-dev/porting/porting-dayu200-on_standard-demo.md @@ -607,7 +607,7 @@ ADM结构框图如下,Audio Peripheral Drivers和Platform Drivers为平台适 - Rk809DeviceInit,读取hcs文件,初始化Codec寄存器,同时将对应的control配置(/* reg, rreg, shift, rshift, min, max, mask, invert, value */添加到kcontorl,便于dispatch contro进行控制 - Rk809DaiStartup, 读取hcs文件,配置可选设备(codec/accessory)的控制寄存器 - - Rk809DaiHwParams, 根据HAL下发的audio attrs(采样率、format、channel等),配置对应的寄存器 + - Rk809DaiHwParams, 根据hal下发的audio attrs(采样率、format、channel等),配置对应的寄存器 - RK809NormalTrigger,根据hal下发的操作命令码,操作对应的寄存器,实现Codec的启动停止、录音和放音的切换等 ##### DAI(i2s)模块 @@ -758,7 +758,7 @@ ops函数相关函数 3. Rk3568DmaConfigChannel ``` - 设置通道配置参数 + //设置通道配置参数 // 放音通道参数配置 slave_config.direction = DMA_MEM_TO_DEV; slave_config.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; @@ -770,7 +770,7 @@ ops函数相关函数 slave_config.src_addr = I2S1_ADDR + I2S_RXDR; slave_config.src_maxburst = 8; - 使用Linux DMA原生接口函数完成DMA通道配置 + //使用Linux DMA原生接口函数完成DMA通道配置 ret = dmaengine_slave_config(dmaChan, &slave_config); if (ret != 0) { AUDIO_DEVICE_LOG_ERR("dmaengine_slave_config failed"); @@ -783,9 +783,11 @@ ops函数相关函数 使用Linux DMA原生接口函数dmaengine_prep_dma_cyclic,初始化一个具体的周期性的DMA传输描述符dmaengine_submit接口将该描述符放到传输队列上,然后调用dma_async_issue_pending接口,启动传输。 5. Rk3568PcmPointer + +第4步完成之后,ADM框架调用Rk3568PcmPointer,循环写cirBuf,计算pointer ``` - 第4步完成之后,ADM框架调用Rk3568PcmPointer,循环写cirBuf,计算pointer + dma_chn = dmaRtd->dmaChn[DMA_TX_CHANNEL]; buf_size = data->renderBufInfo.cirBufSize; dmaengine_tx_status(dma_chn, dmaRtd->cookie[DMA_TX_CHANNEL], &dma_state); diff --git a/zh-cn/device-dev/porting/porting-minichip-overview.md b/zh-cn/device-dev/porting/porting-minichip-overview.md index 2b0ad4f6134ff6db5ae706409705a9fa70a5bff3..6680ac44d9676e36b61e5d7d354eec0f9db2fe64 100644 --- a/zh-cn/device-dev/porting/porting-minichip-overview.md +++ b/zh-cn/device-dev/porting/porting-minichip-overview.md @@ -38,13 +38,13 @@ | 名词 | 介绍 | | -------- | -------- | -| 子系统 | 是一个逻辑概念,它由一个或多个具体的组件组成。OpenHarmony整体遵从分层设计,从下向上依次为:内核层、系统服务层、框架层和应用层。系统功能按照“系统 > 子系统 > 组件”逐级展开,在多设备部署场景下,支持根据实际需求裁剪某些非必要的子系统或组件。 | +| 子系统 | 是一个逻辑概念,它由一个或多个具体的部件组成。OpenHarmony整体遵从分层设计,从下向上依次为:内核层、系统服务层、框架层和应用层。系统功能按照“系统 > 子系统 > 部件”逐级展开,在多设备部署场景下,支持根据实际需求裁剪某些非必要的子系统或部件。 | | 部件 | 系统最小的可复用、可配置、可裁剪的功能单元。部件具备目录独立可并行开发、可独立编译、可独立测试的特征。 | | hb | OpenHarmony的命令行工具,用来执行编译命令。 | | DP平台 | Devicepartner缩写,即华为智能硬件合作伙伴平台,为生态合作伙伴提供产品开发、认证、发布等一站式服务的平台。 | | IR平台 | Developers IssueReporter缩写,是由华为运营的、面向所有华为开发者用户的产品服务平台。 | | HOBT | HiLink SDK OHOS Basic Test缩写,是HiLink SDK 接入 OpenHarmony的基础功能测试,检验HiLink SDK依赖的相关接口功能是否完善。 | | Token | 伙伴从[合作伙伴平台](https://devicepartner.huawei.com/cn/)申请的设备身份凭据,每个设备唯一;需要在产线上逐个设备写入,用来标识设备是经过华为授权的。 | -| Kit Framework | Kit Framework是Kit的基础框架,包含了OpenHarmony的安全组件,不可裁剪。 | +| Kit Framework | Kit Framework是Kit的基础框架,包含了OpenHarmony的安全部件,不可裁剪。 | | HiLink SDK | HarmonyOS Connect套件的一个关键组成部分,用于实现设备的联网,以及设备与HarmonyOS Connect云和智慧生活App的互联互通。 | | kv | 键值对(key-value),描述数据存储的格式。 | diff --git a/zh-cn/device-dev/porting/porting-minichip-subsys-filesystem.md b/zh-cn/device-dev/porting/porting-minichip-subsys-filesystem.md index fc2d572e5dfcdabbcb13f5235b2a35f9b71ced5d..5678f5706b99eca9919ad6c318e81347ea0b79f2 100644 --- a/zh-cn/device-dev/porting/porting-minichip-subsys-filesystem.md +++ b/zh-cn/device-dev/porting/porting-minichip-subsys-filesystem.md @@ -88,9 +88,7 @@ lite_component("file") { { "subsystem": "utils", "components": [ - { "component": "file", "features":[] }, - { "component": "kv_store", "features":[] }, - { "component": "os_dump", "features":[] } + { "component": "file", "features":[] } ] }, ``` diff --git a/zh-cn/device-dev/porting/porting-minichip-subsys-overview.md b/zh-cn/device-dev/porting/porting-minichip-subsys-overview.md index a42474f82ed441079af1355072b0339137f588ba..c4f72cb8c976770a82e867f376b25e3f49a3f3c5 100644 --- a/zh-cn/device-dev/porting/porting-minichip-subsys-overview.md +++ b/zh-cn/device-dev/porting/porting-minichip-subsys-overview.md @@ -1,7 +1,7 @@ # 移植子系统概述 -OpenHarmony系统功能按照“系统 > 子系统 > 部件”逐级展开,支持根据实际需求裁剪某些非必要的部件(本文只对HarmonyOS Connect服务包所必需的子系统、部件进行介绍)。若想使用OpenHarmony系统的能力,需要对相应子系统进行适配。 +OpenHarmony系统功能按照“系统 > 子系统 > 部件”逐级展开,支持根据实际需求裁剪某些非必要的部件,本文以部分子系统、部件为例进行介绍。若想使用OpenHarmony系统的能力,需要对相应子系统进行适配。 OpenHarmony芯片适配常见子系统列表如下(详见表1),需结合具体芯片再做增删减操作。 diff --git a/zh-cn/device-dev/porting/porting-stm32mp15xx-on-smallsystem.md b/zh-cn/device-dev/porting/porting-stm32mp15xx-on-smallsystem.md index 57787c13f1f2eae93f4f57a8e19f83a471c3ea9f..0785be003cb784fc91a1c1f8e63b5385ea22f4ef 100644 --- a/zh-cn/device-dev/porting/porting-stm32mp15xx-on-smallsystem.md +++ b/zh-cn/device-dev/porting/porting-stm32mp15xx-on-smallsystem.md @@ -195,74 +195,74 @@ vendor cmd = "if [ -f $product_path/hdf_config/BUILD.gn ]; then echo true; else echo false; fi" HAVE_PRODUCT_CONFIG = exec_script("//build/lite/run_shell_cmd.py", [ cmd ], "value") - + group("liteos_a") { - deps = [ + deps = [ "board", "drivers", - ] - if (HAVE_PRODUCT_CONFIG) { + ] + if (HAVE_PRODUCT_CONFIG) { deps += [ "$product_path/hdf_config" ] - } else { + } else { deps += [ "hdf_config" ] + } } - } - + config("public") { - configs = [ + configs = [ "board:public", "drivers:public", - ] + ] } ``` 2. 在//device/board/bearpi/bearpi_hm_micro/liteos_a/board中新建BUILD.gn,添加代码如下。将os_adapt.c内核启动相关代码编译进系统。 ``` import("//kernel/liteos_a/liteos.gni") - + module_name = "bsp_config" - + kernel_module(module_name) { - sources = [] - if (defined(LOSCFG_PLATFORM_ADAPT)) { + sources = [] + if (defined(LOSCFG_PLATFORM_ADAPT)) { sources += [ "os_adapt/os_adapt.c" ] + } } - } - + config("public") { - include_dirs = [ "." ] - include_dirs += [ "include" ] - include_dirs += [ "$LITEOSTOPDIR/drivers/block/disk/include" ] - include_dirs += - [ "$LITEOSTOPDIR/../../drivers/adapter/khdf/liteos/osal/include" ] + include_dirs = [ "." ] + include_dirs += [ "include" ] + include_dirs += [ "$LITEOSTOPDIR/drivers/block/disk/include" ] + include_dirs += + [ "$LITEOSTOPDIR/../../drivers/adapter/khdf/liteos/osal/include" ] } ``` 3. 在//device/board/bearpi/bearpi_hm_micro/liteos_a/drivers中新建BUILD.gn,添加代码如下,将device/soc/st/common/platform路径下的HDF驱动编译进系统。 ``` import("//drivers/adapter/khdf/liteos/hdf.gni") - + group("drivers") { - public_deps = [ "//device/soc/st/common/platform:drivers" ] + public_deps = [ "//device/soc/st/common/platform:drivers" ] } - + config("public") { - configs = [ "//device/soc/st/common/platform:public" ] + configs = [ "//device/soc/st/common/platform:public" ] } - + ``` 4. 在//vendor/bearpi/bearpi_hm_micro/hdf_config中新建BUILD.gn,添加代码如下,将HCS配置文件编译进系统。 ``` module_switch = defined(LOSCFG_DRIVERS_HDF) && !defined(LOSCFG_DRIVERS_HDF_TEST) module_name = "libhdf_config" hdf_driver(module_name) { - hcs_sources = [ "hdf.hcs" ] + hcs_sources = [ "hdf.hcs" ] } - + group("hdf_config") { - public_deps = [ ":$module_name" ] - deps = [ + public_deps = [ ":$module_name" ] + deps = [ "hdf_test", "hdf_test/hcs_macro_test", - ] + ] } ``` ### 内核启动适配 diff --git a/zh-cn/device-dev/porting/standard-system-porting-guide.md b/zh-cn/device-dev/porting/standard-system-porting-guide.md index 43b277cd1deac0e828fde5e09bddfdf87b5ce98d..35afad475325a2b59be7f98621e8c2f28707d5a8 100644 --- a/zh-cn/device-dev/porting/standard-system-porting-guide.md +++ b/zh-cn/device-dev/porting/standard-system-porting-guide.md @@ -30,10 +30,10 @@ { "subsystem": "ace", "components": [ - { "component": "ace_engine_lite", "features":[""] } + { "component": "ace_engine_lite", "features":[] } ] - }, - … + }, + ... ] } @@ -155,6 +155,7 @@ BUILD.gn是subsystem构建的唯一入口。 7. 由于应用都需要加载JS的运行环境,涉及大量准备工作,因此appspawn作为应用的孵化器,在接收到foundation里的应用启动请求时,可以直接孵化出应用进程,减少应用启动时间。 2. init。 + init启动引导组件配置文件包含了所有需要由init进程启动的系统关键服务的服务名、可执行文件路径、权限和其他信息。每个系统服务各自安装其启动脚本到/system/etc/init目录下。 新芯片平台移植时,平台相关的初始化配置需要增加平台相关的初始化配置文件/vendor/etc/init/init.{hardware}.cfg;该文件完成平台相关的初始化设置,如安装ko驱动,设置平台相关的/proc节点信息。 diff --git a/zh-cn/device-dev/quick-start/quickstart-ide-standard-running-rk3568-burning.md b/zh-cn/device-dev/quick-start/quickstart-ide-standard-running-rk3568-burning.md index 83a47bd474a7cd364e8365801c87c9c8cc54bd10..52365db0887c7792c76fee7de2a14f0da820279a 100644 --- a/zh-cn/device-dev/quick-start/quickstart-ide-standard-running-rk3568-burning.md +++ b/zh-cn/device-dev/quick-start/quickstart-ide-standard-running-rk3568-burning.md @@ -3,7 +3,7 @@ 烧录是指将编译后的程序文件下载到芯片开发板上的动作,为后续的程序调试提供基础。DevEco Device Tool提供一键烧录功能,操作简单,能快捷、高效的完成程序烧录,提升烧录的效率。 -RK3568的镜像烧录通过Winodow环境进行烧录,开发者启动烧录操作后,DevEco Device Tool通过Remote远程模式,将Ubuntu环境下编译生成的带烧录程序文件拷贝至Windows目录下,然后通过Windows的烧录工具将程序文件烧录至开发板中。 +RK3568的镜像烧录通过Windows环境进行烧录,开发者启动烧录操作后,DevEco Device Tool通过Remote远程模式,将Ubuntu环境下编译生成的带烧录程序文件拷贝至Windows目录下,然后通过Windows的烧录工具将程序文件烧录至开发板中。 1. [下载](https://gitee.com/hihope_iot/docs/blob/master/HiHope_DAYU200/%E7%83%A7%E5%86%99%E5%B7%A5%E5%85%B7%E5%8F%8A%E6%8C%87%E5%8D%97/windows/DriverAssitant_v5.1.1.zip)并安装驱动DriverInstall.exe。 diff --git a/zh-cn/device-dev/quick-start/quickstart-standard-running-rk3568-burning.md b/zh-cn/device-dev/quick-start/quickstart-standard-running-rk3568-burning.md index a268539d00042a2dc289370247ce30e6f35088d6..cd84631224a16430eee21613928b8272677d5b80 100644 --- a/zh-cn/device-dev/quick-start/quickstart-standard-running-rk3568-burning.md +++ b/zh-cn/device-dev/quick-start/quickstart-standard-running-rk3568-burning.md @@ -79,7 +79,7 @@ RK3568的镜像烧录通过Winodow环境进行烧录。 > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > - > 如果开发板未处于烧录模式,屏幕会提示“The boad is not in Loader mode.Please Hold on the VOL+key...”,此时,请长按音量+键,3秒后点击RESET键,然后再过3秒放开音量+键,使开发板进入烧录模式。 + > 如果开发板未处于烧录模式,屏幕会提示“The board is not in Loader mode.Please Hold on the VOL+key...”,此时,请长按音量+键,3秒后点击RESET键,然后再过3秒放开音量+键,使开发板进入烧录模式。 等待开发板烧录完成,当屏幕提示如下信息时,表示烧录成功。 diff --git a/zh-cn/device-dev/security/security-guidelines-overall.md b/zh-cn/device-dev/security/security-guidelines-overall.md index 09e0440bdcd0eb3e20505eef7724ae1c39e7ffc8..948fccd9efb8611098db00444917a9f30a8a1af5 100644 --- a/zh-cn/device-dev/security/security-guidelines-overall.md +++ b/zh-cn/device-dev/security/security-guidelines-overall.md @@ -56,12 +56,14 @@ OpenHarmony操作系统是一个开放的系统,开发者可以通过OpenHarmo 对于128KB~128MB内存的设备,推荐使用OpenHarmony轻内核组件,在该内核下: -- 进程隔离 +- **进程隔离** + 进程隔离是为了防止A进程读写B进程内存数据的情况发生,进程的隔离技术,一般都采用虚拟地址空间映射方式,通过MMU配置,进程A的虚拟地址和进程B的虚拟地址映射各自不同的实际的物理地址段,这样A进程通过访问虚拟地址访问的实际内存数据在非共享内存的情况下,只属于A进程,B进程无法直接访问。 OpenHarmony由于资源有限,对于内核态和用户态的进程采用不同的方式:所有的内核态进程共享同一块VMM空间,即所有的内核态进程之间无隔离,系统启动时内核态创建两个基本进程KProcess和KIdle,KProcess进程为内核态进程的根进程,KIdle进程为KProcess进程的子进程;但是对于每一个用户态进程均拥有自己独立的VMM空间,相互之间不可见,实现进程间隔离。 -- 自主访问控制 +- **自主访问控制** + 自主访问控制DAC(Discretionary Access Control)的思想是文件权限由文件拥有者来决定其他角色的访问权限。权限管控粒度分为三类:user(自身), group(组员),other(其他人),即UGO。将任意用户分类为UGO中三者之一,并采取相应的管控策略,即完成了DAC权限校验流程。 DAC机制依赖于进程的uid、gid等属性,需要以此作为文件创建以及文件访问过程中的特征id。文件创建时,创建者将自身uid写入文件,文件访问时,又以此作为文件归属的分类依据。 @@ -70,13 +72,16 @@ OpenHarmony操作系统是一个开放的系统,开发者可以通过OpenHarmo 下图描述了DAC在文件访问时的鉴权过程,首先匹配进程uid和文件uid属性,其次匹配进程gid和文件gid属性,最后都匹配失败的情况,判断文件other属性是否支持进程的读、写、执行操作。同时支持忽略DAC检测机制(读、写、执行)作为一组系统特权(Capability),支持高权限(如系统服务)对低权限(三方APP)的文件管理。 - **图2** DAC流程图 - ![zh-cn_image_0000001057233092](figures/zh-cn_image_0000001057233092.png) +**图2** DAC流程图 + +![zh-cn_image_0000001057233092](figures/zh-cn_image_0000001057233092.png) + +- **Capability机制** -- Capability机制 Capability机制实际上是对root权限的具体细分。在多用户计算机系统中,一般会有一个特殊的角色拥有系统的所有权限,这个角色一般是系统管理员(root)。对于OpenHarmony这种需要支持三方应用生态的内核,需要将系统中的特权访问进行管控。系统需要对用户层访问内核的特权级系统调用进行限制。仅允许部分高权限应用进行特权操作。具体实现方式是内核spawn第一个用户程序INIT,其包含全部的特权能力,此后,INIT拉起其他应用框架服务,拉起过程中,对各应用框架进行相应的降权操作,为各应用保留必需的特权能力。 当应用去调用特权接口时,内核态就会通过进程ID查看当前访问者是否有权限访问目标接口。 -- 安全启动 +- **安全启动** + 安全启动是整个系统安全的基础,通过采用数字签名和完整性校验机制,从芯片内部固化的可信启动根开始,逐级校验每一层软件的完整性和合法性,确保最终启动的操作系统软件是厂家提供的正确合法的软件,防止攻击者对系统软件做恶意的篡改和植入,为整个系统提供初始安全的基础运行环境。 在芯片上电后,由于片上ROM代码本身不可更改,因此无需校验;片上ROM基于eFuse中的非对称算法公钥hash对bootloader进行校验。这些过程都基于硬件信任根来进行,是完全可信的。经过此过程校验通过的bootloader模块可以作为后续的信任基础,此过程就是启动信任链的构造过程。Bootloader通常首先对执行环境进行一定的初始化,主要是初始化DDR以及flash读写,为进一步加载后续模块以及执行更为复杂的逻辑进行准备。Bootloader完成初始化动作后,首先完成x509证书的完整性校验,然后利用x509证书的公钥对需要校验的镜像包(kernel.bin、teeOS.bin、rootfs.bin)进行校验。 @@ -115,11 +120,17 @@ HUKS(OpenHarmony Universal Keystore Service),提供了密钥管理、证 HUKS在使用中有如下约束: -- 密钥安全存储:密钥要求存储于安全存储区域,数据不可以修改,恢复出厂设置时出厂预置的密钥不能被删除。 +- **密钥安全存储:** + +密钥要求存储于安全存储区域,数据不可以修改,恢复出厂设置时出厂预置的密钥不能被删除。 + +- **密钥访问安全:** + +OpenHarmony通过将不同应用数据保存在不同的位置,来实现应用间数据的隔离。通过参数结构体中包含UID和进程ID,来实现不同应用间的数据隔离。 -- 密钥访问安全:OpenHarmony通过将不同应用数据保存在不同的位置,来实现应用间数据的隔离。通过参数结构体中包含UID和进程ID,来实现不同应用间的数据隔离。 +- **不支持并发访问:** -- 不支持并发访问:HUKS本身不考虑多个应用同时调用的情况,因为HUKS只是一个lib库,也不考虑资源的互斥。如果有多个应用都会用到HUKS服务,那么应该由每个应用各自链接一份HUKS库,并由业务传入持久化数据存储的路径,以实现应用间的数据存储分开。数据存储在各应用各自存储目录下。 +HUKS本身不考虑多个应用同时调用的情况,因为HUKS只是一个lib库,也不考虑资源的互斥。如果有多个应用都会用到HUKS服务,那么应该由每个应用各自链接一份HUKS库,并由业务传入持久化数据存储的路径,以实现应用间的数据存储分开。数据存储在各应用各自存储目录下。 ### 推荐做法 diff --git a/zh-cn/device-dev/subsystems/subsys-ai-aiframework-devguide.md b/zh-cn/device-dev/subsystems/subsys-ai-aiframework-devguide.md index 95590434713f2f5cdcbf08c280794bec6c2711ac..e456894a0672f3858ecff57f929358313d64af89 100644 --- a/zh-cn/device-dev/subsystems/subsys-ai-aiframework-devguide.md +++ b/zh-cn/device-dev/subsystems/subsys-ai-aiframework-devguide.md @@ -442,9 +442,9 @@ Response类的属性如下表所示。 int32_t Release(bool isFullUnload, long long transactionId, const DataInfo &amp;inputInfo) override; }; ``` - - 上述代码实现server提供的IPlugin接口。唤醒词识别的sample中调用的client端接口与插件中的接口对应关系及其实现功能如下表所示。 - **表1** 唤醒词识别中client端接口与插件中的接口对应关系 +上述代码实现server提供的IPlugin接口。唤醒词识别的sample中调用的client端接口与插件中的接口对应关系及其实现功能如下表所示。 + +**表1** 唤醒词识别中client端接口与插件中的接口对应关系 | client端定义的接口 | 插件中定义的接口 | 功能 | | -------- | -------- | -------- | diff --git a/zh-cn/device-dev/subsystems/subsys-boot-overview.md b/zh-cn/device-dev/subsystems/subsys-boot-overview.md index 25a8a748ba9aead0abf1a84c733395c5ab30b436..ac86a7df8e5c36b018054535b62b0090b54a526f 100644 --- a/zh-cn/device-dev/subsystems/subsys-boot-overview.md +++ b/zh-cn/device-dev/subsystems/subsys-boot-overview.md @@ -317,22 +317,24 @@ 因此,当我们看到"Mount required partitions"打印的时候,表示required分区设备已经准备完成,即将执行挂载动作。分区挂载过程中,还有一些关键打印如下: ``` BEGET_LOGE("Unsupported file system \" %s \"", item->fsType); - 表示当前文件系统类型不支持 - + ``` + 表示当前文件系统类型不支持。 + ``` BEGET_LOGE("Cannot get stat of \" %s \", err = %d", target, errno); - 表示无法获取挂载点目录信息 - + ``` + 表示无法获取挂载点目录信息。 + ``` BEGET_LOGE("Failed to create dir \" %s \", err = %d", target, errno); - 表示无法创建挂载点目录 - + ``` + 表示无法创建挂载点目录。 + ``` BEGET_LOGI("Mount %s to %s successful", item->deviceName, item->mountPoint); - 表示成功挂载设备,打印中还包含了挂载的设备名和挂载点信息 ``` - + 表示成功挂载设备,打印中还包含了挂载的设备名和挂载点信息。 - init执行system和vendor中的启动脚本,挂载vendor中更多的分区 - 挂载完必要的分区后,init扫描各个脚本文件。vendor中与芯片或开发板相关的初始化脚本入口如/vendor/etc/init.{ohos.boot.hardware}.cfg。vendor中扩展的挂载分区文件是/vendor/etc/fstab.{ohos.boot.hardware}。hardware的来源是bootloader传递给内核的bootargs。 +挂载完必要的分区后,init扫描各个脚本文件。vendor中与芯片或开发板相关的初始化脚本入口如/vendor/etc/init.{ohos.boot.hardware}.cfg。vendor中扩展的挂载分区文件是/vendor/etc/fstab.{ohos.boot.hardware}。hardware的来源是bootloader传递给内核的bootargs。 ### 无ramdisk的启动加载流程 diff --git a/zh-cn/device-dev/subsystems/subsys-multimedia-video-overview.md b/zh-cn/device-dev/subsystems/subsys-multimedia-video-overview.md index 0a105ae54259ba2f51177028f823b7051b9a00df..0f774c59fe570702f9915c938ce098deb645e706 100755 --- a/zh-cn/device-dev/subsystems/subsys-multimedia-video-overview.md +++ b/zh-cn/device-dev/subsystems/subsys-multimedia-video-overview.md @@ -13,17 +13,16 @@ OpenHarmony音视频包括音视频播放和录制。 在进行应用的开发OpenHarmony前,开发者应了解以下基本概念: -- 流媒体技术 +- **流媒体技术** 流媒体技术是把连续的影像和声音信息进行编码处理后放在网络服务器上,让浏览者一边下载、一边观看与收听,而不需要等整个多媒体文件下载完成就可以即时观看、收听的技术。 -- 视频帧率 +- **视频帧率** 帧率是用于测量显示帧数的度量,帧数就是在每秒钟时间里传输的图片数量。每秒钟帧数 (FPS) 越多,所显示的画面就会越流畅。 -- 码率 +- **码率** 码率就是数据传输时单位时间传送的数据位数,常用单位是kbps即千位每秒。 -- 采样率 - 采样率为每秒从连续信号中提取并组成离散信号的采样个数,单位用赫兹(Hz)来表示。 +- **采样率** 采样率为每秒从连续信号中提取并组成离散信号的采样个数,单位用赫兹(Hz)来表示。 ## 编解码规格 diff --git a/zh-cn/device-dev/subsystems/subsys-ota-guide.md b/zh-cn/device-dev/subsystems/subsys-ota-guide.md index 94cb6dc08681e15e04045f6f2a64fab7992de870..9e42bfedb9f76f9baf59cb349921c0db0dbf3810 100644 --- a/zh-cn/device-dev/subsystems/subsys-ota-guide.md +++ b/zh-cn/device-dev/subsystems/subsys-ota-guide.md @@ -3,32 +3,86 @@ ## 概述 -OTA(Over the Air)提供对设备远程升级的能力,可以让您的设备(如IP摄像头等),轻松支持远程升级能力。目前轻量和小型系统仅支持全量包升级,暂不支持差分包升级。全量包升级是将新系统全部内容做成升级包,进行升级;差分包升级是将新老系统的差异内容做成升级包,进行升级。 +### 简介 -## 约束与限制 +随着设备系统日新月异,用户如何及时获取系统的更新,体验新版本带来的新的体验,以及提升系统的稳定和安全性成为了每个厂商都面临的严峻问题。 + +OTA(Over the Air)提供对设备远程升级的能力。升级子系统对用户屏蔽了底层芯片的差异,对外提供了统一的升级接口。基于接口进行二次开发后,可以让厂商的设备(如IP摄像头等)轻松支持远程升级能力。 + + +### 基本概念 + +- 全量升级包:将所有目标版本的镜像均通过全量镜像的方式打包获得的升级包。 + +- 差分升级包:对源版本和目标版本差分,获得两个版本镜像之间的差异,以这种方式打包制作升级包。 + + +### 实现原理 + +OTA 的升级原理是利用升级包制作工具,将编译出的版本打包生成升级包。厂商设备集成 OTA 升级能力后,将升级包上传至服务器,通过升级应用下载升级包,触发并完成升级。 + +AB 升级:是 OTA 升级的一个场景,原理是设备有一套备份的B系统,在A系统运行时,可以在正常使用的状态下,静默更新B系统,升级成功后,重启切换新系统,实现版本更新的机制。 + + +### 约束与限制 - 支持基于Hi3861/Hi3518EV300/Hi3516DV300芯片的开源套件。 - 对Hi3518EV300/Hi3516DV300开源套件,设备需要支持SD卡(VFAT格式)。 - > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** - > 生成升级包需要在linux系统下面执行。 +- 生成升级包需要在linux系统下面执行。 + +- 目前轻量和小型系统仅支持全量包升级,暂不支持差分包、变分区包升级。 + + +## 环境准备 + +- 在Windows上,下载安装OpenSSL工具,并配置环境变量。 +- 准备升级包制作工具 +- 编译出版本镜像文件 +- 制作升级包需要 Linux 系统环境 +- AB 升级只适用于标准系统支持 AB 分区启动的设备 + + +## OTA 升级指导 + + +### 开发流程 + +1. 使用OpenSSL工具生成公私钥对 + +2. 使用升级包制作工具制作升级包 + +  2.1 轻量与小型系统升级包 + +  2.2 标准系统升级包 + +3. 将升级包上传到厂商的OTA服务器 -## 生成公私钥对 +4. 厂商应用从OTA服务器下载升级包 -1. 准备工作:在Windows上,下载安装[OpenSSL工具](http://slproweb.com/products/Win32OpenSSL.html),并配置环境变量。 +5. 厂商应用集成OTA能力 -2. 使用OpenSSL工具生成公私钥对。 +  5.1 API 应用默认场景 -3. 请妥善保管私钥文件,在升级包制作过程中将私钥文件作为制作命令的参数带入,用于升级包签名,公钥用于升级时对升级包进行签名校验,公钥的放置如下: - 轻量和小型系统将生成的公钥内容预置在代码中,需要厂商实现 HotaHalGetPubKey 这个接口来获取公钥。标准系统需要将生产的公钥放在 ./device/hisilicon/hi3516dv300/build/updater_config/signing_cert.crt 这个文件中。 +  5.2 API 应用定制场景 -4. 对使用 Hi3518EV300/Hi3516DV300 套件的轻量和小型系统,在上一步的基础上,还需用public_arr.txt里面的全部内容替换uboot模块device\hisilicon\third_party\uboot\u-boot-2020.01\product\hiupdate\verify\update_public_key.c 中的g_pub_key中的全部内容。 +  5.2 AB 升级场景 + + +### 开发步骤 + + +#### 生成公私钥对 +1. 使用OpenSSL工具生成公私钥对。 + +3. 请妥善保管私钥文件,在升级包制作过程中将私钥文件作为制作命令的参数带入,用于升级包签名,公钥用于升级时对升级包进行签名校验,公钥的放置如下: 轻量和小型系统将生成的公钥内容预置在代码中,需要厂商实现 HotaHalGetPubKey 这个接口来获取公钥。标准系统需要将生成的公钥放在 ./device/hisilicon/hi3516dv300/build/updater_config/signing_cert.crt 这个文件中。 + +5. 对使用 Hi3518EV300/Hi3516DV300 套件的轻量和小型系统,在上一步的基础上,还需用public_arr.txt里面的全部内容替换uboot模块device\hisilicon\third_party\uboot\u-boot-2020.01\product\hiupdate\verify\update_public_key.c 中的g_pub_key中的全部内容。 示例,uboot模块的公钥: - - ``` + ```c static unsigned char g_pub_key[PUBKEY_LEN] = { 0x30, 0x82, 0x01, 0x0A, 0x02, 0x82, 0x01, 0x01, 0x00, 0xBF, 0xAA, 0xA5, 0xB3, 0xC2, 0x78, 0x5E, @@ -36,14 +90,14 @@ OTA(Over the Air)提供对设备远程升级的能力,可以让您的设 ``` -## 生成升级包 +#### 制作升级包 -### 轻量与小型系统升级包制作 +##### 轻量与小型系统升级包制作 1. 创建目标版本(target_package)文件夹,文件格式如下: - ``` + ```text target_package ├── OTA.tag ├── config @@ -55,13 +109,13 @@ OTA(Over the Air)提供对设备远程升级的能力,可以让您的设 └── updater_specified_config.xml ``` -2. 将待升级的组件,包括镜像文件(例如:rootfs.img等)等放入目标版本文件夹的根目录下,代替上结构中的{component_N}部分。 +2. 将待升级的组件,包括镜像文件(例如:rootfs.img)等放入目标版本文件夹的根目录下,代替上文结构中的{component_N}部分。 -3. 填写“update_config”文件夹中的“updater_specified_config.xml”组件配置文件。 +3. 填写“updater_config”文件夹中的“updater_specified_config.xml”组件配置文件。 组件配置文件“updater_specified_config.xml”,格式如下: - ``` + ```xml @@ -77,17 +131,6 @@ OTA(Over the Air)提供对设备远程升级的能力,可以让您的设 **表1** 组件配置文件节点说明 - | 信息类别 | 节点名称 | 节点标签 | 是否必填 | 内容说明 | - | -------- | -------- | -------- | -------- | -------- | - | 头信息(head节点) | info节点 | / | 必填 | 该节点内容配置为:head info | - | fileVersion | 必填 | 保留字段,内容不影响升级包生成 | - | prdID | 必填 | 保留字段,内容不影响升级包生成 | - | softVersion | 必填 | 软件版本号,即升级包版本号,版本必须在“VERSION.mbn”范围内,否则无法生产升级 | - | date | 必填 | 升级包制作日期,保留字段,不影响升级包生成 | - | time | 必填 | 升级包制作时间,保留字段,不影响升级包生成 | - - **表2** 组件配置文件节点说明 - | 信息类别 | 节点名称 | 节点标签 | 是否必填 | 内容说明 | | -------- | -------- | -------- | -------- | -------- | | 头信息(head节点) | info节点 | / | 必填 | 该节点内容配置为:head info | @@ -103,29 +146,29 @@ OTA(Over the Air)提供对设备远程升级的能力,可以让您的设 | 组件信息(group节点) | component节点 | compType | 必填 | 处理方式全量/差分,配置镜像处理方式的,0为全量处理、1为差分处理。 | > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** - > 对轻量系统/小型系统,不支持做差分升级,component标签中,属性compType值,不能配为‘1’,必须全部配置为‘0’。 + > 对轻量系统/小型系统,不支持做差分升级,component标签中,属性compType值,不能配为 1,必须全部配置为 0。 > > 对轻量系统/小型系统,不支持变分区升级包的制作。 4. 创建“OTA.tag文件”,内容为OTA升级包的魔数,固定如下: - ``` + ```text package_type:ota1234567890qwertw ``` 5. 创建“config文件”,内容为设置bootargs以及bootcmd的信息。 - 例如配置如下: + 配置例如下: - ``` + ```text setenv bootargs 'mem=128M console=ttyAMA0,115200 root=/dev/mmcblk0p3 rw rootfstype=ext4 rootwait blkdevparts=mmcblk0:1M (u-boot.bin),9M(kernel.bin),50M(rootfs_ext4.img),50M(userfs.img)' setenv bootcmd 'mmc read 0x0 0x82000000 0x800 0x4800;bootm 0x82000000' ``` 6. 执行升级包制作命令。 - ``` - python build_update.py ./target_package/ ./output_package/ -pk ./rsa_private_key3072.pem -nz -nl2x + ```text + python build_update.py ./target_package/ ./output_package/ -pk ./rsa_private_key3072.pem -nz -nl2 ``` - ./target_package/:指定target_package路径。 @@ -135,12 +178,12 @@ OTA(Over the Air)提供对设备远程升级的能力,可以让您的设 - -nl2:打开非“标准系统”模式开关 -### 标准系统升级包制作 +##### 标准系统升级包制作 1. 创建目标版本(target_package)文件夹,文件格式如下: - ``` + ```text target_package ├── {component_1} ├── {component_2} @@ -152,30 +195,30 @@ OTA(Over the Air)提供对设备远程升级的能力,可以让您的设 └── updater_specified_config.xml ``` -2. 将待升级的组件,包括镜像文件(例如:system.img等)等放入目标版本文件夹的根目录下,代替上结构中的{component_N}部分。 +2. 将待升级的组件,包括镜像文件(例如:system.img)等放入目标版本文件夹的根目录下,代替上文结构中的{component_N}部分。 -3. 填写“update_config”文件夹中的组件配置文件。 +3. 填写“updater_config”文件夹中的组件配置文件。 -4. 配置“update_config”文件夹中当前升级包支持的产品list:**BOARD.list**。 +4. 配置“updater_config”文件夹中当前升级包支持的产品list:**BOARD.list**。 例如配置如下: - ``` + ```text HI3516 HI3518 ``` -5. 配置“update_config”文件夹中当前升级包所支持的版本范围:**VERSION.mbn**。 +5. 配置“updater_config”文件夹中当前升级包所支持的版本范围:**VERSION.mbn**。 版本名称格式:Hi3516DV300-eng 10 QP1A.XXXXXX.{大版本号(6位)}.XXX{小版本号(3位)}。 例如:Hi3516DV300-eng 10 QP1A.190711.020。名称中“190711”为大版本号,“020”为小版本号。 - 例如配置如下: + 配置例如下: - ``` + ```text Hi3516DV300-eng 10 QP1A.190711.001 Hi3516DV300-eng 10 QP1A.190711.020 Hi3518DV300-eng 10 QP1A.190711.021 @@ -188,7 +231,7 @@ OTA(Over the Air)提供对设备远程升级的能力,可以让您的设 分区表会随镜像一起生成,格式如下: - ``` + ```xml @@ -215,8 +258,8 @@ OTA(Over the Air)提供对设备远程升级的能力,可以让您的设 命令如下: - ``` - python build_update.py ./target_package/ ./output_package/ -pk ./rsa_private_key3072.pem + ```text + python build_update.py ./target_package/ ./output_package/ -pk ./rsa_private_key2048.pem ``` - ./target_package/:指定target_package路径。 @@ -228,8 +271,8 @@ OTA(Over the Air)提供对设备远程升级的能力,可以让您的设 命令如下: - ``` - python build_update.py ./target_package/ ./output_package/ -s ./source_package.zip -pk ./rsa_private_key3072.pem + ```text + python build_update.py ./target_package/ ./output_package/ -s ./source_package.zip -pk ./rsa_private_key2048.pem ``` - ./target_package/:指定target_package路径。 @@ -242,8 +285,8 @@ OTA(Over the Air)提供对设备远程升级的能力,可以让您的设 命令如下: - ``` - python build_update.py ./target_package/ ./output_package/ -pk ./rsa_private_key3072.pem -pf ./partition_file.xml + ```text + python build_update.py ./target_package/ ./output_package/ -pk ./rsa_private_key2048.pem -pf ./partition_file.xml ``` - ./target_package/:指定target_package路径。 @@ -252,36 +295,36 @@ OTA(Over the Air)提供对设备远程升级的能力,可以让您的设 - -pf ./partition_file.xml:指定分区表文件路径。 -## 上传升级包 +#### 上传升级包 将升级包上传到厂商的OTA服务器。 -## 下载升级包 +#### 下载升级包 1. 厂商应用从OTA服务器下载升级包。 2. 对Hi3518EV300/Hi3516DV300开源套件,需要插入SD卡(容量>100MBytes)。 -## 厂商应用集成OTA能力 +#### 厂商应用集成OTA能力 1. 轻量与小型系统 - - 调用OTA模块的动态库libhota.so,对应头文件位于:base\update\ota_lite\interfaces\kits\hota_partition.h&hota_updater.h。 - - libhota.so对应的源码路径为base\update\ota_lite\frameworks\source。 + - 调用OTA模块的动态库libhota.so,对应头文件hota_partition.h和hota_updater.h路径:base\update\ota_lite\interfaces\kits\。 + - libhota.so对应的源码路径为:base\update\ota_lite\frameworks\source。 - API的使用方法,见本文“API应用场景”和API文档的OTA接口章节。 - 如果需要适配开发板,请参考HAL层头文件:base\update\ota_lite\hals\hal_hota_board.h。 2. 标准系统请参考[JS参考规范](../../application-dev/reference/apis/js-apis-update.md)指导中的升级接口参考规范。 -## API应用场景-默认场景 +##### API 应用默认场景 升级包是按照上文“生成公私钥对”和“生成升级包”章节制作的。 -### 开发指导 +###### 开发指导 1. 应用侧通过下载,获取当前设备升级包后,调用HotaInit接口初始化OTA模块。 @@ -290,11 +333,11 @@ OTA(Over the Air)提供对设备远程升级的能力,可以让您的设 3. 写入完成后,调用HotaRestart接口重启系统,升级过程中,使用HotaCancel接口可以取消升级。 -### 示例代码 +###### 示例代码 - 使用OpenHarmony的“升级包格式和校验方法“进行升级。 + 使用OpenHarmony的“升级包格式和校验方法”进行升级。 -``` +```cpp int main(int argc, char **argv) { printf("this is update print!\r\n"); @@ -345,12 +388,12 @@ int main(int argc, char **argv) ``` -## API应用场景-定制场景 +##### API 应用定制场景 升级包不是按照上文“生成公私钥对”和“生成升级包”章节制作的,是通过其它方式制作的。 -### 开发指导 +###### 开发指导 1. 应用侧通过下载,获取当前设备升级包后,调用HotaInit接口初始化。 @@ -365,11 +408,11 @@ int main(int argc, char **argv) 6. 调用HotaRestart接口,进行重启,升级过程中,使用HotaCancel接口可以取消升级。 -### 示例代码 +###### 示例代码 使用非OpenHarmony的“升级包格式和校验方法“进行升级。 -``` +```cpp int main(int argc, char **argv) { printf("this is update print!\r\n"); @@ -418,7 +461,7 @@ int main(int argc, char **argv) while (leftLen > 0) { int tmpLen = leftLen >= READ_BUF_LEN ? READ_BUF_LEN : leftLen; (void)memset_s(g_readBuf, READ_BUF_LEN, 0, READ_BUF_LEN); - if (HotaRead(offset, READ_BUF_LEN, (unsigned char *)g_readBuf) != 0) {} + if (HotaRead(offset, READ_BUF_LEN, (unsigned char *)g_readBuf) != 0) { printf("ota write fail!\r\n"); (void)HotaCancel(); return -1; @@ -437,7 +480,7 @@ int main(int argc, char **argv) ``` -## 系统升级 +###### 系统升级 厂商应用调用OTA模块的API,OTA模块执行升级包的签名验证、版本防回滚、烧写落盘功能,升级完成后自动重启系统。 @@ -445,7 +488,7 @@ int main(int argc, char **argv) 示例,增加版本号。 -``` +```cpp const char *get_local_version(void) { #if defined(CONFIG_TARGET_HI3516EV200) || \ @@ -453,3 +496,89 @@ const char *get_local_version(void) defined(CONFIG_TARGET_HI3518EV300) #define LOCAL_VERSION "ohos default 1.0" /* increase: default release version */ ``` + + +##### AB 升级场景 + + +###### 开发流程 + +1. 应用侧下载获取当前设备升级包 +2. update_service 通过 SAMGR 将系统安装部件拉起 +3. 由系统安装部件完成静默热安装 +4. 下一次重启时激活新版本 + + +###### 开发步骤 + +- JS API 通过 update_service 模块处理AB升级相关流程 + + 1.升级包安装进度显示接口: + ```cpp + on(eventType: "upgradeProgress", callback: UpdateProgressCallback): void; + ``` + + 2.设置激活策略(立即重启,夜间重启,随下次重启激活)接口: + ```cpp + upgrade(apply) + ``` + + +- update_service 通过 SAMGR 将系统安装服务拉起 + + 1.拉起系统安装服务,并建立IPC连接: + ```cpp + int SysInstallerInit(void * callback) + ``` + + 2.安装指定路径的AB升级包: + ```cpp + int StartUpdatePackageZip(string path) + ``` + + 3.设置进度回调: + ```cpp + int SetUpdateProgressCallback(void * callback) + ``` + + 4.获取升级包安装状态(0 未开始,1 安装中,2 安装结束): + ```cpp + int GetUpdateStatus() + ``` + + +- 使用 HDI 接口南向激活新版本 + + 1.获取当前启动的slot,来决策待升级的分区: + ```cpp + int GetCurrentSlot() + ``` + + 2.在升级结束后,将已升级好的slot进行切换,重启完成新版本更新: + ```cpp + int SetActiveBootSlot(int slot) + ``` + + 3.在升级开始时,将待升级的分区slot设置成unbootable状态: + ```cpp + int setSlotUnbootable(int slot) + ``` + + 4.获取slot个数,1位非AB,2为AB分区,用例兼容AB和非AB的流程判断: + ```cpp + int32 GetSlotNum(void) + ``` + + +###### 常见问题 + +1. 升级包下载,安装过程出现异常 +
系统保持当前版本继续运行,在下一个搜包周期重新完成版本升级过程 + +2. 升级包完成非启动分区的包安装,在激活过程中出现异常 +
需要进行异常回滚,并将无法启动的分区设置为 unbootable,下次则不从该分区启动 + + +###### 调测验证 + +设备能在正常使用的情况下,在后台从服务器下载升级包,完成静默升级,并按照厂商设置的策略重启激活版本。 \ No newline at end of file diff --git a/zh-cn/device-dev/subsystems/subsys-toolchain-hdc-guide.md b/zh-cn/device-dev/subsystems/subsys-toolchain-hdc-guide.md index 1ce2e0956dc6d8ae90312172f74ac7784f96355c..679209f76d8a7cf233891e62761057cacdfdb30b 100644 --- a/zh-cn/device-dev/subsystems/subsys-toolchain-hdc-guide.md +++ b/zh-cn/device-dev/subsystems/subsys-toolchain-hdc-guide.md @@ -53,10 +53,30 @@ option涉及以下命令: hdc_std -v / hdc_std version ``` +- **-l 0-5** + 用于指定运行时日志等级,默认为LOG_INFO。 + + **表2** 命令说明 + + | 参数 | 参数说明 | + | -------- | -------- | + | 0 | LOG_OFF | + | 1 | LOG_FATAL| + | 2 | LOG_WARN | + | 3 | LOG_INFO | + | 4 | LOG_DEBUG| + | 5 | LOG_ALL | + + 使用方法: + + ``` + hdc_std -l5 start + ``` + - **-t key** 用于连接指定设备标识为key的设备。 - **表2** 命令说明 + **表3** 命令说明 | 参数 | 参数说明 | | -------- | -------- | @@ -75,6 +95,21 @@ option涉及以下命令: > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > 一台开发机可支持多个设备连接,每个设备有其唯一的设备标识,如果通过网络与设备连接,其标识为IP地址:port格式,如果通过usb连接则标识为设备sn号。该命令需要跟随具体操作命令。 +- **checkserver** + 用于获取client-server版本。 + + **表4** 命令说明 + + | 返回值 | 返回值说明| + | -------- | -------- | + | Client version: server version: | client-server版本号 | + + 使用方法: + + ``` + hdc_std checkserver + ``` + ## 查询设备列表的命令 @@ -89,7 +124,7 @@ list targets[-v] 显示所有已经连接的目标设备列表 - **表3** 命令说明 + **表5** 命令说明 | 参数 | 参数说明| | -------- | -------- | @@ -121,7 +156,7 @@ hdc_std list targets -v - **target mount** 以读写模式挂载系统分区。 - **表4** 命令说明 + **表6** 命令说明 | 参数 | 参数说明 | | -------- | -------- | @@ -136,8 +171,18 @@ hdc_std list targets -v hdc_std target mount ``` -- **smode [off]** - 授予后台服务进程root权限, 使用off参数取消授权。 +- **target boot** + 设备重启。 + + 使用方法: + + + ``` + hdc_std target boot + ``` + +- **smode [-r]** + 授予后台服务进程root权限, 使用-r参数取消授权。 使用方法: @@ -148,13 +193,13 @@ hdc_std list targets -v ``` - hdc_std smode off + hdc_std smode -r ``` - **kill [-r]** 终止服务进程。 - **表5** 命令说明 + **表7** 命令说明 | 参数 | 参数说明 | | -------- | -------- | @@ -171,7 +216,7 @@ hdc_std list targets -v - **start [-r]** 启动服务进程。 - **表6** 命令说明 + **表8** 命令说明 | 参数 | 参数说明 | | -------- | -------- | @@ -185,6 +230,29 @@ hdc_std list targets -v hdc_std start ``` +客户端远程访问服务器 + +1 **kill** + 关闭sever。 + +2 **-s [ip:]port -m** + 启动server。 + + 使用方法: + +``` +hdc_std -s severIP:8710 -m +``` + +3 **-s [ip:]port command** + 指定server执行指令。 + + 使用方法: + +``` +hdc_std -s severIP:8710 list targets +``` + ## 网络相关的命令 @@ -194,7 +262,7 @@ hdc_std list targets -v - **tconn host[:port][-remove]** 通过【ip地址:端口号】来指定连接的设备 - **表7** 命令说明 + **表9** 命令说明 | 参数 | 参数说明 | | -------- | -------- | @@ -213,7 +281,7 @@ hdc_std list targets -v - **tmode usb** 执行后设备端对应daemon进程重启,并首先选用usb连接方式。 - **表8** 命令说明 + **表10** 命令说明 | 参数 | 参数说明 | | -------- | -------- | @@ -231,7 +299,7 @@ hdc_std list targets -v - **tmode port port-number** 执行后设备端对应daemon进程重启,并优先使用网络方式连接设备,如果连接设备失败,再选择usb连接。 - **表9** 命令说明 + **表11** 命令说明 | 参数 | 参数说明 | | -------- | -------- | @@ -249,6 +317,55 @@ hdc_std list targets -v > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > 执行完毕后,远端daemon将会退出并重启,默认启用TCP连接,如果不加上listen端口则listen随机端口。 +- **fport localnode remotenode** + 端口转发,指定 主机端口 转发数据到 设备侧端口。 + + 使用方法: + + + ``` + hdc_std fport tcp:1234 tcp:1080 + ``` + +- **rport remotenode localnode** + 端口转发,指定 设备侧端口 转发数据到 主机端口。 + + 使用方法: + + + ``` + hdc_std rport tcp:2080 tcp:2345 + ``` + +- **fport ls** + 列出全部转发端口转发任务。 + + **表12** 命令说明 + + | 参数 | 参数说明 | + | -------- | -------- | + | 无 | 无 | + | **返回值** | **返回值说明** | + | 'tcp:1234 tcp:1080' [Forward] | 正向端口转发任务 | + | 'tcp:2080 tcp:2345' [Reverse] | 反向端口转发任务 | + + 使用方法: + + + ``` + hdc_std fport ls + ``` + +- **fport rm** + 删除指定端口转发任务。 + + 使用方法: + + + ``` + hdc_std fport rm tcp:1234 tcp:1080 + ``` + ## 文件相关的命令 @@ -258,7 +375,7 @@ hdc_std list targets -v - **file send local remote** 发送文件至远端设备。 - **表10** 命令说明 + **表13** 命令说明 | 参数 | 参数说明 | | -------- | -------- | @@ -277,7 +394,7 @@ hdc_std list targets -v - **file recv [-a] remote local** 从远端设备接收文件至本地。 - **表11** 命令说明 + **表14** 命令说明 | 参数 | 参数说明 | | -------- | -------- | @@ -303,7 +420,7 @@ hdc_std list targets -v - **install [-r/-d/-g] _package_** 安装OpenHarmony APP package。 - **表12** 命令说明 + **表15** 命令说明 | 参数 | 参数说明 | | -------- | -------- | @@ -324,7 +441,7 @@ hdc_std list targets -v - **uninstall [-k] package** 卸载OpenHarmony应用。 - **表13** 命令说明 + **表16** 命令说明 | 参数 | 参数说明 | | -------- | -------- | @@ -349,7 +466,7 @@ hdc_std list targets -v - **hilog** 支持抓取log信息。 - **表14** 命令说明 + **表17** 命令说明 | 参数 | 参数说明 | | -------- | -------- | @@ -374,7 +491,7 @@ hdc_std list targets -v - **shell [_command_]** 远程执行命令或进入交互命令环境。 - **表15** 命令说明 + **表18** 命令说明 | 参数 | 参数说明 | | -------- | -------- | @@ -389,6 +506,16 @@ hdc_std list targets -v hdc_std shell ``` +- **jpid** + 获取可调试进程列表。 + + 使用方法: + + + ``` + hdc_std jpid + ``` + ## 常见问题 diff --git "a/zh-cn/readme/AI\344\270\232\345\212\241\345\255\220\347\263\273\347\273\237.md" "b/zh-cn/readme/AI\344\270\232\345\212\241\345\255\220\347\263\273\347\273\237.md" index 8e062d1450bace80dad9f071044b54c3a64b94a4..8f34ff92d49e53bc40e7ba54fa86a5adb5301271 100644 --- "a/zh-cn/readme/AI\344\270\232\345\212\241\345\255\220\347\263\273\347\273\237.md" +++ "b/zh-cn/readme/AI\344\270\232\345\212\241\345\255\220\347\263\273\347\273\237.md" @@ -420,7 +420,7 @@ AI业务子系统是OpenHarmony提供原生的分布式AI能力的子系统。 [ai_engine](https://gitee.com/openharmony/ai_engine) -依赖仓: +## 依赖仓: [build\_lite](https://gitee.com/openharmony/build_lite/blob/master/README_zh.md) @@ -430,4 +430,4 @@ AI业务子系统是OpenHarmony提供原生的分布式AI能力的子系统。 ## AI引擎开发导航 -[《AI插件开发指南》](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/subsystems/subsys-aiframework-guide.md) \ No newline at end of file +[《AI插件开发指南》](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/subsystems/subsys-ai-aiframework-devguide.md) \ No newline at end of file diff --git "a/zh-cn/readme/\345\256\211\345\205\250\345\255\220\347\263\273\347\273\237.md" "b/zh-cn/readme/\345\256\211\345\205\250\345\255\220\347\263\273\347\273\237.md" index de1ce4bbbac247c44735b9c5eedd04a397a472ee..f7d8d7721681c16e572316c8bace8b782ed64336 100755 --- "a/zh-cn/readme/\345\256\211\345\205\250\345\255\220\347\263\273\347\273\237.md" +++ "b/zh-cn/readme/\345\256\211\345\205\250\345\255\220\347\263\273\347\273\237.md" @@ -103,7 +103,7 @@ OpenHarmony允许应用安装。为了确保应用的完整性和来源可靠, [security_device_auth](https://gitee.com/openharmony/security_device_auth) -[security_permission](https://gitee.com/openharmony/security_permission) +[security_permission_lite](https://gitee.com/openharmony/security_permission_lite) [security_device_security_level](https://gitee.com/openharmony/security_device_security_level) diff --git "a/zh-cn/readme/\347\224\250\346\210\267IAM\345\255\220\347\263\273\347\273\237.md" "b/zh-cn/readme/\347\224\250\346\210\267IAM\345\255\220\347\263\273\347\273\237.md" index f7f7393731dfdea1b4a5252b72e12ab9a6425964..2a5c008647203981e2da766e24c29bb14173d476 100644 --- "a/zh-cn/readme/\347\224\250\346\210\267IAM\345\255\220\347\263\273\347\273\237.md" +++ "b/zh-cn/readme/\347\224\250\346\210\267IAM\345\255\220\347\263\273\347\273\237.md" @@ -10,7 +10,7 @@ ## 简介 -用户身份和访问管理子系统,下称用户IAM(Identity and Access Management),旨在为OpenHarmony提供的统一用户身份凭据信息管理和用户身份认证框架能力,支持多用户分别设置认证凭据信息,并根据用户设置的认证凭据信息提供用户身份认证功能,支撑锁屏等安全场景。同时,用户IAM子系统也提供API,支持三方开发者调用系统提供的身份认证能力来实现业务对用户的访问控制要求。 +用户身份和访问管理子系统,下称用户IAM(Identity and Access Management),旨在为OpenHarmony提供统一用户身份凭据信息管理和用户身份认证框架能力,支持多用户分别设置认证凭据信息,并根据用户设置的认证凭据信息提供用户身份认证功能,支撑锁屏等安全场景。同时,用户IAM子系统也提供API,支持三方开发者调用系统提供的身份认证能力来实现业务对用户的访问控制要求。 **图1** 子系统架构图 diff --git "a/zh-cn/readme/\347\263\273\347\273\237\346\234\215\345\212\241\347\256\241\347\220\206\345\255\220\347\263\273\347\273\237.md" "b/zh-cn/readme/\347\263\273\347\273\237\346\234\215\345\212\241\347\256\241\347\220\206\345\255\220\347\263\273\347\273\237.md" index 26b7704d75d1c3ebfba4954a3cb01540528f5e66..5ea0532010f044a487917f4a50bcfd66e8a11152 100755 --- "a/zh-cn/readme/\347\263\273\347\273\237\346\234\215\345\212\241\347\256\241\347\220\206\345\255\220\347\263\273\347\273\237.md" +++ "b/zh-cn/readme/\347\263\273\347\273\237\346\234\215\345\212\241\347\256\241\347\220\206\345\255\220\347\263\273\347\273\237.md" @@ -1,23 +1,36 @@ # 系统服务管理子系统 -- [系统服务管理子系统](#系统服务管理子系统) - - [简介](#简介) - - [系统架构](#系统架构) - - [目录](#目录) - - [相关仓](#相关仓) - ## 简介 系统服务管理子系统实现系统服务框架,提供系统服务的启动、注册、查询功能,提供查询跨设备的分布式系统服务。 - ## 系统架构 +系统服务管理子系统架构如下图所示。 + **图 1** 子系统架构图 ![](figures/samgr-architecture.png) +系统服务管理子系统主要包含四个组件: + +- safwk组件 + + 在系统服务管理子系统中safwk组件定义OpenHarmony中SystemAbility的实现方法,并提供启动、注册等接口实现。 + +- samgr组件 + + OpenHarmony的核心组件,提供OpenHarmony系统服务启动、注册、查询等功能。 + +- safwk_lite组件 + + 轻量foundation进程实现,负责提供基础服务运行的空进程。 + +- samgr_lite组件 + + 轻量系统服务管理模块,主要提供服务的注册与发现能力。 + ## 目录 ``` diff --git a/zh-cn/website.md b/zh-cn/website.md index 590555164ab73554048b57c2f42db2963af800f8..6171cc9bfc7fba331873424b1f86b7adade5f129 100644 --- a/zh-cn/website.md +++ b/zh-cn/website.md @@ -30,7 +30,7 @@ - API差异报告 - - OpenHamrony 3.2 Beta2 + - OpenHarmony 3.2 Beta2 - JS API差异报告 - [元能力](release-notes/api-change/v3.2-beta2/js-apidiff-ability.md) - [无障碍](release-notes/api-change/v3.2-beta2/js-apidiff-accessibility.md)