From 12f8c19e5464ac6a67a7c3130564cbbaf1cc4207 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=91=9B=E4=BA=9A=E8=8A=B3?= Date: Fri, 9 Sep 2022 07:40:00 +0000 Subject: [PATCH] =?UTF-8?q?application-window-fa.md=EF=BC=9AES6=E8=AF=AD?= =?UTF-8?q?=E6=B3=95=E4=BD=BF=E7=94=A8let=EF=BC=8C=E8=B6=85=E9=95=BF?= =?UTF-8?q?=E5=8F=98=E9=87=8F=E5=90=8D=E7=BC=A9=E5=86=99=EF=BC=8C=E6=98=8E?= =?UTF-8?q?=E7=A1=AEgetTopWindow=E8=8E=B7=E5=8F=96=E4=B8=BB=E7=AA=97?= =?UTF-8?q?=E5=8F=A3=E5=89=8D=E6=8F=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 葛亚芳 --- .../windowmanager/application-window-fa.md | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/zh-cn/application-dev/windowmanager/application-window-fa.md b/zh-cn/application-dev/windowmanager/application-window-fa.md index d52cad63b1..56c532b95b 100644 --- a/zh-cn/application-dev/windowmanager/application-window-fa.md +++ b/zh-cn/application-dev/windowmanager/application-window-fa.md @@ -55,7 +55,7 @@ ```js import window from '@ohos.window'; - var windowClass = null; + let windowClass = null; // 1.方式一:创建子窗口。 window.create("subWindow", window.WindowType.TYPE_APP, (err, data) => { if (err.code) { @@ -162,13 +162,17 @@ 1. 获取主窗口对象。 - 沉浸式能力需要在成功获取应用主窗口对象的前提下进行。使用`window.getTopWindow`接口来获取得到主窗口。 + > **说明:** + > + > 沉浸式能力需要在成功获取应用主窗口对象的前提下进行。 + > + > 确保应用内最后显示的窗口为主窗口,然后再使用`window.getTopWindow`接口来获取得到主窗口。 ```js import window from '@ohos.window'; - var mainWindowClass = null; + let mainWindowClass = null; // 1.获取主窗口 window.getTopWindow((err, data) => { if (err.code) { @@ -188,7 +192,7 @@ ```js // 2.实现沉浸式效果。方式一:设置窗口全屏显示。 - var isFullScreen = true; + let isFullScreen = true; mainWindowClass.setFullScreen(isFullScreen, (err, data) => { if (err.code) { console.error('Failed to enable the full-screen mode. Cause:' + JSON.stringify(err)); @@ -197,7 +201,7 @@ console.info('Succeeded in enabling the full-screen mode. Data: ' + JSON.stringify(data)); }); // 2.实现沉浸式效果。方式二:设置导航栏、状态栏不显示。 - var names = []; + let names = []; mainWindowClass.setSystemBarEnable(names, (err, data) => { if (err.code) { console.error('Failed to set the system bar to be visible. Cause:' + JSON.stringify(err)); @@ -207,7 +211,7 @@ }); // 2.实现沉浸式效果。 // 方式三:设置窗口为全屏布局,配合设置状态栏、导航栏的透明度、背景/文字颜色及高亮图标等属性,与主窗口显示保持协调一致。 - var isLayoutFullScreen = true; + let isLayoutFullScreen = true; mainWindowClass.setLayoutFullScreen(isLayoutFullScreen, (err, data) => { if (err.code) { console.error('Failed to set the window layout to full-screen mode. Cause:' + JSON.stringify(err)); @@ -215,7 +219,7 @@ } console.info('Succeeded in setting the window layout to full-screen mode. Data: ' + JSON.stringify(data)); }); - var SystemBarProperties = { + let sysBarProps = { statusBarColor: '#ff00ff', navigationBarColor: '#00ff00', // 以下两个属性从API Version7开始支持 @@ -225,7 +229,7 @@ statusBarContentColor: '#ffffff', navigationBarContentColor: '#ffffff' }; - mainWindowClass.setSystemBarProperties(SystemBarProperties, (err, data) => { + mainWindowClass.setSystemBarProperties(sysBarProps, (err, data) => { if (err.code) { console.error('Failed to set the system bar properties. Cause: ' + JSON.stringify(err)); return; -- GitLab