From 460a674ebc37d1057c7438104641cd4cb6149a00 Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Sun, 17 May 2026 19:15:57 +0800 Subject: [PATCH] Add 'Check Only' update action Introduce a new "Check Only" feature: add CheckOnlyCmd to CheckUpdateViewModel with CheckOnlyTask that queries updates (via UpdateService.CheckHasUpdateOnly) for selected cores and reports results without performing updates. Wire up a new btnCheckOnly in both Desktop and Avalonia views and bind the command. Add localized menuCheckOnly entries to multiple .resx files and update ResUI.Designer. Also shorten the pre-release label to "Check for pre-release" in resource files. --- v2rayN/ServiceLib/Resx/ResUI.Designer.cs | 11 +++- v2rayN/ServiceLib/Resx/ResUI.fa-Ir.resx | 3 ++ v2rayN/ServiceLib/Resx/ResUI.fr.resx | 3 ++ v2rayN/ServiceLib/Resx/ResUI.hu.resx | 3 ++ v2rayN/ServiceLib/Resx/ResUI.resx | 5 +- v2rayN/ServiceLib/Resx/ResUI.ru.resx | 3 ++ v2rayN/ServiceLib/Resx/ResUI.zh-Hans.resx | 5 +- v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx | 5 +- .../ViewModels/CheckUpdateViewModel.cs | 51 +++++++++++++++++++ .../Views/CheckUpdateView.axaml | 6 +++ .../Views/CheckUpdateView.axaml.cs | 1 + v2rayN/v2rayN/Views/CheckUpdateView.xaml | 7 +++ v2rayN/v2rayN/Views/CheckUpdateView.xaml.cs | 1 + 13 files changed, 100 insertions(+), 4 deletions(-) diff --git a/v2rayN/ServiceLib/Resx/ResUI.Designer.cs b/v2rayN/ServiceLib/Resx/ResUI.Designer.cs index 98fba5a2..f9203dfd 100644 --- a/v2rayN/ServiceLib/Resx/ResUI.Designer.cs +++ b/v2rayN/ServiceLib/Resx/ResUI.Designer.cs @@ -870,6 +870,15 @@ namespace ServiceLib.Resx { } } + /// + /// 查找类似 Only Check 的本地化字符串。 + /// + public static string menuCheckOnly { + get { + return ResourceManager.GetString("menuCheckOnly", resourceCulture); + } + } + /// /// 查找类似 Check Update 的本地化字符串。 /// @@ -3934,7 +3943,7 @@ namespace ServiceLib.Resx { } /// - /// 查找类似 Check for pre-release updates 的本地化字符串。 + /// 查找类似 Check for pre-release 的本地化字符串。 /// public static string TbSettingsEnableCheckPreReleaseUpdate { get { diff --git a/v2rayN/ServiceLib/Resx/ResUI.fa-Ir.resx b/v2rayN/ServiceLib/Resx/ResUI.fa-Ir.resx index 6dd074e9..61fe7743 100644 --- a/v2rayN/ServiceLib/Resx/ResUI.fa-Ir.resx +++ b/v2rayN/ServiceLib/Resx/ResUI.fa-Ir.resx @@ -1734,4 +1734,7 @@ The "Get Certificate" action may fail if a self-signed certificate is used or if {0} has a new version available: {1} + + Only Check + \ No newline at end of file diff --git a/v2rayN/ServiceLib/Resx/ResUI.fr.resx b/v2rayN/ServiceLib/Resx/ResUI.fr.resx index 59cff7c8..69c46098 100644 --- a/v2rayN/ServiceLib/Resx/ResUI.fr.resx +++ b/v2rayN/ServiceLib/Resx/ResUI.fr.resx @@ -1731,4 +1731,7 @@ The "Get Certificate" action may fail if a self-signed certificate is used or if {0} has a new version available: {1} + + Only Check + \ No newline at end of file diff --git a/v2rayN/ServiceLib/Resx/ResUI.hu.resx b/v2rayN/ServiceLib/Resx/ResUI.hu.resx index 0f25830a..0942419a 100644 --- a/v2rayN/ServiceLib/Resx/ResUI.hu.resx +++ b/v2rayN/ServiceLib/Resx/ResUI.hu.resx @@ -1734,4 +1734,7 @@ The "Get Certificate" action may fail if a self-signed certificate is used or if {0} has a new version available: {1} + + Only Check + \ No newline at end of file diff --git a/v2rayN/ServiceLib/Resx/ResUI.resx b/v2rayN/ServiceLib/Resx/ResUI.resx index b989f719..b98f9625 100644 --- a/v2rayN/ServiceLib/Resx/ResUI.resx +++ b/v2rayN/ServiceLib/Resx/ResUI.resx @@ -691,7 +691,7 @@ Automatically adjust column width after subscription update - Check for pre-release updates + Check for pre-release Exception @@ -1734,4 +1734,7 @@ The "Get Certificate" action may fail if a self-signed certificate is used or if {0} has a new version available: {1} + + Only Check + \ No newline at end of file diff --git a/v2rayN/ServiceLib/Resx/ResUI.ru.resx b/v2rayN/ServiceLib/Resx/ResUI.ru.resx index daf33e10..30dd55d5 100644 --- a/v2rayN/ServiceLib/Resx/ResUI.ru.resx +++ b/v2rayN/ServiceLib/Resx/ResUI.ru.resx @@ -1734,4 +1734,7 @@ {0} has a new version available: {1} + + Only Check + \ No newline at end of file diff --git a/v2rayN/ServiceLib/Resx/ResUI.zh-Hans.resx b/v2rayN/ServiceLib/Resx/ResUI.zh-Hans.resx index c3cf5da5..328ecd99 100644 --- a/v2rayN/ServiceLib/Resx/ResUI.zh-Hans.resx +++ b/v2rayN/ServiceLib/Resx/ResUI.zh-Hans.resx @@ -691,7 +691,7 @@ 自动调整配置列宽在更新订阅后 - 检查 Pre-Release 更新 (请谨慎启用) + 检查 Pre-Release 例外 @@ -1731,4 +1731,7 @@ {0} 有新版本可用:{1} + + 仅检查 + \ No newline at end of file diff --git a/v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx b/v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx index 1aad3bfc..09e01d16 100644 --- a/v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx +++ b/v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx @@ -691,7 +691,7 @@ 在更新訂閱後自動調整列寬 - 檢查 Pre-Release 更新 (請謹慎啟用) + 檢查 Pre-Release 例外 @@ -1731,4 +1731,7 @@ {0} 有新版本可用:{1} + + 僅檢查 + \ No newline at end of file diff --git a/v2rayN/ServiceLib/ViewModels/CheckUpdateViewModel.cs b/v2rayN/ServiceLib/ViewModels/CheckUpdateViewModel.cs index f6f98e1a..7aea70c9 100644 --- a/v2rayN/ServiceLib/ViewModels/CheckUpdateViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/CheckUpdateViewModel.cs @@ -9,6 +9,7 @@ public class CheckUpdateViewModel : MyReactiveObject public IObservableCollection CheckUpdateModels { get; } = new ObservableCollectionExtended(); public ReactiveCommand CheckUpdateCmd { get; } + public ReactiveCommand CheckOnlyCmd { get; } [Reactive] public bool EnableCheckPreReleaseUpdate { get; set; } public CheckUpdateViewModel(Func>? updateView) @@ -23,6 +24,13 @@ public class CheckUpdateViewModel : MyReactiveObject _ = UpdateView(_v2rayN, ex.Message); }); + CheckOnlyCmd = ReactiveCommand.CreateFromTask(CheckOnly); + CheckOnlyCmd.ThrownExceptions.Subscribe(ex => + { + Logging.SaveLog(_tag, ex); + _ = UpdateView(_v2rayN, ex.Message); + }); + EnableCheckPreReleaseUpdate = _config.CheckUpdateItem.CheckPreReleaseUpdate; this.WhenAnyValue( @@ -71,11 +79,54 @@ public class CheckUpdateViewModel : MyReactiveObject await ConfigHandler.SaveConfig(_config); } + private async Task CheckOnly() + { + await Task.Run(CheckOnlyTask); + } + private async Task CheckUpdate() { await Task.Run(CheckUpdateTask); } + private async Task CheckOnlyTask() + { + await SaveSelectedCoreTypes(); + + for (var k = CheckUpdateModels.Count - 1; k >= 0; k--) + { + var item = CheckUpdateModels[k]; + if (item.IsSelected != true) + { + continue; + } + + await UpdateView(item.CoreType, "..."); + if (item.CoreType == _geo) + { + await UpdateView(item.CoreType, ResUI.menuCheckOnly + " (Not Support)"); + continue; + } + + if (!Enum.TryParse(item.CoreType, out var type)) + { + await UpdateView(item.CoreType, "Not Support"); + continue; + } + + var updateService = new UpdateService(_config, async (success, msg) => await Task.CompletedTask); + var result = await updateService.CheckHasUpdateOnly(type, EnableCheckPreReleaseUpdate); + if (result.Success && result.Version != null) + { + await UpdateView(item.CoreType, string.Format(ResUI.MsgCheckUpdateHasNewVersion, type, result.Version)); + } + else + { + await UpdateView(item.CoreType, result.Msg); + } + } + } + private async Task CheckUpdateTask() { _lstUpdated.Clear(); diff --git a/v2rayN/v2rayN.Desktop/Views/CheckUpdateView.axaml b/v2rayN/v2rayN.Desktop/Views/CheckUpdateView.axaml index 0055f9ad..e7b1a2f7 100644 --- a/v2rayN/v2rayN.Desktop/Views/CheckUpdateView.axaml +++ b/v2rayN/v2rayN.Desktop/Views/CheckUpdateView.axaml @@ -33,6 +33,12 @@ Margin="{StaticResource Margin4}" HorizontalAlignment="Left" /> +