Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
f444f3c4
D
Docs
项目概览
OpenHarmony
/
Docs
11 个月 前同步成功
通知
158
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,发现更多精彩内容 >>
未验证
提交
f444f3c4
编写于
3月 21, 2022
作者:
O
openharmony_ci
提交者:
Gitee
3月 21, 2022
浏览文件
操作
浏览文件
下载
差异文件
!2266 【轻量级 PR】:update zh-cn/application-dev/reference/apis/js-apis-wallpaper.md.
Merge pull request !2266 from 葛亚芳/N/A
上级
e5a88bf8
755c487b
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
70 addition
and
14 deletion
+70
-14
zh-cn/application-dev/reference/apis/js-apis-wallpaper.md
zh-cn/application-dev/reference/apis/js-apis-wallpaper.md
+70
-14
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-wallpaper.md
浏览文件 @
f444f3c4
...
...
@@ -358,7 +358,7 @@ reset(wallpaperType: WallpaperType, callback: AsyncCallback<void>): void
-
示例:
```
wallpaper.reset((error, data) => {
wallpaper.reset(
wallpaper.WallpaperType.WALLPAPER_SYSTEM,
(error, data) => {
if (error) {
console.error(`failed to reset because: ` + JSON.stringify(error));
return;
...
...
@@ -391,7 +391,7 @@ reset(wallpaperType: WallpaperType): Promise<void>
-
示例:
```
wallpaper.reset(wallpaper.WALLPAPER_SYSTEM).then((data) => {
wallpaper.reset(wallpaper.W
allpaperType.W
ALLPAPER_SYSTEM).then((data) => {
console.log(`success to reset.`);
}).catch((error) => {
console.error(`failed to reset because: ` + JSON.stringify(error));
...
...
@@ -401,7 +401,7 @@ reset(wallpaperType: WallpaperType): Promise<void>
## wallpaper.setWallpaper
setWallpaper(
uriOrPixelMap
: string | image.PixelMap, wallpaperType: WallpaperType, callback: AsyncCallback
<
void
>
): void
setWallpaper(
source
: string | image.PixelMap, wallpaperType: WallpaperType, callback: AsyncCallback
<
void
>
): void
将指定资源设置为指定类型的壁纸。
...
...
@@ -412,16 +412,16 @@ setWallpaper(uriOrPixelMap: string | image.PixelMap, wallpaperType: WallpaperTyp
-
参数:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
|
uriOrPixelMap
| string
\|
[
PixelMap
](
js-apis-image.md#pixelmap7
)
| | JPEG或PNG文件的Uri路径,或者PNG格式文件的位图。 |
|
source
| string
\|
[
PixelMap
](
js-apis-image.md#pixelmap7
)
| | JPEG或PNG文件的Uri路径,或者PNG格式文件的位图。 |
| wallpaperType |
[
WallpaperType
](
#wallpapertype
)
| 是 | 壁纸类型。 |
| callback | AsyncCallback
<
void
>
| 是 | 回调函数,调用成功则返回是返回设置的结果,调用失败则返回error信息。 |
-
示例:
```
//
uriOrPixelMap
类型为string
//
source
类型为string
let wallpaperPath = "/data/data/ohos.acts.aafwk.plrdtest.form/files/Cup_ic.jpg";
wallpaper.setWallpaper(wallpaperPath, wallpaper.W
ALLPAPER_SYSTEM, (error, data) => {
wallpaper.setWallpaper(wallpaperPath, wallpaper.W
allpaperType.WALLPAPER_SYSTEM, (error, data) => {
if (error) {
console.error(`failed to setWallpaper because: ` + JSON.stringify(error));
return;
...
...
@@ -429,7 +429,7 @@ setWallpaper(uriOrPixelMap: string | image.PixelMap, wallpaperType: WallpaperTyp
console.log(`success to setWallpaper.`);
});
//
uriOrPixelMap
类型为image.PixelMap
//
source
类型为image.PixelMap
import image from '@ohos.multimedia.image';
let imageSource = image.createImageSource("file://" + wallpaperPath);
let opts = {
...
...
@@ -439,7 +439,7 @@ setWallpaper(uriOrPixelMap: string | image.PixelMap, wallpaperType: WallpaperTyp
}
};
imageSource.createPixelMap(opts).then((pixelMap) => {
wallpaper.setWallpaper(pixelMap, wallpaper.WALLPAPER_SYSTEM, (error, data) => {
wallpaper.setWallpaper(pixelMap, wallpaper.W
allpaperType.W
ALLPAPER_SYSTEM, (error, data) => {
if (error) {
console.error(`failed to setWallpaper because: ` + JSON.stringify(error));
return;
...
...
@@ -454,7 +454,7 @@ setWallpaper(uriOrPixelMap: string | image.PixelMap, wallpaperType: WallpaperTyp
## wallpaper.setWallpaper
setWallpaper(
uriOrPixelMap
: string | image.PixelMap, wallpaperType: WallpaperType): Promise
<
void
>
setWallpaper(
source
: string | image.PixelMap, wallpaperType: WallpaperType): Promise
<
void
>
将指定资源设置为指定类型的壁纸。
...
...
@@ -465,7 +465,7 @@ setWallpaper(uriOrPixelMap: string | image.PixelMap, wallpaperType: WallpaperTyp
-
参数:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
|
uriOrPixelMap
| string
\|
[
PixelMap
](
js-apis-image.md#pixelmap7
)
| 是 | JPEG或PNG文件的Uri路径,或者PNG格式文件的位图。 |
|
source
| string
\|
[
PixelMap
](
js-apis-image.md#pixelmap7
)
| 是 | JPEG或PNG文件的Uri路径,或者PNG格式文件的位图。 |
| wallpaperType |
[
WallpaperType
](
#wallpapertype
)
| 是 | 壁纸类型。 |
-
返回值:
...
...
@@ -476,15 +476,15 @@ setWallpaper(uriOrPixelMap: string | image.PixelMap, wallpaperType: WallpaperTyp
-
示例:
```
//
uriOrPixelMap
类型为string
//
source
类型为string
let wallpaperPath = "/data/data/ohos.acts.aafwk.plrdtest.form/files/Cup_ic.jpg";
wallpaper.setWallpaper(wallpaperPath, wallpaper.WALLPAPER_SYSTEM).then((data) => {
wallpaper.setWallpaper(wallpaperPath, wallpaper.W
allpaperType.W
ALLPAPER_SYSTEM).then((data) => {
console.log(`success to setWallpaper.`);
}).catch((error) => {
console.error(`failed to setWallpaper because: ` + JSON.stringify(error));
});
//
uriOrPixelMap
类型为image.PixelMap
//
source
类型为image.PixelMap
import image from '@ohos.multimedia.image';
let imageSource = image.createImageSource("file://" + wallpaperPath);
let opts = {
...
...
@@ -494,7 +494,7 @@ setWallpaper(uriOrPixelMap: string | image.PixelMap, wallpaperType: WallpaperTyp
}
};
imageSource.createPixelMap(opts).then((pixelMap) => {
wallpaper.setWallpaper(pixelMap, wallpaper.WALLPAPER_SYSTEM).then((data) => {
wallpaper.setWallpaper(pixelMap, wallpaper.W
allpaperType.W
ALLPAPER_SYSTEM).then((data) => {
console.log(`success to setWallpaper.`);
}).catch((error) => {
console.error(`failed to setWallpaper because: ` + JSON.stringify(error));
...
...
@@ -503,6 +503,62 @@ setWallpaper(uriOrPixelMap: string | image.PixelMap, wallpaperType: WallpaperTyp
console.error(`failed to createPixelMap because: ` + JSON.stringify(error));
});
```
## wallpaper.getFile<sup>8+</sup>
getFile(wallpaperType: WallpaperType, callback: AsyncCallback
<
number
>
): void
获取指定类型的壁纸文件。
**需要权限**
:ohos.permission.SET_WALLPAPER、ohos.permission.READ_USER_STORAGE
**系统能力**
: SystemCapability.Miscservices.Wallpaper
-
参数:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| wallpaperType |
[
WallpaperType
](
#wallpapertype
)
| 是 | 壁纸类型。 |
| callback | AsyncCallback
<
number
>
| 是 | 回调函数,调用成功则返回壁纸文件描述符ID,调用失败则返回error信息。 |
-
示例:
```
wallpaper.getFile(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => {
if (error) {
console.error(`failed to getFile because: ` + JSON.stringify(error));
return;
}
console.log(`success to getFile: ` + JSON.stringify(data));
});
```
## wallpaper.getFile<sup>8+</sup>
getFile(wallpaperType: WallpaperType): Promise
<
number
>
获取指定类型的壁纸文件。
**需要权限:**
ohos.permission.SET_WALLPAPER、ohos.permission.READ_USER_STORAGE
**系统能力**
: SystemCapability.Miscservices.Wallpaper
-
参数:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| wallpaperType |
[
WallpaperType
](
#wallpapertype
)
| 是 | 壁纸类型。 |
-
返回值:
| 类型 | 说明 |
| -------- | -------- |
| Promise
<
number
>
| 调用成功则返回壁纸文件描述符ID,调用失败则返回error信息。 |
-
示例:
```
wallpaper.getFile(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => {
console.log(`success to getFile: ` + JSON.stringify(data));
}).catch((error) => {
console.error(`failed to getFile because: ` + JSON.stringify(error));
});
```
## wallpaper.on('colorChange')
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录