Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
74a2c60a
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看板
未验证
提交
74a2c60a
编写于
11月 11, 2022
作者:
O
openharmony_ci
提交者:
Gitee
11月 11, 2022
浏览文件
操作
浏览文件
下载
差异文件
!11375 删除多余的data打印
Merge pull request !11375 from leafly2021/0415_master
上级
f5a0f39f
8d2dc567
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
73 addition
and
73 deletion
+73
-73
zh-cn/application-dev/reference/apis/js-apis-window.md
zh-cn/application-dev/reference/apis/js-apis-window.md
+6
-6
zh-cn/application-dev/windowmanager/application-window-fa.md
zh-cn/application-dev/windowmanager/application-window-fa.md
+22
-22
zh-cn/application-dev/windowmanager/application-window-stage.md
...application-dev/windowmanager/application-window-stage.md
+35
-35
zh-cn/application-dev/windowmanager/system-window-stage.md
zh-cn/application-dev/windowmanager/system-window-stage.md
+10
-10
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-window.md
浏览文件 @
74a2c60a
...
@@ -1221,7 +1221,7 @@ windowClass.hide((err) => {
...
@@ -1221,7 +1221,7 @@ windowClass.hide((err) => {
console
.
error
(
'
Failed to hide the window. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to hide the window. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
return
;
}
}
console
.
info
(
'
Succeeded in hiding the window.
data:
'
+
JSON
.
stringify
(
data
)
);
console
.
info
(
'
Succeeded in hiding the window.
'
);
})
})
```
```
...
@@ -1329,7 +1329,7 @@ hideWithAnimation(): Promise<void>
...
@@ -1329,7 +1329,7 @@ hideWithAnimation(): Promise<void>
```
js
```
js
let
promise
=
windowClass
.
hideWithAnimation
();
let
promise
=
windowClass
.
hideWithAnimation
();
promise
.
then
(()
=>
{
promise
.
then
(()
=>
{
console
.
info
(
'
Succeeded in hiding the window with animation.
Data:
'
+
JSON
.
stringify
(
data
)
);
console
.
info
(
'
Succeeded in hiding the window with animation.
'
);
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
error
(
'
Failed to hide the window with animation. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to hide the window with animation. Cause:
'
+
JSON
.
stringify
(
err
));
})
})
...
@@ -1856,7 +1856,7 @@ try {
...
@@ -1856,7 +1856,7 @@ try {
getWindowAvoidArea(type: AvoidAreaType): AvoidArea
getWindowAvoidArea(type: AvoidAreaType): AvoidArea
获取窗口内容规避的区域
,如系统的系统栏区域、刘海屏区域、手势区域、软键盘区域等
。
获取窗口内容规避的区域
;如系统栏区域、刘海屏区域、手势区域、软键盘区域等与窗口内容重叠时,需要窗口内容避让的区域
。
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
...
@@ -4590,7 +4590,7 @@ promise.then((data)=> {
...
@@ -4590,7 +4590,7 @@ promise.then((data)=> {
getAvoidArea(type:
[
AvoidAreaType
](
#avoidareatype7
)
, callback: AsyncCallback
<
[AvoidArea](#avoidarea7)
>
): void
getAvoidArea(type:
[
AvoidAreaType
](
#avoidareatype7
)
, callback: AsyncCallback
<
[AvoidArea](#avoidarea7)
>
): void
获取窗口内容规避的区域
,如系统的系统栏区域、刘海屏区域、手势区域、软键盘区域等
。
获取窗口内容规避的区域
;如系统栏区域、刘海屏区域、手势区域、软键盘区域等与窗口内容重叠时,需要窗口内容避让的区域
。
> **说明:**
> **说明:**
>
>
...
@@ -4622,11 +4622,11 @@ windowClass.getAvoidArea(type, (err, data) => {
...
@@ -4622,11 +4622,11 @@ windowClass.getAvoidArea(type, (err, data) => {
getAvoidArea(type:
[
AvoidAreaType
](
#avoidareatype7
)
): Promise
<
[AvoidArea](#avoidarea7)
>
getAvoidArea(type:
[
AvoidAreaType
](
#avoidareatype7
)
): Promise
<
[AvoidArea](#avoidarea7)
>
获取窗口内容规避的区域
,如系统的系统栏区域、刘海屏区域、手势区域、软键盘区域等
。
获取窗口内容规避的区域
;如系统栏区域、刘海屏区域、手势区域、软键盘区域等与窗口内容重叠时,需要窗口内容避让的区域
。
> **说明:**
> **说明:**
>
>
> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[getWindow
Properties
()](#getwindowavoidarea9)。
> 从 API version 7开始支持,从API version 9开始废弃,推荐使用[getWindow
AvoidArea
()](#getwindowavoidarea9)。
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
**系统能力:**
SystemCapability.WindowManager.WindowManager.Core
...
...
zh-cn/application-dev/windowmanager/application-window-fa.md
浏览文件 @
74a2c60a
...
@@ -91,20 +91,20 @@
...
@@ -91,20 +91,20 @@
```
js
```
js
// 移动子窗口位置。
// 移动子窗口位置。
windowClass
.
moveTo
(
300
,
300
,
(
err
,
data
)
=>
{
windowClass
.
moveTo
(
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.
Data:
'
+
JSON
.
stringify
(
data
)
);
console
.
info
(
'
Succeeded in moving the window.
'
);
});
});
// 改变子窗口大小。
// 改变子窗口大小。
windowClass
.
resetSize
(
500
,
1000
,
(
err
,
data
)
=>
{
windowClass
.
resetSize
(
500
,
1000
,
(
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
;
}
}
console
.
info
(
'
Succeeded in changing the window size.
Data:
'
+
JSON
.
stringify
(
data
)
);
console
.
info
(
'
Succeeded in changing the window size.
'
);
});
});
```
```
...
@@ -114,19 +114,19 @@
...
@@ -114,19 +114,19 @@
```
js
```
js
// 为子窗口加载对应的目标页面。
// 为子窗口加载对应的目标页面。
windowClass
.
loadContent
(
"
pages/page2
"
,
(
err
,
data
)
=>
{
windowClass
.
loadContent
(
"
pages/page2
"
,
(
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.
Data:
'
+
JSON
.
stringify
(
data
)
);
console
.
info
(
'
Succeeded in loading the content.
'
);
// 显示子窗口。
// 显示子窗口。
windowClass
.
show
((
err
,
data
)
=>
{
windowClass
.
show
((
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
;
}
}
console
.
info
(
'
Succeeded in showing the window.
Data:
'
+
JSON
.
stringify
(
data
)
);
console
.
info
(
'
Succeeded in showing the window.
'
);
});
});
});
});
```
```
...
@@ -137,12 +137,12 @@
...
@@ -137,12 +137,12 @@
```
js
```
js
// 销毁子窗口。当不再需要某些子窗口时,可根据场景的具体实现逻辑,使用destroy接口销毁子窗口。
// 销毁子窗口。当不再需要某些子窗口时,可根据场景的具体实现逻辑,使用destroy接口销毁子窗口。
windowClass
.
destroy
((
err
,
data
)
=>
{
windowClass
.
destroy
((
err
)
=>
{
if
(
err
.
code
)
{
if
(
err
.
code
)
{
console
.
error
(
'
Failed to destroy the subwindow. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to destroy the subwindow. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
return
;
}
}
console
.
info
(
'
Succeeded in destroying the subwindow.
Data:
'
+
JSON
.
stringify
(
data
)
);
console
.
info
(
'
Succeeded in destroying the subwindow.
'
);
});
});
```
```
...
@@ -186,31 +186,31 @@
...
@@ -186,31 +186,31 @@
```
js
```
js
// 实现沉浸式效果。方式一:设置窗口全屏显示。
// 实现沉浸式效果。方式一:设置窗口全屏显示。
let
isFullScreen
=
true
;
let
isFullScreen
=
true
;
mainWindowClass
.
setFullScreen
(
isFullScreen
,
(
err
,
data
)
=>
{
mainWindowClass
.
setFullScreen
(
isFullScreen
,
(
err
)
=>
{
if
(
err
.
code
)
{
if
(
err
.
code
)
{
console
.
error
(
'
Failed to enable the full-screen mode. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to enable the full-screen mode. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
return
;
}
}
console
.
info
(
'
Succeeded in enabling the full-screen mode.
Data:
'
+
JSON
.
stringify
(
data
)
);
console
.
info
(
'
Succeeded in enabling the full-screen mode.
'
);
});
});
// 实现沉浸式效果。方式二:设置导航栏、状态栏不显示。
// 实现沉浸式效果。方式二:设置导航栏、状态栏不显示。
let
names
=
[];
let
names
=
[];
mainWindowClass
.
setSystemBarEnable
(
names
,
(
err
,
data
)
=>
{
mainWindowClass
.
setSystemBarEnable
(
names
,
(
err
)
=>
{
if
(
err
.
code
)
{
if
(
err
.
code
)
{
console
.
error
(
'
Failed to set the system bar to be visible. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to set the system bar to be visible. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
return
;
}
}
console
.
info
(
'
Succeeded in setting the system bar to be visible.
Data:
'
+
JSON
.
stringify
(
data
)
);
console
.
info
(
'
Succeeded in setting the system bar to be visible.
'
);
});
});
// 实现沉浸式效果。
// 实现沉浸式效果。
// 方式三:设置窗口为全屏布局,配合设置状态栏、导航栏的透明度、背景/文字颜色及高亮图标等属性,与主窗口显示保持协调一致。
// 方式三:设置窗口为全屏布局,配合设置状态栏、导航栏的透明度、背景/文字颜色及高亮图标等属性,与主窗口显示保持协调一致。
let
isLayoutFullScreen
=
true
;
let
isLayoutFullScreen
=
true
;
mainWindowClass
.
setLayoutFullScreen
(
isLayoutFullScreen
,
(
err
,
data
)
=>
{
mainWindowClass
.
setLayoutFullScreen
(
isLayoutFullScreen
,
(
err
)
=>
{
if
(
err
.
code
)
{
if
(
err
.
code
)
{
console
.
error
(
'
Failed to set the window layout to full-screen mode. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to set the window layout to full-screen mode. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
return
;
}
}
console
.
info
(
'
Succeeded in setting the window layout to full-screen mode.
Data:
'
+
JSON
.
stringify
(
data
)
);
console
.
info
(
'
Succeeded in setting the window layout to full-screen mode.
'
);
});
});
let
sysBarProps
=
{
let
sysBarProps
=
{
statusBarColor
:
'
#ff00ff
'
,
statusBarColor
:
'
#ff00ff
'
,
...
@@ -219,12 +219,12 @@
...
@@ -219,12 +219,12 @@
statusBarContentColor
:
'
#ffffff
'
,
statusBarContentColor
:
'
#ffffff
'
,
navigationBarContentColor
:
'
#ffffff
'
navigationBarContentColor
:
'
#ffffff
'
};
};
mainWindowClass
.
setSystemBarProperties
(
sysBarProps
,
(
err
,
data
)
=>
{
mainWindowClass
.
setSystemBarProperties
(
sysBarProps
,
(
err
)
=>
{
if
(
err
.
code
)
{
if
(
err
.
code
)
{
console
.
error
(
'
Failed to set the system bar properties. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to set the system bar properties. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
return
;
}
}
console
.
info
(
'
Succeeded in setting the system bar properties.
Data:
'
+
JSON
.
stringify
(
data
)
);
console
.
info
(
'
Succeeded in setting the system bar properties.
'
);
});
});
```
```
...
@@ -234,19 +234,19 @@
...
@@ -234,19 +234,19 @@
```
js
```
js
// 为沉浸式窗口加载对应的目标页面。
// 为沉浸式窗口加载对应的目标页面。
mainWindowClass
.
loadContent
(
"
pages/page3
"
,
(
err
,
data
)
=>
{
mainWindowClass
.
loadContent
(
"
pages/page3
"
,
(
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.
Data:
'
+
JSON
.
stringify
(
data
)
);
console
.
info
(
'
Succeeded in loading the content.
'
);
// 显示沉浸式窗口。
// 显示沉浸式窗口。
mainWindowClass
.
show
((
err
,
data
)
=>
{
mainWindowClass
.
show
((
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
;
}
}
console
.
info
(
'
Succeeded in showing the window.
Data:
'
+
JSON
.
stringify
(
data
)
);
console
.
info
(
'
Succeeded in showing the window.
'
);
});
});
});
});
```
```
\ No newline at end of file
zh-cn/application-dev/windowmanager/application-window-stage.md
浏览文件 @
74a2c60a
...
@@ -82,21 +82,21 @@ class MainAbility extends Ability {
...
@@ -82,21 +82,21 @@ class MainAbility extends Ability {
console
.
info
(
'
Succeeded in obtaining the main window. Data:
'
+
JSON
.
stringify
(
data
));
console
.
info
(
'
Succeeded in obtaining the main window. Data:
'
+
JSON
.
stringify
(
data
));
// 2.设置主窗口属性。以设置"是否可触"属性为例。
// 2.设置主窗口属性。以设置"是否可触"属性为例。
let
isTouchable
=
true
;
let
isTouchable
=
true
;
windowClass
.
setTouchable
(
isTouchable
,
(
err
,
data
)
=>
{
windowClass
.
setTouchable
(
isTouchable
,
(
err
)
=>
{
if
(
err
.
code
)
{
if
(
err
.
code
)
{
console
.
error
(
'
Failed to set the window to be touchable. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to set the window to be touchable. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
return
;
}
}
console
.
info
(
'
Succeeded in setting the window to be touchable.
Data:
'
+
JSON
.
stringify
(
data
)
);
console
.
info
(
'
Succeeded in setting the window to be touchable.
'
);
})
})
})
})
// 3.为主窗口加载对应的目标页面。
// 3.为主窗口加载对应的目标页面。
windowStage
.
loadContent
(
"
pages/page2
"
,
(
err
,
data
)
=>
{
windowStage
.
loadContent
(
"
pages/page2
"
,
(
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.
Data:
'
+
JSON
.
stringify
(
data
)
);
console
.
info
(
'
Succeeded in loading the content.
'
);
});
});
}
}
};
};
...
@@ -149,34 +149,34 @@ class MainAbility extends Ability {
...
@@ -149,34 +149,34 @@ class MainAbility extends Ability {
sub_windowClass
=
data
;
sub_windowClass
=
data
;
});
});
// 2.子窗口创建成功后,设置子窗口的位置、大小及相关属性等。
// 2.子窗口创建成功后,设置子窗口的位置、大小及相关属性等。
sub_windowClass
.
moveTo
(
300
,
300
,
(
err
,
data
)
=>
{
sub_windowClass
.
moveTo
(
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.
Data:
'
+
JSON
.
stringify
(
data
)
);
console
.
info
(
'
Succeeded in moving the window.
'
);
});
});
sub_windowClass
.
resetSize
(
500
,
1000
,
(
err
,
data
)
=>
{
sub_windowClass
.
resetSize
(
500
,
1000
,
(
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
;
}
}
console
.
info
(
'
Succeeded in changing the window size.
Data:
'
+
JSON
.
stringify
(
data
)
);
console
.
info
(
'
Succeeded in changing the window size.
'
);
});
});
// 3.为子窗口加载对应的目标页面。
// 3.为子窗口加载对应的目标页面。
sub_windowClass
.
loadContent
(
"
pages/page3
"
,
(
err
,
data
)
=>
{
sub_windowClass
.
loadContent
(
"
pages/page3
"
,
(
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.
Data:
'
+
JSON
.
stringify
(
data
)
);
console
.
info
(
'
Succeeded in loading the content.
'
);
// 3.显示子窗口。
// 3.显示子窗口。
sub_windowClass
.
show
((
err
,
data
)
=>
{
sub_windowClass
.
show
((
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
;
}
}
console
.
info
(
'
Succeeded in showing the window.
Data:
'
+
JSON
.
stringify
(
data
)
);
console
.
info
(
'
Succeeded in showing the window.
'
);
});
});
});
});
})
})
...
@@ -184,12 +184,12 @@ class MainAbility extends Ability {
...
@@ -184,12 +184,12 @@ class MainAbility extends Ability {
destroySubWindow
()
{
destroySubWindow
()
{
// 4.销毁子窗口。当不再需要子窗口时,可根据具体实现逻辑,使用destroy对其进行销毁。
// 4.销毁子窗口。当不再需要子窗口时,可根据具体实现逻辑,使用destroy对其进行销毁。
sub_windowClass
.
destroy
((
err
,
data
)
=>
{
sub_windowClass
.
destroy
((
err
)
=>
{
if
(
err
.
code
)
{
if
(
err
.
code
)
{
console
.
error
(
'
Failed to destroy the window. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to destroy the window. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
return
;
}
}
console
.
info
(
'
Succeeded in destroying the window.
Data:
'
+
JSON
.
stringify
(
data
)
);
console
.
info
(
'
Succeeded in destroying the window.
'
);
});
});
}
}
...
@@ -242,30 +242,30 @@ class MainAbility extends Ability {
...
@@ -242,30 +242,30 @@ class MainAbility extends Ability {
// 2.实现沉浸式效果。方式一:设置应用主窗口为全屏显示。
// 2.实现沉浸式效果。方式一:设置应用主窗口为全屏显示。
let
isFullScreen
=
true
;
let
isFullScreen
=
true
;
windowClass
.
setFullScreen
(
isFullScreen
,
(
err
,
data
)
=>
{
windowClass
.
setFullScreen
(
isFullScreen
,
(
err
)
=>
{
if
(
err
.
code
)
{
if
(
err
.
code
)
{
console
.
error
(
'
Failed to enable the full-screen mode. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to enable the full-screen mode. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
return
;
}
}
console
.
info
(
'
Succeeded in enabling the full-screen mode.
Data:
'
+
JSON
.
stringify
(
data
)
);
console
.
info
(
'
Succeeded in enabling the full-screen mode.
'
);
});
});
// 2.实现沉浸式效果。方式二:设置导航栏、状态栏不显示。
// 2.实现沉浸式效果。方式二:设置导航栏、状态栏不显示。
let
names
=
[];
let
names
=
[];
windowClass
.
setSystemBarEnable
(
names
,
(
err
,
data
)
=>
{
windowClass
.
setSystemBarEnable
(
names
,
(
err
)
=>
{
if
(
err
.
code
)
{
if
(
err
.
code
)
{
console
.
error
(
'
Failed to set the system bar to be visible. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to set the system bar to be visible. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
return
;
}
}
console
.
info
(
'
Succeeded in setting the system bar to be visible.
Data:
'
+
JSON
.
stringify
(
data
)
);
console
.
info
(
'
Succeeded in setting the system bar to be visible.
'
);
});
});
// 2.实现沉浸式效果。方式三:设置窗口为全屏布局,配合设置导航栏、状态栏的透明度、背景/文字颜色及高亮图标等属性,与主窗口显示保持协调一致。
// 2.实现沉浸式效果。方式三:设置窗口为全屏布局,配合设置导航栏、状态栏的透明度、背景/文字颜色及高亮图标等属性,与主窗口显示保持协调一致。
let
isLayoutFullScreen
=
true
;
let
isLayoutFullScreen
=
true
;
windowClass
.
setLayoutFullScreen
(
isLayoutFullScreen
,
(
err
,
data
)
=>
{
windowClass
.
setLayoutFullScreen
(
isLayoutFullScreen
,
(
err
)
=>
{
if
(
err
.
code
)
{
if
(
err
.
code
)
{
console
.
error
(
'
Failed to set the window layout to full-screen mode. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to set the window layout to full-screen mode. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
return
;
}
}
console
.
info
(
'
Succeeded in setting the window layout to full-screen mode.
Data:
'
+
JSON
.
stringify
(
data
)
);
console
.
info
(
'
Succeeded in setting the window layout to full-screen mode.
'
);
});
});
let
sysBarProps
=
{
let
sysBarProps
=
{
statusBarColor
:
'
#ff00ff
'
,
statusBarColor
:
'
#ff00ff
'
,
...
@@ -274,21 +274,21 @@ class MainAbility extends Ability {
...
@@ -274,21 +274,21 @@ class MainAbility extends Ability {
statusBarContentColor
:
'
#ffffff
'
,
statusBarContentColor
:
'
#ffffff
'
,
navigationBarContentColor
:
'
#ffffff
'
navigationBarContentColor
:
'
#ffffff
'
};
};
windowClass
.
setSystemBarProperties
(
sysBarProps
,
(
err
,
data
)
=>
{
windowClass
.
setSystemBarProperties
(
sysBarProps
,
(
err
)
=>
{
if
(
err
.
code
)
{
if
(
err
.
code
)
{
console
.
error
(
'
Failed to set the system bar properties. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to set the system bar properties. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
return
;
}
}
console
.
info
(
'
Succeeded in setting the system bar properties.
Data:
'
+
JSON
.
stringify
(
data
)
);
console
.
info
(
'
Succeeded in setting the system bar properties.
'
);
});
});
})
})
// 3.为沉浸式窗口加载对应的目标页面。
// 3.为沉浸式窗口加载对应的目标页面。
windowStage
.
loadContent
(
"
pages/page2
"
,
(
err
,
data
)
=>
{
windowStage
.
loadContent
(
"
pages/page2
"
,
(
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.
Data:
'
+
JSON
.
stringify
(
data
)
);
console
.
info
(
'
Succeeded in loading the content.
'
);
});
});
}
}
};
};
...
@@ -356,43 +356,43 @@ class MainAbility extends Ability {
...
@@ -356,43 +356,43 @@ class MainAbility extends Ability {
console
.
info
(
'
Succeeded in creating the floatWindow. Data:
'
+
JSON
.
stringify
(
data
));
console
.
info
(
'
Succeeded in creating the floatWindow. Data:
'
+
JSON
.
stringify
(
data
));
windowClass
=
data
;
windowClass
=
data
;
// 3.悬浮窗窗口创建成功后,设置悬浮窗的位置、大小及相关属性等。
// 3.悬浮窗窗口创建成功后,设置悬浮窗的位置、大小及相关属性等。
windowClass
.
moveTo
(
300
,
300
,
(
err
,
data
)
=>
{
windowClass
.
moveTo
(
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.
Data:
'
+
JSON
.
stringify
(
data
)
);
console
.
info
(
'
Succeeded in moving the window.
'
);
});
});
windowClass
.
resetSize
(
500
,
1000
,
(
err
,
data
)
=>
{
windowClass
.
resetSize
(
500
,
1000
,
(
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
;
}
}
console
.
info
(
'
Succeeded in changing the window size.
Data:
'
+
JSON
.
stringify
(
data
)
);
console
.
info
(
'
Succeeded in changing the window size.
'
);
});
});
// 4.为悬浮窗加载对应的目标页面。
// 4.为悬浮窗加载对应的目标页面。
windowClass
.
loadContent
(
"
pages/page4
"
,
(
err
,
data
)
=>
{
windowClass
.
loadContent
(
"
pages/page4
"
,
(
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.
Data:
'
+
JSON
.
stringify
(
data
)
);
console
.
info
(
'
Succeeded in loading the content.
'
);
// 4.显示悬浮窗。
// 4.显示悬浮窗。
windowClass
.
show
((
err
,
data
)
=>
{
windowClass
.
show
((
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
;
}
}
console
.
info
(
'
Succeeded in showing the window.
Data:
'
+
JSON
.
stringify
(
data
)
);
console
.
info
(
'
Succeeded in showing the window.
'
);
});
});
});
});
//5.销毁悬浮窗。当不再需要悬浮窗时,可根据具体实现逻辑,使用destroy对其进行销毁。
//5.销毁悬浮窗。当不再需要悬浮窗时,可根据具体实现逻辑,使用destroy对其进行销毁。
windowClass
.
destroy
((
err
,
data
)
=>
{
windowClass
.
destroy
((
err
)
=>
{
if
(
err
.
code
)
{
if
(
err
.
code
)
{
console
.
error
(
'
Failed to destroy the window. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to destroy the window. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
return
;
}
}
console
.
info
(
'
Succeeded in destroying the window.
Data:
'
+
JSON
.
stringify
(
data
)
);
console
.
info
(
'
Succeeded in destroying the window.
'
);
});
});
});
});
}
}
...
...
zh-cn/application-dev/windowmanager/system-window-stage.md
浏览文件 @
74a2c60a
...
@@ -65,46 +65,46 @@ export default class ServiceExtensionAbility1 extends ExtensionContext {
...
@@ -65,46 +65,46 @@ 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
,
data
)
=>
{
windowClass
.
moveTo
(
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.
Data:
'
+
JSON
.
stringify
(
data
)
);
console
.
info
(
'
Succeeded in moving the window.
'
);
});
});
windowClass
.
resetSize
(
500
,
1000
,
(
err
,
data
)
=>
{
windowClass
.
resetSize
(
500
,
1000
,
(
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
;
}
}
console
.
info
(
'
Succeeded in changing the window size.
Data:
'
+
JSON
.
stringify
(
data
)
);
console
.
info
(
'
Succeeded in changing the window size.
'
);
});
});
// 3.为音量条窗口加载对应的目标页面。
// 3.为音量条窗口加载对应的目标页面。
windowClass
.
loadContent
(
"
pages/page_volume
"
,
(
err
,
data
)
=>
{
windowClass
.
loadContent
(
"
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.
Data:
'
+
JSON
.
stringify
(
data
)
);
console
.
info
(
'
Succeeded in loading the content.
'
);
// 3.显示音量条窗口。
// 3.显示音量条窗口。
windowClass
.
show
((
err
,
data
)
=>
{
windowClass
.
show
((
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
;
}
}
console
.
info
(
'
Succeeded in showing the window.
Data:
'
+
JSON
.
stringify
(
data
)
);
console
.
info
(
'
Succeeded in showing the window.
'
);
});
});
});
});
// 4.隐藏/销毁音量条窗口。当不再需要音量条时,可根据具体实现逻辑,对其进行隐藏或销毁。
// 4.隐藏/销毁音量条窗口。当不再需要音量条时,可根据具体实现逻辑,对其进行隐藏或销毁。
// 此处以监听音量条区域外的点击事件为例实现音量条窗口的隐藏。
// 此处以监听音量条区域外的点击事件为例实现音量条窗口的隐藏。
windowClass
.
on
(
'
touchOutside
'
,
()
=>
{
windowClass
.
on
(
'
touchOutside
'
,
()
=>
{
console
.
info
(
'
touch outside
'
);
console
.
info
(
'
touch outside
'
);
windowClass
.
hide
((
err
,
data
)
=>
{
windowClass
.
hide
((
err
)
=>
{
if
(
err
.
code
)
{
if
(
err
.
code
)
{
console
.
error
(
'
Failed to hide the window. Cause:
'
+
JSON
.
stringify
(
err
));
console
.
error
(
'
Failed to hide the window. Cause:
'
+
JSON
.
stringify
(
err
));
return
;
return
;
}
}
console
.
info
(
'
Succeeded in hidinging the window.
Data:
'
+
JSON
.
stringify
(
data
)
);
console
.
info
(
'
Succeeded in hidinging the window.
'
);
});
});
});
});
});
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录