From aa2f15dbf30aaef75cfc7a2893972a0677cbd183 Mon Sep 17 00:00:00 2001 From: status102 <102887808+status102@users.noreply.github.com> Date: Mon, 19 Jan 2026 19:59:09 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20Config=20=E5=88=9B=E5=BB=BA=E5=92=8C?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E6=A3=80=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs b/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs index 15a4266084..8f301bb4a7 100644 --- a/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs +++ b/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs @@ -498,10 +498,16 @@ public class SettingsViewModel : Screen { get => _currentConfiguration; set { - SetAndNotify(ref _currentConfiguration, value); - ConfigurationHelper.SwitchConfiguration(value); - ConfigFactory.SwitchConfig(value); + bool ret = ConfigurationHelper.SwitchConfiguration(value); + ret &= ConfigFactory.SwitchConfig(value); + if (!ret) + { + ConfigurationHelper.SwitchConfiguration(_currentConfiguration); + ConfigFactory.SwitchConfig(_currentConfiguration); + return; + } + SetAndNotify(ref _currentConfiguration, value); Bootstrapper.ShutdownAndRestartWithoutArgs(); } } @@ -540,6 +546,8 @@ public class SettingsViewModel : Screen } else { + ConfigurationHelper.DeleteConfiguration(NewConfigurationName); + ConfigFactory.DeleteConfiguration(NewConfigurationName); var growlInfo = new GrowlInfo { IsCustom = true, Message = string.Format(LocalizationHelper.GetString("ConfigExists"), NewConfigurationName),