未验证 提交 75ea3c8e 编写于 作者: O openharmony_ci 提交者: Gitee

!13312 翻译已完成12332+12384+12442+12654+12629

Merge pull request !13312 from shawn_he/12332-a
...@@ -48,28 +48,28 @@ var callback = { ...@@ -48,28 +48,28 @@ var callback = {
export default class MainAbility extends Ability { export default class MainAbility extends Ability {
onCreate(want, launchParam) { onCreate(want, launchParam) {
console.log("[Demo] MainAbility onCreate") console.log("[Demo] MainAbility onCreate")
registerId = errorManager.registerErrorObserver(callback);
globalThis.abilityWant = want; globalThis.abilityWant = want;
} }
onDestroy() { onDestroy() {
console.log("[Demo] MainAbility onDestroy") console.log("[Demo] MainAbility onDestroy")
errorManager.unregisterErrorObserver(registerId, (result) => {
console.log("[Demo] result " + result.code + ";" + result.message)
});
} }
onWindowStageCreate(windowStage) { onWindowStageCreate(windowStage) {
// Main window is created for this ability. // Main window is created for this ability.
console.log("[Demo] MainAbility onWindowStageCreate") console.log("[Demo] MainAbility onWindowStageCreate")
globalThis.registerObserver = (() => { windowStage.loadContent("pages/index", (err, data) => {
registerId = errorManager.registerErrorObserver(callback); if (err.code) {
}) console.error('Failed to load the content. Cause:' + JSON.stringify(err));
return;
globalThis.unRegisterObserver = (() => { }
errorManager.unregisterErrorObserver(registerId, (result) => { console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data))
console.log("[Demo] result " + result.code + ";" + result.message) });
});
})
windowStage.setUIContent(this.context, "pages/index", null)
} }
onWindowStageDestroy() { onWindowStageDestroy() {
......
...@@ -83,6 +83,7 @@ You can create resource group subdirectories (including element, media, and prof ...@@ -83,6 +83,7 @@ You can create resource group subdirectories (including element, media, and prof
| ------- | ---------------------------------------- | ---------------------------------------- | | ------- | ---------------------------------------- | ---------------------------------------- |
| element | Indicates element resources. Each type of data is represented by a JSON file. The options are as follows:<br>- **boolean**: boolean data<br>- **color**: color data<br>- **float**: floating-point data<br>- **intarray**: array of integers<br>- **integer**: integer data<br>- **pattern**: pattern data<br>- **plural**: plural form data<br>- **strarray**: array of strings<br>- **string**: string data| It is recommended that files in the **element** subdirectory be named the same as the following files, each of which can contain only data of the same type:<br>- boolean.json<br>- color.json<br>- float.json<br>- intarray.json<br>- integer.json<br>- pattern.json<br>- plural.json<br>- strarray.json<br>- string.json | | element | Indicates element resources. Each type of data is represented by a JSON file. The options are as follows:<br>- **boolean**: boolean data<br>- **color**: color data<br>- **float**: floating-point data<br>- **intarray**: array of integers<br>- **integer**: integer data<br>- **pattern**: pattern data<br>- **plural**: plural form data<br>- **strarray**: array of strings<br>- **string**: string data| It is recommended that files in the **element** subdirectory be named the same as the following files, each of which can contain only data of the same type:<br>- boolean.json<br>- color.json<br>- float.json<br>- intarray.json<br>- integer.json<br>- pattern.json<br>- plural.json<br>- strarray.json<br>- string.json |
| media | Indicates media resources, including non-text files such as images, audios, and videos. | The file name can be customized, for example, **icon.png**. | | media | Indicates media resources, including non-text files such as images, audios, and videos. | The file name can be customized, for example, **icon.png**. |
| profile | Indicates a user-defined configuration file. You can obtain the file content by using the [getProfileByAbility](../reference/apis/js-apis-bundleManager.md#bundlemanagergetprofilebyability) API. | The file name can be customized, for example, **test_profile.json**. |
| rawfile | Indicates other types of files, which are stored in their raw formats after the application is built as an HAP file. They will not be integrated into the **resources.index** file.| The file name can be customized. | | rawfile | Indicates other types of files, which are stored in their raw formats after the application is built as an HAP file. They will not be integrated into the **resources.index** file.| The file name can be customized. |
**Media Resource Types** **Media Resource Types**
......
...@@ -33,7 +33,7 @@ Obtains the IDs of all input devices. This API uses an asynchronous callback to ...@@ -33,7 +33,7 @@ Obtains the IDs of all input devices. This API uses an asynchronous callback to
```js ```js
try { try {
inputDevice.getDeviceList((error, ids) => { inputDevice.getDeviceIds((error, ids) => {
if (error) { if (error) {
console.log(`Failed to get device list. console.log(`Failed to get device list.
error code=${JSON.stringify(err.code)} msg=${JSON.stringify(err.message)}`); error code=${JSON.stringify(err.code)} msg=${JSON.stringify(err.message)}`);
...@@ -65,7 +65,7 @@ Obtains the IDs of all input devices. This API uses a promise to return the resu ...@@ -65,7 +65,7 @@ Obtains the IDs of all input devices. This API uses a promise to return the resu
```js ```js
try { try {
inputDevice.getDeviceList().then((ids) => { inputDevice.getDeviceIds().then((ids) => {
console.log("The device ID list is: " + ids); console.log("The device ID list is: " + ids);
}); });
} catch (error) { } catch (error) {
...@@ -245,10 +245,15 @@ This API is deprecated since API version 9. You are advised to use [inputDevice. ...@@ -245,10 +245,15 @@ This API is deprecated since API version 9. You are advised to use [inputDevice.
**Example** **Example**
```js ```js
inputDevice.getDeviceIds((ids)=>{ inputDevice.getDeviceIds((error, ids) => {
console.log("The device ID list is: " + ids); if (error) {
console.log(`Failed to get device id list, error: ${JSON.stringify(error, [`code`, `message`])}`);
return;
}
console.log(`Device id list: ${JSON.stringify(ids)}`);
}); });
``` ```
```
## inputDevice.getDeviceIds<sup>(deprecated)</sup> ## inputDevice.getDeviceIds<sup>(deprecated)</sup>
...@@ -269,8 +274,8 @@ This API is deprecated since API version 9. You are advised to use [inputDevice. ...@@ -269,8 +274,8 @@ This API is deprecated since API version 9. You are advised to use [inputDevice.
**Example** **Example**
```js ```js
inputDevice.getDeviceIds().then((ids)=>{ inputDevice.getDeviceIds().then((ids) => {
console.log("The device ID list is: " + ids); console.log(`Device id list: ${JSON.stringify(ids)}`);
}); });
``` ```
...@@ -295,8 +300,12 @@ This API is deprecated since API version 9. You are advised to use [inputDevice. ...@@ -295,8 +300,12 @@ This API is deprecated since API version 9. You are advised to use [inputDevice.
```js ```js
// Obtain the name of the device whose ID is 1. // Obtain the name of the device whose ID is 1.
inputDevice.getDevice(1, (inputDevice)=>{ inputDevice.getDevice(1, (error, deviceData) => {
console.log("The device name is: " + inputDevice.name); if (error) {
console.log(`Failed to get device info, error: ${JSON.stringify(error, [`code`, `message`])}`);
return;
}
console.log(`Device info: ${JSON.stringify(deviceData)}`);
}); });
``` ```
...@@ -326,8 +335,8 @@ This API is deprecated since API version 9. You are advised to use [inputDevice. ...@@ -326,8 +335,8 @@ This API is deprecated since API version 9. You are advised to use [inputDevice.
```js ```js
// Obtain the name of the device whose ID is 1. // Obtain the name of the device whose ID is 1.
inputDevice.getDevice(1).then((inputDevice)=>{ inputDevice.getDevice(1).then((deviceData) => {
console.log("The device name is: " + inputDevice.name); console.log(`Device info: ${JSON.stringify(deviceData)}`);
}); });
``` ```
......
...@@ -19,7 +19,7 @@ Other APIs are not affected. ...@@ -19,7 +19,7 @@ Other APIs are not affected.
**Key API/Component Changes** **Key API/Component Changes**
| Class| API Type| API Declaration| Change Type| | Class| Type| Declaration| Change Type|
| -- | -- | -- | -- | | -- | -- | -- | -- |
|geolocation| namespace | declare namespacegeolocation| Migrated this API in API version 9 to **@ohos.geoLocationManager.d.ts**.| |geolocation| namespace | declare namespacegeolocation| Migrated this API in API version 9 to **@ohos.geoLocationManager.d.ts**.|
|geolocation | interface | export interface ReverseGeocodingMockInfo | Migrated this API in API version 9 to **@ohos.geoLocationManager.d.ts**.| |geolocation | interface | export interface ReverseGeocodingMockInfo | Migrated this API in API version 9 to **@ohos.geoLocationManager.d.ts**.|
...@@ -52,8 +52,8 @@ Other APIs are not affected. ...@@ -52,8 +52,8 @@ Other APIs are not affected.
|geolocation| method | function setReverseGeocodingMockInfo(mockInfos: Array&lt;ReverseGeocodingMockInfo&gt;): Promise&lt;void&gt;; | Migrated this API in API version 9 to **@ohos.geoLocationManager.d.ts**. | |geolocation| method | function setReverseGeocodingMockInfo(mockInfos: Array&lt;ReverseGeocodingMockInfo&gt;): Promise&lt;void&gt;; | Migrated this API in API version 9 to **@ohos.geoLocationManager.d.ts**. |
|geolocation| method | function isLocationPrivacyConfirmed(type: LocationPrivacyType, callback: AsyncCallback&lt;boolean&gt;): void; | Migrated this API in API version 9 to **@ohos.geoLocationManager.d.ts**. | |geolocation| method | function isLocationPrivacyConfirmed(type: LocationPrivacyType, callback: AsyncCallback&lt;boolean&gt;): void; | Migrated this API in API version 9 to **@ohos.geoLocationManager.d.ts**. |
|geolocation| method | function isLocationPrivacyConfirmed(type: LocationPrivacyType): Promise&lt;boolean&gt;; | Migrated this API in API version 9 to **@ohos.geoLocationManager.d.ts**. | |geolocation| method | function isLocationPrivacyConfirmed(type: LocationPrivacyType): Promise&lt;boolean&gt;; | Migrated this API in API version 9 to **@ohos.geoLocationManager.d.ts**. |
|geolocation| method | function setLocationPrivacyConfirmStatus(type: LocationPrivacyType, isConfirmed: boolean, callback: AsyncCallback&lt;boolean&gt;): void; | Migrated this API in API version 9 to **@ohos.geoLocationManager.d.ts** and changed the callback return value to **void**. | |geolocation| method | function setLocationPrivacyConfirmStatus(type: LocationPrivacyType, isConfirmed: boolean, callback: AsyncCallback&lt;boolean&gt;): void; | Migrated this API in API version 9 to **@ohos.geoLocationManager.d.ts** and changed the return value in the callback to **void**. |
|geolocation| method | function setLocationPrivacyConfirmStatus(type: LocationPrivacyType, isConfirmed: boolean): Promise&lt;boolean&gt;; | Migrated this API in API version 9 to **@ohos.geoLocationManager.d.ts** and changed the promise return value to **void**. | |geolocation| method | function setLocationPrivacyConfirmStatus(type: LocationPrivacyType, isConfirmed: boolean): Promise&lt;boolean&gt;; | Migrated this API in API version 9 to **@ohos.geoLocationManager.d.ts** and changed the return value in the promise to **void**. |
**(Optional) Adaptation Guide** **(Optional) Adaptation Guide**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册