From bb2344270e8714a9a47a62627b91a9711e91a104 Mon Sep 17 00:00:00 2001 From: zhangalong Date: Sun, 24 Apr 2022 19:20:57 +0800 Subject: [PATCH] add code type for sample codes Signed-off-by:zhang_along Signed-off-by: zhangalong --- .../reference/apis/js-apis-appAccount.md | 112 +++++++-------- .../apis/js-apis-distributed-account.md | 12 +- .../reference/apis/js-apis-osAccount.md | 128 +++++++++--------- .../reference/apis/js-apis-appAccount.md | 112 +++++++-------- .../apis/js-apis-distributed-account.md | 12 +- .../reference/apis/js-apis-osAccount.md | 118 ++++++++-------- 6 files changed, 247 insertions(+), 247 deletions(-) diff --git a/en/application-dev/reference/apis/js-apis-appAccount.md b/en/application-dev/reference/apis/js-apis-appAccount.md index 7041eaef27..30d7ac0dd8 100644 --- a/en/application-dev/reference/apis/js-apis-appAccount.md +++ b/en/application-dev/reference/apis/js-apis-appAccount.md @@ -6,7 +6,7 @@ ## Modules to Import -``` +```js import account_appAccount from '@ohos.account.appAccount'; ``` @@ -25,7 +25,7 @@ Creates an **AppAccountManager** instance. | AppAccountManager | **AppAccountManager** instance created.| **Example** - ``` + ```js var appAccountManager = account.createAppAccountManager(); ``` @@ -50,7 +50,7 @@ Adds an app account to the account management service. This method uses an async **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.addAccount("WangWu", (err) => { console.log("addAccount err: " + JSON.stringify(err)); @@ -75,7 +75,7 @@ Adds an app account and its additional information to the account management ser **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.addAccount("LiSi", "token101", (err) => { console.log("addAccount err: " + JSON.stringify(err)); @@ -107,7 +107,7 @@ Adds an app account and its additional information to the account management ser **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.addAccount("LiSi", "token101").then(()=> { console.log('addAccount Success'); @@ -135,7 +135,7 @@ Implicitly adds an app account based on the specified account owner, authenticat **Example** - ``` + ```js import featureAbility from '@ohos.ability.featureAbility'; function onResultCallback(code, result) { @@ -174,7 +174,7 @@ Deletes an app account from the account management service. This method uses an **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.deleteAccount("ZhaoLiu", (err) => { console.log("deleteAccount err: " + JSON.stringify(err)); @@ -203,7 +203,7 @@ Deletes an app account from the account management service. This method uses a p **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.deleteAccount("ZhaoLiu").then(() => { console.log('deleteAccount Success'); @@ -230,7 +230,7 @@ Disables an app account from accessing an application with the given bundle name **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.disableAppAccess("ZhangSan", "com.example.ohos.accountjsdemo", (err) => { console.log("disableAppAccess err: " + JSON.stringify(err)); @@ -260,7 +260,7 @@ Disables an app account from accessing an application with the given bundle name **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.disableAppAccess("ZhangSan", "com.example.ohos.accountjsdemo").then(() => { console.log('disableAppAccess Success'); @@ -287,7 +287,7 @@ Enables an app account to access an application with the given bundle name. This **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.enableAppAccess("ZhangSan", "com.example.ohos.accountjsdemo", (err) => { console.log("enableAppAccess: " + JSON.stringify(err)); @@ -317,7 +317,7 @@ Enables an app account to access an application with the given bundle name. This **Example** - ``` + ```js app_account_instance.enableAppAccess("ZhangSan", "com.example.ohos.accountjsdemo").then(() => { console.log('enableAppAccess Success'); }).catch((err) => { @@ -344,7 +344,7 @@ Checks whether an app account allows application data synchronization. This meth **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.checkAppAccountSyncEnable("ZhangSan", (err, result) => { console.log("checkAppAccountSyncEnable err: " + JSON.stringify(err)); @@ -376,7 +376,7 @@ Checks whether an app account allows application data synchronization. This meth **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.checkAppAccountSyncEnable("ZhangSan").then((data) => { console.log('checkAppAccountSyncEnable, result: ' + data); @@ -404,7 +404,7 @@ Sets a credential for an app account. This method uses an asynchronous callback **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.setAccountCredential("ZhangSan", "credentialType001", "credential001", (err) => { console.log("setAccountCredential err: " + JSON.stringify(err)); @@ -435,7 +435,7 @@ Sets a credential for an app account. This method uses a promise to return the r **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.setAccountCredential("ZhangSan", "credentialType001", "credential001").then(() => { console.log('setAccountCredential Success'); @@ -462,7 +462,7 @@ Sets additional information for an app account. This method uses an asynchronous **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.setAccountExtraInfo("ZhangSan", "Tk002", (err) => { console.log("setAccountExtraInfo err: " + JSON.stringify(err)); @@ -492,7 +492,7 @@ Sets additional information for an app account. This method uses a promise to re **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.setAccountExtraInfo("ZhangSan", "Tk002").then(() => { console.log('setAccountExtraInfo Success'); @@ -521,7 +521,7 @@ Sets whether to enable application data synchronization for an app account. This **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.setAppAccountSyncEnable("ZhangSan", true, (err) => { console.log("setAppAccountSyncEnable err: " + JSON.stringify(err)); @@ -553,7 +553,7 @@ Sets whether to enable application data synchronization for an app account. This **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager .setAppAccountSyncEnable("ZhangSan", true).then(() => { console.log('setAppAccountSyncEnable Success'); @@ -581,7 +581,7 @@ Sets data to be associated with an app account. This method uses an asynchronous **Example** - ``` + ```js app_account_instance.setAssociatedData("ZhangSan", "k001", "v001", (err) => { console.log("setAssociatedData err: " + JSON.stringify(err)); }); @@ -611,7 +611,7 @@ Sets data to be associated with an app account. This method uses a promise to re **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.setAssociatedData("ZhangSan", "k001", "v001").then(() => { console.log('setAssociatedData Success'); @@ -638,7 +638,7 @@ Obtains the credential of an app account. This method uses an asynchronous callb **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.getAccountCredential("ZhangSan", "credentialType001", (err, result) => { console.log("getAccountCredential err: " + JSON.stringify(err)); @@ -669,7 +669,7 @@ Obtains the credential of an app account. This method uses a promise to return t **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.getAccountCredential("ZhangSan", "credentialType001").then((data) => { console.log('getAccountCredential, result: ' + data); @@ -695,7 +695,7 @@ Obtains additional information of an app account. This method uses an asynchrono **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.getAccountExtraInfo("ZhangSan", (err, result) => { console.log("getAccountExtraInfo err: " + JSON.stringify(err)); @@ -725,7 +725,7 @@ Obtains additional information of an app account. This method uses a promise to **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.getAccountExtraInfo("ZhangSan").then((data) => { console.log('getAccountExtraInfo, result: ' + data); @@ -752,7 +752,7 @@ Obtains data associated with an app account. This method uses an asynchronous ca **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.getAssociatedData("ZhangSan", "k001", (err, result) => { console.log("getAssociatedData err: " + JSON.stringify(err)); @@ -783,7 +783,7 @@ Obtains data associated with an app account. This method uses a promise to retur **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.getAssociatedData("ZhangSan", "k001").then((data) => { console.log('getAssociatedData: ' + data); @@ -810,7 +810,7 @@ Obtains information about all accessible app accounts. This method uses an async **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.getAllAccessibleAccounts((err, data)=>{ console.debug("getAllAccessibleAccounts err:" + JSON.stringify(err)); @@ -836,7 +836,7 @@ Obtains information about all accessible app accounts. This method uses an async **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.getAllAccessibleAccounts().then((data) => { console.log('getAllAccessibleAccounts: ' + data); @@ -864,7 +864,7 @@ Obtains information about all app accounts of the specified app. This method use **Example** - ``` + ```js const appAccountManager = account.createAppAccountManager(); const selfBundle = "com.example.actsgetallaaccounts"; appAccountManager.getAllAccounts(selfBundle, (err, data)=>{ @@ -897,7 +897,7 @@ Obtains information about all app accounts of the specified app. This method use **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); const selfBundle = "com.example.actsgetallaaccounts"; appAccountManager.getAllAccounts(selfBundle).then((data) => { @@ -925,7 +925,7 @@ Subscribes to the account change event of the specified account owners. This met **Example** - ``` + ```js const appAccountManager = account.createAppAccountManager(); function changeOnCallback(data){ console.debug("receive change data:" + JSON.stringify(data)); @@ -955,7 +955,7 @@ Unsubscribes from the account change event. This method uses an asynchronous cal **Example** - ``` + ```js const appAccountManager = account.createAppAccountManager(); function changeOnCallback(data){ console.debug("receive change data:" + JSON.stringify(data)); @@ -991,7 +991,7 @@ Authenticates an app account to obtain the Open Authorization (OAuth) access tok **Example** - ``` + ```js import featureAbility from '@ohos.ability.featureAbility'; function onResultCallback(code, result) { @@ -1032,7 +1032,7 @@ Obtains the OAuth access token of an app account based on the specified authenti **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.getOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "readAge", (err, data) => { console.log('getOAuthToken err: ' + JSON.stringify(err)); @@ -1064,7 +1064,7 @@ Obtains the OAuth access token of an app account based on the specified authenti **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.getOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "readAge").then((data) => { console.log('getOAuthToken token: ' + data); @@ -1092,7 +1092,7 @@ Sets an OAuth access token for an app account. This method uses an asynchronous **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.setOAuthToken("LiSi", "readAge", "xxxx", (err) => { console.log('setOAuthToken err: ' + JSON.stringify(err)); @@ -1123,7 +1123,7 @@ Sets an OAuth access token for an app account. This method uses a promise to ret **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.setOAuthToken("LiSi", "readAge", "xxxx").then(() => { console.log('setOAuthToken successfully'); @@ -1152,7 +1152,7 @@ Deletes the specified OAuth access token for an app account. This method uses an **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.deleteOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "readAge", "xxxxx", (err) => { console.log('deleteOAuthToken err: ' + JSON.stringify(err)); @@ -1184,7 +1184,7 @@ Deletes the specified OAuth access token for an app account. This method uses a **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.deleteOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "readAge", "xxxxx").then(() => { console.log('deleteOAuthToken successfully'); @@ -1213,7 +1213,7 @@ Sets the visibility of an OAuth access token to the specified app. This method u **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.setOAuthTokenVisibility("LiSi", "readAge", "com.example.ohos.accountjsdemo", true, (err) => { console.log('setOAuthTokenVisibility err: ' + JSON.stringify(err)); @@ -1245,7 +1245,7 @@ Sets the visibility of an OAuth access token to the specified app. This method u **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.setOAuthTokenVisibility("LiSi", "readAge", "com.example.ohos.accountjsdemo", true).then(() => { console.log('setOAuthTokenVisibility successfully'); @@ -1273,7 +1273,7 @@ Checks whether an OAuth token is visible to the specified app. This method uses **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.checkOAuthTokenVisibility("LiSi", "readAge", "com.example.ohos.accountjsdemo", true, (err, data) => { console.log('checkOAuthTokenVisibility err: ' + JSON.stringify(err)); @@ -1305,7 +1305,7 @@ Checks whether an OAuth token is visible to the specified app. This method uses **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.checkOAuthTokenVisibility("LiSi", "readAge", "com.example.ohos.accountjsdemo", true).then((data) => { console.log('checkOAuthTokenVisibility isVisible: ' + data); @@ -1332,7 +1332,7 @@ Obtains information about all OAuth access tokens of an app account visible to t **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.getAllOAuthTokens("LiSi", "com.example.ohos.accountjsdemo", (err, data) => { console.log("getAllOAuthTokens err: " + JSON.stringify(err)); @@ -1363,7 +1363,7 @@ Obtains information about all OAuth access tokens of an app account visible to t **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.getAllOAuthTokens("LiSi", "com.example.ohos.accountjsdemo").then((data) => { console.log('getAllOAuthTokens data: ' + JSON.stringify(data)); @@ -1390,7 +1390,7 @@ Obtains the authorization list of OAuth access tokens of an app account. This me **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.getOAuthList("com.example.ohos.accountjsdemo", "readAge", (err, data) => { console.log('getOAuthList err: ' + JSON.stringify(err)); @@ -1421,7 +1421,7 @@ Obtains the authorization list of OAuth access tokens of an app account. This me **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.getOAuthList("com.example.ohos.accountjsdemo", "readAge").then((data) => { console.log('getOAuthList data: ' + JSON.stringify(data)); @@ -1447,7 +1447,7 @@ Obtains the authenticator callback for a session. This method uses an asynchrono **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); featureAbility.getWant((err, want) => { var sessionId = want.parameters[account_appAccount.Constants.KEY_SESSION_ID]; @@ -1487,7 +1487,7 @@ Obtains the authenticator callback for a session. This method uses a promise to **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); featureAbility.getWant().then((want) => { var sessionId = want.parameters[account_appAccount.Constants.KEY_SESSION_ID]; @@ -1522,7 +1522,7 @@ Obtains authenticator information of an app account. This method uses an asynchr **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.getAuthenticatorInfo("com.example.ohos.accountjsdemo", (err, data) => { console.log("getAuthenticatorInfo err: " + JSON.stringify(err)); @@ -1552,7 +1552,7 @@ Obtains authenticator information of an app account. This method uses a promise **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.getAuthenticatorInfo("com.example.ohos.accountjsdemo").then((data) => { console.log('getAuthenticatorInfo: ' + JSON.stringify(data)); @@ -1663,7 +1663,7 @@ Called back to send the authentication result. **Example** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); var sessionId = "1234"; appAccountManager.getAuthenticatorCallback(sessionId).then((callback) => { @@ -1692,7 +1692,7 @@ Called back to redirect an authentication request. **Example** - ``` + ```js class MyAuthenticator extends account_appAccount.Authenticator { addAccountImplicitly(authType, callerBundleName, options, callback) { callback.onRequestRedirected({ @@ -1749,7 +1749,7 @@ Authenticates an app account to obtain the OAuth access token. This method uses **Example** - ``` + ```js class MyAuthenticator extends account_appAccount.Authenticator { addAccountImplicitly(authType, callerBundleName, options, callback) { callback.onRequestRedirected({ diff --git a/en/application-dev/reference/apis/js-apis-distributed-account.md b/en/application-dev/reference/apis/js-apis-distributed-account.md index ddf747f756..73f6216d25 100644 --- a/en/application-dev/reference/apis/js-apis-distributed-account.md +++ b/en/application-dev/reference/apis/js-apis-distributed-account.md @@ -6,7 +6,7 @@ ## Modules to Import -``` +```js import account_distributedAccount from '@ohos.account.distributedAccount'; ``` @@ -28,7 +28,7 @@ Obtains a **DistributedAccountAbility** instance. | [DistributedAccountAbility](#distributedaccountability) | **DistributedAccountAbility** instance obtained. This instance provides methods for querying and updating the login state of a distributed account.| - Example - ``` + ```js const accountAbility = account_distributedAccount.getDistributedAccountAbility(); ``` @@ -50,7 +50,7 @@ Obtains distributed account information. This method uses an asynchronous callba | callback | AsyncCallback<[DistributedInfo](#distributedinfo)> | Yes| Callback invoked to return the distributed account information obtained.| - Example - ``` + ```js const accountAbility = account_distributedAccount.getDistributedAccountAbility(); accountAbility.queryOsAccountDistributedInfo((err, data) => { console.log("queryOsAccountDistributedInfo err: " + JSON.stringify(err)); @@ -73,7 +73,7 @@ Obtains distributed account information. This method uses a promise to return th | Promise<[DistributedInfo](#distributedinfo)> | Promise used to return the distributed account information obtained.| - Example - ``` + ```js const accountAbility = account_distributedAccount.getDistributedAccountAbility(); accountAbility.queryOsAccountDistributedInfo().then((data) => { console.log('Query account info name: ' + data.name); @@ -98,7 +98,7 @@ Updates distributed account information. This method uses an asynchronous callba | callback | AsyncCallback<void> | Yes| Callback invoked when the distributed account information is updated.| - Example - ``` + ```js const accountAbility = account_distributedAccount.getDistributedAccountAbility(); let accountInfo = {id: '12345', name: 'ZhangSan', event: 'Ohos.account.event.LOGIN'}; accountAbility.updateOsAccountDistributedInfo(accountInfo, (err) => { @@ -125,7 +125,7 @@ Updates distributed account information. This method uses a promise to return th | Promise<void> | Promise used to return the result.| - Example - ``` + ```js const accountAbility = account_distributedAccount.getDistributedAccountAbility(); let accountInfo = {id: '12345', name: 'ZhangSan', event: 'Ohos.account.event.LOGIN'}; accountAbility.updateOsAccountDistributedInfo(accountInfo).then(() => { diff --git a/en/application-dev/reference/apis/js-apis-osAccount.md b/en/application-dev/reference/apis/js-apis-osAccount.md index de757b71b4..f0e93479b9 100644 --- a/en/application-dev/reference/apis/js-apis-osAccount.md +++ b/en/application-dev/reference/apis/js-apis-osAccount.md @@ -6,7 +6,7 @@ ## Modules to Import -``` +```js import account_osAccount from '@ohos.account.osAccount'; ``` @@ -24,7 +24,7 @@ Obtains an **AccountManager** instance. | [AccountManager](#accountmanager) | Obtains an **AccountManager** instance.| **Example** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); ``` @@ -64,7 +64,7 @@ This is a system API and cannot be called by third-party applications. | callback | AsyncCallback<void> | Yes | Callback used to return the result. | **Example**: Activate OS account 100. - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var localId = 100; accountManager.activateOsAccount(localId, (err)=>{ @@ -97,7 +97,7 @@ This is a system API and cannot be called by third-party applications. | Promise<void> | Promise used to return the result.| **Example**: Activate OS account 100. - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var localId = 100; accountManager.activateOsAccount(localId).then(() => { @@ -123,7 +123,7 @@ Checks whether multiple OS accounts are supported. This method uses an asynchron **Example** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.isMultiOsAccountEnable((err, isEnabled) => { console.log("isMultiOsAccountEnable err: " + JSON.stringify(err)); @@ -147,7 +147,7 @@ Checks whether multiple OS accounts are supported. This method uses a promise to **Example** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.isMultiOsAccountEnable().then((isEnabled) => { console.log('isMultiOsAccountEnable, isEnabled: ' + isEnabled); @@ -175,7 +175,7 @@ Checks whether an OS account is activated. This method uses an asynchronous call **Example**: Check whether OS account 100 is activated. - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var osLocalId = 100; accountManager.isOsAccountActived(osLocalId, (err, isActive)=>{ @@ -208,7 +208,7 @@ Checks whether an OS account is activated. This method uses a promise to return **Example**: Check whether OS account 100 is activated. - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var osLocalId = 100; accountManager.isOsAccountActived(osLocalId).then((isActive) => { @@ -236,9 +236,9 @@ Checks whether the specified constraint is enabled for an OS account. This metho | constraint | string | Yes | [Constraint](#constraints) specified. | | callback | AsyncCallback<boolean> | Yes | Callback used to return the result. If the constraint is enabled for the OS account, **true** will be returned. Otherwise, **false** will be returned.| -** Example**: Check whether OS account 100 is forbidden to use Wi-Fi. +**Example**: Check whether OS account 100 is forbidden to use Wi-Fi. - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var localId = 100; accountManager.isOsAccountConstraintEnable(localId, "constraint.wifi", (err, isConstraintEnabled)=>{ @@ -270,9 +270,9 @@ Checks whether the specified constraint is enabled for an OS account. This metho | :--------------------- | :----------------------------------------------------------- | | Promise<boolean> | Promise used to return the result. If the constraint is enabled for the OS account, **true** will be returned. Otherwise, **false** will be returned.| -** Example**: Check whether OS account 100 is forbidden to use Wi-Fi. +**Example**: Check whether OS account 100 is forbidden to use Wi-Fi. - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var localId = 100; accountManager.isOsAccountConstraintEnable(localId, "constraint.wifi").then((isConstraintEnabled) => { @@ -298,7 +298,7 @@ Checks whether this OS account is a test account. This method uses an asynchrono **Example** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.isTestOsAccount((err, isTest) => { console.log("isTestOsAccount err: " + JSON.stringify(err)); @@ -322,7 +322,7 @@ Checks whether this OS account is a test account. This method uses a promise to **Example** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.isTestOsAccount().then((isTest) => { console.log('isTestOsAccount, isTest: ' + isTest); @@ -347,7 +347,7 @@ Checks whether this OS account has been verified. This method uses an asynchrono **Example** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.isOsAccountVerified((err, isVerified) => { console.log("isOsAccountVerified err: " + JSON.stringify(err)); @@ -374,7 +374,7 @@ Checks whether an OS account has been verified. This method uses an asynchronous **Example** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.isOsAccountVerified((err, isVerified) => { console.log("isOsAccountVerified err: " + JSON.stringify(err)); @@ -406,7 +406,7 @@ Checks whether an OS account has been verified. This method uses a promise to re **Example** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.isOsAccountVerified().then((isVerified) => { console.log('isOsAccountVerified, isVerified: ' + isVerified); @@ -436,7 +436,7 @@ This is a system API and cannot be called by third-party applications. **Example** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var createIocalId; osAccountManager.createOsAccount("testAccountName", osaccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{ @@ -473,7 +473,7 @@ This is a system API and cannot be called by third-party applications. **Example** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var createIocalId; osAccountManager.createOsAccount("testAccountName", osaccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{ @@ -508,9 +508,9 @@ This is a system API and cannot be called by third-party applications. | enable | boolean | Yes | Set or remove constraints. The value **true** means to set constraints, and **false** means to remove constraints. | | callback | AsyncCallback<void> | Yes | Callback used to return the result. | -** Example**: Disable Wi-Fi for OS account 100. +**Example**: Disable Wi-Fi for OS account 100. - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var localId = 100; accountManager.setOsAccountConstraints(localId, ["constraint.wifi"], true, (err)=>{ @@ -546,7 +546,7 @@ This is a system API and cannot be called by third-party applications. **Example**: Remote the constraint on the use of Wi-Fi for OS account 100. - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var localId = 100; accountManager.setOsAccountConstraints(localId, ["constraint.location.set"], false).then(() => { @@ -578,7 +578,7 @@ This is a system API and cannot be called by third-party applications. **Example**: Set the name of OS account 100 to **demoName**. - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var localId = 100; var newName = "demoName"; @@ -614,7 +614,7 @@ This is a system API and cannot be called by third-party applications. **Example**: Set the name of OS account 100 to **demoName**. - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var localId = 100; var nameLimit = "demoName"; @@ -643,7 +643,7 @@ Obtains the number of OS accounts created. This method uses an asynchronous call **Example** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.getCreatedOsAccountsCount((err, accountCnt)=>{ console.log("obtains the number of all os accounts created err:" + JSON.stringify(err)); @@ -669,7 +669,7 @@ Obtains the number of OS accounts created. This method uses a promise to return **Example** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.getCreatedOsAccountsCount().then((accountCnt) => { console.log('getCreatedOsAccountsCount, accountCnt: ' + accountCnt); @@ -694,7 +694,7 @@ Obtains the ID of the OS account to which the current process belongs. This meth **Example** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.getOsAccountLocalIdFromProcess((err, accountID) => { console.log("getOsAccountLocalIdFromProcess err: " + JSON.stringify(err)); @@ -718,7 +718,7 @@ Obtains the ID of the OS account to which the current process belongs. This meth **Example** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.getOsAccountLocalIdFromProcess().then((accountID) => { console.log('getOsAccountLocalIdFromProcess, accountID: ' + accountID); @@ -744,7 +744,7 @@ Obtains the OS account ID based on the process UID. This method uses an asynchro **Example**: Obtain the ID of the OS account whose process UID is **12345678**. - ``` + ```js const accountManager = account_osAccount.getAccountManager(); let uid = 12345678; accountManager.getOsAccountLocalIdFromUid(uid, (err, accountID) => { @@ -775,7 +775,7 @@ Obtains the OS account ID based on the process UID. This method uses a promise t **Example**: Obtain the ID of the OS account whose process UID is **12345678**. - ``` + ```js const accountManager = account_osAccount.getAccountManager(); let uid = 12345678; accountManager.getOsAccountLocalIdFromUid(uid).then((accountID) => { @@ -804,7 +804,7 @@ Obtains the OS account ID based on domain account information. This method uses **Example** - ``` + ```js var domainInfo = {domain: "testDomain", accountName: "testAccountName"}; const accountManager = account_osAccount.getAccountManager(); accountManager.getOsAccountLocalIdFromDomain(domainInfo, (err, accountID) => { @@ -837,7 +837,7 @@ Obtains the OS account ID based on domain account information. This method uses **Example** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var domainInfo = {domain: "testDomain", accountName: "testAccountName"}; accountManager.getOsAccountLocalIdFromDomain(domainInfo).then((accountID) => { @@ -865,7 +865,7 @@ This is a system API and cannot be called by third-party applications. **Example** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.queryMaxOsAccountNumber((err, maxCnt)=>{ console.log("queryMaxOsAccountNumber err:" + JSON.stringify(err)); @@ -891,7 +891,7 @@ This is a system API and cannot be called by third-party applications. **Example** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.queryMaxOsAccountNumber().then((maxCnt) => { console.log('queryMaxOsAccountNumber, maxCnt: ' + maxCnt); @@ -917,9 +917,9 @@ Obtains all constraints enabled for an OS account. This method uses an asynchron | localId | number | Yes | ID of the target OS account. | | callback | AsyncCallback<Array<string>> | Yes | Callback used to return all [constraints](#constraints) obtained.| -** Example**: Obtain all constraints of OS account 100. +**Example**: Obtain all constraints of OS account 100. - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var localId = 100; accountManager.getOsAccountAllConstraints(localId, (err, constraints)=>{ @@ -950,9 +950,9 @@ Obtains all constraints enabled for an OS account. This method uses a promise to | :--------------------------------- | :----------------------------------------------------------- | | Promise<Array<string>> | Promise used to return the [constraints](#constraints) obtained.| -** Example**: Obtain all constraints of OS account 100. +**Example**: Obtain all constraints of OS account 100. - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var localId = 100; accountManager.getOsAccountAllConstraints(localId).then((constraints) => { @@ -980,7 +980,7 @@ This is a system API and cannot be called by third-party applications. **Example** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.queryAllCreatedOsAccounts((err, accountArr)=>{ console.log("queryAllCreatedOsAccounts err:" + JSON.stringify(err)); @@ -1006,7 +1006,7 @@ This is a system API and cannot be called by third-party applications. **Example** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.queryAllCreatedOsAccounts().then((accountArr) => { console.log('queryAllCreatedOsAccounts, accountArr: ' + JSON.stringify(accountArr)); @@ -1031,7 +1031,7 @@ Obtains information about all activated OS accounts. This method uses an asynchr **Example** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.queryActivatedOsAccountIds((err, idArray)=>{ console.log("queryActivatedOsAccountIds err:" + JSON.stringify(err)); @@ -1058,7 +1058,7 @@ Obtains information about all activated OS accounts. This method uses a promise **Example** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.queryActivatedOsAccountIds().then((idArray) => { console.log('queryActivatedOsAccountIds, idArray: ' + idArray); @@ -1089,7 +1089,7 @@ This is a system API and cannot be called by third-party applications. **Example** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.createOsAccount("testName", osaccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{ console.log("createOsAccount err:" + JSON.stringify(err)); @@ -1124,7 +1124,7 @@ This is a system API and cannot be called by third-party applications. **Example** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.createOsAccount("testAccountName", osaccount.OsAccountType.NORMAL).then((accountInfo) => { console.log("createOsAccount, accountInfo: " + JSON.stringify(accountInfo)); @@ -1155,7 +1155,7 @@ This is a system API and cannot be called by third-party applications. **Example** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var domainInfo = {domain: "testDomain", accountName: "testAccountName"}; accountManager.createOsAccountForDomain(osaccount.OsAccountType.NORMAL, domainInfo, (err, osAccountInfo)=>{ @@ -1191,7 +1191,7 @@ This is a system API and cannot be called by third-party applications. **Example** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var domainInfo = {domain: "testDomain", accountName: "testAccountName"}; accountManager.createOsAccountForDomain(osaccount.OsAccountType.NORMAL, domainInfo).then((accountInfo) => { @@ -1219,7 +1219,7 @@ Obtains information about the OS account to which the current process belongs. T **Example** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.queryCurrentOsAccount((err, curAccountInfo)=>{ console.log("queryCurrentOsAccount err:" + JSON.stringify(err)); @@ -1245,7 +1245,7 @@ Obtains information about the OS account to which the current process belongs. T **Example** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.queryCurrentOsAccount().then((accountInfo) => { console.log("queryCurrentOsAccount, accountInfo: " + JSON.stringify(accountInfo)); @@ -1275,7 +1275,7 @@ This is a system API and cannot be called by third-party applications. **Example**: Query information about OS account 100. - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var localId = 100; accountManager.queryOsAccountById(localId, (err, accountInfo)=>{ @@ -1310,7 +1310,7 @@ This is a system API and cannot be called by third-party applications. **Example**: Query information about OS account 100. - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var localId = 100; accountManager.queryOsAccountById(localId).then((accountInfo) => { @@ -1336,7 +1336,7 @@ Obtains the type of the OS account to which the current process belongs. This me **Example** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.getOsAccountTypeFromProcess((err, accountType) => { console.log("getOsAccountTypeFromProcess err: " + JSON.stringify(err)); @@ -1360,7 +1360,7 @@ Obtains the type of the OS account to which the current process belongs. This me **Example** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.getOsAccountTypeFromProcess().then((accountType) => { console.log('getOsAccountTypeFromProcess, accountType: ' + accountType); @@ -1387,7 +1387,7 @@ Obtains the ID of this distributed virtual device. This method uses an asynchron **Example** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.getDistributedVirtualDeviceId((err, virtualID) => { console.log("getDistributedVirtualDeviceId err: " + JSON.stringify(err)); @@ -1413,7 +1413,7 @@ Obtains the ID of this distributed virtual device. This method uses a promise to **Example** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.getDistributedVirtualDeviceId().then((virtualID) => { console.log('getDistributedVirtualDeviceId, virtualID: ' + virtualID); @@ -1443,7 +1443,7 @@ This is a system API and cannot be called by third-party applications. **Example**: Obtain the profile photo of OS account 100. - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var localId = 100; accountManager.getOsAccountProfilePhoto(localId, (err, photo)=>{ @@ -1478,7 +1478,7 @@ This is a system API and cannot be called by third-party applications. **Example**: Obtain the profile photo of OS account 100. - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var localId = 100; accountManager.getOsAccountProfilePhoto(localId).then((photo) => { @@ -1510,7 +1510,7 @@ This is a system API and cannot be called by third-party applications. **Example**: Set a profile photo for OS account 100. - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var localId = 100; var photo = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAPCAYAAAA/I0V3AAAAAXNSR0IArs4c6QAAAARnQU1BAA"+ @@ -1549,7 +1549,7 @@ This is a system API and cannot be called by third-party applications. **Example**: Set a profile photo for OS account 100. - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var localId = 100; var photo = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAPCAYAAAA/I0V3AAAAAXNSR0IArs4c6QAAAARnQU1BAA"+ @@ -1580,7 +1580,7 @@ Obtains the OS account ID based on the SN. This method uses an asynchronous call **Example**: Obtain the ID of the OS account whose SN is **12345**. - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var serialNumber = 12345; accountManager.getOsAccountLocalIdBySerialNumber(serialNumber, (err, localId)=>{ @@ -1611,7 +1611,7 @@ Obtains the OS account ID based on the SN. This method uses a promise to return **Example**: Obtain the ID of the OS account whose SN is **12345**. - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var serialNumber = 12345; accountManager.getOsAccountLocalIdBySerialNumber(serialNumber).then((localId) => { @@ -1638,7 +1638,7 @@ Obtains the SN of an OS account based on the account ID. This method uses an asy **Example**: Obtain the SN of OS account 100. - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var localId = 100; accountManager.getSerialNumberByOsAccountLocalId(localId, (err, serialNumber)=>{ @@ -1669,7 +1669,7 @@ Obtains the SN of an OS account based on the account ID. This method uses a prom **Example**: Obtain the SN of OS account 100. - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var localId = 100; accountManager.getSerialNumberByOsAccountLocalId(localId).then((serialNumber) => { @@ -1701,7 +1701,7 @@ This is a system API and cannot be called by third-party applications. **Example** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); function onCallback(receiveLocalId){ console.log("receive localId:" + receiveLocalId); @@ -1731,7 +1731,7 @@ This is a system API and cannot be called by third-party applications. **Example** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); function offCallback(){ console.log("off enter") diff --git a/zh-cn/application-dev/reference/apis/js-apis-appAccount.md b/zh-cn/application-dev/reference/apis/js-apis-appAccount.md index 267300d717..7fb71c1da3 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-appAccount.md +++ b/zh-cn/application-dev/reference/apis/js-apis-appAccount.md @@ -6,7 +6,7 @@ ## 导入模块 -``` +```js import account_appAccount from '@ohos.account.appAccount'; ``` @@ -25,7 +25,7 @@ createAppAccountManager(): AppAccountManager | AppAccountManager | 获取应用帐号模块的实例。 | **示例:** - ``` + ```js var appAccountManager = account.createAppAccountManager(); ``` @@ -50,7 +50,7 @@ addAccount(name: string, callback: AsyncCallback<void>): void **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.addAccount("WangWu", (err) => { console.log("addAccount err: " + JSON.stringify(err)); @@ -75,7 +75,7 @@ addAccount(name: string, extraInfo: string, callback: AsyncCallback<void>) **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.addAccount("LiSi", "token101", (err) => { console.log("addAccount err: " + JSON.stringify(err)); @@ -107,7 +107,7 @@ addAccount(name: string, extraInfo?: string): Promise<void> **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.addAccount("LiSi", "token101").then(()=> { console.log('addAccount Success'); @@ -135,7 +135,7 @@ addAccountImplicitly(owner: string, authType: string, options: {[key: string]: a **示例:** - ``` + ```js import featureAbility from '@ohos.ability.featureAbility'; function onResultCallback(code, result) { @@ -174,7 +174,7 @@ deleteAccount(name: string, callback: AsyncCallback<void>): void **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.deleteAccount("ZhaoLiu", (err) => { console.log("deleteAccount err: " + JSON.stringify(err)); @@ -203,7 +203,7 @@ deleteAccount(name: string): Promise<void> **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.deleteAccount("ZhaoLiu").then(() => { console.log('deleteAccount Success'); @@ -230,7 +230,7 @@ disableAppAccess(name: string, bundleName: string, callback: AsyncCallback<vo **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.disableAppAccess("ZhangSan", "com.example.ohos.accountjsdemo", (err) => { console.log("disableAppAccess err: " + JSON.stringify(err)); @@ -260,7 +260,7 @@ disableAppAccess(name: string, bundleName: string): Promise<void> **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.disableAppAccess("ZhangSan", "com.example.ohos.accountjsdemo").then(() => { console.log('disableAppAccess Success'); @@ -287,7 +287,7 @@ enableAppAccess(name: string, bundleName: string, callback: AsyncCallback<voi **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.enableAppAccess("ZhangSan", "com.example.ohos.accountjsdemo", (err) => { console.log("enableAppAccess: " + JSON.stringify(err)); @@ -317,7 +317,7 @@ enableAppAccess(name: string, bundleName: string): Promise<void> **示例:** - ``` + ```js app_account_instance.enableAppAccess("ZhangSan", "com.example.ohos.accountjsdemo").then(() => { console.log('enableAppAccess Success'); }).catch((err) => { @@ -344,7 +344,7 @@ checkAppAccountSyncEnable(name: string, callback: AsyncCallback<boolean>): **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.checkAppAccountSyncEnable("ZhangSan", (err, result) => { console.log("checkAppAccountSyncEnable err: " + JSON.stringify(err)); @@ -376,7 +376,7 @@ checkAppAccountSyncEnable(name: string): Promise<boolean> **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.checkAppAccountSyncEnable("ZhangSan").then((data) => { console.log('checkAppAccountSyncEnable, result: ' + data); @@ -404,7 +404,7 @@ setAccountCredential(name: string, credentialType: string, credential: string,ca **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.setAccountCredential("ZhangSan", "credentialType001", "credential001", (err) => { console.log("setAccountCredential err: " + JSON.stringify(err)); @@ -435,7 +435,7 @@ setAccountCredential(name: string, credentialType: string, credential: string): **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.setAccountCredential("ZhangSan", "credentialType001", "credential001").then(() => { console.log('setAccountCredential Success'); @@ -462,7 +462,7 @@ setAccountExtraInfo(name: string, extraInfo: string, callback: AsyncCallback< **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.setAccountExtraInfo("ZhangSan", "Tk002", (err) => { console.log("setAccountExtraInfo err: " + JSON.stringify(err)); @@ -492,7 +492,7 @@ setAccountExtraInfo(name: string, extraInfo: string): Promise<void> **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.setAccountExtraInfo("ZhangSan", "Tk002").then(() => { console.log('setAccountExtraInfo Success'); @@ -521,7 +521,7 @@ setAppAccountSyncEnable(name: string, isEnable: boolean, callback: AsyncCallback **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.setAppAccountSyncEnable("ZhangSan", true, (err) => { console.log("setAppAccountSyncEnable err: " + JSON.stringify(err)); @@ -553,7 +553,7 @@ setAppAccountSyncEnable(name: string, isEnable: boolean): Promise<void> **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager .setAppAccountSyncEnable("ZhangSan", true).then(() => { console.log('setAppAccountSyncEnable Success'); @@ -581,7 +581,7 @@ setAssociatedData(name: string, key: string, value: string, callback: AsyncCallb **示例:** - ``` + ```js app_account_instance.setAssociatedData("ZhangSan", "k001", "v001", (err) => { console.log("setAssociatedData err: " + JSON.stringify(err)); }); @@ -611,7 +611,7 @@ setAssociatedData(name: string, key: string, value: string): Promise<void> **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.setAssociatedData("ZhangSan", "k001", "v001").then(() => { console.log('setAssociatedData Success'); @@ -638,7 +638,7 @@ getAccountCredential(name: string, credentialType: string, callback: AsyncCallba **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.getAccountCredential("ZhangSan", "credentialType001", (err, result) => { console.log("getAccountCredential err: " + JSON.stringify(err)); @@ -669,7 +669,7 @@ getAccountCredential(name: string, credentialType: string): Promise<string> **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.getAccountCredential("ZhangSan", "credentialType001").then((data) => { console.log('getAccountCredential, result: ' + data); @@ -695,7 +695,7 @@ getAccountExtraInfo(name: string, callback: AsyncCallback<string>): void **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.getAccountExtraInfo("ZhangSan", (err, result) => { console.log("getAccountExtraInfo err: " + JSON.stringify(err)); @@ -725,7 +725,7 @@ getAccountExtraInfo(name: string): Promise<string> **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.getAccountExtraInfo("ZhangSan").then((data) => { console.log('getAccountExtraInfo, result: ' + data); @@ -752,7 +752,7 @@ getAssociatedData(name: string, key: string, callback: AsyncCallback<string&g **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.getAssociatedData("ZhangSan", "k001", (err, result) => { console.log("getAssociatedData err: " + JSON.stringify(err)); @@ -783,7 +783,7 @@ getAssociatedData(name: string, key: string): Promise<string> **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.getAssociatedData("ZhangSan", "k001").then((data) => { console.log('getAssociatedData: ' + data); @@ -810,7 +810,7 @@ getAllAccessibleAccounts(callback: AsyncCallback<Array<AppAccountInfo>& **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.getAllAccessibleAccounts((err, data)=>{ console.debug("getAllAccessibleAccounts err:" + JSON.stringify(err)); @@ -836,7 +836,7 @@ getAllAccessibleAccounts(): Promise<Array<AppAccountInfo>> **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.getAllAccessibleAccounts().then((data) => { console.log('getAllAccessibleAccounts: ' + data); @@ -864,7 +864,7 @@ getAllAccounts(owner: string, callback: AsyncCallback<Array<AppAccountInfo **示例:** - ``` + ```js const appAccountManager = account.createAppAccountManager(); const selfBundle = "com.example.actsgetallaaccounts"; appAccountManager.getAllAccounts(selfBundle, (err, data)=>{ @@ -897,7 +897,7 @@ getAllAccounts(owner: string): Promise<Array<AppAccountInfo>> **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); const selfBundle = "com.example.actsgetallaaccounts"; appAccountManager.getAllAccounts(selfBundle).then((data) => { @@ -925,7 +925,7 @@ on(type: 'change', owners: Array<string>, callback: Callback<Array<A **示例:** - ``` + ```js const appAccountManager = account.createAppAccountManager(); function changeOnCallback(data){ console.debug("receive change data:" + JSON.stringify(data)); @@ -955,7 +955,7 @@ off(type: 'change', callback?: Callback>): void **示例:** - ``` + ```js const appAccountManager = account.createAppAccountManager(); function changeOnCallback(data){ console.debug("receive change data:" + JSON.stringify(data)); @@ -991,7 +991,7 @@ authenticate(name: string, owner: string, authType: string, options: {[key: stri **示例:** - ``` + ```js import featureAbility from '@ohos.ability.featureAbility'; function onResultCallback(code, result) { @@ -1032,7 +1032,7 @@ getOAuthToken(name: string, owner: string, authType: string, callback: AsyncCall **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.getOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "readAge", (err, data) => { console.log('getOAuthToken err: ' + JSON.stringify(err)); @@ -1064,7 +1064,7 @@ getOAuthToken(name: string, owner: string, authType: string): Promise<string& **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.getOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "readAge").then((data) => { console.log('getOAuthToken token: ' + data); @@ -1092,7 +1092,7 @@ setOAuthToken(name: string, authType: string, token: string, callback: AsyncCall **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.setOAuthToken("LiSi", "readAge", "xxxx", (err) => { console.log('setOAuthToken err: ' + JSON.stringify(err)); @@ -1123,7 +1123,7 @@ setOAuthToken(name: string, authType: string, token: string): Promise<void> **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.setOAuthToken("LiSi", "readAge", "xxxx").then(() => { console.log('setOAuthToken successfully'); @@ -1152,7 +1152,7 @@ deleteOAuthToken(name: string, owner: string, authType: string, token: string, c **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.deleteOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "readAge", "xxxxx", (err) => { console.log('deleteOAuthToken err: ' + JSON.stringify(err)); @@ -1184,7 +1184,7 @@ deleteOAuthToken(name: string, owner: string, authType: string, token: string): **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.deleteOAuthToken("LiSi", "com.example.ohos.accountjsdemo", "readAge", "xxxxx").then(() => { console.log('deleteOAuthToken successfully'); @@ -1213,7 +1213,7 @@ setOAuthTokenVisibility(name: string, authType: string, bundleName: string, isVi **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.setOAuthTokenVisibility("LiSi", "readAge", "com.example.ohos.accountjsdemo", true, (err) => { console.log('setOAuthTokenVisibility err: ' + JSON.stringify(err)); @@ -1245,7 +1245,7 @@ setOAuthTokenVisibility(name: string, authType: string, bundleName: string, isVi **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.setOAuthTokenVisibility("LiSi", "readAge", "com.example.ohos.accountjsdemo", true).then(() => { console.log('setOAuthTokenVisibility successfully'); @@ -1273,7 +1273,7 @@ checkOAuthTokenVisibility(name: string, authType: string, bundleName: string, ca **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.checkOAuthTokenVisibility("LiSi", "readAge", "com.example.ohos.accountjsdemo", true, (err, data) => { console.log('checkOAuthTokenVisibility err: ' + JSON.stringify(err)); @@ -1305,7 +1305,7 @@ checkOAuthTokenVisibility(name: string, authType: string, bundleName: string): P **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.checkOAuthTokenVisibility("LiSi", "readAge", "com.example.ohos.accountjsdemo", true).then((data) => { console.log('checkOAuthTokenVisibility isVisible: ' + data); @@ -1332,7 +1332,7 @@ getAllOAuthTokens(name: string, owner: string, callback: AsyncCallback<Array& **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.getAllOAuthTokens("LiSi", "com.example.ohos.accountjsdemo", (err, data) => { console.log("getAllOAuthTokens err: " + JSON.stringify(err)); @@ -1363,7 +1363,7 @@ getAllOAuthTokens(name: string, owner: string): Promise<Array<OAuthTokenIn **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.getAllOAuthTokens("LiSi", "com.example.ohos.accountjsdemo").then((data) => { console.log('getAllOAuthTokens data: ' + JSON.stringify(data)); @@ -1390,7 +1390,7 @@ getOAuthList(name: string, authType: string, callback: AsyncCallback<Array< **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.getOAuthList("com.example.ohos.accountjsdemo", "readAge", (err, data) => { console.log('getOAuthList err: ' + JSON.stringify(err)); @@ -1421,7 +1421,7 @@ getOAuthList(name: string, authType: string): Promise<Array<string>> **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.getOAuthList("com.example.ohos.accountjsdemo", "readAge").then((data) => { console.log('getOAuthList data: ' + JSON.stringify(data)); @@ -1447,7 +1447,7 @@ getAuthenticatorCallback(sessionId: string, callback: AsyncCallback<Authentic **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); featureAbility.getWant((err, want) => { var sessionId = want.parameters[account_appAccount.Constants.KEY_SESSION_ID]; @@ -1487,7 +1487,7 @@ getAuthenticatorCallback(sessionId: string): Promise<AuthenticatorCallback> **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); featureAbility.getWant().then((want) => { var sessionId = want.parameters[account_appAccount.Constants.KEY_SESSION_ID]; @@ -1522,7 +1522,7 @@ getAuthenticatorInfo(owner: string, callback: AsyncCallback<AuthenticatorInfo **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.getAuthenticatorInfo("com.example.ohos.accountjsdemo", (err, data) => { console.log("getAuthenticatorInfo err: " + JSON.stringify(err)); @@ -1552,7 +1552,7 @@ getAuthenticatorInfo(owner: string): Promise<AuthenticatorInfo> **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); appAccountManager.getAuthenticatorInfo("com.example.ohos.accountjsdemo").then((data) => { console.log('getAuthenticatorInfo: ' + JSON.stringify(data)); @@ -1663,7 +1663,7 @@ onResult: (code: number, result: {[key: string]: any}) => void **示例:** - ``` + ```js const appAccountManager = account_appAccount.createAppAccountManager(); var sessionId = "1234"; appAccountManager.getAuthenticatorCallback(sessionId).then((callback) => { @@ -1692,7 +1692,7 @@ onRequestRedirected: (request: Want) => void **示例:** - ``` + ```js class MyAuthenticator extends account_appAccount.Authenticator { addAccountImplicitly(authType, callerBundleName, options, callback) { callback.onRequestRedirected({ @@ -1749,7 +1749,7 @@ authenticate(name: string, authType: string, callerBundleName: string, options: **示例:** - ``` + ```js class MyAuthenticator extends account_appAccount.Authenticator { addAccountImplicitly(authType, callerBundleName, options, callback) { callback.onRequestRedirected({ diff --git a/zh-cn/application-dev/reference/apis/js-apis-distributed-account.md b/zh-cn/application-dev/reference/apis/js-apis-distributed-account.md index 67ada72665..7cf4c74eba 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-distributed-account.md +++ b/zh-cn/application-dev/reference/apis/js-apis-distributed-account.md @@ -6,7 +6,7 @@ ## 导入模块 -``` +```js import account_distributedAccount from '@ohos.account.distributedAccount'; ``` @@ -28,7 +28,7 @@ getDistributedAccountAbility(): DistributedAccountAbility | [DistributedAccountAbility](#distributedaccountability) | 返回一个实例,实例提供查询和更新分布式帐号登录状态方法。 | - 示例: - ``` + ```js const accountAbility = account_distributedAccount.getDistributedAccountAbility(); ``` @@ -50,7 +50,7 @@ queryOsAccountDistributedInfo(callback: AsyncCallback<DistributedInfo>): v | callback | AsyncCallback<[DistributedInfo](#distributedinfo)> | 是 | 获取分布式帐号信息的回调。 | - 示例: - ``` + ```js const accountAbility = account_distributedAccount.getDistributedAccountAbility(); accountAbility.queryOsAccountDistributedInfo((err, data) => { console.log("queryOsAccountDistributedInfo err: " + JSON.stringify(err)); @@ -73,7 +73,7 @@ queryOsAccountDistributedInfo(): Promise<DistributedInfo> | Promise<[DistributedInfo](#distributedinfo)> | Promise实例,用于获取异步返回结果。 | - 示例: - ``` + ```js const accountAbility = account_distributedAccount.getDistributedAccountAbility(); accountAbility.queryOsAccountDistributedInfo().then((data) => { console.log('Query account info name: ' + data.name); @@ -98,7 +98,7 @@ updateOsAccountDistributedInfo(accountInfo: DistributedInfo, callback: AsyncCall | callback | AsyncCallback<void> | 是 | 更新分布式帐号信息的回调。 | - 示例: - ``` + ```js const accountAbility = account_distributedAccount.getDistributedAccountAbility(); let accountInfo = {id: '12345', name: 'ZhangSan', event: 'Ohos.account.event.LOGIN'}; accountAbility.updateOsAccountDistributedInfo(accountInfo, (err) => { @@ -125,7 +125,7 @@ updateOsAccountDistributedInfo(accountInfo: DistributedInfo): Promise<void> | Promise<void> | Promise实例,用于获取异步返回结果。 | - 示例: - ``` + ```js const accountAbility = account_distributedAccount.getDistributedAccountAbility(); let accountInfo = {id: '12345', name: 'ZhangSan', event: 'Ohos.account.event.LOGIN'}; accountAbility.updateOsAccountDistributedInfo(accountInfo).then(() => { diff --git a/zh-cn/application-dev/reference/apis/js-apis-osAccount.md b/zh-cn/application-dev/reference/apis/js-apis-osAccount.md index 7a8240be84..33868672cb 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-osAccount.md +++ b/zh-cn/application-dev/reference/apis/js-apis-osAccount.md @@ -6,7 +6,7 @@ ## 导入模块 -``` +```js import account_osAccount from '@ohos.account.osAccount'; ``` @@ -24,7 +24,7 @@ getAccountManager(): AccountManager | [AccountManager](#accountmanager) | 获取系统帐号能力的实例。 | **示例:** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); ``` @@ -64,7 +64,7 @@ activateOsAccount(localId: number, callback: AsyncCallback<void>): void | callback | AsyncCallback<void> | 是 | 回调结果。 | **示例:**激活ID为100的系统帐号 - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var localId = 100; accountManager.activateOsAccount(localId, (err)=>{ @@ -97,7 +97,7 @@ activateOsAccount(localId: number): Promise<void> | Promise<void> | Promise实例,用于获取异步返回结果。 | **示例:**激活ID为100的系统帐号 - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var localId = 100; accountManager.activateOsAccount(localId).then(() => { @@ -123,7 +123,7 @@ isMultiOsAccountEnable(callback: AsyncCallback<boolean>): void **示例:** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.isMultiOsAccountEnable((err, isEnabled) => { console.log("isMultiOsAccountEnable err: " + JSON.stringify(err)); @@ -147,7 +147,7 @@ isMultiOsAccountEnable(): Promise<boolean> **示例:** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.isMultiOsAccountEnable().then((isEnabled) => { console.log('isMultiOsAccountEnable, isEnabled: ' + isEnabled); @@ -175,7 +175,7 @@ isOsAccountActived(localId: number, callback: AsyncCallback<boolean>): voi **示例:**判断ID为100的系统帐号是否处于激活状态 - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var osLocalId = 100; accountManager.isOsAccountActived(osLocalId, (err, isActive)=>{ @@ -208,7 +208,7 @@ isOsAccountActived(localId: number): Promise<boolean> **示例:**判断ID为100的系统帐号是否处于激活状态 - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var osLocalId = 100; accountManager.isOsAccountActived(osLocalId).then((isActive) => { @@ -238,7 +238,7 @@ isOsAccountConstraintEnable(localId: number, constraint: string, callback: Async **示例:**判断ID为100的系统帐号是否有禁止使用wifi的约束 - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var localId = 100; accountManager.isOsAccountConstraintEnable(localId, "constraint.wifi", (err, isConstraintEnabled)=>{ @@ -272,7 +272,7 @@ isOsAccountConstraintEnable(localId: number, constraint: string): Promise<boo **示例:**判断ID为100的系统帐号是否有禁止使用wifi的约束 - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var localId = 100; accountManager.isOsAccountConstraintEnable(localId, "constraint.wifi").then((isConstraintEnabled) => { @@ -298,7 +298,7 @@ isTestOsAccount(callback: AsyncCallback<boolean>): void **示例:** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.isTestOsAccount((err, isTest) => { console.log("isTestOsAccount err: " + JSON.stringify(err)); @@ -322,7 +322,7 @@ isTestOsAccount(): Promise<boolean> **示例:** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.isTestOsAccount().then((isTest) => { console.log('isTestOsAccount, isTest: ' + isTest); @@ -347,7 +347,7 @@ isOsAccountVerified(callback: AsyncCallback<boolean>): void **示例:** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.isOsAccountVerified((err, isVerified) => { console.log("isOsAccountVerified err: " + JSON.stringify(err)); @@ -374,7 +374,7 @@ isOsAccountVerified(localId: number, callback: AsyncCallback<boolean>): vo **示例:** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.isOsAccountVerified((err, isVerified) => { console.log("isOsAccountVerified err: " + JSON.stringify(err)); @@ -406,7 +406,7 @@ isOsAccountVerified(localId?: number): Promise<boolean> **示例:** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.isOsAccountVerified().then((isVerified) => { console.log('isOsAccountVerified, isVerified: ' + isVerified); @@ -436,7 +436,7 @@ removeOsAccount(localId: number, callback: AsyncCallback<void>): void **示例:** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var createIocalId; osAccountManager.createOsAccount("testAccountName", osaccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{ @@ -473,7 +473,7 @@ removeOsAccount(localId: number): Promise<void> **示例:** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var createIocalId; osAccountManager.createOsAccount("testAccountName", osaccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{ @@ -510,7 +510,7 @@ setOsAccountConstraints(localId: number, constraints: Array<string>, enabl **示例:**给ID为100的系统帐号设置禁止使用wifi的约束 - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var localId = 100; accountManager.setOsAccountConstraints(localId, ["constraint.wifi"], true, (err)=>{ @@ -546,7 +546,7 @@ setOsAccountConstraints(localId: number, constraints: Array<string>, enabl **示例:**删除ID为100的系统帐号的禁止使用wifi的约束 - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var localId = 100; accountManager.setOsAccountConstraints(localId, ["constraint.location.set"], false).then(() => { @@ -578,7 +578,7 @@ setOsAccountName(localId: number, localName: string, callback: AsyncCallback< **示例:**将ID为100的系统帐号的帐号名设置成demoName - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var localId = 100; var newName = "demoName"; @@ -614,7 +614,7 @@ setOsAccountName(localId: number, localName: string): Promise<void> **示例:**将ID为100的系统帐号的帐号名设置成demoName - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var localId = 100; var nameLimit = "demoName"; @@ -643,7 +643,7 @@ getCreatedOsAccountsCount(callback: AsyncCallback<number>): void **示例:** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.getCreatedOsAccountsCount((err, accountCnt)=>{ console.log("obtains the number of all os accounts created err:" + JSON.stringify(err)); @@ -669,7 +669,7 @@ getCreatedOsAccountsCount(): Promise<number> **示例:** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.getCreatedOsAccountsCount().then((accountCnt) => { console.log('getCreatedOsAccountsCount, accountCnt: ' + accountCnt); @@ -694,7 +694,7 @@ getOsAccountLocalIdFromProcess(callback: AsyncCallback<number>): void **示例:** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.getOsAccountLocalIdFromProcess((err, accountID) => { console.log("getOsAccountLocalIdFromProcess err: " + JSON.stringify(err)); @@ -718,7 +718,7 @@ getOsAccountLocalIdFromProcess(): Promise<number> **示例:** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.getOsAccountLocalIdFromProcess().then((accountID) => { console.log('getOsAccountLocalIdFromProcess, accountID: ' + accountID); @@ -744,7 +744,7 @@ getOsAccountLocalIdFromUid(uid: number, callback: AsyncCallback<number>): **示例:**查询值为12345678的uid所属的系统帐号的帐号ID - ``` + ```js const accountManager = account_osAccount.getAccountManager(); let uid = 12345678; accountManager.getOsAccountLocalIdFromUid(uid, (err, accountID) => { @@ -775,7 +775,7 @@ getOsAccountLocalIdFromUid(uid: number): Promise<number> **示例:**查询值为12345678的uid所属的系统帐号的帐号ID - ``` + ```js const accountManager = account_osAccount.getAccountManager(); let uid = 12345678; accountManager.getOsAccountLocalIdFromUid(uid).then((accountID) => { @@ -804,7 +804,7 @@ getOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo, callback: AsyncCall **示例:** - ``` + ```js var domainInfo = {domain: "testDomain", accountName: "testAccountName"}; const accountManager = account_osAccount.getAccountManager(); accountManager.getOsAccountLocalIdFromDomain(domainInfo, (err, accountID) => { @@ -837,7 +837,7 @@ getOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo): Promise<number& **示例:** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var domainInfo = {domain: "testDomain", accountName: "testAccountName"}; accountManager.getOsAccountLocalIdFromDomain(domainInfo).then((accountID) => { @@ -865,7 +865,7 @@ queryMaxOsAccountNumber(callback: AsyncCallback<number>): void **示例:** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.queryMaxOsAccountNumber((err, maxCnt)=>{ console.log("queryMaxOsAccountNumber err:" + JSON.stringify(err)); @@ -891,7 +891,7 @@ queryMaxOsAccountNumber(): Promise<number> **示例:** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.queryMaxOsAccountNumber().then((maxCnt) => { console.log('queryMaxOsAccountNumber, maxCnt: ' + maxCnt); @@ -919,7 +919,7 @@ getOsAccountAllConstraints(localId: number, callback: AsyncCallback<Array< **示例:**获取ID为100的系统帐号的全部约束 - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var localId = 100; accountManager.getOsAccountAllConstraints(localId, (err, constraints)=>{ @@ -952,7 +952,7 @@ getOsAccountAllConstraints(localId: number): Promise<Array<string>> **示例:**获取ID为100的系统帐号的全部约束 - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var localId = 100; accountManager.getOsAccountAllConstraints(localId).then((constraints) => { @@ -980,7 +980,7 @@ queryAllCreatedOsAccounts(callback: AsyncCallback<Array<OsAccountInfo>& **示例:** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.queryAllCreatedOsAccounts((err, accountArr)=>{ console.log("queryAllCreatedOsAccounts err:" + JSON.stringify(err)); @@ -1006,7 +1006,7 @@ queryAllCreatedOsAccounts(): Promise<Array<OsAccountInfo>> **示例:** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.queryAllCreatedOsAccounts().then((accountArr) => { console.log('queryAllCreatedOsAccounts, accountArr: ' + JSON.stringify(accountArr)); @@ -1031,7 +1031,7 @@ queryActivatedOsAccountIds(callback: AsyncCallback<Array<number>>): **示例:** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.queryActivatedOsAccountIds((err, idArray)=>{ console.log("queryActivatedOsAccountIds err:" + JSON.stringify(err)); @@ -1058,7 +1058,7 @@ queryActivatedOsAccountIds(): Promise<Array<number>> **示例:** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.queryActivatedOsAccountIds().then((idArray) => { console.log('queryActivatedOsAccountIds, idArray: ' + idArray); @@ -1089,7 +1089,7 @@ createOsAccount(localName: string, type: OsAccountType, callback: AsyncCallback& **示例:** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.createOsAccount("testName", osaccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{ console.log("createOsAccount err:" + JSON.stringify(err)); @@ -1124,7 +1124,7 @@ createOsAccount(localName: string, type: OsAccountType): Promise<OsAccountInf **示例:** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.createOsAccount("testAccountName", osaccount.OsAccountType.NORMAL).then((accountInfo) => { console.log("createOsAccount, accountInfo: " + JSON.stringify(accountInfo)); @@ -1155,7 +1155,7 @@ createOsAccountForDomain(type: OsAccountType, domainInfo: DomainAccountInfo, cal **示例:** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var domainInfo = {domain: "testDomain", accountName: "testAccountName"}; accountManager.createOsAccountForDomain(osaccount.OsAccountType.NORMAL, domainInfo, (err, osAccountInfo)=>{ @@ -1191,7 +1191,7 @@ createOsAccountForDomain(type: OsAccountType, domainInfo: DomainAccountInfo): Pr **示例:** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var domainInfo = {domain: "testDomain", accountName: "testAccountName"}; accountManager.createOsAccountForDomain(osaccount.OsAccountType.NORMAL, domainInfo).then((accountInfo) => { @@ -1219,7 +1219,7 @@ queryCurrentOsAccount(callback: AsyncCallback<OsAccountInfo>): void **示例:** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.queryCurrentOsAccount((err, curAccountInfo)=>{ console.log("queryCurrentOsAccount err:" + JSON.stringify(err)); @@ -1245,7 +1245,7 @@ queryCurrentOsAccount(): Promise<OsAccountInfo> **示例:** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.queryCurrentOsAccount().then((accountInfo) => { console.log("queryCurrentOsAccount, accountInfo: " + JSON.stringify(accountInfo)); @@ -1275,7 +1275,7 @@ queryOsAccountById(localId: number, callback: AsyncCallback<OsAccountInfo> **示例:**查询ID为100的系统帐号信息 - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var localId = 100; accountManager.queryOsAccountById(localId, (err, accountInfo)=>{ @@ -1310,7 +1310,7 @@ queryOsAccountById(localId: number): Promise<OsAccountInfo> **示例:**查询ID为100的系统帐号信息 - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var localId = 100; accountManager.queryOsAccountById(localId).then((accountInfo) => { @@ -1336,7 +1336,7 @@ getOsAccountTypeFromProcess(callback: AsyncCallback<OsAccountType>): void **示例:** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.getOsAccountTypeFromProcess((err, accountType) => { console.log("getOsAccountTypeFromProcess err: " + JSON.stringify(err)); @@ -1360,7 +1360,7 @@ getOsAccountTypeFromProcess(): Promise<OsAccountType> **示例:** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.getOsAccountTypeFromProcess().then((accountType) => { console.log('getOsAccountTypeFromProcess, accountType: ' + accountType); @@ -1387,7 +1387,7 @@ getDistributedVirtualDeviceId(callback: AsyncCallback<string>): void **示例:** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.getDistributedVirtualDeviceId((err, virtualID) => { console.log("getDistributedVirtualDeviceId err: " + JSON.stringify(err)); @@ -1413,7 +1413,7 @@ getDistributedVirtualDeviceId(): Promise<string> **示例:** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); accountManager.getDistributedVirtualDeviceId().then((virtualID) => { console.log('getDistributedVirtualDeviceId, virtualID: ' + virtualID); @@ -1443,7 +1443,7 @@ getOsAccountProfilePhoto(localId: number, callback: AsyncCallback<string>) **示例:**获取ID为100的系统帐号的头像 - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var localId = 100; accountManager.getOsAccountProfilePhoto(localId, (err, photo)=>{ @@ -1478,7 +1478,7 @@ getOsAccountProfilePhoto(localId: number): Promise<string> **示例:**获取ID为100的系统帐号的头像 - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var localId = 100; accountManager.getOsAccountProfilePhoto(localId).then((photo) => { @@ -1510,7 +1510,7 @@ setOsAccountProfilePhoto(localId: number, photo: string, callback: AsyncCallback **示例:**给ID为100的系统帐号设置头像 - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var localId = 100; var photo = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAPCAYAAAA/I0V3AAAAAXNSR0IArs4c6QAAAARnQU1BAA"+ @@ -1549,7 +1549,7 @@ setOsAccountProfilePhoto(localId: number, photo: string): Promise<void> **示例:**给ID为100的系统帐号设置头像 - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var localId = 100; var photo = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAPCAYAAAA/I0V3AAAAAXNSR0IArs4c6QAAAARnQU1BAA"+ @@ -1580,7 +1580,7 @@ getOsAccountLocalIdBySerialNumber(serialNumber: number, callback: AsyncCallback& **示例:**查询与SN码12345关联的系统帐号的ID - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var serialNumber = 12345; accountManager.getOsAccountLocalIdBySerialNumber(serialNumber, (err, localId)=>{ @@ -1611,7 +1611,7 @@ getOsAccountLocalIdBySerialNumber(serialNumber: number): Promise<number> **示例:**查询与SN码12345关联的系统帐号的ID - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var serialNumber = 12345; accountManager.getOsAccountLocalIdBySerialNumber(serialNumber).then((localId) => { @@ -1638,7 +1638,7 @@ getSerialNumberByOsAccountLocalId(localId: number, callback: AsyncCallback<nu **示例:**获取ID为100的系统帐号关联的SN码 - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var localId = 100; accountManager.getSerialNumberByOsAccountLocalId(localId, (err, serialNumber)=>{ @@ -1669,7 +1669,7 @@ getSerialNumberByOsAccountLocalId(localId: number): Promise<number> **示例:**获取ID为100的系统帐号关联的SN码 - ``` + ```js const accountManager = account_osAccount.getAccountManager(); var localId = 100; accountManager.getSerialNumberByOsAccountLocalId(localId).then((serialNumber) => { @@ -1701,7 +1701,7 @@ on(type: 'activate' | 'activating', name: string, callback: Callback<number&g **示例:** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); function onCallback(receiveLocalId){ console.log("receive localId:" + receiveLocalId); @@ -1731,7 +1731,7 @@ off(type: 'activate' | 'activating', name: string, callback?: Callback<number **示例:** - ``` + ```js const accountManager = account_osAccount.getAccountManager(); function offCallback(){ console.log("off enter") -- GitLab