Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
fa55bbb6
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,发现更多精彩内容 >>
未验证
提交
fa55bbb6
编写于
12月 08, 2022
作者:
葛
葛亚芳
提交者:
Gitee
12月 08, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update zh-cn/application-dev/windowmanager/system-window-stage.md.
Signed-off-by:
N
葛亚芳
<
geyafang@huawei.com
>
上级
3dd1d730
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
15 addition
and
14 deletion
+15
-14
zh-cn/application-dev/windowmanager/system-window-stage.md
zh-cn/application-dev/windowmanager/system-window-stage.md
+15
-14
未找到文件。
zh-cn/application-dev/windowmanager/system-window-stage.md
浏览文件 @
fa55bbb6
...
@@ -15,14 +15,14 @@
...
@@ -15,14 +15,14 @@
| 实例名 | 接口名 | 描述 |
| 实例名 | 接口名 | 描述 |
| -------- | -------- | -------- |
| -------- | -------- | -------- |
| window静态方法 | create
(ctx: Context, id: string, type: WindowType, callback: AsyncCallback
<
Window
>
): void | 创建窗口。
<br/>
-
`ctx`
:为应用上下文信息。当
`Context`
为
[
ServiceExtensionContext
](
../reference/apis/js-apis-inner-application-serviceExtensionContext.md
)
时,创建系统窗口。
<br/>
-
`type`
:为创建的窗口类型
。 |
| window静态方法 | create
Window(config: Configuration, callback: AsyncCallback
<Window>
): void | 创建子窗口或系统窗口。
<br/>
-
`config`
:创建窗口时的参数
。 |
| Window | res
etS
ize(width: number, height: number, callback: AsyncCallback
<
void
>
): void | 改变当前窗口大小。 |
| Window | resize(width: number, height: number, callback: AsyncCallback
<
void
>
): void | 改变当前窗口大小。 |
| Window | moveTo(x: number, y: number, callback: AsyncCallback
<
void
>
): void | 移动当前窗口位置。 |
| Window | move
Window
To(x: number, y: number, callback: AsyncCallback
<
void
>
): void | 移动当前窗口位置。 |
| Window |
load
Content(path: string, callback: AsyncCallback
<
void
>
): void | 为当前窗口加载具体页面。 |
| Window |
SetUI
Content(path: string, callback: AsyncCallback
<
void
>
): void | 为当前窗口加载具体页面。 |
| Window | show(callback: AsyncCallback
\<
void>): void | 显示当前窗口。 |
| Window | show
Window
(callback: AsyncCallback
\<
void>): void | 显示当前窗口。 |
| Window | on(type: 'touchOutside', callback: Callback
<
void
>
): void | 开启本窗口区域外的点击事件的监听。 |
| Window | on(type: 'touchOutside', callback: Callback
<
void
>
): void | 开启本窗口区域外的点击事件的监听。 |
| Window | hide (callback: AsyncCallback
\<
void>): void | 隐藏当前窗口。此接口为系统接口。 |
| Window | hide (callback: AsyncCallback
\<
void>): void | 隐藏当前窗口。此接口为系统接口。 |
| Window | destroy(callback: AsyncCallback
<
void
>
): void | 销毁当前窗口。 |
| Window | destroy
Window
(callback: AsyncCallback
<
void
>
): void | 销毁当前窗口。 |
## 开发步骤
## 开发步骤
...
@@ -33,7 +33,7 @@
...
@@ -33,7 +33,7 @@
1.
创建系统窗口。
1.
创建系统窗口。
在
[
ServiceExtensionContext
](
../reference/apis/js-apis-inner-application-serviceExtensionContext.md
)
下,使用
`window.create`
接口创建音量条系统窗口。
在
[
ServiceExtensionContext
](
../reference/apis/js-apis-inner-application-serviceExtensionContext.md
)
下,使用
`window.create
Window
`
接口创建音量条系统窗口。
2.
操作或设置系统窗口的属性。
2.
操作或设置系统窗口的属性。
...
@@ -41,11 +41,11 @@
...
@@ -41,11 +41,11 @@
3.
加载显示系统窗口的具体内容。
3.
加载显示系统窗口的具体内容。
通过
`
loadContent`
和
`sh
ow`
接口加载显示音量条窗口的具体内容。
通过
`
SetUIContent`
和
`showWind
ow`
接口加载显示音量条窗口的具体内容。
4.
隐藏/销毁系统窗口。
4.
隐藏/销毁系统窗口。
当不再需要音量条窗口时,可根据具体实现逻辑,使用
`hide`
接口或
`destroy`
接口对其进行隐藏或销毁。
当不再需要音量条窗口时,可根据具体实现逻辑,使用
`hide`
接口或
`destroy
Window
`
接口对其进行隐藏或销毁。
```
ts
```
ts
import
ExtensionContext
from
'
@ohos.application.ServiceExtensionAbility
'
;
import
ExtensionContext
from
'
@ohos.application.ServiceExtensionAbility
'
;
...
@@ -57,7 +57,8 @@ export default class ServiceExtensionAbility1 extends ExtensionContext {
...
@@ -57,7 +57,8 @@ export default class ServiceExtensionAbility1 extends ExtensionContext {
globalThis
.
abilityWant
=
want
;
globalThis
.
abilityWant
=
want
;
// 1.创建音量条窗口。
// 1.创建音量条窗口。
let
windowClass
=
null
;
let
windowClass
=
null
;
window
.
create
(
this
.
context
,
"
volume
"
,
window
.
WindowType
.
TYPE_VOLUME_OVERLAY
,
(
err
,
data
)
=>
{
let
config
=
{
name
:
"
volume
"
,
windowType
:
window
.
WindowType
.
TYPE_VOLUME_OVERLAY
,
ctx
:
this
.
context
};
window
.
createWindow
(
config
,
(
err
,
data
)
=>
{
if
(
err
.
code
)
{
if
(
err
.
code
)
{
console
.
error
(
'
Failed to create the volume window. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to create the volume window. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
return
;
...
@@ -65,14 +66,14 @@ export default class ServiceExtensionAbility1 extends ExtensionContext {
...
@@ -65,14 +66,14 @@ export default class ServiceExtensionAbility1 extends ExtensionContext {
console
.
info
(
'
Succeeded in creating the volume window.
'
)
console
.
info
(
'
Succeeded in creating the volume window.
'
)
windowClass
=
data
;
windowClass
=
data
;
// 2.创建音量条窗口成功之后,可以改变其大小、位置或设置背景色、亮度等属性。
// 2.创建音量条窗口成功之后,可以改变其大小、位置或设置背景色、亮度等属性。
windowClass
.
moveTo
(
300
,
300
,
(
err
)
=>
{
windowClass
.
move
Window
To
(
300
,
300
,
(
err
)
=>
{
if
(
err
.
code
)
{
if
(
err
.
code
)
{
console
.
error
(
'
Failed to move the window. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to move the window. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
return
;
}
}
console
.
info
(
'
Succeeded in moving the window.
'
);
console
.
info
(
'
Succeeded in moving the window.
'
);
});
});
windowClass
.
res
etSize
(
500
,
10
00
,
(
err
)
=>
{
windowClass
.
res
ize
(
500
,
5
00
,
(
err
)
=>
{
if
(
err
.
code
)
{
if
(
err
.
code
)
{
console
.
error
(
'
Failed to change the window size. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to change the window size. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
return
;
...
@@ -80,14 +81,14 @@ export default class ServiceExtensionAbility1 extends ExtensionContext {
...
@@ -80,14 +81,14 @@ export default class ServiceExtensionAbility1 extends ExtensionContext {
console
.
info
(
'
Succeeded in changing the window size.
'
);
console
.
info
(
'
Succeeded in changing the window size.
'
);
});
});
// 3.为音量条窗口加载对应的目标页面。
// 3.为音量条窗口加载对应的目标页面。
windowClass
.
load
Content
(
"
pages/page_volume
"
,
(
err
)
=>
{
windowClass
.
setUI
Content
(
"
pages/page_volume
"
,
(
err
)
=>
{
if
(
err
.
code
)
{
if
(
err
.
code
)
{
console
.
error
(
'
Failed to load the content. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to load the content. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
return
;
}
}
console
.
info
(
'
Succeeded in loading the content.
'
);
console
.
info
(
'
Succeeded in loading the content.
'
);
// 3.显示音量条窗口。
// 3.显示音量条窗口。
windowClass
.
show
((
err
)
=>
{
windowClass
.
show
Window
((
err
)
=>
{
if
(
err
.
code
)
{
if
(
err
.
code
)
{
console
.
error
(
'
Failed to show the window. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to show the window. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
return
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录