From 3bcb48d1f5f0817ab35e7b50458fb74336d9428c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=98=E6=B5=A9=E7=A8=8B?= <798994511@qq.com> Date: Thu, 3 Apr 2025 11:16:10 +0800 Subject: [PATCH 1/2] 1 --- .../main/ets/entryability/EntryAbility.ets | 38 +++++++++---------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets index 09ef9e4..19e0b10 100644 --- a/entry/src/main/ets/entryability/EntryAbility.ets +++ b/entry/src/main/ets/entryability/EntryAbility.ets @@ -23,19 +23,24 @@ export default class EntryAbility extends UIAbility { private curBp: string = ''; private updateBreakpoint(windowWidth: number): void { - let windowWidthVp = windowWidth / display.getDefaultDisplaySync().densityPixels; - let newBp: string = ''; - if (windowWidthVp < 600) { - newBp = 'sm'; - } else if (windowWidthVp < 840) { - newBp = 'md'; - } else { - newBp = 'lg'; - } - if (this.curBp !== newBp) { - this.curBp = newBp; - AppStorage.setOrCreate('currentBreakpoint', this.curBp); + try { + let windowWidthVp = windowWidth / display.getDefaultDisplaySync().densityPixels; + let newBp: string = ''; + if (windowWidthVp < 600) { + newBp = 'sm'; + } else if (windowWidthVp < 840) { + newBp = 'md'; + } else { + newBp = 'lg'; + } + if (this.curBp !== newBp) { + this.curBp = newBp; + AppStorage.setOrCreate('currentBreakpoint', this.curBp); + } + } catch (err) { + hilog.error(0x0000, 'EntryAbility', `An unexpected error occurred. Code: ${err.code}, message: ${err.message}`); } + } onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { @@ -44,15 +49,6 @@ export default class EntryAbility extends UIAbility { this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); } - onConfigurationUpdate(newConfig: Configuration): void { - let newColorMode: ConfigurationConstant.ColorMode = - newConfig.colorMode || ConfigurationConstant.ColorMode.COLOR_MODE_DARK; - let currentColorMode = AppStorage.get('systemColorMode'); - if (newColorMode !== currentColorMode) { - AppStorage.setOrCreate('systemColorMode', newColorMode); - } - } - onDestroy(): void { hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); } -- Gitee From 32b14bf09f68e0551903105b6b4c36a2d3418403 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=98=E6=B5=A9=E7=A8=8B?= <798994511@qq.com> Date: Thu, 3 Apr 2025 11:35:21 +0800 Subject: [PATCH 2/2] 1 --- entry/src/main/ets/entryability/EntryAbility.ets | 1 - 1 file changed, 1 deletion(-) diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets index 19e0b10..3a1f3c2 100644 --- a/entry/src/main/ets/entryability/EntryAbility.ets +++ b/entry/src/main/ets/entryability/EntryAbility.ets @@ -40,7 +40,6 @@ export default class EntryAbility extends UIAbility { } catch (err) { hilog.error(0x0000, 'EntryAbility', `An unexpected error occurred. Code: ${err.code}, message: ${err.message}`); } - } onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { -- Gitee