From 2e5aa7afb866ee9f899a4e552db246db88e802dc Mon Sep 17 00:00:00 2001 From: wpp <58198665+879356503@users.noreply.github.com> Date: Fri, 18 Apr 2025 19:59:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E8=A7=84=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/src/main/ets/entryability/EntryAbility.ets | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets index 0da01c6..595a743 100644 --- a/entry/src/main/ets/entryability/EntryAbility.ets +++ b/entry/src/main/ets/entryability/EntryAbility.ets @@ -67,12 +67,12 @@ export default class EntryAbility extends UIAbility { // Main window is created, set main page for this ability hilog.info(0x0000, TAG, '%{public}s', 'Ability onWindowStageCreate'); windowStage.getMainWindow().then((windowObj: window.Window) => { - let type: window.AvoidAreaType = window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR; - let avoidArea: window.AvoidArea = windowObj.getWindowAvoidArea(type); - let bottomRectHeight: number = avoidArea.bottomRect.height; - AppStorage.setOrCreate('bottomRectHeight', bottomRectHeight); - this.updateBreakpoint(windowObj.getWindowProperties().windowRect.width); try { + let type: window.AvoidAreaType = window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR; + let avoidArea: window.AvoidArea = windowObj.getWindowAvoidArea(type); + let bottomRectHeight: number = avoidArea.bottomRect.height; + AppStorage.setOrCreate('bottomRectHeight', bottomRectHeight); + this.updateBreakpoint(windowObj.getWindowProperties().windowRect.width); windowObj.on('windowSizeChange', (windowSize) => { this.updateBreakpoint(windowSize.width); }); @@ -92,7 +92,9 @@ export default class EntryAbility extends UIAbility { hilog.error(0x0000, TAG, '%{public}s', `onWindowStageCreate failed. Cause code: ${error.code}, message: ${error.message}`); } - }) + }).catch((err: BusinessError) => { + hilog.error(0x0000, TAG, `Failed to get main window. Cause:`, err.message); + }); } onWindowStageDestroy(): void { -- Gitee