提交 2ac37e62 编写于 作者: G Gloria

Update docs against 11641+11923+11618+11555

Signed-off-by: wusongqing<wusongqing@huawei.com>
上级 a2c3bd87
...@@ -21,7 +21,7 @@ import WindowExtensionAbility from '@ohos.application.WindowExtensionAbility'; ...@@ -21,7 +21,7 @@ import WindowExtensionAbility from '@ohos.application.WindowExtensionAbility';
| Name | Type| Readable| Writable| Description | | Name | Type| Readable| Writable| Description |
| --------- | -------- | ---- | ---- | ------------------------- | | --------- | -------- | ---- | ---- | ------------------------- |
| context | [ExtensionContext](js-apis-extension-context.md) | Yes | No | Context of an Extension ability. | | context | [ExtensionContext](js-apis-inner-application-extensionContext.md) | Yes | No | Context of an Extension ability. |
## WindowExtensionAbility.onConnect ## WindowExtensionAbility.onConnect
...@@ -35,7 +35,7 @@ Called when this Window Extension ability is connected to an ability for the fir ...@@ -35,7 +35,7 @@ Called when this Window Extension ability is connected to an ability for the fir
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Information related to this Window Extension ability, including the ability name and bundle name.| | want | [Want](js-apis-application-want.md) | Yes| Information related to this Window Extension ability, including the ability name and bundle name.|
**Example** **Example**
...@@ -61,7 +61,7 @@ Called when this Window Extension ability is disconnected from all connected abi ...@@ -61,7 +61,7 @@ Called when this Window Extension ability is disconnected from all connected abi
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | Yes| Information related to this Window Extension ability, including the ability name and bundle name.| | want | [Want](js-apis-application-want.md) | Yes| Information related to this Window Extension ability, including the ability name and bundle name.|
**Example** **Example**
...@@ -107,3 +107,5 @@ export default class MyWindowExtensionAbility extends WindowExtensionAbility { ...@@ -107,3 +107,5 @@ export default class MyWindowExtensionAbility extends WindowExtensionAbility {
} }
``` ```
<!--no_check-->
\ No newline at end of file
...@@ -35,10 +35,10 @@ Describes a rectangle on the display. ...@@ -35,10 +35,10 @@ Describes a rectangle on the display.
| Name | Type| Readable| Writable| Description | | Name | Type| Readable| Writable| Description |
| ------ | -------- | ---- | ---- | ------------------ | | ------ | -------- | ---- | ---- | ------------------ |
| left | number | Yes | Yes | Left boundary of the rectangle.| | left | number | Yes | Yes | Left boundary of the rectangle, in pixels.|
| top | number | Yes | Yes | Top boundary of the rectangle.| | top | number | Yes | Yes | Top boundary of the rectangle, in pixels.|
| width | number | Yes | Yes | Width of the rectangle. | | width | number | Yes | Yes | Width of the rectangle, in pixels. |
| height | number | Yes | Yes | Height of the rectangle. | | height | number | Yes | Yes | Height of the rectangle, in pixels. |
## WaterfallDisplayAreaRects<sup>9+</sup> ## WaterfallDisplayAreaRects<sup>9+</sup>
...@@ -94,7 +94,7 @@ try { ...@@ -94,7 +94,7 @@ try {
displayClass = display.getDefaultDisplaySync(); displayClass = display.getDefaultDisplaySync();
} catch (exception) { } catch (exception) {
console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception)); console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception));
}; }
``` ```
## display.getAllDisplays<sup>9+</sup> ## display.getAllDisplays<sup>9+</sup>
...@@ -204,25 +204,24 @@ For details about the error codes, see [Display Error Codes](../errorcodes/error ...@@ -204,25 +204,24 @@ For details about the error codes, see [Display Error Codes](../errorcodes/error
let displayClass = null; let displayClass = null;
try { try {
displayClass = display.getDefaultDisplaySync(); displayClass = display.getDefaultDisplaySync();
} catch (exception) {
console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception));
return;
};
let ret = undefined; let ret = undefined;
try { try {
ret = display.hasPrivateWindow(displayClass.id); ret = display.hasPrivateWindow(displayClass.id);
} catch (exception) { } catch (exception) {
console.error('Failed to check has privateWindow or not. Code: ' + JSON.stringify(exception)); console.error('Failed to check has privateWindow or not. Code: ' + JSON.stringify(exception));
}; }
if (ret == undefined) { if (ret == undefined) {
console.log("Failed to check has privateWindow or not."); console.log("Failed to check has privateWindow or not.");
} }
if (ret) { if (ret) {
console.log("There has privateWindow."); console.log("There has privateWindow.");
} else if (!ret) { } else if (!ret) {
console.log("There has no privateWindow."); console.log("There has no privateWindow.");
}; }
} catch (exception) {
console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception));
}
``` ```
## display.on('add'|'remove'|'change') ## display.on('add'|'remove'|'change')
...@@ -237,7 +236,7 @@ Subscribes to display changes. ...@@ -237,7 +236,7 @@ Subscribes to display changes.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes| Event type.<br>- **add**, indicating the display addition event. Example: event indicating that a display is connected to a PC.<br>- **remove**, indicating the display removal event. Example: event that a display is disconnected from a PC.<br>- **change**, indicating the display change event. Example: event that the display orientation is changed.| | type | string | Yes| Event type.<br>- **add**, indicating the display addition event. Example: event that a display is connected.<br>- **remove**, indicating the display removal event. Example: event that a display is disconnected.<br>- **change**, indicating the display change event. Example: event that the display orientation is changed.|
| callback | Callback&lt;number&gt; | Yes| Callback used to return the ID of the display.| | callback | Callback&lt;number&gt; | Yes| Callback used to return the ID of the display.|
**Example** **Example**
...@@ -250,7 +249,7 @@ try { ...@@ -250,7 +249,7 @@ try {
display.on("add", callback); display.on("add", callback);
} catch (exception) { } catch (exception) {
console.error('Failed to register callback. Code: ' + JSON.stringify(exception)); console.error('Failed to register callback. Code: ' + JSON.stringify(exception));
}; }
``` ```
## display.off('add'|'remove'|'change') ## display.off('add'|'remove'|'change')
...@@ -265,7 +264,7 @@ Unsubscribes from display changes. ...@@ -265,7 +264,7 @@ Unsubscribes from display changes.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes| Event type.<br>- **add**, indicating the display addition event. Example: event indicating that a display is connected to a PC.<br>- **remove**, indicating the display removal event. Example: event that a display is disconnected from a PC.<br>- **change**, indicating the display change event. Example: event that the display orientation is changed.| | type | string | Yes| Event type.<br>- **add**, indicating the display addition event. Example: event that a display is connected.<br>- **remove**, indicating the display removal event. Example: event indicating that a display is disconnected.<br>- **change**, indicating the display change event. Example: event that the display orientation is changed.|
| callback | Callback&lt;number&gt; | No| Callback used to return the ID of the display.| | callback | Callback&lt;number&gt; | No| Callback used to return the ID of the display.|
**Example** **Example**
...@@ -275,7 +274,7 @@ try { ...@@ -275,7 +274,7 @@ try {
display.off("remove"); display.off("remove");
} catch (exception) { } catch (exception) {
console.error('Failed to unregister callback. Code: ' + JSON.stringify(exception)); console.error('Failed to unregister callback. Code: ' + JSON.stringify(exception));
}; }
``` ```
## display.getDefaultDisplay<sup>(deprecated)</sup> ## display.getDefaultDisplay<sup>(deprecated)</sup>
...@@ -434,7 +433,7 @@ Obtains the cutout information of the display. This API uses an asynchronous cal ...@@ -434,7 +433,7 @@ Obtains the cutout information of the display. This API uses an asynchronous cal
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ----------- | --------------------------- | ---- | ------------------------------------------------------------ | | ----------- | --------------------------- | ---- | ------------------------------------------------------------ |
| callback | AsyncCallback&lt;[CutoutInfo](#cutoutinfo9)&gt; | Yes | Callback used to return the result. If the operation is successful, **err** is **undefined** and **data** is the **CutoutInfo** object obtained. Otherwise, **err** is an error object.| | callback | AsyncCallback&lt;[CutoutInfo](#cutoutinfo9)&gt; | Yes | Callback used to return the **CutoutInfo** object.|
**Error codes** **Error codes**
...@@ -450,17 +449,17 @@ For details about the error codes, see [Display Error Codes](../errorcodes/error ...@@ -450,17 +449,17 @@ For details about the error codes, see [Display Error Codes](../errorcodes/error
let displayClass = null; let displayClass = null;
try { try {
displayClass = display.getDefaultDisplaySync(); displayClass = display.getDefaultDisplaySync();
} catch (exception) {
console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception));
};
displayClass.getCutoutInfo((err, data) => { displayClass.getCutoutInfo((err, data) => {
if (err.code) { if (err.code) {
console.error('Failed to get cutoutInfo. Code: ' + JSON.stringify(err)); console.error('Failed to get cutoutInfo. Code: ' + JSON.stringify(err));
return; return;
} }
console.info('Succeeded in getting cutoutInfo. data: ' + JSON.stringify(data)); console.info('Succeeded in getting cutoutInfo. data: ' + JSON.stringify(data));
}); });
} catch (exception) {
console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception));
}
``` ```
### getCutoutInfo<sup>9+</sup> ### getCutoutInfo<sup>9+</sup>
getCutoutInfo(): Promise&lt;CutoutInfo&gt; getCutoutInfo(): Promise&lt;CutoutInfo&gt;
...@@ -489,12 +488,14 @@ For details about the error codes, see [Display Error Codes](../errorcodes/error ...@@ -489,12 +488,14 @@ For details about the error codes, see [Display Error Codes](../errorcodes/error
let displayClass = null; let displayClass = null;
try { try {
displayClass = display.getDefaultDisplaySync(); displayClass = display.getDefaultDisplaySync();
} catch (exception) {
console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception));
};
let promise = displayClass.getCutoutInfo(); let promise = displayClass.getCutoutInfo();
promise.then((data) => { promise.then((data) => {
console.info('Succeeded in getting cutoutInfo. Data: ' + JSON.stringify(data)); console.info('Succeeded in getting cutoutInfo. Data: ' + JSON.stringify(data));
}); }).catch((err) => {
console.error('Failed to obtain all the display objects. Code: ' + JSON.stringify(err));
});
} catch (exception) {
console.error('Failed to obtain the default display object. Code: ' + JSON.stringify(exception));
}
``` ```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册