perf: 旧config移除简化

This commit is contained in:
status102
2025-06-04 15:29:53 +08:00
parent 4de88035be
commit 45765a3932
2 changed files with 11 additions and 3 deletions

View File

@@ -107,7 +107,7 @@ namespace MaaWpfGui.Helper
{
_logger.Information("Read global configuration key {Key} with current configuration value {Value}, configuration hit: {HasValue}, configuration value {Value}", key, value, true, value);
SetGlobalValue(key, value);
DeleteValue(key, out _);
DeleteValue(key);
return value;
}
@@ -170,6 +170,14 @@ namespace MaaWpfGui.Helper
public static bool ContainsKey(string key, bool isGlobal = false) => isGlobal ? _globalKvs.ContainsKey(key) : _kvs.ContainsKey(key);
/// <summary>
/// Deletes a configuration
/// </summary>
/// <param name="key">The configuration key.</param>
/// <returns>The return value of <see cref="Save"/>.</returns>
// ReSharper disable once UnusedMember.Global
public static bool DeleteValue(string key) => DeleteValue(key, out _);
/// <summary>
/// Deletes a configuration
/// </summary>

View File

@@ -364,7 +364,7 @@ namespace MaaWpfGui.ViewModels.UI
{
// TODO: 删除老数据节省 gui.json 的大小,后续版本可以删除
// var json = ConfigurationHelper.GetValue(ConfigurationKeys.DepotResult, string.Empty);
ConfigurationHelper.DeleteValue(ConfigurationKeys.DepotResult, out _);
ConfigurationHelper.DeleteValue(ConfigurationKeys.DepotResult);
var json = JsonDataHelper.Get(JsonDataKey.DepotData, string.Empty);
if (string.IsNullOrWhiteSpace(json))
{
@@ -644,7 +644,7 @@ namespace MaaWpfGui.ViewModels.UI
{
// TODO: 删除老数据节省 gui.json 的大小,后续版本可以删除
// var json = ConfigurationHelper.GetValue(ConfigurationKeys.OperBoxData, string.Empty);
ConfigurationHelper.DeleteValue(ConfigurationKeys.OperBoxData, out _);
ConfigurationHelper.DeleteValue(ConfigurationKeys.OperBoxData);
var json = JsonDataHelper.Get(JsonDataKey.OperBoxData, string.Empty);
if (string.IsNullOrWhiteSpace(json))
{