diff --git a/v2rayN/ServiceLib/Models/ConfigItems.cs b/v2rayN/ServiceLib/Models/ConfigItems.cs index e7b8f079..dff71a45 100644 --- a/v2rayN/ServiceLib/Models/ConfigItems.cs +++ b/v2rayN/ServiceLib/Models/ConfigItems.cs @@ -171,6 +171,7 @@ public int SpeedTestTimeout { get; set; } public string SpeedTestUrl { get; set; } public string SpeedPingTestUrl { get; set; } + public int SpeedTestPageSize { get; set; } } [Serializable] diff --git a/v2rayN/ServiceLib/Resx/ResUI.Designer.cs b/v2rayN/ServiceLib/Resx/ResUI.Designer.cs index 49a08c2a..95a47fcd 100644 --- a/v2rayN/ServiceLib/Resx/ResUI.Designer.cs +++ b/v2rayN/ServiceLib/Resx/ResUI.Designer.cs @@ -3337,6 +3337,15 @@ namespace ServiceLib.Resx { } } + /// + /// 查找类似 Number per time for auto batch during speedtest(max 1000) 的本地化字符串。 + /// + public static string TbSettingsSpeedTestPageSize { + get { + return ResourceManager.GetString("TbSettingsSpeedTestPageSize", resourceCulture); + } + } + /// /// 查找类似 SpeedTest Single Timeout Value 的本地化字符串。 /// diff --git a/v2rayN/ServiceLib/Resx/ResUI.fa-Ir.resx b/v2rayN/ServiceLib/Resx/ResUI.fa-Ir.resx index 37d4d93c..4a2e3cea 100644 --- a/v2rayN/ServiceLib/Resx/ResUI.fa-Ir.resx +++ b/v2rayN/ServiceLib/Resx/ResUI.fa-Ir.resx @@ -1384,4 +1384,7 @@ Hide to tray when closing the window + + Number per time for auto batch during speedtest(max 1000) + \ No newline at end of file diff --git a/v2rayN/ServiceLib/Resx/ResUI.resx b/v2rayN/ServiceLib/Resx/ResUI.resx index 0b24b483..d3256609 100644 --- a/v2rayN/ServiceLib/Resx/ResUI.resx +++ b/v2rayN/ServiceLib/Resx/ResUI.resx @@ -1384,4 +1384,7 @@ Hide to tray when closing the window + + Number per time for auto batch during speedtest(max 1000) + \ No newline at end of file diff --git a/v2rayN/ServiceLib/Resx/ResUI.ru.resx b/v2rayN/ServiceLib/Resx/ResUI.ru.resx index 9134409b..773e9006 100644 --- a/v2rayN/ServiceLib/Resx/ResUI.ru.resx +++ b/v2rayN/ServiceLib/Resx/ResUI.ru.resx @@ -1384,4 +1384,7 @@ Hide to tray when closing the window + + Number per time for auto batch during speedtest(max 1000) + \ 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 c1f3426c..00588917 100644 --- a/v2rayN/ServiceLib/Resx/ResUI.zh-Hans.resx +++ b/v2rayN/ServiceLib/Resx/ResUI.zh-Hans.resx @@ -1381,4 +1381,7 @@ 关闭窗口时隐藏至托盘 + + 测速时自动分批的每批数量(最大1000) + \ 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 30b605c6..7abecd6c 100644 --- a/v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx +++ b/v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx @@ -1381,4 +1381,7 @@ 關閉視窗時隱藏至托盤 + + 測速時自動分批的每批數量(最大1000) + \ No newline at end of file diff --git a/v2rayN/ServiceLib/Services/SpeedtestService.cs b/v2rayN/ServiceLib/Services/SpeedtestService.cs index eff28410..aaa3e98a 100644 --- a/v2rayN/ServiceLib/Services/SpeedtestService.cs +++ b/v2rayN/ServiceLib/Services/SpeedtestService.cs @@ -74,9 +74,24 @@ namespace ServiceLib.Services return; } + var pageSize = _config.SpeedTestItem.SpeedTestPageSize; + if (pageSize is <= 0 or > 1000) + { + pageSize = 1000; + } + List> lstTest = new(); - lstTest.Add(lstSelected.Where(t => t.ConfigType is not (EConfigType.Hysteria2 or EConfigType.TUIC or EConfigType.WireGuard)).ToList()); - lstTest.Add(lstSelected.Where(t => t.ConfigType is EConfigType.Hysteria2 or EConfigType.TUIC or EConfigType.WireGuard).ToList()); + var lst1 = lstSelected.Where(t => t.ConfigType is not (EConfigType.Hysteria2 or EConfigType.TUIC or EConfigType.WireGuard)).ToList(); + var lst2 = lstSelected.Where(t => t.ConfigType is EConfigType.Hysteria2 or EConfigType.TUIC or EConfigType.WireGuard).ToList(); + + for (var num = 0; num < (int)Math.Ceiling(lst1.Count * 1.0 / pageSize); num++) + { + lstTest.Add(lst1.Skip(num * pageSize).Take(pageSize).ToList()); + } + for (var num = 0; num < (int)Math.Ceiling(lst2.Count * 1.0 / pageSize); num++) + { + lstTest.Add(lst2.Skip(num * pageSize).Take(pageSize).ToList()); + } foreach (var lst in lstTest) { @@ -95,7 +110,7 @@ namespace ServiceLib.Services break; } - await Task.Delay(1000); + await Task.Delay(100); } UpdateFunc("", ResUI.SpeedtestingCompleted); diff --git a/v2rayN/ServiceLib/ViewModels/OptionSettingViewModel.cs b/v2rayN/ServiceLib/ViewModels/OptionSettingViewModel.cs index c07001f3..8e61b36a 100644 --- a/v2rayN/ServiceLib/ViewModels/OptionSettingViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/OptionSettingViewModel.cs @@ -62,6 +62,7 @@ namespace ServiceLib.ViewModels [Reactive] public int SpeedTestTimeout { get; set; } [Reactive] public string SpeedTestUrl { get; set; } [Reactive] public string SpeedPingTestUrl { get; set; } + [Reactive] public int SpeedTestPageSize { get; set; } [Reactive] public bool EnableHWA { get; set; } [Reactive] public string SubConvertUrl { get; set; } [Reactive] public int MainGirdOrientation { get; set; } @@ -175,6 +176,7 @@ namespace ServiceLib.ViewModels CurrentFontFamily = _config.UiItem.CurrentFontFamily; SpeedTestTimeout = _config.SpeedTestItem.SpeedTestTimeout; SpeedTestUrl = _config.SpeedTestItem.SpeedTestUrl; + SpeedTestPageSize = _config.SpeedTestItem.SpeedTestPageSize; SpeedPingTestUrl = _config.SpeedTestItem.SpeedPingTestUrl; EnableHWA = _config.GuiItem.EnableHWA; SubConvertUrl = _config.ConstItem.SubConvertUrl; @@ -325,6 +327,7 @@ namespace ServiceLib.ViewModels _config.GuiItem.TrayMenuServersLimit = TrayMenuServersLimit; _config.UiItem.CurrentFontFamily = CurrentFontFamily; _config.SpeedTestItem.SpeedTestTimeout = SpeedTestTimeout; + _config.SpeedTestItem.SpeedTestPageSize = SpeedTestPageSize; _config.SpeedTestItem.SpeedTestUrl = SpeedTestUrl; _config.SpeedTestItem.SpeedPingTestUrl = SpeedPingTestUrl; _config.GuiItem.EnableHWA = EnableHWA; diff --git a/v2rayN/v2rayN.Desktop/Views/OptionSettingWindow.axaml b/v2rayN/v2rayN.Desktop/Views/OptionSettingWindow.axaml index 717551e9..b837de6c 100644 --- a/v2rayN/v2rayN.Desktop/Views/OptionSettingWindow.axaml +++ b/v2rayN/v2rayN.Desktop/Views/OptionSettingWindow.axaml @@ -532,26 +532,40 @@ Classes="Margin8" /> + + + vm.SpeedTestTimeout, v => v.cmbSpeedTestTimeout.SelectedValue).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SpeedTestUrl, v => v.cmbSpeedTestUrl.SelectedValue).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SpeedPingTestUrl, v => v.cmbSpeedPingTestUrl.SelectedValue).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SpeedTestPageSize, v => v.txtSpeedTestPageSize.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SubConvertUrl, v => v.cmbSubConvertUrl.SelectedValue).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.MainGirdOrientation, v => v.cmbMainGirdOrientation.SelectedIndex).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.GeoFileSourceUrl, v => v.cmbGetFilesSourceUrl.SelectedValue).DisposeWith(disposables); diff --git a/v2rayN/v2rayN/Views/OptionSettingWindow.xaml b/v2rayN/v2rayN/Views/OptionSettingWindow.xaml index 2303d8f6..571f19fb 100644 --- a/v2rayN/v2rayN/Views/OptionSettingWindow.xaml +++ b/v2rayN/v2rayN/Views/OptionSettingWindow.xaml @@ -698,7 +698,7 @@ HorizontalAlignment="Left" /> + + + - + + MaxDropDownHeight="1000" + Style="{StaticResource DefComboBox}" /> + - + - + HorizontalAlignment="Left" + Style="{StaticResource DefTextBox}" /> vm.SpeedTestTimeout, v => v.cmbSpeedTestTimeout.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SpeedTestUrl, v => v.cmbSpeedTestUrl.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SpeedPingTestUrl, v => v.cmbSpeedPingTestUrl.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SpeedTestPageSize, v => v.txtSpeedTestPageSize.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.EnableHWA, v => v.togEnableHWA.IsChecked).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SubConvertUrl, v => v.cmbSubConvertUrl.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.MainGirdOrientation, v => v.cmbMainGirdOrientation.SelectedIndex).DisposeWith(disposables);