From 4fd41b26f93ae43fe1a48c21f677752db1c6aea2 Mon Sep 17 00:00:00 2001 From: uye <99072975+ABA2396@users.noreply.github.com> Date: Sun, 17 Sep 2023 15:41:48 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E5=85=A8=E5=B1=80=E9=80=89=E9=A1=B9?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E5=87=8F=E5=B0=91=E5=B5=8C=E5=A5=97=EF=BC=8C?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MaaWpfGui/Helper/ConfigurationHelper.cs | 25 +++++++++++---------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/MaaWpfGui/Helper/ConfigurationHelper.cs b/src/MaaWpfGui/Helper/ConfigurationHelper.cs index 4335e9f6dd..58c8ed535a 100644 --- a/src/MaaWpfGui/Helper/ConfigurationHelper.cs +++ b/src/MaaWpfGui/Helper/ConfigurationHelper.cs @@ -63,21 +63,22 @@ namespace MaaWpfGui.Helper { var hasValue = _globalKvs.TryGetValue(key, out var value); _logger.Debug("Read global configuration key {Key} with default value {DefaultValue}, configuration hit: {HasValue}, configuration value {Value}", key, defaultValue, hasValue, value); - if (!hasValue) + if (hasValue) { - hasValue = _kvs.TryGetValue(key, out value); - if (hasValue) - { - _logger.Debug("Read global configuration key {Key} with current configuration value {Value}, configuration hit: {HasValue}, configuration value {Value}", key, value, hasValue, value); - SetGlobalValue(key, value); - return value; - } - - SetGlobalValue(key, defaultValue); - return defaultValue; + return value; } - return value; + hasValue = _kvs.TryGetValue(key, out value); + if (hasValue) + { + _logger.Information("Read global configuration key {Key} with current configuration value {Value}, configuration hit: {HasValue}, configuration value {Value}", key, value, hasValue, value); + SetGlobalValue(key, value); + return value; + } + + // 保证有全局配置 + SetGlobalValue(key, defaultValue); + return defaultValue; } ///