提交 18a6cf7b 编写于 作者: S swg3156201044

账号文档示例代码ArxTs规范整改

Signed-off-by: Nswg3156201044 <shiweigang2@huawei.com>
上级 d8d387e9
...@@ -59,9 +59,12 @@ getOsAccountDistributedInfo(callback: AsyncCallback&lt;DistributedInfo&gt;): voi ...@@ -59,9 +59,12 @@ getOsAccountDistributedInfo(callback: AsyncCallback&lt;DistributedInfo&gt;): voi
**示例:** **示例:**
```js ```js
import { BusinessError } from '@ohos.base';
const accountAbility = account_distributedAccount.getDistributedAccountAbility(); const accountAbility = account_distributedAccount.getDistributedAccountAbility();
try { try {
accountAbility.getOsAccountDistributedInfo((err, data) => { accountAbility.getOsAccountDistributedInfo(
(err: BusinessError, data: account_distributedAccount.DistributedInfo) => {
if (err) { if (err) {
console.log('getOsAccountDistributedInfo exception: ' + JSON.stringify(err)); console.log('getOsAccountDistributedInfo exception: ' + JSON.stringify(err));
} else { } else {
...@@ -97,11 +100,13 @@ getOsAccountDistributedInfo(): Promise&lt;DistributedInfo&gt; ...@@ -97,11 +100,13 @@ getOsAccountDistributedInfo(): Promise&lt;DistributedInfo&gt;
**示例:** **示例:**
```js ```js
import { BusinessError } from '@ohos.base';
const accountAbility = account_distributedAccount.getDistributedAccountAbility(); const accountAbility = account_distributedAccount.getDistributedAccountAbility();
try { try {
accountAbility.getOsAccountDistributedInfo().then((data) => { accountAbility.getOsAccountDistributedInfo().then((data: account_distributedAccount.DistributedInfo) => {
console.log('distributed information: ' + JSON.stringify(data)); console.log('distributed information: ' + JSON.stringify(data));
}).catch((err) => { }).catch((err: BusinessError) => {
console.log('getOsAccountDistributedInfo exception: ' + JSON.stringify(err)); console.log('getOsAccountDistributedInfo exception: ' + JSON.stringify(err));
}); });
} catch (err) { } catch (err) {
...@@ -137,9 +142,12 @@ getOsAccountDistributedInfoByLocalId(localId: number, callback: AsyncCallback&lt ...@@ -137,9 +142,12 @@ getOsAccountDistributedInfoByLocalId(localId: number, callback: AsyncCallback&lt
**示例:** **示例:**
```js ```js
import { BusinessError } from '@ohos.base';
const accountAbility = account_distributedAccount.getDistributedAccountAbility(); const accountAbility = account_distributedAccount.getDistributedAccountAbility();
try { try {
accountAbility.getOsAccountDistributedInfoByLocalId(100, (err, data) => { accountAbility.getOsAccountDistributedInfoByLocalId(100,
(err: BusinessError, data: account_distributedAccount.DistributedInfo) => {
if (err) { if (err) {
console.log('getOsAccountDistributedInfoByLocalId exception: ' + JSON.stringify(err)); console.log('getOsAccountDistributedInfoByLocalId exception: ' + JSON.stringify(err));
} else { } else {
...@@ -178,11 +186,14 @@ getOsAccountDistributedInfoByLocalId(localId: number): Promise&lt;DistributedInf ...@@ -178,11 +186,14 @@ getOsAccountDistributedInfoByLocalId(localId: number): Promise&lt;DistributedInf
**示例:** **示例:**
```js ```js
import { BusinessError } from '@ohos.base';
const accountAbility = account_distributedAccount.getDistributedAccountAbility(); const accountAbility = account_distributedAccount.getDistributedAccountAbility();
try { try {
accountAbility.getOsAccountDistributedInfoByLocalId(100).then((data) => { accountAbility.getOsAccountDistributedInfoByLocalId(100).then((
data: account_distributedAccount.DistributedInfo) => {
console.log('distributed information: ' + JSON.stringify(data)); console.log('distributed information: ' + JSON.stringify(data));
}).catch((err) => { }).catch((err: BusinessError) => {
console.log('getOsAccountDistributedInfoByLocalId exception: ' + JSON.stringify(err)); console.log('getOsAccountDistributedInfoByLocalId exception: ' + JSON.stringify(err));
}); });
} catch (err) { } catch (err) {
...@@ -211,8 +222,11 @@ queryOsAccountDistributedInfo(callback: AsyncCallback&lt;DistributedInfo&gt;): v ...@@ -211,8 +222,11 @@ queryOsAccountDistributedInfo(callback: AsyncCallback&lt;DistributedInfo&gt;): v
**示例:** **示例:**
```js ```js
import { BusinessError } from '@ohos.base';
const accountAbility = account_distributedAccount.getDistributedAccountAbility(); const accountAbility = account_distributedAccount.getDistributedAccountAbility();
accountAbility.queryOsAccountDistributedInfo((err, data) => { accountAbility.queryOsAccountDistributedInfo(
(err: BusinessError, data: account_distributedAccount.DistributedInfo) => {
if (err) { if (err) {
console.log('queryOsAccountDistributedInfo exception: ' + JSON.stringify(err)); console.log('queryOsAccountDistributedInfo exception: ' + JSON.stringify(err));
} else { } else {
...@@ -243,10 +257,12 @@ queryOsAccountDistributedInfo(): Promise&lt;DistributedInfo&gt; ...@@ -243,10 +257,12 @@ queryOsAccountDistributedInfo(): Promise&lt;DistributedInfo&gt;
**示例:** **示例:**
```js ```js
import { BusinessError } from '@ohos.base';
const accountAbility = account_distributedAccount.getDistributedAccountAbility(); const accountAbility = account_distributedAccount.getDistributedAccountAbility();
accountAbility.queryOsAccountDistributedInfo().then((data) => { accountAbility.queryOsAccountDistributedInfo().then((data: account_distributedAccount.DistributedInfo) => {
console.log('distributed information: ' + JSON.stringify(data)); console.log('distributed information: ' + JSON.stringify(data));
}).catch((err) => { }).catch((err: BusinessError) => {
console.log('queryOsAccountDistributedInfo exception: ' + JSON.stringify(err)); console.log('queryOsAccountDistributedInfo exception: ' + JSON.stringify(err));
}); });
``` ```
...@@ -278,10 +294,12 @@ setOsAccountDistributedInfo(accountInfo: DistributedInfo, callback: AsyncCallbac ...@@ -278,10 +294,12 @@ setOsAccountDistributedInfo(accountInfo: DistributedInfo, callback: AsyncCallbac
**示例:** **示例:**
```js ```js
import { BusinessError } from '@ohos.base';
const accountAbility = account_distributedAccount.getDistributedAccountAbility(); const accountAbility = account_distributedAccount.getDistributedAccountAbility();
let accountInfo = {id: '12345', name: 'ZhangSan', event: 'Ohos.account.event.LOGIN'}; let accountInfo = {id: '12345', name: 'ZhangSan', event: 'Ohos.account.event.LOGIN'};
try { try {
accountAbility.setOsAccountDistributedInfo(accountInfo, (err) => { accountAbility.setOsAccountDistributedInfo(accountInfo, (err: BusinessError) => {
if (err) { if (err) {
console.log('setOsAccountDistributedInfo exception: ' + JSON.stringify(err)); console.log('setOsAccountDistributedInfo exception: ' + JSON.stringify(err));
} else { } else {
...@@ -325,12 +343,14 @@ setOsAccountDistributedInfo(accountInfo: DistributedInfo): Promise&lt;void&gt; ...@@ -325,12 +343,14 @@ setOsAccountDistributedInfo(accountInfo: DistributedInfo): Promise&lt;void&gt;
**示例:** **示例:**
```js ```js
import { BusinessError } from '@ohos.base';
const accountAbility = account_distributedAccount.getDistributedAccountAbility(); const accountAbility = account_distributedAccount.getDistributedAccountAbility();
let accountInfo = {id: '12345', name: 'ZhangSan', event: 'Ohos.account.event.LOGIN'}; let accountInfo = {id: '12345', name: 'ZhangSan', event: 'Ohos.account.event.LOGIN'};
try { try {
accountAbility.setOsAccountDistributedInfo(accountInfo).then(() => { accountAbility.setOsAccountDistributedInfo(accountInfo).then(() => {
console.log('setOsAccountDistributedInfo successfully'); console.log('setOsAccountDistributedInfo successfully');
}).catch((err) => { }).catch((err: BusinessError) => {
console.log('setOsAccountDistributedInfo exception: ' + JSON.stringify(err)); console.log('setOsAccountDistributedInfo exception: ' + JSON.stringify(err));
}); });
} catch (err) { } catch (err) {
...@@ -368,10 +388,12 @@ setOsAccountDistributedInfoByLocalId(localId: number, distributedInfo: Distribut ...@@ -368,10 +388,12 @@ setOsAccountDistributedInfoByLocalId(localId: number, distributedInfo: Distribut
**示例:** **示例:**
```js ```js
import { BusinessError } from '@ohos.base';
const accountAbility = account_distributedAccount.getDistributedAccountAbility(); const accountAbility = account_distributedAccount.getDistributedAccountAbility();
let accountInfo = {id: '12345', name: 'ZhangSan', event: 'Ohos.account.event.LOGIN'}; let accountInfo = {id: '12345', name: 'ZhangSan', event: 'Ohos.account.event.LOGIN'};
try { try {
accountAbility.setOsAccountDistributedInfoByLocalId(100, accountInfo, (err) => { accountAbility.setOsAccountDistributedInfoByLocalId(100, accountInfo, (err: BusinessError) => {
if (err) { if (err) {
console.log('setOsAccountDistributedInfoByLocalId exception: ' + JSON.stringify(err)); console.log('setOsAccountDistributedInfoByLocalId exception: ' + JSON.stringify(err));
} else { } else {
...@@ -419,12 +441,14 @@ setOsAccountDistributedInfoByLocalId(localId: number, distributedInfo: Distribut ...@@ -419,12 +441,14 @@ setOsAccountDistributedInfoByLocalId(localId: number, distributedInfo: Distribut
**示例:** **示例:**
```js ```js
import { BusinessError } from '@ohos.base';
const accountAbility = account_distributedAccount.getDistributedAccountAbility(); const accountAbility = account_distributedAccount.getDistributedAccountAbility();
let accountInfo = {id: '12345', name: 'ZhangSan', event: 'Ohos.account.event.LOGIN'}; let accountInfo = {id: '12345', name: 'ZhangSan', event: 'Ohos.account.event.LOGIN'};
try { try {
accountAbility.setOsAccountDistributedInfoByLocalId(100, accountInfo).then(() => { accountAbility.setOsAccountDistributedInfoByLocalId(100, accountInfo).then(() => {
console.log('setOsAccountDistributedInfoByLocalId successfully'); console.log('setOsAccountDistributedInfoByLocalId successfully');
}).catch((err) => { }).catch((err: BusinessError) => {
console.log('setOsAccountDistributedInfoByLocalId exception: ' + JSON.stringify(err)); console.log('setOsAccountDistributedInfoByLocalId exception: ' + JSON.stringify(err));
}); });
} catch (err) { } catch (err) {
...@@ -455,9 +479,11 @@ updateOsAccountDistributedInfo(accountInfo: DistributedInfo, callback: AsyncCall ...@@ -455,9 +479,11 @@ updateOsAccountDistributedInfo(accountInfo: DistributedInfo, callback: AsyncCall
**示例:** **示例:**
```js ```js
import { BusinessError } from '@ohos.base';
const accountAbility = account_distributedAccount.getDistributedAccountAbility(); const accountAbility = account_distributedAccount.getDistributedAccountAbility();
let accountInfo = {id: '12345', name: 'ZhangSan', event: 'Ohos.account.event.LOGIN'}; let accountInfo = {id: '12345', name: 'ZhangSan', event: 'Ohos.account.event.LOGIN'};
accountAbility.updateOsAccountDistributedInfo(accountInfo, (err) => { accountAbility.updateOsAccountDistributedInfo(accountInfo, (err: BusinessError) => {
if (err) { if (err) {
console.log('queryOsAccountDistributedInfo exception: ' + JSON.stringify(err)); console.log('queryOsAccountDistributedInfo exception: ' + JSON.stringify(err));
} else { } else {
...@@ -492,11 +518,13 @@ updateOsAccountDistributedInfo(accountInfo: DistributedInfo): Promise&lt;void&gt ...@@ -492,11 +518,13 @@ updateOsAccountDistributedInfo(accountInfo: DistributedInfo): Promise&lt;void&gt
**示例:** **示例:**
```js ```js
import { BusinessError } from '@ohos.base';
const accountAbility = account_distributedAccount.getDistributedAccountAbility(); const accountAbility = account_distributedAccount.getDistributedAccountAbility();
let accountInfo = {id: '12345', name: 'ZhangSan', event: 'Ohos.account.event.LOGIN'}; let accountInfo = {id: '12345', name: 'ZhangSan', event: 'Ohos.account.event.LOGIN'};
accountAbility.updateOsAccountDistributedInfo(accountInfo).then(() => { accountAbility.updateOsAccountDistributedInfo(accountInfo).then(() => {
console.log('updateOsAccountDistributedInfo successfully'); console.log('updateOsAccountDistributedInfo successfully');
}).catch((err) => { }).catch((err: BusinessError) => {
console.log('updateOsAccountDistributedInfo exception: ' + JSON.stringify(err)); console.log('updateOsAccountDistributedInfo exception: ' + JSON.stringify(err));
}); });
``` ```
......
...@@ -4195,7 +4195,7 @@ auth(challenge: Uint8Array, authType: AuthType, authTrustLevel: AuthTrustLevel, ...@@ -4195,7 +4195,7 @@ auth(challenge: Uint8Array, authType: AuthType, authTrustLevel: AuthTrustLevel,
let authTrustLevel = account_osAccount.AuthTrustLevel.ATL1; let authTrustLevel = account_osAccount.AuthTrustLevel.ATL1;
try { try {
userAuth.auth(challenge, authType, authTrustLevel, { userAuth.auth(challenge, authType, authTrustLevel, {
onResult: function(result,extraInfo){ onResult: (result,extraInfo) => {
console.log('auth result = ' + result); console.log('auth result = ' + result);
console.log('auth extraInfo = ' + JSON.stringify(extraInfo)); console.log('auth extraInfo = ' + JSON.stringify(extraInfo));
} }
...@@ -4257,7 +4257,7 @@ authUser(userId: number, challenge: Uint8Array, authType: AuthType, authTrustLev ...@@ -4257,7 +4257,7 @@ authUser(userId: number, challenge: Uint8Array, authType: AuthType, authTrustLev
let authTrustLevel = account_osAccount.AuthTrustLevel.ATL1; let authTrustLevel = account_osAccount.AuthTrustLevel.ATL1;
try { try {
userAuth.authUser(userID, challenge, authType, authTrustLevel, { userAuth.authUser(userID, challenge, authType, authTrustLevel, {
onResult: function(result,extraInfo){ onResult: (result,extraInfo) => {
console.log('authUser result = ' + result); console.log('authUser result = ' + result);
console.log('authUser extraInfo = ' + JSON.stringify(extraInfo)); console.log('authUser extraInfo = ' + JSON.stringify(extraInfo));
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册