Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
f30e5464
D
Docs
项目概览
OpenHarmony
/
Docs
大约 2 年 前同步成功
通知
161
Star
293
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
f30e5464
编写于
5月 25, 2023
作者:
Y
ylq121
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
xiugai
Signed-off-by:
N
ylq121
<
yangqing89@huawei.com
>
上级
c7d39c68
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
76 addition
and
92 deletion
+76
-92
zh-cn/application-dev/reference/apis/js-apis-data-cloudData.md
.../application-dev/reference/apis/js-apis-data-cloudData.md
+76
-92
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-data-cloudData.md
浏览文件 @
f30e5464
...
...
@@ -13,7 +13,7 @@
## 导入模块
```
js
import
ddm
from
'
@ohos.data.cloudData
'
;
import
cloudData
from
'
@ohos.data.cloudData
'
;
```
## Action
...
...
@@ -39,20 +39,18 @@ static enableCloud(accountId: string, switches: {[bundleName: string]: boolean},
打开端云协同,使用callback异步回调。
使用规则:
-
调用方应用位于后台时,使用该接口访问DataShareExtension需申请
`ohos.permission.CLOUDDATA_CONFIG`
权限。
**系统接口:**
此接口为系统接口。
**需要权限**
:ohos.permission.CLOUDDATA_CONFIG
**系统能力:**
SystemCapability.DistributedDataManager.CloudSync.Config
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| --------- | ------------------------------- | ---- | -------------------------- |
| --------- | ------------------------------- | ---- | --------------------------
----------------------------------
|
| accountId | string | 是 | 具体打开的云ID。 |
| switches | {[bundleName: string]: boolean} | 是 | 各应用的端云协同开关信息。 |
| switches | {[bundleName: string]: boolean} | 是 | 各应用的端云协同开关信息
,true为打开该应用端云开关,false为关闭该应用端云开关
。 |
| callback | AsyncCallback
<
void
>
| 是 | 回调函数。 |
**示例:**
...
...
@@ -61,15 +59,15 @@ 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
,
switches
,
function
(
err
,
data
)
{
if
(
err
==
undefined
)
{
console
.
info
(
'
Succeed
ing
in enabling cloud
'
);
cloudData
.
Config
.
enableCloud
(
account
,
switches
,
function
(
err
)
{
if
(
err
==
=
undefined
)
{
console
.
info
(
'
Succeed
ed
in enabling cloud
'
);
}
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
)
{
console
.
error
(
'
An unexpected error occurred
'
+
`, error code is
${
e
.
code
}
, message is $ { e
.message }`
);
}
catch
(
e
rror
)
{
console
.
error
(
'
An unexpected error occurred
.
'
+
`Code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
}
```
...
...
@@ -79,20 +77,18 @@ static enableCloud(accountId: string, switches: {[bundleName: string]: boolean})
打开端云协同,使用Promise异步回调。
使用规则:
-
调用方应用位于后台时,使用该接口访问DataShareExtension需申请
`ohos.permission.CLOUDDATA_CONFIG`
权限。
**系统接口:**
此接口为系统接口。
**需要权限**
:ohos.permission.CLOUDDATA_CONFIG
**系统能力:**
SystemCapability.DistributedDataManager.CloudSync.Config
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| --------- | ------------------------------- | ---- | -------------------------- |
| --------- | ------------------------------- | ---- | --------------------------
----------------------------------
|
| 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})
let
account
=
"
test_id
"
;
let
switches
=
{
"
test_bundleName1
"
:
true
,
"
test_bundleName2
"
:
false
};
try
{
await
ddm
.
Config
.
enableCloud
(
account
,
switches
).
then
((
data
)
=>
{
console
.
info
(
'
Succeed
ing
in enabling cloud
'
);
}).
catch
((
err
or
)
=>
{
console
.
error
(
'
Failed to enable
'
+
`, error code is
${
error
.
code
}
, message is $ { erro
r.message }`
);
cloudData
.
Config
.
enableCloud
(
account
,
switches
).
then
((
)
=>
{
console
.
info
(
'
Succeed
ed
in enabling cloud
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to enable
.
'
+
`Code:
${
err
.
code
}
, message:
${
er
r
.
message
}
`
);
});
}
catch
(
e
)
{
console
.
error
(
'
An unexpected error occurred
'
+
`, error code is
${
e
.
code
}
, message is $ { e
.message }`
);
}
catch
(
e
rror
)
{
console
.
error
(
`An unexpected error occurred. Code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
}
```
...
...
@@ -122,12 +118,10 @@ static disableCloud(accountId: string, callback: AsyncCallback<void>):void
关闭端云协同,使用callback异步回调。
使用规则:
-
调用方应用位于后台时,使用该接口访问DataShareExtension需申请
`ohos.permission.CLOUDDATA_CONFIG`
权限。
**系统接口:**
此接口为系统接口。
**需要权限**
:ohos.permission.CLOUDDATA_CONFIG
**系统能力:**
SystemCapability.DistributedDataManager.CloudSync.Config
**参数:**
...
...
@@ -142,15 +136,15 @@ static disableCloud(accountId: string, callback: AsyncCallback<void>):void
```
js
let
account
=
"
test_id
"
;
try
{
await
ddm
.
Config
.
disableCloud
(
account
,
function
(
err
,
data
)
{
if
(
err
==
undefined
)
{
console
.
info
(
'
Succeed
ing
in disabling cloud
'
);
cloudData
.
Config
.
disableCloud
(
account
,
function
(
err
)
{
if
(
err
==
=
undefined
)
{
console
.
info
(
'
Succeed
ed
in disabling cloud
'
);
}
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
)
{
console
.
error
(
'
An unexpected error occurred
'
+
`, error code is
${
e
.
code
}
, message is
${
e
.
message
}
`
);
}
catch
(
e
rror
)
{
console
.
error
(
`An unexpected error occurred. Code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
}
```
...
...
@@ -160,12 +154,10 @@ static disableCloud(accountId: string): Promise<void>
关闭端云协同,使用Promise异步回调。
使用规则:
-
调用方应用位于后台时,使用该接口访问DataShareExtension需申请
`ohos.permission.CLOUDDATA_CONFIG`
权限。
**系统接口:**
此接口为系统接口。
**需要权限**
:ohos.permission.CLOUDDATA_CONFIG
**系统能力:**
SystemCapability.DistributedDataManager.CloudSync.Config
**参数:**
...
...
@@ -186,13 +178,13 @@ static disableCloud(accountId: string): Promise<void>
let
account
=
"
test_id
"
;
let
switches
=
{
"
test_bundleName1
"
:
true
,
"
test_bundleName2
"
:
false
};
try
{
await
ddm
.
Config
.
disableCloud
(
account
).
then
((
data
)
=>
{
console
.
info
(
'
Succeed
ing
in disabling cloud
'
);
}).
catch
((
err
or
)
=>
{
console
.
error
(
'
Failed to disableCloud
'
+
`, error code is
${
error
.
code
}
, message is
${
erro
r
.
message
}
`
);
cloudData
.
Config
.
disableCloud
(
account
).
then
((
)
=>
{
console
.
info
(
'
Succeed
ed
in disabling cloud
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to disableCloud
.
'
+
`Code:
${
err
.
code
}
, message:
${
er
r
.
message
}
`
);
});
}
catch
(
e
)
{
console
.
error
(
'
An unexpected error occurred
'
+
`, error code is
${
e
.
code
}
, message is
${
e
.
message
}
`
);
}
catch
(
e
rror
)
{
console
.
error
(
`An unexpected error occurred. Code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
}
```
...
...
@@ -202,12 +194,10 @@ static changeAppCloudSwitch(accountId: string,bundleName:string,status:boolean,
修改单个应用端云协同开关,使用callback异步回调。
使用规则:
-
调用方应用位于后台时,使用该接口访问DataShareExtension需申请
`ohos.permission.CLOUDDATA_CONFIG`
权限。
**系统接口:**
此接口为系统接口。
**需要权限**
:ohos.permission.CLOUDDATA_CONFIG
**系统能力:**
SystemCapability.DistributedDataManager.CloudSync.Config
**参数:**
...
...
@@ -216,7 +206,7 @@ static changeAppCloudSwitch(accountId: string,bundleName:string,status:boolean,
| --------- | ------------------------------- | ---- | ---------------------------- |
| accountId | string | 是 | 具体打开的云ID。 |
| bundleName| string | 是 | 应用名 |
| status | boolean | 是 | 应用的端云协同开关
状态信息
。 |
| status | boolean | 是 | 应用的端云协同开关
信息,true为打开该应用端云开关,false为关闭该应用端云开关
。 |
| callback | AsyncCallback
<
void
>
| 是 | 回调函数。 |
**示例:**
...
...
@@ -225,15 +215,15 @@ static changeAppCloudSwitch(accountId: string,bundleName:string,status:boolean,
let
account
=
"
test_id
"
;
let
bundleName
=
"
test_bundleName
"
;
try
{
await
ddm
.
Config
.
changeAppCloudSwitch
(
account
,
bundleName
,
true
,
function
(
err
,
data
)
{
if
(
err
==
undefined
)
{
console
.
info
(
'
Succeed
ing
in changing App cloud switch
'
);
cloudData
.
Config
.
changeAppCloudSwitch
(
account
,
bundleName
,
true
,
function
(
err
)
{
if
(
err
==
=
undefined
)
{
console
.
info
(
'
Succeed
ed
in changing App cloud switch
'
);
}
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
)
{
console
.
error
(
'
An unexpected error occurred
'
+
`, error code is
${
e
.
code
}
, message is
${
e
.
message
}
`
);
}
catch
(
e
rror
)
{
console
.
error
(
`An unexpected error occurred. Code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
}
```
...
...
@@ -243,12 +233,10 @@ static changeAppCloudSwitch(accountId: string,bundleName:string,status:boolean):
修改单个应用端云协同开关,使用Promise异步回调。
使用规则:
-
调用方应用位于后台时,使用该接口访问DataShareExtension需申请
`ohos.permission.CLOUDDATA_CONFIG`
权限。
**系统接口:**
此接口为系统接口。
**需要权限**
:ohos.permission.CLOUDDATA_CONFIG
**系统能力:**
SystemCapability.DistributedDataManager.CloudSync.Config
**参数:**
...
...
@@ -257,7 +245,7 @@ static changeAppCloudSwitch(accountId: string,bundleName:string,status:boolean):
| --------- | ------------------------------- | ---- | ---------------------------- |
| accountId | string | 是 | 具体打开的云ID。 |
| bundleName| string | 是 | 应用名 |
| status | boolean | 是 | 应用的端云协同开关
状态信息
。 |
| status | boolean | 是 | 应用的端云协同开关
信息,true为打开该应用端云开关,false为关闭该应用端云开关
。 |
**返回值:**
...
...
@@ -271,13 +259,13 @@ static changeAppCloudSwitch(accountId: string,bundleName:string,status:boolean):
let
account
=
"
test_id
"
;
let
bundleName
=
"
test_bundleName
"
;
try
{
await
ddm
.
Config
.
changeAppCloudSwitch
(
account
,
bundleName
,
true
).
then
((
data
)
=>
{
console
.
info
(
'
Succeed
ing
in changing App cloud switch
'
);
}).
catch
((
err
or
)
=>
{
console
.
error
(
'
Failed to change App cloud switch
'
+
`, error code is
${
error
.
code
}
, message is
${
erro
r
.
message
}
`
);
cloudData
.
Config
.
changeAppCloudSwitch
(
account
,
bundleName
,
true
).
then
((
)
=>
{
console
.
info
(
'
Succeed
ed
in changing App cloud switch
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to change App cloud switch
.
'
+
`Code is
${
err
.
code
}
, message is
${
er
r
.
message
}
`
);
});
}
catch
(
e
)
{
console
.
error
(
'
An unexpected error occurred
'
+
`, error code is
${
e
.
code
}
, message is
${
e
.
message
}
`
);
}
catch
(
e
rror
)
{
console
.
error
(
`An unexpected error occurred. Code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
}
```
...
...
@@ -287,12 +275,10 @@ static notifyDataChange(accountId: string,bundleName:string, callback: AsyncCall
通知云端的数据变更,使用callback异步回调。
使用规则:
-
调用方应用位于后台时,使用该接口访问DataShareExtension需申请
`ohos.permission.CLOUDDATA_CONFIG`
权限。
**系统接口:**
此接口为系统接口。
**需要权限**
:ohos.permission.CLOUDDATA_CONFIG
**系统能力:**
SystemCapability.DistributedDataManager.CloudSync.Server
**参数:**
...
...
@@ -309,15 +295,15 @@ static notifyDataChange(accountId: string,bundleName:string, callback: AsyncCall
let
account
=
"
test_id
"
;
let
bundleName
=
"
test_bundleName
"
;
try
{
await
ddm
.
Config
.
notifyDataChange
(
account
,
bundleName
,
function
(
err
,
data
)
{
if
(
err
==
undefined
)
{
console
.
info
(
'
Succeed
ing
in notifying the change of data
'
);
cloudData
.
Config
.
notifyDataChange
(
account
,
bundleName
,
function
(
err
)
{
if
(
err
==
=
undefined
)
{
console
.
info
(
'
Succeed
ed
in notifying the change of data
'
);
}
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
)
{
console
.
error
(
'
An unexpected error occurred.
'
+
`, error code is
${
e
.
code
}
, message is
${
e
.
message
}
`
);
}
catch
(
e
rror
)
{
console
.
error
(
`An unexpected error occurred. Code:
${
error
.
code
}
, message:
${
error
.
message
}
`
);
}
```
...
...
@@ -327,12 +313,10 @@ static notifyDataChange(accountId: string,bundleName:string): Promise<void>
通知云端的数据变更,使用Promise异步回调。
使用规则:
-
调用方应用位于后台时,使用该接口访问DataShareExtension需申请
`ohos.permission.CLOUDDATA_CONFIG`
权限。
**系统接口:**
此接口为系统接口。
**需要权限**
:ohos.permission.CLOUDDATA_CONFIG
**系统能力:**
SystemCapability.DistributedDataManager.CloudSync.Server
**参数:**
...
...
@@ -354,13 +338,13 @@ static notifyDataChange(accountId: string,bundleName:string): Promise<void>
let
account
=
"
test_id
"
;
let
bundleName
=
"
test_bundleName
"
;
try
{
await
ddm
.
Config
.
notifyDataChange
(
account
,
bundleName
).
then
((
data
)
=>
{
console
.
info
(
'
Succeed
ing
in notifying the change of data
'
);
}).
catch
((
err
or
)
=>
{
console
.
error
(
'
Failed to notify the change of data
'
+
`, error code is
${
error
.
code
}
, message is
${
erro
r
.
message
}
`
);
cloudData
.
Config
.
notifyDataChange
(
account
,
bundleName
).
then
((
)
=>
{
console
.
info
(
'
Succeed
ed
in notifying the change of data
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to notify the change of data
.
'
+
`Code:
${
err
.
code
}
, message:
${
er
r
.
message
}
`
);
});
}
catch
(
e
)
{
console
.
error
(
'
An unexpected error occurred.
'
+
`, error code is
${
e
.
code
}
, message is
${
e
.
message
}
`
);
}
catch
(
e
rror
)
{
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录