From a25620abf2a93dedccae70649ddee3dea883560e Mon Sep 17 00:00:00 2001 From: wpp <58198665+879356503@users.noreply.github.com> Date: Fri, 18 Apr 2025 19:41:18 +0800 Subject: [PATCH 1/2] =?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 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets index e365757..b7dc3a1 100644 --- a/entry/src/main/ets/entryability/EntryAbility.ets +++ b/entry/src/main/ets/entryability/EntryAbility.ets @@ -48,12 +48,14 @@ export default class EntryAbility extends UIAbility { this.updateBreakpoint(windowObj.getWindowProperties().windowRect.width); windowObj.on('windowSizeChange', (windowSize) => { this.updateBreakpoint(windowSize.width); - }) + }); } catch (error) { const err: BusinessError = error as BusinessError; hilog.error(0x0000, TAG, 'get window info catch err: Cause: %{public}s', `the code is ${err.code}, the message is ${err.message}`); } + }).catch((err: BusinessError) => { + hilog.error(0x0000, 'testTag', `Failed to get main window. Cause:`, err.message); }); windowStage.loadContent('pages/Index', (err, _data) => { if (err.code) { -- Gitee From 5f3a85e4fb9e3ce58e6505a3c05775437553d9dd Mon Sep 17 00:00:00 2001 From: wpp <58198665+879356503@users.noreply.github.com> Date: Fri, 18 Apr 2025 19:43:35 +0800 Subject: [PATCH 2/2] =?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 --- .../main/ets/entryability/EntryAbility.ets | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets index b7dc3a1..024c30e 100644 --- a/entry/src/main/ets/entryability/EntryAbility.ets +++ b/entry/src/main/ets/entryability/EntryAbility.ets @@ -63,16 +63,21 @@ export default class EntryAbility extends UIAbility { `the code is ${err.code}, the message is ${err.message}`); return; } - this.setWindowClass(windowStage); - hilog.info(0x0000, TAG, '%{public}s', 'Succeeded in loading the content.'); - let windowClass: window.Window = windowStage.getMainWindowSync(); - let isLayoutFullScreen = true; - windowClass.setWindowLayoutFullScreen(isLayoutFullScreen).then(() => { - hilog.info(0x0000, TAG, '%{public}s', 'Succeeded in setting the window layout to full-screen mode.'); - }).catch((err: BusinessError) => { - hilog.error(0x0000, TAG, 'Failed to set the window layout to full-screen mode. Cause: %{public}s', - `the code is ${err.code}, the message is ${err.message}`); - }); + try { + this.setWindowClass(windowStage); + hilog.info(0x0000, TAG, '%{public}s', 'Succeeded in loading the content.'); + let windowClass: window.Window = windowStage.getMainWindowSync(); + let isLayoutFullScreen = true; + windowClass.setWindowLayoutFullScreen(isLayoutFullScreen).then(() => { + hilog.info(0x0000, TAG, '%{public}s', 'Succeeded in setting the window layout to full-screen mode.'); + }).catch((err: BusinessError) => { + hilog.error(0x0000, TAG, 'Failed to set the window layout to full-screen mode. Cause: %{public}s', + `the code is ${err.code}, the message is ${err.message}`); + }); + } catch (err) { + hilog.error(0x0000, TAG, + `onWindowStageCreate failed. code: ${(err as BusinessError).code}, message: ${(err as BusinessError).message}`); + } }); } -- Gitee