From 309469908a9ddfa0b7c0b4b636dc365480d1766e Mon Sep 17 00:00:00 2001 From: wpp <58198665+879356503@users.noreply.github.com> Date: Tue, 22 Apr 2025 21:57:24 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=84=E8=8C=83=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/ets/entryability/EntryAbility.ets | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets index 38b535e..51b3851 100644 --- a/entry/src/main/ets/entryability/EntryAbility.ets +++ b/entry/src/main/ets/entryability/EntryAbility.ets @@ -65,9 +65,16 @@ export default class EntryAbility extends UIAbility { let topRectHeight = avoidArea.topRect.height; AppStorage.setOrCreate('topRectHeight', topRectHeight); this.updateBreakpoint(windowObj.getWindowProperties().windowRect.width); + windowObj.on('windowSizeChange', (windowSize) => { this.updateBreakpoint(windowSize.width); }); + + windowObj.setWindowLayoutFullScreen(true).then(() => { + hilog.info(0x0000, 'testTag', '%{public}s', 'Succeeded in setting the window layout to full-screen mode.'); + }).catch((err: BusinessError) => { + hilog.error(0x0000, 'testTag', `Failed to set the window layout to full-screen mode. Cause: ${err.message}`); + }); } catch (err) { hilog.error(0x0000, 'testTag', '%{public}s', `config window fail. Cause: ${err.code}`); } @@ -84,18 +91,7 @@ export default class EntryAbility extends UIAbility { hilog.error(0x0000, 'testTag', '%{public}s', `Failed to load the content. Cause: ${err.code}`); return; } - try { - let windowClass: window.Window = windowStage.getMainWindowSync(); - let isLayoutFullScreen = true; - windowClass.setWindowLayoutFullScreen(isLayoutFullScreen).then(() => { - hilog.info(0x0000, 'testTag', '%{public}s', 'Succeeded in setting the window layout to full-screen mode.'); - }).catch((err: BusinessError) => { - hilog.error(0x0000, 'testTag', `Failed to set the window layout to full-screen mode. Cause: ${err.message}`); - }); - } catch (err) { - hilog.error(0x0000, 'testTag', '%{public}s', - `Failed to set the window layout to full-screen mode. ${err.code}`); - } + hilog.info(0x0000, 'testTag', '%{public}s', `Succeed in loading the content.`); }); } -- Gitee