diff --git a/v2rayN/ServiceLib/Manager/ActionPrecheckManager.cs b/v2rayN/ServiceLib/Manager/ActionPrecheckManager.cs index 15c14d07..8d7077f1 100644 --- a/v2rayN/ServiceLib/Manager/ActionPrecheckManager.cs +++ b/v2rayN/ServiceLib/Manager/ActionPrecheckManager.cs @@ -10,7 +10,7 @@ public class ActionPrecheckManager(Config config) private readonly Config _config = config; - public async Task> CheckBeforeSetActive(string? indexId) + public async Task> Check(string? indexId) { if (indexId.IsNullOrEmpty()) { @@ -23,10 +23,10 @@ public class ActionPrecheckManager(Config config) return [ResUI.PleaseSelectServer]; } - return await CheckBeforeGenerateConfig(item); + return await Check(item); } - public async Task> CheckBeforeGenerateConfig(ProfileItem? item) + public async Task> Check(ProfileItem? item) { if (item is null) { diff --git a/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs b/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs index 8120b64d..ccdeea53 100644 --- a/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs @@ -538,6 +538,18 @@ public class MainWindowViewModel : MyReactiveObject BlReloadEnabled = false; + var msgs = await ActionPrecheckManager.Instance.Check(_config.IndexId); + if (msgs.Count > 0) + { + foreach (var msg in msgs) + { + NoticeManager.Instance.SendMessage(msg); + } + NoticeManager.Instance.Enqueue(Utils.List2String(msgs)); + BlReloadEnabled = true; + return; + } + await Task.Run(async () => { await LoadCore(); diff --git a/v2rayN/ServiceLib/ViewModels/ProfilesViewModel.cs b/v2rayN/ServiceLib/ViewModels/ProfilesViewModel.cs index 8223632d..ecc83a6a 100644 --- a/v2rayN/ServiceLib/ViewModels/ProfilesViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/ProfilesViewModel.cs @@ -605,16 +605,6 @@ public class ProfilesViewModel : MyReactiveObject return; } - var msgs = await ActionPrecheckManager.Instance.CheckBeforeSetActive(indexId); - foreach (var msg in msgs) - { - NoticeManager.Instance.SendMessage(msg); - } - if (msgs.Count > 0) - { - NoticeManager.Instance.Enqueue(msgs.First()); - } - if (await ConfigHandler.SetDefaultServerIndex(_config, indexId) == 0) { await RefreshServers(); @@ -779,15 +769,17 @@ public class ProfilesViewModel : MyReactiveObject return; } - var msgs = await ActionPrecheckManager.Instance.CheckBeforeGenerateConfig(item); - foreach (var msg in msgs) - { - NoticeManager.Instance.SendMessage(msg); - } + var msgs = await ActionPrecheckManager.Instance.Check(item); if (msgs.Count > 0) { - NoticeManager.Instance.Enqueue(msgs.First()); + foreach (var msg in msgs) + { + NoticeManager.Instance.SendMessage(msg); + } + NoticeManager.Instance.Enqueue(Utils.List2String(msgs)); + return; } + if (blClipboard) { var result = await CoreConfigHandler.GenerateClientConfig(item, null);