diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets index 38b535e8a8cfbfff21ea13178fed20f0096c9d47..51b3851f4a9c0d20d912afe86eae0116c6e3e9da 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.`); }); }