Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
c133e7d6
D
Docs
项目概览
OpenHarmony
/
Docs
大约 1 年 前同步成功
通知
159
Star
292
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
c133e7d6
编写于
9月 16, 2022
作者:
葛
葛亚芳
提交者:
Gitee
9月 16, 2022
1
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
js-apis-settings.md:自动化测试问题修改
Signed-off-by:
N
葛亚芳
<
geyafang@huawei.com
>
上级
af85432a
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
75 addition
and
71 deletion
+75
-71
zh-cn/application-dev/reference/apis/js-apis-settings.md
zh-cn/application-dev/reference/apis/js-apis-settings.md
+75
-71
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-settings.md
浏览文件 @
c133e7d6
...
...
@@ -8,7 +8,7 @@
## 导入模块
```
t
s
```
j
s
import
settings
from
'
@ohos.settings
'
;
```
...
...
@@ -203,9 +203,9 @@ getURI(name: string, callback: AsyncCallback\<object>): void
**示例**
:
```
js
settings
.
getUri
(
settings
.
display
.
SCREEN_BRIGHTNESS_STATUS
,
(
uri
)
=>
{
settings
.
getURI
(
settings
.
display
.
SCREEN_BRIGHTNESS_STATUS
,
(
uri
)
=>
{
console
.
log
(
`callback:uri ->
${
JSON
.
stringify
(
uri
)}
`
)
})
})
```
## setting.getURI
...
...
@@ -231,9 +231,9 @@ getURI(name: string): Promise\<object>
**示例**
:
```
js
settings
.
getUri
(
settings
.
display
.
SCREEN_BRIGHTNESS_STATUS
).
then
((
uri
)
=>
{
settings
.
getURI
(
settings
.
display
.
SCREEN_BRIGHTNESS_STATUS
).
then
((
uri
)
=>
{
console
.
log
(
`promise:uri ->
${
JSON
.
stringify
(
uri
)}
`
)
})
})
```
## setting.getValue
...
...
@@ -255,15 +255,17 @@ getValue(dataAbilityHelper: DataAbilityHelper, name: string, callback: AsyncCall
**示例**
:
```
js
let
uri
=
settings
.
getUriSync
(
settings
.
display
.
SCREEN_BRIGHTNESS_STATUS
);
let
helper
=
featureAbility
.
acquireDataAbilityHelper
(
uri
);
settings
.
getValue
(
helper
,
settings
.
display
.
SCREEN_BRIGHTNESS_STATUS
,
(
err
,
value
)
=>
{
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
uri
=
settings
.
getUriSync
(
settings
.
display
.
SCREEN_BRIGHTNESS_STATUS
);
let
helper
=
featureAbility
.
acquireDataAbilityHelper
(
uri
);
settings
.
getValue
(
helper
,
settings
.
display
.
SCREEN_BRIGHTNESS_STATUS
,
(
err
,
value
)
=>
{
if
(
err
)
{
console
.
error
(
`Failed to get the setting.
${
err
.
message
}
`
);
return
;
}
console
.
log
(
`callback:value ->
${
JOS
N
.
stringify
(
value
)}
`
)
});
console
.
log
(
`callback:value ->
${
JSO
N
.
stringify
(
value
)}
`
)
});
```
## setting.getValue
...
...
@@ -290,11 +292,13 @@ getValue(dataAbilityHelper: DataAbilityHelper, name: string): Promise\<object>
**示例**
:
```
js
let
uri
=
settings
.
getUriSync
(
settings
.
display
.
SCREEN_BRIGHTNESS_STATUS
);
let
helper
=
featureAbility
.
acquireDataAbilityHelper
(
uri
);
settings
.
getValue
(
helper
,
settings
.
display
.
SCREEN_BRIGHTNESS_STATUS
).
then
((
value
)
=>
{
console
.
log
(
`promise:value ->
${
JOSN
.
stringify
(
value
)}
`
)
});
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
uri
=
settings
.
getUriSync
(
settings
.
display
.
SCREEN_BRIGHTNESS_STATUS
);
let
helper
=
featureAbility
.
acquireDataAbilityHelper
(
uri
);
settings
.
getValue
(
helper
,
settings
.
display
.
SCREEN_BRIGHTNESS_STATUS
).
then
((
value
)
=>
{
console
.
log
(
`promise:value ->
${
JSON
.
stringify
(
value
)}
`
)
});
```
## settings.setValue
...
...
@@ -319,14 +323,14 @@ setValue(dataAbilityHelper: DataAbilityHelper, name: string, value: object, call
**示例**
:
```
js
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
//更新数据项亮度的值(该数据项在数据库中已存在,故setValue方法将更新该数据项的值)
let
uri
=
settings
.
getUriSync
(
settings
.
display
.
SCREEN_BRIGHTNESS_STATUS
);
let
helper
=
featureAbility
.
acquireDataAbilityHelper
(
uri
);
settings
.
setValue
(
helper
,
settings
.
display
.
SCREEN_BRIGHTNESS_STATUS
,
'
100
'
,
(
status
)
=>
{
//更新数据项亮度的值(该数据项在数据库中已存在,故setValue方法将更新该数据项的值)
let
uri
=
settings
.
getUriSync
(
settings
.
display
.
SCREEN_BRIGHTNESS_STATUS
);
let
helper
=
featureAbility
.
acquireDataAbilityHelper
(
uri
);
settings
.
setValue
(
helper
,
settings
.
display
.
SCREEN_BRIGHTNESS_STATUS
,
'
100
'
,
(
status
)
=>
{
console
.
log
(
'
Callback return whether value is set.
'
);
});
});
```
## settings.setValue
...
...
@@ -356,14 +360,14 @@ setValue(dataAbilityHelper: DataAbilityHelper, name: string, value: object): Pro
**示例**
:
```
js
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
//更新数据项亮度的值(该数据项在数据库中已存在,故setValue方法将更新该数据项的值)
let
uri
=
settings
.
getUriSync
(
settings
.
display
.
SCREEN_BRIGHTNESS_STATUS
);
let
helper
=
featureAbility
.
acquireDataAbilityHelper
(
uri
);
settings
.
setValue
(
helper
,
settings
.
display
.
SCREEN_BRIGHTNESS_STATUS
,
'
100
'
).
then
((
status
)
=>
{
//更新数据项亮度的值(该数据项在数据库中已存在,故setValue方法将更新该数据项的值)
let
uri
=
settings
.
getUriSync
(
settings
.
display
.
SCREEN_BRIGHTNESS_STATUS
);
let
helper
=
featureAbility
.
acquireDataAbilityHelper
(
uri
);
settings
.
setValue
(
helper
,
settings
.
display
.
SCREEN_BRIGHTNESS_STATUS
,
'
100
'
).
then
((
status
)
=>
{
console
.
log
(
'
Callback return whether value is set.
'
);
});
});
```
## settings.enableAirplaneMode
...
...
@@ -384,14 +388,14 @@ enableAirplaneMode(enable: boolean, callback: AsyncCallback\<void>): void
**示例**
:
```
js
isEnabled
=
true
;
enableAirplaneMode
(
isEnabled
,
(
err
)
=>
{
if
(
err
)
{
let
isEnabled
=
true
;
settings
.
enableAirplaneMode
(
isEnabled
,
(
err
)
=>
{
if
(
err
)
{
console
.
log
(
'
Failed to enable AirplaneMode.
'
);
return
;
}
console
.
log
(
'
Return true if enable.
'
);
})
})
```
## settings.enableAirplaneMode
...
...
@@ -417,14 +421,14 @@ enableAirplaneMode(enable: boolean): Promise\<void>
**示例**
:
```
js
isEnabled
=
true
;
enableAirplaneMode
(
isEnabled
).
then
((
err
)
=>
{
if
(
err
)
{
let
isEnabled
=
true
;
settings
enableAirplaneMode
(
isEnabled
).
then
((
err
)
=>
{
if
(
err
)
{
console
.
log
(
'
Failed to enable AirplaneMode.
'
);
return
;
}
console
.
log
(
'
Return true if enable.
'
);
});
});
```
## settings.canShowFloating
...
...
@@ -444,9 +448,9 @@ canShowFloating(callback: AsyncCallback\<boolean>): void
**示例**
:
```
js
canShowFloating
((
status
)
=>
{
settings
.
canShowFloating
((
status
)
=>
{
console
.
log
(
'
Checks whether a specified application can show as float window.
'
);
});
});
```
## settings.canShowFloating
...
...
@@ -466,9 +470,9 @@ canShowFloating(): Promise\<boolean>
**示例**
:
```
js
canShowFloating
().
then
((
status
)
=>
{
settings
.
canShowFloating
().
then
((
status
)
=>
{
console
.
log
(
'
Checks whether a specified application can show as float window.
'
);
});
});
```
## settings.getUriSync<sup>8+</sup>
...
...
@@ -494,8 +498,8 @@ getUriSync(name: string): string
**示例**
:
```
js
// 获取数据项的URI
let
urivar
=
settings
.
getUriSync
(
settings
.
display
.
SCREEN_BRIGHTNESS_STATUS
);
// 获取数据项的URI
let
urivar
=
settings
.
getUriSync
(
settings
.
display
.
SCREEN_BRIGHTNESS_STATUS
);
```
## settings.getValueSync<sup>8+</sup>
...
...
@@ -523,12 +527,12 @@ getValueSync(dataAbilityHelper: DataAbilityHelper, name: string, defValue: strin
**示例**
:
```
js
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
//获取数据项亮度的值(该数据项在数据库中已存在)
let
uri
=
settings
.
getUriSync
(
settings
.
display
.
SCREEN_BRIGHTNESS_STATUS
);
let
helper
=
featureAbility
.
acquireDataAbilityHelper
(
uri
);
let
value
=
settings
.
getValueSync
(
helper
,
settings
.
display
.
SCREEN_BRIGHTNESS_STATUS
,
'
10
'
);
//获取数据项亮度的值(该数据项在数据库中已存在)
let
uri
=
settings
.
getUriSync
(
settings
.
display
.
SCREEN_BRIGHTNESS_STATUS
);
let
helper
=
featureAbility
.
acquireDataAbilityHelper
(
uri
);
let
value
=
settings
.
getValueSync
(
helper
,
settings
.
display
.
SCREEN_BRIGHTNESS_STATUS
,
'
10
'
);
```
## settings.setValueSync<sup>8+</sup>
...
...
@@ -560,10 +564,10 @@ setValueSync(dataAbilityHelper: DataAbilityHelper, name: string, value: string):
**示例**
:
```
js
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
//更新数据项亮度的值(该数据项在数据库中已存在,故setValueSync方法将更新该数据项的值)
let
uri
=
settings
.
getUriSync
(
settings
.
display
.
SCREEN_BRIGHTNESS_STATUS
);
let
helper
=
featureAbility
.
acquireDataAbilityHelper
(
uri
);
let
ret
=
settings
.
setValueSync
(
helper
,
settings
.
display
.
SCREEN_BRIGHTNESS_STATUS
,
'
100
'
);
//更新数据项亮度的值(该数据项在数据库中已存在,故setValueSync方法将更新该数据项的值)
let
uri
=
settings
.
getUriSync
(
settings
.
display
.
SCREEN_BRIGHTNESS_STATUS
);
let
helper
=
featureAbility
.
acquireDataAbilityHelper
(
uri
);
let
ret
=
settings
.
setValueSync
(
helper
,
settings
.
display
.
SCREEN_BRIGHTNESS_STATUS
,
'
100
'
);
```
Miykael_xxm
🚴
@xiongjiamu
mentioned in commit
c6c7843d
·
9月 19, 2022
mentioned in commit
c6c7843d
mentioned in commit c6c7843d103c5f3b1c538554df4f777614b35b9a
开关提交列表
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录