perf: 优化客户端切换逻辑,官服B服切换无需重载

This commit is contained in:
uye
2025-07-21 22:41:53 +08:00
parent e4bee97168
commit e7a273e9c8

View File

@@ -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