From 3a79d9b455d3c4b61cbcf94a47084aa0ae859c37 Mon Sep 17 00:00:00 2001 From: kuangning <2540487435@qq.com> Date: Fri, 23 May 2025 16:59:31 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4json=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E6=B3=A8=E9=87=8A=EF=BC=8C=E6=B7=BB=E5=8A=A0=E5=9C=A8=E6=B7=B1?= =?UTF-8?q?=E8=89=B2=E6=A8=A1=E5=BC=8F=E5=88=87=E6=8D=A2=E4=B8=8B=E5=A6=82?= =?UTF-8?q?=E4=BD=95=E9=80=82=E9=85=8D=E7=8A=B6=E6=80=81=E6=A0=8F=E9=A2=9C?= =?UTF-8?q?=E8=89=B2=E9=83=A8=E5=88=86=E7=89=87=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/ets/entryability/MyAbilityStage.ets | 38 +++++++++++++++++++ .../main/resources/en_US/element/string.json | 23 +---------- .../main/resources/zh_CN/element/string.json | 23 +---------- 3 files changed, 40 insertions(+), 44 deletions(-) create mode 100644 ArkUI/entry/src/main/ets/entryability/MyAbilityStage.ets diff --git a/ArkUI/entry/src/main/ets/entryability/MyAbilityStage.ets b/ArkUI/entry/src/main/ets/entryability/MyAbilityStage.ets new file mode 100644 index 00000000..a4ccd99b --- /dev/null +++ b/ArkUI/entry/src/main/ets/entryability/MyAbilityStage.ets @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* +* FAQ:在深色模式切换下如何适配状态栏颜色? +*/ + +import { AbilityStage, Configuration, ConfigurationConstant } from '@kit.AbilityKit'; + + +class MyAbilityStage extends AbilityStage { + // [Start dark_mode_switch_status_bar_color_ability_stage] + // EntryAbility.ets + + // 监听系统配置变更 + onConfigurationUpdate(newConfig: Configuration): void { + let newColorMode = newConfig.colorMode; + let currentColorMode = AppStorage.get('currentColorMode'); + if (newColorMode === currentColorMode) { + return; + } + // 更新缓存中的颜色模式 + AppStorage.setOrCreate('currentColorMode', newConfig.colorMode); + } + // [End dark_mode_switch_status_bar_color_ability_stage] +} \ No newline at end of file diff --git a/ArkUI/entry/src/main/resources/en_US/element/string.json b/ArkUI/entry/src/main/resources/en_US/element/string.json index bb8992fc..5bfed3b1 100644 --- a/ArkUI/entry/src/main/resources/en_US/element/string.json +++ b/ArkUI/entry/src/main/resources/en_US/element/string.json @@ -1,23 +1,3 @@ -/* -* Copyright (c) 2024 Huawei Device Co., Ltd. -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* -* FAQ:ArkUI组件的字符串中如何实现字符串变量拼接 -*/ - -// [Start implementing_string_variable_concatenation_three] { "string": [ { @@ -33,5 +13,4 @@ "value": "label" } ] -} -// [End implementing_string_variable_concatenation_three] \ No newline at end of file +} \ No newline at end of file diff --git a/ArkUI/entry/src/main/resources/zh_CN/element/string.json b/ArkUI/entry/src/main/resources/zh_CN/element/string.json index 5d385d52..a4518a25 100644 --- a/ArkUI/entry/src/main/resources/zh_CN/element/string.json +++ b/ArkUI/entry/src/main/resources/zh_CN/element/string.json @@ -1,23 +1,3 @@ -/* -* Copyright (c) 2024 Huawei Device Co., Ltd. -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -/* -* FAQ:ArkUI组件的字符串中如何实现字符串变量拼接 -*/ - -// [Start implementing_string_variable_concatenation_two] { "string": [ { @@ -33,5 +13,4 @@ "value": "label" } ] -} -// [Start implementing_string_variable_concatenation_two] \ No newline at end of file +} \ No newline at end of file -- Gitee