From 577fa44db08c612d26f9e359b7c8ef909b435c87 Mon Sep 17 00:00:00 2001 From: wpp <58198665+879356503@users.noreply.github.com> Date: Fri, 18 Apr 2025 19:20:44 +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 | 30 ++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets index bf6ca96..ef952b2 100644 --- a/entry/src/main/ets/entryability/EntryAbility.ets +++ b/entry/src/main/ets/entryability/EntryAbility.ets @@ -44,7 +44,7 @@ export default class EntryAbility extends UIAbility { } } - onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + onCreate(): void { hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); AppStorage.setOrCreate('systemColorMode', this.context.config.colorMode); this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); @@ -80,9 +80,12 @@ export default class EntryAbility extends UIAbility { this.updateBreakpoint(windowSize.width); }); } catch (error) { - const err = error as BusinessError; - hilog.error(0x000, '[EntryAbility]', `onWindowStageCreate catch err, code: ${err.code}, message:${err.message}`); + const err = error as BusinessError; + hilog.error(0x000, '[EntryAbility]', + `onWindowStageCreate catch err, code: ${err.code}, message:${err.message}`); } + }).catch((err: BusinessError) => { + hilog.error(0x0000, 'testTag', `Failed to get main window. Cause:`, err.message); }); // Main window is created, set main page for this ability hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); @@ -95,14 +98,19 @@ export default class EntryAbility extends UIAbility { return; } hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); - 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, err code: ${err.code}, message: ${err.message}}`); - }); + 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, err code: ${err.code}, message: ${err.message}}`); + }); + } catch (error) { + hilog.error(0x0000, 'testTag', '%{public}s', + `onWindowStageCreate failed. Cause code: ${error.code}, message: ${error.message}`); + } }); } -- Gitee