提交 f30e5464 编写于 作者: Y ylq121

xiugai

Signed-off-by: Nylq121 <yangqing89@huawei.com>
上级 c7d39c68
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
## 导入模块 ## 导入模块
```js ```js
import ddm from '@ohos.data.cloudData'; import cloudData from '@ohos.data.cloudData';
``` ```
## Action ## Action
...@@ -39,21 +39,19 @@ static enableCloud(accountId: string, switches: {[bundleName: string]: boolean}, ...@@ -39,21 +39,19 @@ static enableCloud(accountId: string, switches: {[bundleName: string]: boolean},
打开端云协同,使用callback异步回调。 打开端云协同,使用callback异步回调。
使用规则:
- 调用方应用位于后台时,使用该接口访问DataShareExtension需申请`ohos.permission.CLOUDDATA_CONFIG`权限。
**系统接口:** 此接口为系统接口。 **系统接口:** 此接口为系统接口。
**需要权限**:ohos.permission.CLOUDDATA_CONFIG
**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config **系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| --------- | ------------------------------- | ---- | -------------------------- | | --------- | ------------------------------- | ---- | ------------------------------------------------------------ |
| accountId | string | 是 | 具体打开的云ID。 | | accountId | string | 是 | 具体打开的云ID。 |
| switches | {[bundleName: string]: boolean} | 是 | 各应用的端云协同开关信息。 | | switches | {[bundleName: string]: boolean} | 是 | 各应用的端云协同开关信息,true为打开该应用端云开关,false为关闭该应用端云开关。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。 | | callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。 |
**示例:** **示例:**
...@@ -61,15 +59,15 @@ static enableCloud(accountId: string, switches: {[bundleName: string]: boolean}, ...@@ -61,15 +59,15 @@ static enableCloud(accountId: string, switches: {[bundleName: string]: boolean},
let account = "test_id"; let account = "test_id";
let switches = { "test_bundleName1": true, "test_bundleName2": false }; let switches = { "test_bundleName1": true, "test_bundleName2": false };
try { try {
await ddm.Config.enableCloud(account, switches, function (err, data) { cloudData.Config.enableCloud(account, switches, function (err) {
if (err == undefined) { if (err === undefined) {
console.info('Succeeding in enabling cloud'); console.info('Succeeded in enabling cloud');
} else { } else {
console.error('Failed to enable' + `, error code is ${err.code}, message is $ { err.message }`); console.error('Failed to enable.' + `Code: ${err.code}, message: ${ err.message }`);
} }
}); });
} catch (e) { } catch (error) {
console.error('An unexpected error occurred' + `, error code is ${e.code}, message is $ { e.message }`); console.error('An unexpected error occurred.' + `Code: ${error.code}, message: ${ error.message }`);
} }
``` ```
...@@ -79,20 +77,18 @@ static enableCloud(accountId: string, switches: {[bundleName: string]: boolean}) ...@@ -79,20 +77,18 @@ static enableCloud(accountId: string, switches: {[bundleName: string]: boolean})
打开端云协同,使用Promise异步回调。 打开端云协同,使用Promise异步回调。
使用规则:
- 调用方应用位于后台时,使用该接口访问DataShareExtension需申请`ohos.permission.CLOUDDATA_CONFIG`权限。
**系统接口:** 此接口为系统接口。 **系统接口:** 此接口为系统接口。
**需要权限**:ohos.permission.CLOUDDATA_CONFIG
**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config **系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config
**参数:** **参数:**
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| --------- | ------------------------------- | ---- | -------------------------- | | --------- | ------------------------------- | ---- | ------------------------------------------------------------ |
| accountId | string | 是 | 具体打开的云ID。 | | accountId | string | 是 | 具体打开的云ID。 |
| switches | {[bundleName: string]: boolean} | 是 | 各应用的端云协同开关信息。 | | switches | {[bundleName: string]: boolean} | 是 | 各应用的端云协同开关信息,true为打开该应用端云开关,false为关闭该应用端云开关。 |
**返回值:** **返回值:**
...@@ -106,13 +102,13 @@ static enableCloud(accountId: string, switches: {[bundleName: string]: boolean}) ...@@ -106,13 +102,13 @@ static enableCloud(accountId: string, switches: {[bundleName: string]: boolean})
let account = "test_id"; let account = "test_id";
let switches = { "test_bundleName1": true, "test_bundleName2": false }; let switches = { "test_bundleName1": true, "test_bundleName2": false };
try { try {
await ddm.Config.enableCloud(account, switches).then((data) => { cloudData.Config.enableCloud(account, switches).then(() => {
console.info('Succeeding in enabling cloud'); console.info('Succeeded in enabling cloud');
}).catch((error) => { }).catch((err) => {
console.error('Failed to enable' + `, error code is ${error.code}, message is $ { error.message }`); console.error('Failed to enable.' + `Code: ${err.code}, message: ${ err.message }`);
}); });
} catch (e) { } catch (error) {
console.error('An unexpected error occurred' + `, error code is ${e.code}, message is $ { e.message }`); console.error(`An unexpected error occurred. Code: ${error.code}, message: ${ error.message }`);
} }
``` ```
...@@ -122,12 +118,10 @@ static disableCloud(accountId: string, callback: AsyncCallback&lt;void&gt;):void ...@@ -122,12 +118,10 @@ static disableCloud(accountId: string, callback: AsyncCallback&lt;void&gt;):void
关闭端云协同,使用callback异步回调。 关闭端云协同,使用callback异步回调。
使用规则:
- 调用方应用位于后台时,使用该接口访问DataShareExtension需申请`ohos.permission.CLOUDDATA_CONFIG`权限。
**系统接口:** 此接口为系统接口。 **系统接口:** 此接口为系统接口。
**需要权限**:ohos.permission.CLOUDDATA_CONFIG
**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config **系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config
**参数:** **参数:**
...@@ -142,15 +136,15 @@ static disableCloud(accountId: string, callback: AsyncCallback&lt;void&gt;):void ...@@ -142,15 +136,15 @@ static disableCloud(accountId: string, callback: AsyncCallback&lt;void&gt;):void
```js ```js
let account = "test_id"; let account = "test_id";
try { try {
await ddm.Config.disableCloud(account, function (err, data) { cloudData.Config.disableCloud(account, function (err) {
if (err == undefined) { if (err === undefined) {
console.info('Succeeding in disabling cloud'); console.info('Succeeded in disabling cloud');
} else { } else {
console.error('Failed to disableCloud' + `, error code is ${err.code}, message is ${err.message}`); console.error('Failed to disableCloud.' + `Code: ${err.code}, message: ${err.message}`);
} }
}); });
} catch (e) { } catch (error) {
console.error('An unexpected error occurred' + `, error code is ${e.code}, message is ${e.message}`); console.error(`An unexpected error occurred. Code: ${error.code}, message: ${error.message}`);
} }
``` ```
...@@ -160,12 +154,10 @@ static disableCloud(accountId: string): Promise&lt;void&gt; ...@@ -160,12 +154,10 @@ static disableCloud(accountId: string): Promise&lt;void&gt;
关闭端云协同,使用Promise异步回调。 关闭端云协同,使用Promise异步回调。
使用规则:
- 调用方应用位于后台时,使用该接口访问DataShareExtension需申请`ohos.permission.CLOUDDATA_CONFIG`权限。
**系统接口:** 此接口为系统接口。 **系统接口:** 此接口为系统接口。
**需要权限**:ohos.permission.CLOUDDATA_CONFIG
**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config **系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config
**参数:** **参数:**
...@@ -186,13 +178,13 @@ static disableCloud(accountId: string): Promise&lt;void&gt; ...@@ -186,13 +178,13 @@ static disableCloud(accountId: string): Promise&lt;void&gt;
let account = "test_id"; let account = "test_id";
let switches = { "test_bundleName1": true, "test_bundleName2": false }; let switches = { "test_bundleName1": true, "test_bundleName2": false };
try { try {
await ddm.Config.disableCloud(account).then((data) => { cloudData.Config.disableCloud(account).then(() => {
console.info('Succeeding in disabling cloud'); console.info('Succeeded in disabling cloud');
}).catch((error) => { }).catch((err) => {
console.error('Failed to disableCloud' + `, error code is ${error.code}, message is ${error.message}`); console.error('Failed to disableCloud.' + `Code: ${err.code}, message: ${err.message}`);
}); });
} catch (e) { } catch (error) {
console.error('An unexpected error occurred' + `, error code is ${e.code}, message is ${e.message}`); console.error(`An unexpected error occurred. Code: ${error.code}, message: ${ error.message }`);
} }
``` ```
...@@ -202,12 +194,10 @@ static changeAppCloudSwitch(accountId: string,bundleName:string,status:boolean, ...@@ -202,12 +194,10 @@ static changeAppCloudSwitch(accountId: string,bundleName:string,status:boolean,
修改单个应用端云协同开关,使用callback异步回调。 修改单个应用端云协同开关,使用callback异步回调。
使用规则:
- 调用方应用位于后台时,使用该接口访问DataShareExtension需申请`ohos.permission.CLOUDDATA_CONFIG`权限。
**系统接口:** 此接口为系统接口。 **系统接口:** 此接口为系统接口。
**需要权限**:ohos.permission.CLOUDDATA_CONFIG
**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config **系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config
**参数:** **参数:**
...@@ -216,7 +206,7 @@ static changeAppCloudSwitch(accountId: string,bundleName:string,status:boolean, ...@@ -216,7 +206,7 @@ static changeAppCloudSwitch(accountId: string,bundleName:string,status:boolean,
| --------- | ------------------------------- | ---- | ---------------------------- | | --------- | ------------------------------- | ---- | ---------------------------- |
| accountId | string | 是 | 具体打开的云ID。 | | accountId | string | 是 | 具体打开的云ID。 |
| bundleName| string | 是 | 应用名 | | bundleName| string | 是 | 应用名 |
| status | boolean | 是 | 应用的端云协同开关状态信息。 | | status | boolean | 是 | 应用的端云协同开关信息,true为打开该应用端云开关,false为关闭该应用端云开关。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。 | | callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。 |
**示例:** **示例:**
...@@ -225,15 +215,15 @@ static changeAppCloudSwitch(accountId: string,bundleName:string,status:boolean, ...@@ -225,15 +215,15 @@ static changeAppCloudSwitch(accountId: string,bundleName:string,status:boolean,
let account = "test_id"; let account = "test_id";
let bundleName = "test_bundleName"; let bundleName = "test_bundleName";
try { try {
await ddm.Config.changeAppCloudSwitch(account, bundleName, true, function (err, data) { cloudData.Config.changeAppCloudSwitch(account, bundleName, true, function (err) {
if (err == undefined) { if (err === undefined) {
console.info('Succeeding in changing App cloud switch'); console.info('Succeeded in changing App cloud switch');
} else { } else {
console.error('Failed to change App cloud switch' + `, error code is ${err.code}, message is ${err.message}`); console.error('Failed to change App cloud switch.' + `Code: ${err.code}, message: ${err.message}`);
} }
}); });
} catch (e) { } catch (error) {
console.error('An unexpected error occurred' + `, error code is ${e.code}, message is ${e.message}`); console.error(`An unexpected error occurred. Code: ${error.code}, message: ${ error.message }`);
} }
``` ```
...@@ -243,12 +233,10 @@ static changeAppCloudSwitch(accountId: string,bundleName:string,status:boolean): ...@@ -243,12 +233,10 @@ static changeAppCloudSwitch(accountId: string,bundleName:string,status:boolean):
修改单个应用端云协同开关,使用Promise异步回调。 修改单个应用端云协同开关,使用Promise异步回调。
使用规则:
- 调用方应用位于后台时,使用该接口访问DataShareExtension需申请`ohos.permission.CLOUDDATA_CONFIG`权限。
**系统接口:** 此接口为系统接口。 **系统接口:** 此接口为系统接口。
**需要权限**:ohos.permission.CLOUDDATA_CONFIG
**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config **系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config
**参数:** **参数:**
...@@ -257,7 +245,7 @@ static changeAppCloudSwitch(accountId: string,bundleName:string,status:boolean): ...@@ -257,7 +245,7 @@ static changeAppCloudSwitch(accountId: string,bundleName:string,status:boolean):
| --------- | ------------------------------- | ---- | ---------------------------- | | --------- | ------------------------------- | ---- | ---------------------------- |
| accountId | string | 是 | 具体打开的云ID。 | | accountId | string | 是 | 具体打开的云ID。 |
| bundleName| string | 是 | 应用名 | | bundleName| string | 是 | 应用名 |
| status | boolean | 是 | 应用的端云协同开关状态信息。 | | status | boolean | 是 | 应用的端云协同开关信息,true为打开该应用端云开关,false为关闭该应用端云开关。 |
**返回值:** **返回值:**
...@@ -271,13 +259,13 @@ static changeAppCloudSwitch(accountId: string,bundleName:string,status:boolean): ...@@ -271,13 +259,13 @@ static changeAppCloudSwitch(accountId: string,bundleName:string,status:boolean):
let account = "test_id"; let account = "test_id";
let bundleName = "test_bundleName"; let bundleName = "test_bundleName";
try { try {
await ddm.Config.changeAppCloudSwitch(account, bundleName, true).then((data) => { cloudData.Config.changeAppCloudSwitch(account, bundleName, true).then(() => {
console.info('Succeeding in changing App cloud switch'); console.info('Succeeded in changing App cloud switch');
}).catch((error) => { }).catch((err) => {
console.error('Failed to change App cloud switch' + `, error code is ${error.code}, message is ${error.message}`); console.error('Failed to change App cloud switch.' + `Code is ${err.code}, message is ${err.message}`);
}); });
} catch (e) { } catch (error) {
console.error('An unexpected error occurred' + `, error code is ${e.code}, message is ${e.message}`); console.error(`An unexpected error occurred. Code: ${error.code}, message: ${ error.message }`);
} }
``` ```
...@@ -287,12 +275,10 @@ static notifyDataChange(accountId: string,bundleName:string, callback: AsyncCall ...@@ -287,12 +275,10 @@ static notifyDataChange(accountId: string,bundleName:string, callback: AsyncCall
通知云端的数据变更,使用callback异步回调。 通知云端的数据变更,使用callback异步回调。
使用规则:
- 调用方应用位于后台时,使用该接口访问DataShareExtension需申请`ohos.permission.CLOUDDATA_CONFIG`权限。
**系统接口:** 此接口为系统接口。 **系统接口:** 此接口为系统接口。
**需要权限**:ohos.permission.CLOUDDATA_CONFIG
**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Server **系统能力:** SystemCapability.DistributedDataManager.CloudSync.Server
**参数:** **参数:**
...@@ -309,15 +295,15 @@ static notifyDataChange(accountId: string,bundleName:string, callback: AsyncCall ...@@ -309,15 +295,15 @@ static notifyDataChange(accountId: string,bundleName:string, callback: AsyncCall
let account = "test_id"; let account = "test_id";
let bundleName = "test_bundleName"; let bundleName = "test_bundleName";
try { try {
await ddm.Config.notifyDataChange(account, bundleName, function (err, data) { cloudData.Config.notifyDataChange(account, bundleName, function (err) {
if (err == undefined) { if (err === undefined) {
console.info('Succeeding in notifying the change of data'); console.info('Succeeded in notifying the change of data');
} else { } else {
console.error('Failed to notify the change of data' + `, error code is ${err.code}, message is ${err.message}`); console.error('Failed to notify the change of data.' + `Code: ${err.code}, message: ${err.message}`);
} }
}); });
} catch (e) { } catch (error) {
console.error('An unexpected error occurred.' + `, error code is ${e.code}, message is ${e.message}`); console.error(`An unexpected error occurred. Code: ${error.code}, message: ${ error.message }`);
} }
``` ```
...@@ -327,12 +313,10 @@ static notifyDataChange(accountId: string,bundleName:string): Promise&lt;void&gt ...@@ -327,12 +313,10 @@ static notifyDataChange(accountId: string,bundleName:string): Promise&lt;void&gt
通知云端的数据变更,使用Promise异步回调。 通知云端的数据变更,使用Promise异步回调。
使用规则:
- 调用方应用位于后台时,使用该接口访问DataShareExtension需申请`ohos.permission.CLOUDDATA_CONFIG`权限。
**系统接口:** 此接口为系统接口。 **系统接口:** 此接口为系统接口。
**需要权限**:ohos.permission.CLOUDDATA_CONFIG
**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Server **系统能力:** SystemCapability.DistributedDataManager.CloudSync.Server
**参数:** **参数:**
...@@ -354,13 +338,13 @@ static notifyDataChange(accountId: string,bundleName:string): Promise&lt;void&gt ...@@ -354,13 +338,13 @@ static notifyDataChange(accountId: string,bundleName:string): Promise&lt;void&gt
let account = "test_id"; let account = "test_id";
let bundleName = "test_bundleName"; let bundleName = "test_bundleName";
try { try {
await ddm.Config.notifyDataChange(account, bundleName).then((data) => { cloudData.Config.notifyDataChange(account, bundleName).then(() => {
console.info('Succeeding in notifying the change of data'); console.info('Succeeded in notifying the change of data');
}).catch((error) => { }).catch((err) => {
console.error('Failed to notify the change of data' + `, error code is ${error.code}, message is ${error.message}`); console.error('Failed to notify the change of data.' + `Code: ${err.code}, message: ${err.message}`);
}); });
} catch (e) { } catch (error) {
console.error('An unexpected error occurred.' + `, error code is ${e.code}, message is ${e.message}`); console.error(`An unexpected error occurred. Code: ${error.code}, message: ${ error.message }`);
} }
``` ```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册