From e7a273e9c8a337efb46d2cfb2ab6f83e0833431b Mon Sep 17 00:00:00 2001 From: uye <99072975+ABA2396@users.noreply.github.com> Date: Mon, 21 Jul 2025 22:41:53 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E5=AE=A2=E6=88=B7?= =?UTF-8?q?=E7=AB=AF=E5=88=87=E6=8D=A2=E9=80=BB=E8=BE=91=EF=BC=8C=E5=AE=98?= =?UTF-8?q?=E6=9C=8DB=E6=9C=8D=E5=88=87=E6=8D=A2=E6=97=A0=E9=9C=80?= =?UTF-8?q?=E9=87=8D=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Settings/GameSettingsUserControlModel.cs | 34 +++++++++++++++++-- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/src/MaaWpfGui/ViewModels/UserControl/Settings/GameSettingsUserControlModel.cs b/src/MaaWpfGui/ViewModels/UserControl/Settings/GameSettingsUserControlModel.cs index 8e7882e448..467c9f8494 100644 --- a/src/MaaWpfGui/ViewModels/UserControl/Settings/GameSettingsUserControlModel.cs +++ b/src/MaaWpfGui/ViewModels/UserControl/Settings/GameSettingsUserControlModel.cs @@ -15,6 +15,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.Threading.Tasks; using MaaWpfGui.Constants; using MaaWpfGui.Helper; using MaaWpfGui.States; @@ -86,16 +87,43 @@ public class GameSettingsUserControlModel : PropertyChangedBase set { - SetAndNotify(ref _clientType, value); + var oldValue = _clientType; + if (!SetAndNotify(ref _clientType, value)) + { + return; + } + ConfigurationHelper.SetValue(ConfigurationKeys.ClientType, value); VersionUpdateSettings.ResourceInfoUpdate(); Instances.TaskQueueViewModel.UpdateStageList(); Instances.TaskQueueViewModel.UpdateDatePrompt(); - Instances.AsstProxy.LoadResource(); - SettingsViewModel.AskRestartToApplySettings(_clientType is "YoStarEN"); + + if (!NeedRestartAfterClientTypeChange(oldValue, value)) + { + return; + } + + Task.Run(() => + { + Instances.AsstProxy.LoadResource(); + }); + + SettingsViewModel.AskRestartToApplySettings(value is "YoStarEN"); } } + private static bool NeedRestartAfterClientTypeChange(string oldType, string newType) + { + if (string.IsNullOrEmpty(oldType) || oldType == newType) + { + return false; + } + + // 官服 <-> B服 之间切换不需要重启 + return (oldType != "Official" || newType != "Bilibili") && + (oldType != "Bilibili" || newType != "Official"); + } + private bool _deploymentWithPause = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.RoguelikeDeploymentWithPause, bool.FalseString)); public bool DeploymentWithPause