From 5a0222cf7b11df35895e17125eb2f4be558712e2 Mon Sep 17 00:00:00 2001 From: rex <1491721419@qq.com> Date: Thu, 30 Oct 2025 15:09:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8F=98=E9=87=8F=E5=90=8D?= =?UTF-8?q?=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EntryAbilityExtactScreenAdaption.ets | 14 +++++++++----- .../main/ets/pages/ExcavationScreenAdaptation.ets | 3 +-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/ArkUI/entry/src/main/ets/entryability/EntryAbilityExtactScreenAdaption.ets b/ArkUI/entry/src/main/ets/entryability/EntryAbilityExtactScreenAdaption.ets index 48d7c5c..9a063bb 100644 --- a/ArkUI/entry/src/main/ets/entryability/EntryAbilityExtactScreenAdaption.ets +++ b/ArkUI/entry/src/main/ets/entryability/EntryAbilityExtactScreenAdaption.ets @@ -26,7 +26,11 @@ const DOMAIN = 0x0000; export default class EntryAbility extends UIAbility { onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + try { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + } catch (err) { + hilog.error(DOMAIN, 'testTag', 'Failed to set colorMode. Cause: %{public}s', JSON.stringify(err)); + } hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate'); } @@ -36,10 +40,10 @@ export default class EntryAbility extends UIAbility { // [Start extract_screen_adaption] onWindowStageCreate(windowStage: window.WindowStage): void { - AppStorage.setOrCreate('context', windowStage); - windowStage.getMainWindow((err: BusinessError, data) => { + AppStorage.setOrCreate('context', this.context); + windowStage.getMainWindow((err: BusinessError, window: window.Window) => { // The settings window is displayed in full screen - data.setWindowLayoutFullScreen(true) + window.setWindowLayoutFullScreen(true) .then(() => { console.info('Succeeded in setting the window layout to full-screen mode.'); }).catch((err: BusinessError) => { @@ -47,7 +51,7 @@ export default class EntryAbility extends UIAbility { }); // Set the top status bar to be hidden let names: Array<'status' | 'navigation'> = []; - data.setWindowSystemBarEnable(names) + window.setWindowSystemBarEnable(names) .then(() => { console.info('Succeeded in setting the system bar to be invisible.'); }).catch((err: BusinessError) => { diff --git a/ArkUI/entry/src/main/ets/pages/ExcavationScreenAdaptation.ets b/ArkUI/entry/src/main/ets/pages/ExcavationScreenAdaptation.ets index 6635c82..84c02f9 100644 --- a/ArkUI/entry/src/main/ets/pages/ExcavationScreenAdaptation.ets +++ b/ArkUI/entry/src/main/ets/pages/ExcavationScreenAdaptation.ets @@ -37,8 +37,7 @@ struct Index { @State screenWidth: number = 0; // Screen width @State displayClass: display.Display | null = null; @State topTextMargin: TextMargin = { left: 0, right: 0 }; // Top status bar offset - @StorageLink('context') context: common.UIAbilityContext | undefined = - AppStorage.get('context'); // Get UIAbilityContext + @StorageLink('context') context: common.UIAbilityContext | undefined = AppStorage.get('context'); // Get UIAbilityContext aboutToAppear(): void { try { -- Gitee