未验证 提交 059101aa 编写于 作者: O openharmony_ci 提交者: Gitee

!23988 【挑单Monthly分支】翻译完成...

!23988 【挑单Monthly分支】翻译完成 23661+23276+23354+23828+23377+23196+23630:自定义弹窗文档+js-apis-uitest.md整改+系统参数文档修改
Merge pull request !23988 from ester.zhou/M-0905
# @ohos.systemParameter (System Parameter)
The **SystemParameter** module provides system services with easy access to key-value pairs. You can use the APIs provided by this module to describe the service status and change the service behavior. The basic operation primitives are get and set. You can obtain the values of system parameters through getters and modify the values through setters.
For details about the system parameter design principles and definitions, see
[Service Management](../../../device-dev/subsystems/subsys-boot-init-sysparam.md).
For details about the system parameter design principles and definitions, see [Parameter Management](../../../device-dev/subsystems/subsys-boot-init-sysparam.md).
> **NOTE**
> - The APIs of this module are no longer maintained since API version 9. It is recommended that you use [@ohos.systemParameterEnhance](js-apis-system-parameterEnhance.md) instead.
......@@ -14,7 +14,7 @@ For details about the system parameter design principles and definitions, see
## Modules to Import
```ts
import systemparameter from '@ohos.systemparameter'
import systemparameter from '@ohos.systemparameter';
```
## systemparameter.getSync<sup>(deprecated)</sup>
......@@ -30,19 +30,19 @@ Obtains the value of the system parameter with the specified key.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| key | string | Yes| Key of the system parameter.|
| def | string | No| Default value of the system parameter.<br>It works only when the system parameter does not exist.<br>The value can be **undefined** or any custom value. |
| def | string | No| Default value of the system parameter.<br> It works only when the system parameter does not exist.<br>The value can be **undefined** or any custom value.|
**Return value**
| Type| Description|
| -------- | -------- |
| string | Value of the system parameter.<br>If the specified key exists, the set value is returned.<br>If the specified key does not exist and **def** is set to a valid value, the set value is returned. If the specified key does not exist and **def** is set to an invalid value (such as **undefined**) or is not set, an empty string is returned. |
| string | Value of the system parameter.<br>If the specified key exists, the set value is returned.<br>If the specified key does not exist and **def** is set to a valid value, the set value is returned. If the specified key does not exist and **def** is set to an invalid value (such as **undefined**) or is not set, an empty string is returned.|
**Example**
```ts
try {
var info = systemparameter.getSync("const.ohos.apiversion");
let info = systemparameter.getSync("const.ohos.apiversion");
console.log(JSON.stringify(info));
} catch(e) {
console.log("getSync unexpected error: " + e);
......@@ -67,8 +67,10 @@ Obtains the value of the system parameter with the specified key. This API uses
**Example**
```ts
import { BusinessError } from '@ohos.base';
try {
systemparameter.get("const.ohos.apiversion", function (err, data) {
systemparameter.get("const.ohos.apiversion", (err: BusinessError, data: string) => {
if (err == undefined) {
console.log("get test.parameter.key value success:" + data)
} else {
......@@ -98,8 +100,10 @@ Obtains the value of the system parameter with the specified key. This API uses
**Example**
```ts
import { BusinessError } from '@ohos.base';
try {
systemparameter.get("const.ohos.apiversion", "default", function (err, data) {
systemparameter.get("const.ohos.apiversion", "default", (err: BusinessError, data: string) => {
if (err == undefined) {
console.log("get test.parameter.key value success:" + data)
} else {
......@@ -124,7 +128,7 @@ Obtains the value of the system parameter with the specified key. This API uses
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| key | string | Yes| Key of the system parameter.|
| def | string | No| Default value of the system parameter.<br>It works only when the system parameter does not exist.<br>The value can be **undefined** or any custom value. |
| def | string | No| Default value of the system parameter.<br> It works only when the system parameter does not exist.<br> The value can be **undefined** or any custom value.|
**Return value**
......@@ -135,11 +139,13 @@ Obtains the value of the system parameter with the specified key. This API uses
**Example**
```ts
import { BusinessError } from '@ohos.base';
try {
var p = systemparameter.get("const.ohos.apiversion");
p.then(function (value) {
let p = systemparameter.get("const.ohos.apiversion");
p.then((value: string) => {
console.log("get test.parameter.key success: " + value);
}).catch(function (err) {
}).catch((err: BusinessError) => {
console.log("get test.parameter.key error: " + err.code);
});
} catch(e) {
......@@ -200,8 +206,10 @@ Sets a value for the system parameter with the specified key. This API uses an a
**Example**
```ts
import { BusinessError } from '@ohos.base';
try {
systemparameter.set("test.parameter.key", "testValue", function (err, data) {
systemparameter.set("test.parameter.key", "testValue", (err: BusinessError, data: void) =>{
if (err == undefined) {
console.log("set test.parameter.key value success :" + data)
} else {
......@@ -240,11 +248,13 @@ Sets a value for the system parameter with the specified key. This API uses a pr
**Example**
```ts
import { BusinessError } from '@ohos.base';
try {
var p = systemparameter.set("test.parameter.key", "testValue");
p.then(function (value) {
let p = systemparameter.set("test.parameter.key", "testValue");
p.then((value: void) => {
console.log("set test.parameter.key success: " + value);
}).catch(function (err) {
}).catch((err: BusinessError) => {
console.log(" set test.parameter.key error: " + err.code);
});
} catch(e) {
......
# @ohos.systemParameterEnhance (System Parameter)
The **SystemParameter** module provides system services with easy access to key-value pairs. You can use the APIs provided by this module to describe the service status and change the service behavior. The basic operation primitives are get and set. You can obtain the values of system parameters through getters and modify the values through setters.
For details about the system parameter design principles and definitions, see
[Service Management](../../../device-dev/subsystems/subsys-boot-init-sysparam.md).
For details about the system parameter design principles and definitions, see [Parameter Management](../../../device-dev/subsystems/subsys-boot-init-sysparam.md).
> **NOTE**
>
......@@ -13,7 +13,7 @@ For details about the system parameter design principles and definitions, see
## Modules to Import
```ts
import systemparameter from '@ohos.systemParameterEnhance'
import systemparameter from '@ohos.systemParameterEnhance';
```
## systemparameter.getSync
......@@ -29,19 +29,30 @@ Obtains the value of the system parameter with the specified key.
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| key | string | Yes| Key of the system parameter.|
| def | string | No| Default value of the system parameter.<br>It works only when the system parameter does not exist.<br>The value can be **undefined** or any custom value. |
| def | string | No| Default value of the system parameter.<br> It works only when the system parameter does not exist.<br> The value can be **undefined** or any custom value.|
**Return value**
| Type| Description|
| -------- | -------- |
| string | Value of the system parameter.<br>If the specified key exists, the set value is returned.<br>If the specified key does not exist and **def** is set to a valid value, the set value is returned. If the specified key does not exist and **def** is set to an invalid value (such as **undefined**) or is not set, an exception is thrown. |
| string | Value of the system parameter.<br> If the specified key exists, the set value is returned.<br> If the specified key does not exist and **def** is set to a valid value, the set value is returned. If the specified key does not exist and **def** is set to an invalid value (such as **undefined**) or is not set, an exception is thrown.|
**Error codes**
| ID| Error Message |
| -------- | ------------------------------------------------------------ |
| 14700101 | System parameter can not be found. |
| 14700102 | System parameter value is invalid. |
| 14700103 | System permission operation permission denied. |
| 14700104 | System internal error including out of memory, deadlock etc. |
For details about the error codes, see [System Parameter Error Codes](../errorcodes/errorcode-system-parameterV9.md).
**Example**
```ts
try {
var info = systemparameter.getSync("const.ohos.apiversion");
let info = systemparameter.getSync("const.ohos.apiversion");
console.log(JSON.stringify(info));
} catch(e) {
console.log("getSync unexpected error: " + e);
......@@ -63,11 +74,24 @@ Obtains the value of the system parameter with the specified key.
| key | string | Yes| Key of the system parameter.|
| callback | AsyncCallback&lt;string&gt; | Yes| Callback used to return the result.|
**Error codes**
| ID| Error Message |
| -------- | ------------------------------------------------------------ |
| 14700101 | System parameter can not be found. |
| 14700102 | System parameter value is invalid. |
| 14700103 | System permission operation permission denied. |
| 14700104 | System internal error including out of memory, deadlock etc. |
For details about the error codes, see [System Parameter Error Codes](../errorcodes/errorcode-system-parameterV9.md).
**Example**
```ts
import { BusinessError } from '@ohos.base';
try {
systemparameter.get("const.ohos.apiversion", function (err, data) {
systemparameter.get("const.ohos.apiversion", (err: BusinessError, data: string) => {
if (err == undefined) {
console.log("get test.parameter.key value success:" + data)
} else {
......@@ -94,11 +118,24 @@ Obtains the value of the system parameter with the specified key. This API uses
| def | string | Yes| Default value.|
| callback | AsyncCallback&lt;string&gt; | Yes| Callback used to return the result.|
**Error codes**
| ID| Error Message |
| -------- | ------------------------------------------------------------ |
| 14700101 | System parameter can not be found. |
| 14700102 | System parameter value is invalid. |
| 14700103 | System permission operation permission denied. |
| 14700104 | System internal error including out of memory, deadlock etc. |
For details about the error codes, see [System Parameter Error Codes](../errorcodes/errorcode-system-parameterV9.md).
**Example**
```ts
import { BusinessError } from '@ohos.base';
try {
systemparameter.get("const.ohos.apiversion", "default", function (err, data) {
systemparameter.get("const.ohos.apiversion", "default", (err: BusinessError, data: string) => {
if (err == undefined) {
console.log("get test.parameter.key value success:" + data)
} else {
......@@ -123,7 +160,7 @@ Obtains the value of the system parameter with the specified key. This API uses
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| key | string | Yes| Key of the system parameter.|
| def | string | No| Default value of the system parameter.<br>It works only when the system parameter does not exist.<br>The value can be **undefined** or any custom value. |
| def | string | No| Default value of the system parameter.<br> It works only when the system parameter does not exist.<br> The value can be **undefined** or any custom value.|
**Return value**
......@@ -131,14 +168,27 @@ Obtains the value of the system parameter with the specified key. This API uses
| -------- | -------- |
| Promise&lt;string&gt; | Promise used to return the execution result.|
**Error codes**
| ID| Error Message |
| -------- | ------------------------------------------------------------ |
| 14700101 | System parameter can not be found. |
| 14700102 | System parameter value is invalid. |
| 14700103 | System permission operation permission denied. |
| 14700104 | System internal error including out of memory, deadlock etc. |
For details about the error codes, see [System Parameter Error Codes](../errorcodes/errorcode-system-parameterV9.md).
**Example**
```ts
import { BusinessError } from '@ohos.base';
try {
var p = systemparameter.get("const.ohos.apiversion");
p.then(function (value) {
let p = systemparameter.get("const.ohos.apiversion");
p.then((value: string) => {
console.log("get test.parameter.key success: " + value);
}).catch(function (err) {
}).catch((err: BusinessError) => {
console.log("get test.parameter.key error: " + err.code);
});
} catch(e) {
......@@ -161,9 +211,21 @@ Sets a value for the system parameter with the specified key.
| key | string | Yes| Key of the system parameter.|
| value | string | Yes| Value of the system parameter to set.|
**Error codes**
| ID| Error Message |
| -------- | ------------------------------------------------------------ |
| 14700102 | System parameter value is invalid. |
| 14700103 | System permission operation permission denied. |
| 14700104 | System internal error including out of memory, deadlock etc. |
For details about the error codes, see [System Parameter Error Codes](../errorcodes/errorcode-system-parameterV9.md).
**Example**
```ts
import { BusinessError } from '@ohos.base';
try {
systemparameter.setSync("test.parameter.key", "default");
} catch(e) {
......@@ -187,11 +249,23 @@ Sets a value for the system parameter with the specified key. This API uses an a
| value | string | Yes| Value of the system parameter to set.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
**Error codes**
| ID| Error Message |
| -------- | ------------------------------------------------------------ |
| 14700102 | System parameter value is invalid. |
| 14700103 | System permission operation permission denied. |
| 14700104 | System internal error including out of memory, deadlock etc. |
For details about the error codes, see [System Parameter Error Codes](../errorcodes/errorcode-system-parameterV9.md).
**Example**
```ts
import { BusinessError } from '@ohos.base';
try {
systemparameter.set("test.parameter.key", "testValue", function (err, data) {
systemparameter.set("test.parameter.key", "testValue", (err: BusinessError, data: void) => {
if (err == undefined) {
console.log("set test.parameter.key value success :" + data)
} else {
......@@ -223,14 +297,26 @@ Sets a value for the system parameter with the specified key. This API uses a pr
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the execution result.|
**Error codes**
| ID| Error Message |
| -------- | ------------------------------------------------------------ |
| 14700102 | System parameter value is invalid. |
| 14700103 | System permission operation permission denied. |
| 14700104 | System internal error including out of memory, deadlock etc. |
For details about the error codes, see [System Parameter Error Codes](../errorcodes/errorcode-system-parameterV9.md).
**Example**
```ts
import { BusinessError } from '@ohos.base';
try {
var p = systemparameter.set("test.parameter.key", "testValue");
p.then(function (value) {
let p = systemparameter.set("test.parameter.key", "testValue");
p.then((value: void) => {
console.log("set test.parameter.key success: " + value);
}).catch(function (err) {
}).catch((err: BusinessError) => {
console.log(" set test.parameter.key error: " + err.code);
});
} catch(e) {
......
......@@ -17,7 +17,7 @@ CustomDialogController(value:{builder: CustomDialog, cancel?: () =&gt; void, aut
| Name | Type | Mandatory | Description |
| ----------------------------- | ---------------------------------------- | ---- | ---------------------------------------- |
| builder | CustomDialog | Yes | Constructor of the custom dialog box content. |
| builder | CustomDialog | Yes | Builder of the custom dialog box content. |
| cancel | () =&gt; void | No | Callback invoked when the dialog box is closed after the overlay exits. |
| autoCancel | boolean | No | Whether to allow users to click the overlay to exit.<br>Default value: **true** |
| alignment | [DialogAlignment](ts-methods-alert-dialog-box.md#dialogalignment) | No | Alignment mode of the dialog box in the vertical direction.<br>Default value: **DialogAlignment.Default**|
......@@ -29,7 +29,7 @@ CustomDialogController(value:{builder: CustomDialog, cancel?: () =&gt; void, aut
| openAnimation<sup>10+</sup> | [AnimateParam](ts-explicit-animation.md#animateparam) | No | Parameters for defining the open animation of the dialog box.<br>**NOTE**<br>**iterations**: The default value is **1**, indicating that the animation is played once; any other value evaluates to the default value.<br>**playMode**: The default value is **PlayMode.Normal**; any other value evaluates to the default value.|
| closeAniamtion<sup>10+</sup> | [AnimateParam](ts-explicit-animation.md#animateparam) | No | Parameters for defining the close animation of the dialog box.<br>**NOTE**<br>**iterations**: The default value is **1**, indicating that the animation is played once; any other value evaluates to the default value.<br>**playMode**: The default value is **PlayMode.Normal**; any other value evaluates to the default value. |
| showInSubWindow<sup>10+</sup> | boolean | No | Whether to display a dialog box in a subwindow.<br>Default value: **false**, indicating that the dialog box is not displayed in the subwindow<br>**NOTE**<br>A dialog box whose **showInSubWindow** attribute is **true** cannot trigger the display of another dialog box whose **showInSubWindow** attribute is also **true**.|
| backgroundColor<sup>10+</sup> | [ResourceColor](ts-types.md#resourcecolor) | No | Background color of the dialog box. |
| backgroundColor<sup>10+</sup> | [ResourceColor](ts-types.md#resourcecolor) | No | Background color of the dialog box.<br>**NOTE**<br>If the content builder also has the background color set, the background color set here will be overridden by the background color of the content builder.|
| cornerRadius<sup>10+</sup> | [BorderRadiuses](ts-types.md#borderradiuses9) \| [Dimension](ts-types.md#dimension10) | No | Radius of the rounded corners of the background.<br>You can set separate radiuses for the four rounded corners.<br>Default value: **{ topLeft: '24vp', topRight: '24vp', bottomLeft: '24vp', bottomRight: '24vp' }**<br>**NOTE**<br>This attribute must be used together with the [borderRadius](ts-universal-attributes-border.md) attribute.|
## CustomDialogController
......@@ -110,7 +110,7 @@ struct CustomDialogUser {
}),
cancel: this.existApp,
autoCancel: true,
alignment: DialogAlignment.Default,
alignment: DialogAlignment.Bottom,
offset: { dx: 0, dy: -20 },
gridCount: 4,
customStyle: false,
......
......@@ -44,7 +44,7 @@ You can bind a popup to a component, specifying its content, interaction logic,
| ---------------------------- | ---------------------------------------- | ---- | ---------------------------------------- |
| builder | [CustomBuilder](ts-types.md#custombuilder8) | Yes | Popup builder.<br>**NOTE**<br>The **popup** attribute is a universal attribute. A custom popup does not support display of another popup. The **position** attribute cannot be used for the first-layer container under the builder. If the **position** attribute is used, the popup will not be displayed. |
| placement | [Placement](ts-appendix-enums.md#placement8) | No | Preferred position of the popup. If the set position is insufficient for holding the popup, it will be automatically adjusted.<br>Default value: **Placement.Bottom**|
| popupColor | [ResourceColor](ts-types.md#resourcecolor) | No | Color of the popup. |
| popupColor | [ResourceColor](ts-types.md#resourcecolor) | No | Color of the popup.<br>Default value: **'#4d4d4d'**|
| enableArrow | boolean | No | Whether to display an arrow.<br>Since API version 9, if the position set for the popup is not large enough, the arrow will not be displayed. For example, if **placement** is set to **Left**, but the popup height (80 vp) is less than the sum of the arrow width (32 vp) and diameter of popup rounded corner (48 vp), the arrow will not be displayed.<br>Default value: **true**|
| autoCancel | boolean | No | Whether to automatically close the popup when an operation is performed on the page.<br>Default value: **true** |
| onStateChange | (event: { isVisible: boolean }) =&gt; void | No | Callback for the popup status change event.<br/>**isVisible**: whether the popup is visible. |
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册