diff --git a/zh-cn/application-dev/reference/apis/js-apis-data-cloudData.md b/zh-cn/application-dev/reference/apis/js-apis-data-cloudData.md index 63fcfad2ef7bad189ef6b6e0c5c10a955c581e04..aef40603dd57f51c6f545423c3f2e2fb79761d6a 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-data-cloudData.md +++ b/zh-cn/application-dev/reference/apis/js-apis-data-cloudData.md @@ -37,6 +37,12 @@ static enableCloud(accountId: string, switches: {[bundleName: string]: boolean}, 打开端云ååŒï¼Œä½¿ç”¨callback异æ¥å›žè°ƒã€‚ +使用规则: + +- 调用方应用ä½äºŽåŽå°æ—¶ï¼Œä½¿ç”¨è¯¥æŽ¥å£è®¿é—®DataShareExtension需申请`ohos.permission.CLOUDDATA_CONFIG`æƒé™ã€‚ + +**系统接å£ï¼š** æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + **系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config **å‚数:** @@ -53,7 +59,7 @@ static enableCloud(accountId: string, switches: {[bundleName: string]: boolean}, let account = "test_id"; let switches = { "test_bundleName1": true, "test_bundleName2": false }; try { - await ddm.Config.enableCloud(account, function (err, data) { + await ddm.Config.enableCloud(account, switches, function (err, data) { if (err == undefined) { console.info('Succeeding in enabling cloud'); } else { @@ -71,6 +77,12 @@ static enableCloud(accountId: string, switches: {[bundleName: string]: boolean}) 打开端云ååŒï¼Œä½¿ç”¨Promise异æ¥å›žè°ƒã€‚ +使用规则: + +- 调用方应用ä½äºŽåŽå°æ—¶ï¼Œä½¿ç”¨è¯¥æŽ¥å£è®¿é—®DataShareExtension需申请`ohos.permission.CLOUDDATA_CONFIG`æƒé™ã€‚ + +**系统接å£ï¼š** æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + **系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config **å‚数:** @@ -92,7 +104,7 @@ static enableCloud(accountId: string, switches: {[bundleName: string]: boolean}) let account = "test_id"; let switches = { "test_bundleName1": true, "test_bundleName2": false }; try { - await ddm.Config.enableCloud(account).then((data) => { + await ddm.Config.enableCloud(account, switches).then((data) => { console.info('Succeeding in enabling cloud'); }).catch((error) => { console.error('Failed to enable' + `, error code is ${error.code}, message is $ { error.message }`); @@ -108,6 +120,12 @@ static disableCloud(accountId: string, callback: AsyncCallback<void>):void å…³é—端云ååŒï¼Œä½¿ç”¨callback异æ¥å›žè°ƒã€‚ +使用规则: + +- 调用方应用ä½äºŽåŽå°æ—¶ï¼Œä½¿ç”¨è¯¥æŽ¥å£è®¿é—®DataShareExtension需申请`ohos.permission.CLOUDDATA_CONFIG`æƒé™ã€‚ + +**系统接å£ï¼š** æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + **系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config **å‚数:** @@ -140,6 +158,12 @@ static disableCloud(accountId: string): Promise<void> å…³é—端云ååŒï¼Œä½¿ç”¨Promise异æ¥å›žè°ƒã€‚ +使用规则: + +- 调用方应用ä½äºŽåŽå°æ—¶ï¼Œä½¿ç”¨è¯¥æŽ¥å£è®¿é—®DataShareExtension需申请`ohos.permission.CLOUDDATA_CONFIG`æƒé™ã€‚ + +**系统接å£ï¼š** æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + **系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config **å‚数:** @@ -176,6 +200,12 @@ static changeAppCloudSwitch(accountId: string,bundleName:string,status:boolean, 修改å•ä¸ªåº”用端云ååŒå¼€å…³ï¼Œä½¿ç”¨callback异æ¥å›žè°ƒã€‚ +使用规则: + +- 调用方应用ä½äºŽåŽå°æ—¶ï¼Œä½¿ç”¨è¯¥æŽ¥å£è®¿é—®DataShareExtension需申请`ohos.permission.CLOUDDATA_CONFIG`æƒé™ã€‚ + +**系统接å£ï¼š** æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + **系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config **å‚数:** @@ -211,6 +241,12 @@ static changeAppCloudSwitch(accountId: string,bundleName:string,status:boolean): 修改å•ä¸ªåº”用端云ååŒå¼€å…³ï¼Œä½¿ç”¨Promise异æ¥å›žè°ƒã€‚ +使用规则: + +- 调用方应用ä½äºŽåŽå°æ—¶ï¼Œä½¿ç”¨è¯¥æŽ¥å£è®¿é—®DataShareExtension需申请`ohos.permission.CLOUDDATA_CONFIG`æƒé™ã€‚ + +**系统接å£ï¼š** æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + **系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config **å‚数:** @@ -243,85 +279,18 @@ try { } ``` -### clean - -static clean(accountId: string, appActions: {[bundleName: string]: Action}, callback: AsyncCallback<void>):void - -清除本地数æ®ä¸äº‘ä¿¡æ¯ï¼Œä½¿ç”¨callback异æ¥å›žè°ƒã€‚ - -**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config - -**å‚数:** - -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| ---------- | ----------------------------------------- | ---- | -------------------- | -| accountId | string | 是 | 具体打开的云ID。 | -| appActions | {[bundleName: string]: [Action](#Action)} | 是 | è¦æ¸…除数æ®çš„åº”ç”¨ä¿¡æ¯ | -| callback | AsyncCallback<void> | 是 | 回调函数。 | - -**示例:** - -```js -let con = ddm.Action; -let account = "test_id"; -let appActions = { "test_bundleName1": con.CLEAR_CLOUD_INFO, "test_bundleName2": con.CLEAR_CLOUD_DATA_AND_INFO } -try { - await ddm.Config.clean(account, appActions, function (err, data) { - if (err == undefined) { - console.info('Succeeding in cleaning cloud data'); - } else { - console.error('Failed to clean' + `, error code is ${err.code}, message is ${err.message}`); - } - }); -} catch (e) { - console.error('An unexpected error occurred.' + `, error code is ${e.code}, message is ${e.message}`); -} -``` - -### clean - -static clean(accountId: string, appActions: {[bundleName: string]: Action}): Promise<void> - -清除本地数æ®ä¸äº‘ä¿¡æ¯ï¼Œä½¿ç”¨Promise异æ¥å›žè°ƒã€‚ - -**系统能力:** SystemCapability.DistributedDataManager.CloudSync.Config - -**å‚数:** - -| å‚æ•°å | 类型 | å¿…å¡« | 说明 | -| ---------- | ----------------------------------------- | ---- | -------------------- | -| accountId | string | 是 | 具体打开的云ID。 | -| appActions | {[bundleName: string]: [Action](#Action)} | 是 | è¦æ¸…除数æ®çš„åº”ç”¨ä¿¡æ¯ | - -**返回值:** - -| 类型 | 说明 | -| ------------------- | ------------------------- | -| Promise<void> | æ— è¿”å›žç»“æžœçš„Promise对象。 | - -**示例:** - -```js -let con = ddm.Action; -let account = "test_id"; -let appActions = { "test_bundleName1": con.CLEAR_CLOUD_INFO, "test_bundleName2": con.CLEAR_CLOUD_DATA_AND_INFO } -try { - await ddm.Config.clean(account, appActions).then((data) => { - console.info('Succeeding in cleaning cloud data'); - }).catch((error) => { - console.error('Failed to clean' + `, error code is ${error.code}, message is ${error.message}`); - }); -} catch (e) { - console.error('An unexpected error occurred.' + `, error code is ${e.code}, message is ${e.message}`); -} -``` - ### notifyDataChange static notifyDataChange(accountId: string,bundleName:string, callback: AsyncCallback<void>):void 通知云端的数æ®å˜æ›´ï¼Œä½¿ç”¨callback异æ¥å›žè°ƒã€‚ +使用规则: + +- 调用方应用ä½äºŽåŽå°æ—¶ï¼Œä½¿ç”¨è¯¥æŽ¥å£è®¿é—®DataShareExtension需申请`ohos.permission.CLOUDDATA_CONFIG`æƒé™ã€‚ + +**系统接å£ï¼š** æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + **系统能力:** SystemCapability.DistributedDataManager.CloudSync.Server **å‚数:** @@ -356,6 +325,12 @@ static notifyDataChange(accountId: string,bundleName:string): Promise<void> 通知云端的数æ®å˜æ›´ï¼Œä½¿ç”¨Promise异æ¥å›žè°ƒã€‚ +使用规则: + +- 调用方应用ä½äºŽåŽå°æ—¶ï¼Œä½¿ç”¨è¯¥æŽ¥å£è®¿é—®DataShareExtension需申请`ohos.permission.CLOUDDATA_CONFIG`æƒé™ã€‚ + +**系统接å£ï¼š** æ¤æŽ¥å£ä¸ºç³»ç»ŸæŽ¥å£ã€‚ + **系统能力:** SystemCapability.DistributedDataManager.CloudSync.Server **å‚数:**