From 6771eb25d16aefd99d28b381276248abff121c9c Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Thu, 9 Oct 2025 20:22:35 +0800 Subject: [PATCH] Adjust ActionPrecheckManager --- .../Manager/ActionPrecheckManager.cs | 6 ++--- .../ViewModels/MainWindowViewModel.cs | 12 ++++++++++ .../ViewModels/ProfilesViewModel.cs | 24 +++++++------------ 3 files changed, 23 insertions(+), 19 deletions(-) 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);