Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
37303588
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,发现更多精彩内容 >>
未验证
提交
37303588
编写于
10月 13, 2022
作者:
O
openharmony_ci
提交者:
Gitee
10月 13, 2022
浏览文件
操作
浏览文件
下载
差异文件
!10212 窗口子系统模块文档更新
Merge pull request !10212 from ZhengJiangliang/master
上级
a4f0b2ca
804b035e
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
4847 addition
and
1779 deletion
+4847
-1779
zh-cn/application-dev/reference/apis/js-apis-display.md
zh-cn/application-dev/reference/apis/js-apis-display.md
+231
-85
zh-cn/application-dev/reference/apis/js-apis-screen.md
zh-cn/application-dev/reference/apis/js-apis-screen.md
+375
-151
zh-cn/application-dev/reference/apis/js-apis-screenshot.md
zh-cn/application-dev/reference/apis/js-apis-screenshot.md
+37
-25
zh-cn/application-dev/reference/apis/js-apis-window.md
zh-cn/application-dev/reference/apis/js-apis-window.md
+4109
-1518
zh-cn/application-dev/reference/errorcodes/errorcode-display.md
...application-dev/reference/errorcodes/errorcode-display.md
+34
-0
zh-cn/application-dev/reference/errorcodes/errorcode-window.md
.../application-dev/reference/errorcodes/errorcode-window.md
+61
-0
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-display.md
浏览文件 @
37303588
...
...
@@ -11,7 +11,6 @@
import
display
from
'
@ohos.display
'
;
```
## DisplayState
显示设备的状态枚举。
...
...
@@ -65,61 +64,6 @@ import display from '@ohos.display';
| boundingRects | Array
\<
[
Rect
](
#rect9
)
> | 是 | 否 | 挖孔、刘海等区域的边界矩形。 |
| waterfallDisplayAreaRects |
[
WaterfallDisplayAreaRects
](
#waterfalldisplayarearects9
)
| 是 | 否 | 瀑布屏曲面部分显示区域。 |
## display.getDefaultDisplay
getDefaultDisplay(callback: AsyncCallback
<
Display
>
): void
获取当前默认的display对象,使用callback异步回调。
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback
<
[Display](#display)
>
| 是 | 回调函数。返回当前默认的display对象。 |
**示例:**
```
js
var
displayClass
=
null
;
display
.
getDefaultDisplay
((
err
,
data
)
=>
{
if
(
err
.
code
)
{
console
.
error
(
'
Failed to obtain the default display object. Code:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
info
(
'
Succeeded in obtaining the default display object. Data:
'
+
JSON
.
stringify
(
data
));
displayClass
=
data
;
});
```
## display.getDefaultDisplay
getDefaultDisplay(): Promise
<
Display
>
获取当前默认的display对象,使用Promise异步回调。
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
**返回值:**
| 类型 | 说明 |
| ---------------------------------- | ---------------------------------------------- |
| Promise
<
[Display](#display)
>
| Promise对象。返回当前默认的display对象。 |
**示例:**
```
js
var
displayClass
=
null
;
let
promise
=
display
.
getDefaultDisplay
();
promise
.
then
((
data
)
=>
{
displayClass
=
data
;
console
.
info
(
'
Succeeded in obtaining the default display object. Data:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to obtain the default display object. Code:
'
+
JSON
.
stringify
(
err
));
});
```
## display.getDefaultDisplaySync<sup>9+</sup>
getDefaultDisplaySync(): Display
...
...
@@ -134,15 +78,27 @@ getDefaultDisplaySync(): Display
| ------------------------------| ----------------------------------------------|
|
[
Display
](
#display
)
| 返回默认的display对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
屏幕错误码
](
../errorcodes/errorcode-display.md
)
。
| 错误码ID | 错误信息 |
| ------- | ----------------------- |
| 1400001 | This is invalid screen. |
**示例:**
```
js
var
displayClass
=
display
.
getDefaultDisplaySync
();
try
{
let
displayClass
=
display
.
getDefaultDisplaySync
();
}
catch
(
exception
)
{
console
.
error
(
'
Failed to obtain the default display object. Code:
'
+
JSON
.
stringify
(
exception
));
};
```
## display.getAllDisplay
## display.getAllDisplay
s<sup>9+</sup>
getAllDisplay(callback: AsyncCallback
<
Array
<
Display
>>
): void
getAllDisplay
s
(callback: AsyncCallback
<
Array
<
Display
>>
): void
获取当前所有的display对象,使用callback异步回调。
...
...
@@ -154,10 +110,20 @@ getAllDisplay(callback: AsyncCallback<Array<Display>>): void
| -------- | ---------------------------------------------------- | ---- | ------------------------------- |
| callback | AsyncCallback
<
Array
<
[Display](#display)
>>
| 是 | 回调函数。返回当前所有的display对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
屏幕错误码
](
../errorcodes/errorcode-display.md
)
。
| 错误码ID | 错误信息 |
| ------- | ----------------------- |
| 1400001 | This is invalid screen. |
**示例:**
```
js
display
.
getAllDisplay
((
err
,
data
)
=>
{
let
displayClass
=
null
;
display
.
getAllDisplays
((
err
,
data
)
=>
{
displayClass
=
data
;
if
(
err
.
code
)
{
console
.
error
(
'
Failed to obtain all the display objects. Code:
'
+
JSON
.
stringify
(
err
));
return
;
...
...
@@ -166,9 +132,9 @@ display.getAllDisplay((err, data) => {
});
```
## display.getAllDisplay
## display.getAllDisplay
s<sup>9+</sup>
getAllDisplay(): Promise
<
Array
<
Display
>>
getAllDisplay
s
(): Promise
<
Array
<
Display
>>
获取当前所有的display对象,使用Promise异步回调。
...
...
@@ -180,11 +146,21 @@ getAllDisplay(): Promise<Array<Display>>
| ----------------------------------------------- | ------------------------------------------------------- |
| Promise
<
Array
<
[Display](#display)
>>
| Promise对象。返回当前所有的display对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
屏幕错误码
](
../errorcodes/errorcode-display.md
)
。
| 错误码ID | 错误信息 |
| ------- | ----------------------- |
| 1400001 | This is invalid screen. |
**示例:**
```
js
let
promise
=
display
.
getAllDisplay
();
let
displayClass
=
null
;
let
promise
=
display
.
getAllDisplays
();
promise
.
then
((
data
)
=>
{
displayClass
=
data
;
console
.
info
(
'
Succeeded in obtaining all the display objects. Data:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to obtain all the display objects. Code:
'
+
JSON
.
stringify
(
err
));
...
...
@@ -195,7 +171,7 @@ promise.then((data) => {
hasPrivateWindow(displayId: number): boolean
查询指定display对象上是否有可见的隐私窗口。可通过
[
set
PrivacyMode
](
js-apis-window.md#setprivacymode7
)
接口设置隐私窗口。隐私窗口内容将无法被截屏或录屏。
查询指定display对象上是否有可见的隐私窗口。可通过
[
set
WindowPrivacyMode()
](
js-apis-window.md#setwindowprivacymode9
)
接口设置隐私窗口。隐私窗口内容将无法被截屏或录屏。
**系统接口:**
此接口为系统接口。
...
...
@@ -213,20 +189,30 @@ hasPrivateWindow(displayId: number): boolean
| -------------------------------- |-----------------------------------------------------------------------|
|boolean | 查询的display对象上是否有可见的隐私窗口。
<br>
true表示此display对象上有可见的隐私窗口,false表示此display对象上没有可见的隐私窗口。
</br>
|
**错误码:**
以下错误码的详细介绍请参见
[
屏幕错误码
](
../errorcodes/errorcode-display.md
)
。
| 错误码ID | 错误信息 |
| ------- | -------------------------------------------- |
| 1400003 | This window manager service work abnormally. |
**示例:**
```
js
var
displayClass
=
null
;
display
.
getDefaultDisplay
((
err
,
data
)
=>
{
if
(
err
.
code
)
{
console
.
error
(
'
Failed to obtain the default display object. Code:
'
+
JSON
.
stringify
(
err
));
let
displayClass
=
null
;
try
{
displayClass
=
display
.
getDefaultDisplaySync
();
}
catch
(
exception
)
{
console
.
error
(
'
Failed to obtain the default display object. Code:
'
+
JSON
.
stringify
(
exception
));
return
;
}
console
.
info
(
'
Succeeded in obtaining the default display object. Data:
'
+
JSON
.
stringify
(
data
));
displayClass
=
data
;
});
};
var
ret
=
display
.
hasPrivateWindow
(
displayClass
.
id
);
try
{
let
ret
=
display
.
hasPrivateWindow
(
displayClass
.
id
);
}
catch
(
exception
)
{
console
.
error
(
'
Failed to check has privateWindow or not. Code:
'
+
JSON
.
stringify
(
exception
));
};
if
(
ret
==
undefined
)
{
console
.
log
(
"
Failed to check has privateWindow or not.
"
);
}
...
...
@@ -234,7 +220,7 @@ if (ret) {
console
.
log
(
"
There has privateWindow.
"
);
}
else
if
(
!
ret
)
{
console
.
log
(
"
There has no privateWindow.
"
);
}
}
;
```
## display.on('add'|'remove'|'change')
...
...
@@ -255,10 +241,14 @@ on(type: 'add'|'remove'|'change', callback: Callback<number>): void
**示例:**
```
js
var
callback
=
(
data
)
=>
{
let
callback
=
(
data
)
=>
{
console
.
info
(
'
Listening enabled. Data:
'
+
JSON
.
stringify
(
data
));
}
display
.
on
(
"
add
"
,
callback
);
try
{
display
.
on
(
"
add
"
,
callback
);
}
catch
(
exception
)
{
console
.
error
(
'
Failed to register callback. Code:
'
+
JSON
.
stringify
(
exception
));
};
```
## display.off('add'|'remove'|'change')
...
...
@@ -279,13 +269,139 @@ off(type: 'add'|'remove'|'change', callback?: Callback<number>): void
**示例:**
```
js
display
.
off
(
"
remove
"
);
try
{
display
.
off
(
"
remove
"
);
}
catch
(
exception
)
{
console
.
error
(
'
Failed to unregister callback. Code:
'
+
JSON
.
stringify
(
exception
));
};
```
## display.getDefaultDisplay<sup>(deprecated)</sup>
getDefaultDisplay(callback: AsyncCallback
<
Display
>
): void
获取当前默认的display对象,使用callback异步回调。
> **说明:**
>
> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[getDefaultDisplaySync()](#displaygetdefaultdisplaysync9)。
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback
<
[Display](#display)
>
| 是 | 回调函数。返回当前默认的display对象。 |
**示例:**
```
js
let
displayClass
=
null
;
display
.
getDefaultDisplay
((
err
,
data
)
=>
{
if
(
err
.
code
)
{
console
.
error
(
'
Failed to obtain the default display object. Code:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
info
(
'
Succeeded in obtaining the default display object. Data:
'
+
JSON
.
stringify
(
data
));
displayClass
=
data
;
});
```
## display.getDefaultDisplay<sup>(deprecated)</sup>
getDefaultDisplay(): Promise
<
Display
>
获取当前默认的display对象,使用Promise异步回调。
> **说明:**
>
> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[getDefaultDisplaySync()](#displaygetdefaultdisplaysync9)。
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
**返回值:**
| 类型 | 说明 |
| ---------------------------------- | ---------------------------------------------- |
| Promise
<
[Display](#display)
>
| Promise对象。返回当前默认的display对象。 |
**示例:**
```
js
let
displayClass
=
null
;
let
promise
=
display
.
getDefaultDisplay
();
promise
.
then
((
data
)
=>
{
displayClass
=
data
;
console
.
info
(
'
Succeeded in obtaining the default display object. Data:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to obtain the default display object. Code:
'
+
JSON
.
stringify
(
err
));
});
```
## display.getAllDisplay<sup>(deprecated)</sup>
getAllDisplay(callback: AsyncCallback
<
Array
<
Display
>>
): void
获取当前所有的display对象,使用callback异步回调。
> **说明:**
>
> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[getAllDisplays()](#displaygetalldisplays9)。
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------------------- | ---- | ------------------------------- |
| callback | AsyncCallback
<
Array
<
[Display](#display)
>>
| 是 | 回调函数。返回当前所有的display对象。 |
**示例:**
```
js
display
.
getAllDisplay
((
err
,
data
)
=>
{
if
(
err
.
code
)
{
console
.
error
(
'
Failed to obtain all the display objects. Code:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
info
(
'
Succeeded in obtaining all the display objects. Data:
'
+
JSON
.
stringify
(
data
));
});
```
## display.getAllDisplay<sup>(deprecated)</sup>
getAllDisplay(): Promise
<
Array
<
Display
>>
获取当前所有的display对象,使用Promise异步回调。
> **说明:**
>
> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[getAllDisplays()](#displaygetalldisplays9-1)。
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
**返回值:**
| 类型 | 说明 |
| ----------------------------------------------- | ------------------------------------------------------- |
| Promise
<
Array
<
[Display](#display)
>>
| Promise对象。返回当前所有的display对象。 |
**示例:**
```
js
let
promise
=
display
.
getAllDisplay
();
promise
.
then
((
data
)
=>
{
console
.
info
(
'
Succeeded in obtaining all the display objects. Data:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to obtain all the display objects. Code:
'
+
JSON
.
stringify
(
err
));
});
```
## Display
屏幕实例。描述display对象的属性和方法。
下列API示例中都需先使用
[
getAllDisplay
()
](
#displaygetalldisplay
)
、
[
getDefaultDisplay()
](
#displaygetdefaultdisplay
)
、
[
getDefaultDisplaySync()
](
#displaygetdefaultdisplaysync
)
中的任一方法获取到Display实例,再通过此实例调用对应方法。
下列API示例中都需先使用
[
getAllDisplay
s()
](
#displaygetalldisplays9
)
、
[
getDefaultDisplaySync()
](
#displaygetdefaultdisplaysync9
)
中的任一方法获取到Display实例,再通过此实例调用对应方法。
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
...
...
@@ -312,20 +428,36 @@ getCutoutInfo(callback: AsyncCallback<CutoutInfo>): void
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ----------- | --------------------------- | ---- | ------------------------------------------------------------ |
| callback | AsyncCallback
<
[CutoutInfo](#cutoutinfo9)
>
| 是 | 回调函数。当获取信息成功,err为undefined,data为获取到的CutoutInfo对象;否则err为错误对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
屏幕错误码
](
../errorcodes/errorcode-display.md
)
。
| 错误码ID | 错误信息 |
| ------- | ----------------------- |
| 1400001 | This is invalid screen. |
**示例:**
```
js
try
{
let
displayClass
=
display
.
getDefaultDisplaySync
();
}
catch
(
exception
)
{
console
.
error
(
'
Failed to obtain the default display object. Code:
'
+
JSON
.
stringify
(
exception
));
};
displayClass
.
getCutoutInfo
((
err
,
data
)
=>
{
if
(
err
.
code
)
{
console
.
error
(
'
Failed to get cutoutInfo. C
aus
e:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to get cutoutInfo. C
od
e:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
info
(
'
Succeeded in getting cutoutInfo. data:
'
+
JSON
.
stringify
(
data
));
})
})
;
```
### getCutoutInfo<sup>9+</sup>
getCutoutInfo(): Promise
<
CutoutInfo
>
...
...
@@ -340,9 +472,23 @@ getCutoutInfo(): Promise<CutoutInfo>
| ------------------- | ------------------------- |
| Promise
<
[CutoutInfo](#cutoutinfo9)
>
| Promise对象,返回描述不可用屏幕区域的CutoutInfo对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
屏幕错误码
](
../errorcodes/errorcode-display.md
)
。
| 错误码ID | 错误信息 |
| ------- | ----------------------- |
| 1400001 | This is invalid screen. |
**示例:**
```
js
try
{
let
displayClass
=
display
.
getDefaultDisplaySync
();
}
catch
(
exception
)
{
console
.
error
(
'
Failed to obtain the default display object. Code:
'
+
JSON
.
stringify
(
exception
));
};
let
promise
=
displayClass
.
getCutoutInfo
();
promise
.
then
((
data
)
=>
{
console
.
info
(
'
Succeeded in getting cutoutInfo. Data:
'
+
JSON
.
stringify
(
data
));
...
...
zh-cn/application-dev/reference/apis/js-apis-screen.md
浏览文件 @
37303588
...
...
@@ -28,6 +28,14 @@ getAllScreens(callback: AsyncCallback<Array<Screen>>): void
| -------- | --------------------------------------------------- | ---- | -------------------------------------- |
| callback | AsyncCallback
<
Array
<
[Screen](#screen)
>>
| 是 | 回调函数。返回当前获取的屏幕对象集合。 |
**错误码:**
以下错误码的详细介绍请参见
[
屏幕错误码
](
../errorcodes/errorcode-display.md
)
。
| 错误码ID | 错误信息 |
| ------- | ----------------------- |
| 1400001 | This is invalid screen. |
**示例:**
```
js
...
...
@@ -56,6 +64,14 @@ getAllScreens(): Promise<Array<Screen>>
| --------------------------------------------- | ----------------------------------------- |
| Promise
<
Array
<
[Screen](#screen)
>>
| Promise对象。返回当前获取的屏幕对象集合。 |
**错误码:**
以下错误码的详细介绍请参见
[
屏幕错误码
](
../errorcodes/errorcode-display.md
)
。
| 错误码ID | 错误信息 |
| ------- | ----------------------- |
| 1400001 | This is invalid screen. |
**示例:**
```
js
...
...
@@ -87,10 +103,14 @@ on(eventType: 'connect' | 'disconnect' | 'change', callback: Callback<number&
**示例:**
```
js
var
callback
=
(
data
)
=>
{
try
{
let
callback
=
(
data
)
=>
{
console
.
info
(
'
Register the callback for screen changes. Data:
'
+
JSON
.
stringify
(
data
))
};
screen
.
on
(
'
connect
'
,
callback
);
}
catch
(
exception
)
{
console
.
error
(
'
Failed to register the callback for screen changes. Code:
'
+
JSON
.
stringify
(
exception
));
};
screen
.
on
(
"
connect
"
,
callback
);
```
## screen.off('connect' | 'disconnect' | 'change')
...
...
@@ -111,10 +131,14 @@ off(eventType: 'connect' | 'disconnect' | 'change', callback?: Callback<numbe
**示例:**
```
js
var
callback
=
(
data
)
=>
{
try
{
let
callback
=
(
data
)
=>
{
console
.
info
(
'
Unregister the callback for screen changes. Data:
'
+
JSON
.
stringify
(
data
))
};
screen
.
off
(
'
connect
'
,
callback
);
}
catch
(
exception
)
{
console
.
error
(
'
Failed to register the callback for screen changes. Code:
'
+
JSON
.
stringify
(
exception
));
};
screen
.
off
(
"
connect
"
,
callback
);
```
## screen.makeExpand
...
...
@@ -132,18 +156,30 @@ makeExpand(options:Array<ExpandOption>, callback: AsyncCallback<number&
| options | Array
<
[ExpandOption](#expandoption)
>
| 是 | 设置扩展屏幕的参数集合。 |
| callback | Callback
<
number
>
| 是 | 回调函数。返回扩展屏幕的群组id。 |
**错误码:**
以下错误码的详细介绍请参见
[
屏幕错误码
](
../errorcodes/errorcode-display.md
)
。
| 错误码ID | 错误信息 |
| ------- | ----------------------- |
| 1400001 | This is invalid screen. |
**示例:**
```
js
var
groupId
=
null
;
screen
.
makeExpand
([{
screenId
:
0
,
startX
:
0
,
startY
:
0
},
{
screenId
:
1
,
startX
:
1080
,
startY
:
0
}],
(
err
,
data
)
=>
{
try
{
let
groupId
=
null
;
screen
.
makeExpand
([{
screenId
:
0
,
startX
:
0
,
startY
:
0
},
{
screenId
:
1
,
startX
:
1080
,
startY
:
0
}],
(
err
,
data
)
=>
{
if
(
err
.
code
)
{
console
.
error
(
'
Failed to make screens as expand-screen. Caus
e:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to make screens as expand-screen. Cod
e:
'
+
JSON
.
stringify
(
err
));
return
;
}
groupId
=
data
;
console
.
info
(
'
Succeeded in making screens as expand-screen.Data:
'
+
JSON
.
stringify
(
data
));
});
console
.
info
(
'
Succeeded in making screens as expand-screen. Data:
'
+
JSON
.
stringify
(
data
));
});
}
catch
(
exception
)
{
console
.
error
(
'
Failed to make screens as expand-screen. Code:
'
+
JSON
.
stringify
(
exception
));
};
```
## screen.makeExpand
...
...
@@ -166,14 +202,26 @@ makeExpand(options:Array<ExpandOption>): Promise<number>
| --------------------- | ----------------------------------- |
| Promise
<
number
>
| Promise对象。返回扩展屏幕的群组id。 |
**错误码:**
以下错误码的详细介绍请参见
[
屏幕错误码
](
../errorcodes/errorcode-display.md
)
。
| 错误码ID | 错误信息 |
| ------- | ----------------------- |
| 1400001 | This is invalid screen. |
**示例:**
```
js
screen
.
makeExpand
([{
screenId
:
0
,
startX
:
0
,
startY
:
0
},
{
screenId
:
1
,
startX
:
1080
,
startY
:
0
}]).
then
((
data
)
=>
{
console
.
info
(
'
Succeeded in making screens as expand-screen.Data:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to make screens as expand-screen. Cause:
'
+
JSON
.
stringify
(
err
));
});
try
{
screen
.
makeExpand
([{
screenId
:
0
,
startX
:
0
,
startY
:
0
},
{
screenId
:
1
,
startX
:
1080
,
startY
:
0
}]).
then
((
data
)
=>
{
console
.
info
(
'
Succeeded in making screens as expand-screen. Data:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to make screens as expand-screen. Code:
'
+
JSON
.
stringify
(
err
));
});
}
catch
(
exception
)
{
console
.
error
(
'
Failed to make screens as expand-screen. Code:
'
+
JSON
.
stringify
(
exception
));
};
```
## screen.makeMirror
...
...
@@ -192,18 +240,30 @@ makeMirror(mainScreen:number, mirrorScreen:Array<number>, callback: AsyncC
| mirrorScreen | Array
<
number
>
| 是 | 镜像屏幕id集合。 |
| callback | AsyncCallback
<
number
>
| 是 | 回调函数。返回镜像屏幕的群组id。 |
**错误码:**
以下错误码的详细介绍请参见
[
屏幕错误码
](
../errorcodes/errorcode-display.md
)
。
| 错误码ID | 错误信息 |
| ------- | ----------------------- |
| 1400001 | This is invalid screen. |
**示例:**
```
js
var
mainScreenId
=
0
;
var
mirrorScreenIds
=
[
1
,
2
,
3
];
screen
.
makeMirror
(
mainScreenId
,
mirrorScreenIds
,
(
err
,
data
)
=>
{
let
mainScreenId
=
0
;
let
mirrorScreenIds
=
[
1
,
2
,
3
];
try
{
screen
.
makeMirror
(
mainScreenId
,
mirrorScreenIds
,
(
err
,
data
)
=>
{
if
(
err
.
code
)
{
console
.
error
(
'
Failed to make screens as mirror-screen.Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to make screens as mirror-screen. Code:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
info
(
'
Succeeded in making screens as mirror-screen.Data:
'
+
JSON
.
stringify
(
data
));
});
console
.
info
(
'
Succeeded in making screens as mirror-screen. Data:
'
+
JSON
.
stringify
(
data
));
});
}
catch
(
exception
)
{
console
.
error
(
'
Failed to make screens as mirror-screen. Code:
'
+
JSON
.
stringify
(
exception
));
};
```
## screen.makeMirror
...
...
@@ -227,16 +287,28 @@ makeMirror(mainScreen:number, mirrorScreen:Array<number>): Promise<numb
| --------------------- | ----------------------------------- |
| Promise
<
number
>
| Promise对象。返回镜像屏幕的群组id。 |
**错误码:**
以下错误码的详细介绍请参见
[
屏幕错误码
](
../errorcodes/errorcode-display.md
)
。
| 错误码ID | 错误信息 |
| ------- | ----------------------- |
| 1400001 | This is invalid screen. |
**示例:**
```
js
var
mainScreenId
=
0
;
var
mirrorScreenIds
=
[
1
,
2
,
3
];
screen
.
makeMirror
(
mainScreenId
,
mirrorScreenIds
).
then
((
data
)
=>
{
console
.
info
(
'
Succeeded in making screens as mirror-screen.Data:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to make screens as mirror-screen.Cause:
'
+
JSON
.
stringify
(
err
));
});
let
mainScreenId
=
0
;
let
mirrorScreenIds
=
[
1
,
2
,
3
];
try
{
screen
.
makeMirror
(
mainScreenId
,
mirrorScreenIds
).
then
((
data
)
=>
{
console
.
info
(
'
Succeeded in making screens as mirror-screen. Data:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to make screens as mirror-screen. Code:
'
+
JSON
.
stringify
(
err
));
});
}
catch
(
exception
)
{
console
.
error
(
'
Failed to make screens as mirror-screen. Code:
'
+
JSON
.
stringify
(
exception
));
};
```
## screen.createVirtualScreen
...
...
@@ -256,24 +328,36 @@ createVirtualScreen(options:VirtualScreenOption, callback: AsyncCallback<Scre
| options |
[
VirtualScreenOption
](
#virtualscreenoption
)
| 是 | 用于创建虚拟屏幕的参数。 |
| callback | AsyncCallback
<
[Screen](#screen)
>
| 是 | 回调函数,返回创建的虚拟屏幕对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
屏幕错误码
](
../errorcodes/errorcode-display.md
)
。
| 错误码ID | 错误信息 |
| ------- | ----------------------- |
| 1400001 | This is invalid screen. |
**示例:**
```
js
var
screenClass
=
null
;
screen
.
createVirtualScreen
({
let
screenClass
=
null
;
try
{
screen
.
createVirtualScreen
({
name
:
'
screen01
'
,
width
:
1080
,
height
:
2340
,
density
:
2
,
surfaceId
:
''
},
(
err
,
data
)
=>
{
},
(
err
,
data
)
=>
{
if
(
err
.
code
)
{
console
.
error
(
'
Failed to create virtual screen.Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to create virtual screen. Code:
'
+
JSON
.
stringify
(
err
));
return
;
}
screenClass
=
data
;
console
.
info
(
'
Succeeded in creating virtual screen.Data:
'
+
JSON
.
stringify
(
data
));
});
console
.
info
(
'
Succeeded in creating virtual screen. Data:
'
+
JSON
.
stringify
(
data
));
});
}
catch
(
exception
)
{
console
.
error
(
'
Failed to create virtual screen. Code:
'
+
JSON
.
stringify
(
exception
));
};
```
## screen.createVirtualScreen
...
...
@@ -298,22 +382,34 @@ createVirtualScreen(options:VirtualScreenOption): Promise<Screen>
| -------------------------------- | ------------------------------------- |
| Promise
<
[Screen](#screen)
>
| Promise对象。返回创建的虚拟屏幕对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
屏幕错误码
](
../errorcodes/errorcode-display.md
)
。
| 错误码ID | 错误信息 |
| ------- | ----------------------- |
| 1400001 | This is invalid screen. |
**示例:**
```
js
var
screenClass
=
null
;
screen
.
createVirtualScreen
({
let
screenClass
=
null
;
try
{
screen
.
createVirtualScreen
({
name
:
'
screen01
'
,
width
:
1080
,
height
:
2340
,
density
:
2
,
surfaceId
:
''
}).
then
((
data
)
=>
{
}).
then
((
data
)
=>
{
screenClass
=
data
;
console
.
info
(
'
Succeeded in creating virtual screen.Data:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to create virtual screen.Cause:
'
+
JSON
.
stringify
(
err
));
});
console
.
info
(
'
Succeeded in creating virtual screen. Data:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to create virtual screen. Code:
'
+
JSON
.
stringify
(
err
));
});
}
catch
(
exception
)
{
console
.
error
(
'
Failed to create virtual screen. Code:
'
+
JSON
.
stringify
(
exception
));
};
```
## screen.destroyVirtualScreen
...
...
@@ -331,17 +427,29 @@ destroyVirtualScreen(screenId:number, callback: AsyncCallback<void>): void
| screenId | number | 是 | 屏幕的id。 |
| callback | AsyncCallback
<
void
>
| 是 | 回调函数。当销毁虚拟屏幕成功,err为undefined,否则为错误对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
屏幕错误码
](
../errorcodes/errorcode-display.md
)
。
| 错误码ID | 错误信息 |
| ------- | ----------------------------- |
| 1400002 | This operation is not access. |
**示例:**
```
js
var
screenId
=
1
;
screen
.
destroyVirtualScreen
(
screenId
,
(
err
,
data
)
=>
{
let
screenId
=
1
;
try
{
screen
.
destroyVirtualScreen
(
screenId
,
(
err
,
data
)
=>
{
if
(
err
.
code
)
{
console
.
error
(
'
Failed to destroy virtual screen.Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to destroy virtual screen. Code:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
info
(
'
Succeeded in destroying virtual screen.
'
);
});
});
}
catch
(
exception
)
{
console
.
error
(
'
Failed to destroy virtual screen. Code:
'
+
JSON
.
stringify
(
exception
));
};
```
## screen.destroyVirtualScreen
...
...
@@ -364,15 +472,27 @@ destroyVirtualScreen(screenId:number): Promise<void>
| ------------------- | ------------------------- |
| Promise
<
void
>
| 无返回结果的Promise对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
屏幕错误码
](
../errorcodes/errorcode-display.md
)
。
| 错误码ID | 错误信息 |
| ------- | ----------------------------- |
| 1400002 | This operation is not access. |
**示例:**
```
js
var
screenId
=
1
;
screen
.
destroyVirtualScreen
(
screenId
).
then
((
data
)
=>
{
let
screenId
=
1
;
try
{
screen
.
destroyVirtualScreen
(
screenId
).
then
((
data
)
=>
{
console
.
info
(
'
Succeeded in destroying virtual screen.
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to destroy virtual screen.Cause:
'
+
JSON
.
stringify
(
err
));
});
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to destroy virtual screen. Code:
'
+
JSON
.
stringify
(
err
));
});
}
catch
(
exception
)
{
console
.
error
(
'
Failed to destroy virtual screen. Code:
'
+
JSON
.
stringify
(
exception
));
};
```
## screen.setVirtualScreenSurface
...
...
@@ -393,18 +513,30 @@ setVirtualScreenSurface(screenId:number, surfaceId: string, callback: AsyncCallb
| surfaceId | string | 是 | surface的id。 |
| callback | AsyncCallback
<
void
>
| 是 | 回调函数。当设置虚拟屏幕surface成功,err为undefined,否则为错误对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
屏幕错误码
](
../errorcodes/errorcode-display.md
)
。
| 错误码ID | 错误信息 |
| ------- | ----------------------- |
| 1400001 | This is invalid screen. |
**示例:**
```
js
var
screenId
=
1
;
var
surfaceId
=
'
2048
'
;
screen
.
setVirtualScreenSurface
(
screenId
,
surfaceId
,
(
err
,
data
)
=>
{
let
screenId
=
1
;
let
surfaceId
=
'
2048
'
;
try
{
screen
.
setVirtualScreenSurface
(
screenId
,
surfaceId
,
(
err
,
data
)
=>
{
if
(
err
.
code
)
{
console
.
error
(
'
Failed to Set surface for the virtual screen.Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to Set surface for the virtual screen. Code:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
info
(
'
Succeeded in setting surface for the virtual screen.
'
);
});
});
}
catch
(
exception
)
{
console
.
error
(
'
Failed to Set surface for the virtual screen. Code:
'
+
JSON
.
stringify
(
exception
));
};
```
## screen.setVirtualScreenSurface
...
...
@@ -430,16 +562,28 @@ setVirtualScreenSurface(screenId:number, surfaceId: string): Promise<void>
| ------------------- | ------------------------- |
| Promise
<
void
>
| 无返回结果的Promise对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
屏幕错误码
](
../errorcodes/errorcode-display.md
)
。
| 错误码ID | 错误信息 |
| ------- | ----------------------- |
| 1400001 | This is invalid screen. |
**示例:**
```
js
var
screenId
=
1
;
var
surfaceId
=
'
2048
'
;
screen
.
setVirtualScreenSurface
(
screenId
,
surfaceId
).
then
((
data
)
=>
{
let
screenId
=
1
;
let
surfaceId
=
'
2048
'
;
try
{
screen
.
setVirtualScreenSurface
(
screenId
,
surfaceId
).
then
((
data
)
=>
{
console
.
info
(
'
Succeeded in setting surface for the virtual screen.
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to Set surface for the virtual screen.Cause:
'
+
JSON
.
stringify
(
err
));
});
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to Set surface for the virtual screen. Code:
'
+
JSON
.
stringify
(
err
));
});
}
catch
(
exception
)
{
console
.
error
(
'
Failed to Set surface for the virtual screen. Code:
'
+
JSON
.
stringify
(
exception
));
};
```
## screen.isScreenRotationLocked
...
...
@@ -515,12 +659,16 @@ setScreenRotationLocked(isLocked: boolean): Promise<void>
**示例:**
```
js
var
isLocked
=
false
;
screen
.
setScreenRotationLocked
(
isLocked
).
then
((
data
)
=>
{
let
isLocked
=
false
;
try
{
screen
.
setScreenRotationLocked
(
isLocked
).
then
((
data
)
=>
{
console
.
info
(
'
Succeeded in setting whether to lock screen rotation
'
);
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to set whether to lock screen rotation. Cause:
'
+
JSON
.
stringify
(
err
));
});
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to set whether to lock screen rotation. Code:
'
+
JSON
.
stringify
(
err
));
});
}
catch
(
exception
)
{
console
.
error
(
'
Failed to set whether to lock screen rotation. Code:
'
+
JSON
.
stringify
(
exception
));
};
```
## screen.setScreenRotationLocked
...
...
@@ -541,14 +689,18 @@ setScreenRotationLocked(isLocked: boolean, callback: AsyncCallback<void>):
**示例:**
```
js
var
isLocked
=
false
;
screen
.
setScreenRotationLocked
(
isLocked
,
(
err
,
data
)
=>
{
let
isLocked
=
false
;
try
{
screen
.
setScreenRotationLocked
(
isLocked
,
(
err
,
data
)
=>
{
if
(
err
.
code
)
{
console
.
error
(
'
Failed to set whether to lock screen rotation. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
info
(
'
Succeeded in setting whether to lock screen rotation.
'
);
});
});
}
catch
(
exception
)
{
console
.
error
(
'
Failed to set whether to lock screen rotation. Code:
'
+
JSON
.
stringify
(
exception
));
};
```
## ExpandOption
...
...
@@ -606,16 +758,28 @@ setOrientation(orientation: Orientation, callback: AsyncCallback<void>): v
| orientation |
[
Orientation
](
#orientation
)
| 是 | 屏幕方向。 |
| callback | AsyncCallback
<
void
>
| 是 | 回调函数。当设置屏幕方向成功,err为undefined,否则为错误对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
屏幕错误码
](
../errorcodes/errorcode-display.md
)
。
| 错误码ID | 错误信息 |
| ------- | -------------------------------------------- |
| 1400003 | This window manager service work abnormally. |
**示例:**
```
js
screenClass
.
setOrientation
(
screen
.
Orientation
.
VERTICAL
,
(
err
,
data
)
=>
{
try
{
screenClass
.
setOrientation
(
screen
.
Orientation
.
VERTICAL
,
(
err
,
data
)
=>
{
if
(
err
.
code
)
{
console
.
error
(
'
Failed to setOrientation VERTICAL. Caus
e:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to set Orientation VERTICAL. Cod
e:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
info
(
'
Succeeded in setting Orientation VERTICAL. data:
'
+
JSON
.
stringify
(
data
));
})
});
}
catch
(
exception
)
{
console
.
error
(
'
Failed to set Orientation VERTICAL. Code:
'
+
JSON
.
stringify
(
exception
));
};
```
### setOrientation
...
...
@@ -636,15 +800,27 @@ setOrientation(orientation: Orientation): Promise<void>
| ------------------- | ------------------------- |
| Promise
<
void
>
| 无返回结果的Promise对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
屏幕错误码
](
../errorcodes/errorcode-display.md
)
。
| 错误码ID | 错误信息 |
| ------- | -------------------------------------------- |
| 1400003 | This window manager service work abnormally. |
**示例:**
```
js
let
promise
=
screenClass
.
setOrientation
(
screen
.
Orientation
.
VERTICAL
);
promise
.
then
((
data
)
=>
{
try
{
let
promise
=
screenClass
.
setOrientation
(
screen
.
Orientation
.
VERTICAL
);
promise
.
then
((
data
)
=>
{
console
.
info
(
'
Succeeded in setting Orientation VERTICAL. Data:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to set Orientation VERTICAL. Cause:
'
+
JSON
.
stringify
(
err
));
})
});
}
catch
(
exception
)
{
console
.
error
(
'
Failed to set Orientation VERTICAL. Code:
'
+
JSON
.
stringify
(
exception
));
};
```
### setScreenActiveMode
...
...
@@ -660,17 +836,29 @@ setScreenActiveMode(modeIndex: number, callback: AsyncCallback<void>): voi
| modeIndex | number | 是 | 模式索引。 |
| callback | AsyncCallback
<
void
>
| 是 | 回调函数。当设置屏幕当前显示模式成功,err为undefined,否则为错误对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
屏幕错误码
](
../errorcodes/errorcode-display.md
)
。
| 错误码ID | 错误信息 |
| ------- | -------------------------------------------- |
| 1400003 | This window manager service work abnormally. |
**示例:**
```
js
var
modeIndex
=
0
;
screenClass
.
setScreenActiveMode
(
modeIndex
,
(
err
,
data
)
=>
{
let
modeIndex
=
0
;
try
{
screenClass
.
setScreenActiveMode
(
modeIndex
,
(
err
,
data
)
=>
{
if
(
err
.
code
)
{
console
.
error
(
'
Failed to set ScreenActiveMode 0. Caus
e:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to set ScreenActiveMode 0. Cod
e:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
info
(
'
Succeeded in setting ScreenActiveMode 0. data:
'
+
JSON
.
stringify
(
data
));
})
});
}
catch
(
exception
)
{
console
.
error
(
'
Failed to set ScreenActiveMode 0. Code:
'
+
JSON
.
stringify
(
exception
));
};
```
### setScreenActiveMode
...
...
@@ -691,16 +879,28 @@ setScreenActiveMode(modeIndex: number): Promise<void>
| ------------------- | ------------------------- |
| Promise
<
void
>
| 无返回结果的Promise对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
屏幕错误码
](
../errorcodes/errorcode-display.md
)
。
| 错误码ID | 错误信息 |
| ------- | -------------------------------------------- |
| 1400003 | This window manager service work abnormally. |
**示例:**
```
js
var
modeIndex
=
0
;
let
promise
=
screenClass
.
setScreenActiveMode
(
modeIndex
);
promise
.
then
((
data
)
=>
{
let
modeIndex
=
0
;
try
{
let
promise
=
screenClass
.
setScreenActiveMode
(
modeIndex
);
promise
.
then
((
data
)
=>
{
console
.
info
(
'
Succeeded in setting ScreenActiveMode 0. Data:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to set ScreenActiveMode 0. Cause:
'
+
JSON
.
stringify
(
err
));
})
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to set ScreenActiveMode 0. Code:
'
+
JSON
.
stringify
(
err
));
});
}
catch
(
exception
)
{
console
.
error
(
'
Failed to set ScreenActiveMode 0. Code:
'
+
JSON
.
stringify
(
exception
));
};
```
### setDensityDpi
...
...
@@ -716,17 +916,29 @@ setDensityDpi(densityDpi: number, callback: AsyncCallback<void>): void;
| densityDpi | number | 是 | 像素密度。支持的输入范围为80-640。 |
| callback | AsyncCallback
<
void
>
| 是 | 回调函数。当设置屏幕的像素密度成功,err为undefined,否则为错误对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
屏幕错误码
](
../errorcodes/errorcode-display.md
)
。
| 错误码ID | 错误信息 |
| ------- | -------------------------------------------- |
| 1400003 | This window manager service work abnormally. |
**示例:**
```
js
var
densityDpi
=
320
;
screenClass
.
setDensityDpi
(
densityDpi
,
(
err
,
data
)
=>
{
let
densityDpi
=
320
;
try
{
screenClass
.
setDensityDpi
(
densityDpi
,
(
err
,
data
)
=>
{
if
(
err
.
code
)
{
console
.
error
(
'
Failed to set DensityDpi 320. Caus
e:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to set DensityDpi 320. Cod
e:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
info
(
'
Succeed in setting DensityDpi 320. data:
'
+
JSON
.
stringify
(
data
));
})
});
}
catch
(
exception
)
{
console
.
error
(
'
Failed to set DensityDpi 320. Code:
'
+
JSON
.
stringify
(
exception
));
};
```
### setDensityDpi
...
...
@@ -747,16 +959,28 @@ setDensityDpi(densityDpi: number): Promise<void>
| ------------------- | ------------------------- |
| Promise
<
void
>
| 无返回结果的Promise对象。 |
**错误码:**
以下错误码的详细介绍请参见
[
屏幕错误码
](
../errorcodes/errorcode-display.md
)
。
| 错误码ID | 错误信息 |
| ------- | -------------------------------------------- |
| 1400003 | This window manager service work abnormally. |
**示例:**
```
js
var
densityDpi
=
320
;
var
promise
=
screenClass
.
setDensityDpi
(
densityDpi
);
promise
.
then
((
data
)
=>
{
let
densityDpi
=
320
;
try
{
let
promise
=
screenClass
.
setDensityDpi
(
densityDpi
);
promise
.
then
((
data
)
=>
{
console
.
info
(
'
Succeeded in setting DensityDpi 320. Data:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to set DensityDpi 320. Cause:
'
+
JSON
.
stringify
(
err
));
})
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to set DensityDpi 320. Code:
'
+
JSON
.
stringify
(
err
));
});
}
catch
(
exception
)
{
console
.
error
(
'
Failed to set DensityDpi 320. Code:
'
+
JSON
.
stringify
(
exception
));
};
```
## Orientation
...
...
zh-cn/application-dev/reference/apis/js-apis-screenshot.md
浏览文件 @
37303588
...
...
@@ -73,7 +73,7 @@ save(options: ScreenshotOptions, callback: AsyncCallback<image.PixelMap>):
**示例:**
```
js
var
screenshotOptions
=
{
let
screenshotOptions
=
{
"
screenRect
"
:
{
"
left
"
:
200
,
"
top
"
:
100
,
...
...
@@ -85,14 +85,18 @@ save(options: ScreenshotOptions, callback: AsyncCallback<image.PixelMap>):
"
rotation
"
:
0
,
"
displayId
"
:
0
};
try
{
screenshot
.
save
(
screenshotOptions
,
(
err
,
pixelMap
)
=>
{
if
(
err
)
{
console
.
log
(
'
Failed to save screenshot
:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
Failed to save screenshot. Code
:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
log
(
'
Succeeded in saving sreenshot. Pixel bytes number:
'
+
pixelMap
.
getPixelBytesNumber
());
pixelMap
.
release
();
// PixelMap使用完后及时释放内存
});
}
catch
(
exception
)
{
console
.
error
(
'
Failed to save screenshot. Code:
'
+
JSON
.
stringify
(
exception
));
};
```
## screenshot.save
...
...
@@ -114,14 +118,18 @@ save(callback: AsyncCallback<image.PixelMap>): void
**示例:**
```
js
try
{
screenshot
.
save
((
err
,
pixelMap
)
=>
{
if
(
err
)
{
console
.
log
(
'
Failed to save screenshot
:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
Failed to save screenshot. Code
:
'
+
JSON
.
stringify
(
err
));
return
;
}
console
.
log
(
'
Succeeded in saving sreenshot. Pixel bytes number:
'
+
pixelMap
.
getPixelBytesNumber
());
pixelMap
.
release
();
// PixelMap使用完后及时释放内存
});
}
catch
(
exception
)
{
console
.
error
(
'
Failed to save screenshot. Code:
'
+
JSON
.
stringify
(
exception
));
};
```
## screenshot.save
...
...
@@ -149,7 +157,7 @@ save(options?: ScreenshotOptions): Promise<image.PixelMap>
**示例:**
```
js
var
screenshotOptions
=
{
let
screenshotOptions
=
{
"
screenRect
"
:
{
"
left
"
:
200
,
"
top
"
:
100
,
...
...
@@ -161,11 +169,15 @@ save(options?: ScreenshotOptions): Promise<image.PixelMap>
"
rotation
"
:
0
,
"
displayId
"
:
0
};
try
{
let
promise
=
screenshot
.
save
(
screenshotOptions
);
promise
.
then
((
pixelMap
)
=>
{
console
.
log
(
'
Succeeded in saving sreenshot. Pixel bytes number:
'
+
pixelMap
.
getPixelBytesNumber
());
pixelMap
.
release
();
// PixelMap使用完后及时释放内存
}).
catch
((
err
)
=>
{
console
.
log
(
'
Failed to save screenshot
:
'
+
JSON
.
stringify
(
err
));
console
.
log
(
'
Failed to save screenshot. Code
:
'
+
JSON
.
stringify
(
err
));
});
}
catch
(
exception
)
{
console
.
error
(
'
Failed to save screenshot. Code:
'
+
JSON
.
stringify
(
exception
));
};
```
zh-cn/application-dev/reference/apis/js-apis-window.md
浏览文件 @
37303588
因为 它太大了无法显示 source diff 。你可以改为
查看blob
。
zh-cn/application-dev/reference/errorcodes/errorcode-display.md
0 → 100755
浏览文件 @
37303588
# 屏幕错误码
## 1400001 无效虚拟屏
### 错误信息
This is invalid screen.
### 错误描述
当操作无效的虚拟屏时,会报此错误码。
### 可能原因
1.
虚拟屏未创建。
2.
虚拟屏已销毁。
### 处理步骤
1.
在操作虚拟屏前,检查该虚拟屏是否已经存在,确保已创建该虚拟屏。
2.
在操作虚拟屏前,检查虚拟屏是否已被销毁,确保其未被销毁,再进行相关操作。
## 1400002 无权限操作
### 错误信息
This operation is not access.
### 错误描述
当对无操作权限的对象进行操作时,会报此错误码。
### 可能原因
操作了其它进程的虚拟屏对象。
### 处理步骤
请检查是否非法操作了别的进程的对象,删除相关非法操作。
## 1400003 系统服务工作异常
### 错误信息
This window manager service work abnormally.
### 错误描述
当系统服务工作异常时,会报此错误码。
### 可能原因
1.
窗口内部服务没有正常启动。
2.
底层图形图像合成渲染异常。
### 处理步骤
系统服务内部工作异常,请稍候重试,或者重启设备尝试。
zh-cn/application-dev/reference/errorcodes/errorcode-window.md
0 → 100755
浏览文件 @
37303588
# 窗口错误码
## 1300001 重复操作
### 错误信息
This is repeat operation.
### 错误描述
当进行某些重复操作时,系统会报此错误码。
### 可能原因
创建的窗口已经存在时,再次创建该窗口会报错。
### 处理步骤
在创建窗口前,检查该窗口是否已经存在,确保为首次创建该窗口。
## 1300002 窗口状态异常
### 错误信息
This window state is abnormal.
### 错误描述
当窗口状态异常,如已被销毁时,操作该窗口,会报此错误码。
### 可能原因
操作窗口时,该窗口已被销毁。
### 处理步骤
在对窗口进行操作前,检查该窗口是否存在,确保其未被销毁,再进行相关操作。
## 1300003 系统服务工作异常
### 错误信息
This window manager service work abnormally.
### 错误描述
当系统服务工作异常时,会报此错误码。
### 可能原因
窗口内部服务没有正常启动。
### 处理步骤
系统服务内部工作异常,请稍候重试,或者重启设备尝试。
## 1300004 无权限操作
### 错误信息
This operation is not access.
### 错误描述
当对无操作权限的对象进行操作时,会报此错误码。
### 可能原因
操作了其它进程的窗口对象。
### 处理步骤
请检查是否非法操作了别的进程的对象,删除相关操作。
## 1300005 WindowStage异常
### 错误信息
This window stage is abnormal.
### 错误描述
当WindowStage异常,如已被销毁时,操作该WindowStage,会报此错误码。
### 可能原因
操作WindowStage时,该WindowStage已被销毁。
### 处理步骤
在对WindowStage进行操作前,检查该WindowStage是否存在,若已被销毁,请释放该WindowStage下的窗口。
## 1300006 窗口上下文异常
### 错误信息
This window context is abnormal.
### 错误描述
当窗口上下文异常,如已被销毁时,操作该窗口上下文,会报此错误码。
### 可能原因
操作窗口上下文时,该窗口上下文已被销毁。
### 处理步骤
在对窗口上下文进行操作前,检查该窗口上下文是否存在,确保其未被销毁,再进行相关操作。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录