提交 ee25bb22 编写于 作者: A Annie_wang

update docs

Signed-off-by: NAnnie_wang <annie.wangli@huawei.com>
上级 5a8c3d76
......@@ -59,15 +59,18 @@ Obtains distributed account information. This API uses an asynchronous callback
**Example**
```js
import { BusinessError } from '@ohos.base';
const accountAbility = account_distributedAccount.getDistributedAccountAbility();
try {
accountAbility.getOsAccountDistributedInfo((err, data) => {
if (err) {
console.log('getOsAccountDistributedInfo exception: ' + JSON.stringify(err));
} else {
console.log('distributed information: ' + JSON.stringify(data));
}
});
accountAbility.getOsAccountDistributedInfo(
(err: BusinessError, data: account_distributedAccount.DistributedInfo) => {
if (err) {
console.log('getOsAccountDistributedInfo exception: ' + JSON.stringify(err));
} else {
console.log('distributed information: ' + JSON.stringify(data));
}
});
} catch (err) {
console.log('getOsAccountDistributedInfo exception: ' + JSON.stringify(err));
}
......@@ -97,11 +100,13 @@ Obtains distributed account information. This API uses a promise to return the r
**Example**
```js
import { BusinessError } from '@ohos.base';
const accountAbility = account_distributedAccount.getDistributedAccountAbility();
try {
accountAbility.getOsAccountDistributedInfo().then((data) => {
accountAbility.getOsAccountDistributedInfo().then((data: account_distributedAccount.DistributedInfo) => {
console.log('distributed information: ' + JSON.stringify(data));
}).catch((err) => {
}).catch((err: BusinessError) => {
console.log('getOsAccountDistributedInfo exception: ' + JSON.stringify(err));
});
} catch (err) {
......@@ -137,15 +142,18 @@ Obtains distributed information about an OS account. This API uses an asynchrono
**Example**
```js
import { BusinessError } from '@ohos.base';
const accountAbility = account_distributedAccount.getDistributedAccountAbility();
try {
accountAbility.getOsAccountDistributedInfoByLocalId(100, (err, data) => {
if (err) {
console.log('getOsAccountDistributedInfoByLocalId exception: ' + JSON.stringify(err));
} else {
console.log('distributed information: ' + JSON.stringify(data));
}
});
accountAbility.getOsAccountDistributedInfoByLocalId(100,
(err: BusinessError, data: account_distributedAccount.DistributedInfo) => {
if (err) {
console.log('getOsAccountDistributedInfoByLocalId exception: ' + JSON.stringify(err));
} else {
console.log('distributed information: ' + JSON.stringify(data));
}
});
} catch (err) {
console.log('getOsAccountDistributedInfoByLocalId exception: ' + JSON.stringify(err));
}
......@@ -178,15 +186,18 @@ Obtains distributed information about an OS account. This API uses a promise to
**Example**
```js
import { BusinessError } from '@ohos.base';
const accountAbility = account_distributedAccount.getDistributedAccountAbility();
try {
accountAbility.getOsAccountDistributedInfoByLocalId(100).then((data) => {
console.log('distributed information: ' + JSON.stringify(data));
}).catch((err) => {
console.log('getOsAccountDistributedInfoByLocalId exception: ' + JSON.stringify(err));
accountAbility.getOsAccountDistributedInfoByLocalId(100).then((
data: account_distributedAccount.DistributedInfo) => {
console.log('distributed information: ' + JSON.stringify(data));
}).catch((err: BusinessError) => {
console.log('getOsAccountDistributedInfoByLocalId exception: ' + JSON.stringify(err));
});
} catch (err) {
console.log('getOsAccountDistributedInfoByLocalId exception: ' + JSON.stringify(err));
console.log('getOsAccountDistributedInfoByLocalId exception: ' + JSON.stringify(err));
}
```
......@@ -211,14 +222,17 @@ Obtains distributed account information. This API uses an asynchronous callback
**Example**
```js
import { BusinessError } from '@ohos.base';
const accountAbility = account_distributedAccount.getDistributedAccountAbility();
accountAbility.queryOsAccountDistributedInfo((err, data) => {
if (err) {
console.log('queryOsAccountDistributedInfo exception: ' + JSON.stringify(err));
} else {
console.log('distributed information: ' + JSON.stringify(data));
}
});
accountAbility.queryOsAccountDistributedInfo(
(err: BusinessError, data: account_distributedAccount.DistributedInfo) => {
if (err) {
console.log('queryOsAccountDistributedInfo exception: ' + JSON.stringify(err));
} else {
console.log('distributed information: ' + JSON.stringify(data));
}
});
```
### queryOsAccountDistributedInfo<sup>(deprecated)</sup>
......@@ -243,10 +257,12 @@ Obtains distributed account information. This API uses a promise to return the r
**Example**
```js
import { BusinessError } from '@ohos.base';
const accountAbility = account_distributedAccount.getDistributedAccountAbility();
accountAbility.queryOsAccountDistributedInfo().then((data) => {
accountAbility.queryOsAccountDistributedInfo().then((data: account_distributedAccount.DistributedInfo) => {
console.log('distributed information: ' + JSON.stringify(data));
}).catch((err) => {
}).catch((err: BusinessError) => {
console.log('queryOsAccountDistributedInfo exception: ' + JSON.stringify(err));
});
```
......@@ -278,10 +294,13 @@ Sets the distributed account information. This API uses an asynchronous callback
**Example**
```js
import { BusinessError } from '@ohos.base';
const accountAbility = account_distributedAccount.getDistributedAccountAbility();
let accountInfo = {id: '12345', name: 'ZhangSan', event: 'Ohos.account.event.LOGIN'};
let accountInfo: account_distributedAccount.DistributedInfo =
{id: '12345', name: 'ZhangSan', event: 'Ohos.account.event.LOGIN'};
try {
accountAbility.setOsAccountDistributedInfo(accountInfo, (err) => {
accountAbility.setOsAccountDistributedInfo(accountInfo, (err: BusinessError) => {
if (err) {
console.log('setOsAccountDistributedInfo exception: ' + JSON.stringify(err));
} else {
......@@ -325,12 +344,15 @@ Sets the distributed account information. This API uses a promise to return the
**Example**
```js
import { BusinessError } from '@ohos.base';
const accountAbility = account_distributedAccount.getDistributedAccountAbility();
let accountInfo = {id: '12345', name: 'ZhangSan', event: 'Ohos.account.event.LOGIN'};
let accountInfo: account_distributedAccount.DistributedInfo =
{id: '12345', name: 'ZhangSan', event: 'Ohos.account.event.LOGIN'};
try {
accountAbility.setOsAccountDistributedInfo(accountInfo).then(() => {
console.log('setOsAccountDistributedInfo successfully');
}).catch((err) => {
}).catch((err: BusinessError) => {
console.log('setOsAccountDistributedInfo exception: ' + JSON.stringify(err));
});
} catch (err) {
......@@ -368,10 +390,13 @@ Sets the distributed information for an OS account. This API uses an asynchronou
**Example**
```js
import { BusinessError } from '@ohos.base';
const accountAbility = account_distributedAccount.getDistributedAccountAbility();
let accountInfo = {id: '12345', name: 'ZhangSan', event: 'Ohos.account.event.LOGIN'};
let accountInfo: account_distributedAccount.DistributedInfo =
{id: '12345', name: 'ZhangSan', event: 'Ohos.account.event.LOGIN'};
try {
accountAbility.setOsAccountDistributedInfoByLocalId(100, accountInfo, (err) => {
accountAbility.setOsAccountDistributedInfoByLocalId(100, accountInfo, (err: BusinessError) => {
if (err) {
console.log('setOsAccountDistributedInfoByLocalId exception: ' + JSON.stringify(err));
} else {
......@@ -419,12 +444,15 @@ Sets the distributed information for an OS account. This API uses a promise to r
**Example**
```js
import { BusinessError } from '@ohos.base';
const accountAbility = account_distributedAccount.getDistributedAccountAbility();
let accountInfo = {id: '12345', name: 'ZhangSan', event: 'Ohos.account.event.LOGIN'};
let accountInfo: account_distributedAccount.DistributedInfo =
{id: '12345', name: 'ZhangSan', event: 'Ohos.account.event.LOGIN'};
try {
accountAbility.setOsAccountDistributedInfoByLocalId(100, accountInfo).then(() => {
console.log('setOsAccountDistributedInfoByLocalId successfully');
}).catch((err) => {
}).catch((err: BusinessError) => {
console.log('setOsAccountDistributedInfoByLocalId exception: ' + JSON.stringify(err));
});
} catch (err) {
......@@ -455,9 +483,12 @@ Updates the distributed account information. This API uses an asynchronous callb
**Example**
```js
import { BusinessError } from '@ohos.base';
const accountAbility = account_distributedAccount.getDistributedAccountAbility();
let accountInfo = {id: '12345', name: 'ZhangSan', event: 'Ohos.account.event.LOGIN'};
accountAbility.updateOsAccountDistributedInfo(accountInfo, (err) => {
let accountInfo: account_distributedAccount.DistributedInfo =
{id: '12345', name: 'ZhangSan', event: 'Ohos.account.event.LOGIN'};
accountAbility.updateOsAccountDistributedInfo(accountInfo, (err: BusinessError) => {
if (err) {
console.log('queryOsAccountDistributedInfo exception: ' + JSON.stringify(err));
} else {
......@@ -492,11 +523,14 @@ Updates the distributed account information. This API uses a promise to return t
**Example**
```js
import { BusinessError } from '@ohos.base';
const accountAbility = account_distributedAccount.getDistributedAccountAbility();
let accountInfo = {id: '12345', name: 'ZhangSan', event: 'Ohos.account.event.LOGIN'};
let accountInfo: account_distributedAccount.DistributedInfo =
{id: '12345', name: 'ZhangSan', event: 'Ohos.account.event.LOGIN'};
accountAbility.updateOsAccountDistributedInfo(accountInfo).then(() => {
console.log('updateOsAccountDistributedInfo successfully');
}).catch((err) => {
}).catch((err: BusinessError) => {
console.log('updateOsAccountDistributedInfo exception: ' + JSON.stringify(err));
});
```
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册