From 3a2c9e7aaa5020f89cdb0ce9260c052cae6049c2 Mon Sep 17 00:00:00 2001 From: fonaix Date: Sat, 2 Nov 2024 10:28:18 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9A=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E6=96=87=E6=9C=AC=E6=A1=86=E5=9E=82=E7=9B=B4=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E4=B8=8A=E4=B8=8B=E7=A9=BA=E7=99=BD=E9=97=AE=E9=A2=98?= =?UTF-8?q?=20(#5967)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- v2rayN/v2rayN.Desktop/Views/MsgView.axaml | 1 + 1 file changed, 1 insertion(+) diff --git a/v2rayN/v2rayN.Desktop/Views/MsgView.axaml b/v2rayN/v2rayN.Desktop/Views/MsgView.axaml index 4ff25dcb..99dd5121 100644 --- a/v2rayN/v2rayN.Desktop/Views/MsgView.axaml +++ b/v2rayN/v2rayN.Desktop/Views/MsgView.axaml @@ -83,6 +83,7 @@ Classes="TextArea" IsReadOnly="True" TextAlignment="Left" + VerticalAlignment="Stretch" TextWrapping="Wrap"> From 046421f34547451e200a3725b2e90dc2b16d2ae3 Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Sat, 2 Nov 2024 14:42:01 +0800 Subject: [PATCH 2/4] Code clean --- v2rayN/ServiceLib/Services/UpdateService.cs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/v2rayN/ServiceLib/Services/UpdateService.cs b/v2rayN/ServiceLib/Services/UpdateService.cs index 5a430a9c..1a8e8d64 100644 --- a/v2rayN/ServiceLib/Services/UpdateService.cs +++ b/v2rayN/ServiceLib/Services/UpdateService.cs @@ -6,12 +6,10 @@ namespace ServiceLib.Services public class UpdateService { private Action? _updateFunc; - private Config _config; private int _timeout = 30; public async Task CheckUpdateGuiN(Config config, Action updateFunc, bool preRelease) { - _config = config; _updateFunc = updateFunc; var url = string.Empty; var fileName = string.Empty; @@ -53,7 +51,6 @@ namespace ServiceLib.Services public async Task CheckUpdateCore(ECoreType type, Config config, Action updateFunc, bool preRelease) { - _config = config; _updateFunc = updateFunc; var url = string.Empty; var fileName = string.Empty; @@ -108,7 +105,6 @@ namespace ServiceLib.Services public async Task UpdateSubscriptionProcess(Config config, string subId, bool blProxy, Action updateFunc) { - _config = config; _updateFunc = updateFunc; _updateFunc?.Invoke(false, ResUI.MsgUpdateSubscriptionStart); @@ -454,7 +450,6 @@ namespace ServiceLib.Services private async Task UpdateGeoFile(string geoName, Config config, Action updateFunc) { - _config = config; _updateFunc = updateFunc; var geoUrl = string.IsNullOrEmpty(config?.ConstItem.GeoSourceUrl) @@ -470,7 +465,6 @@ namespace ServiceLib.Services private async Task UpdateSrsFileAll(Config config, Action updateFunc) { - _config = config; _updateFunc = updateFunc; var geoipFiles = new List(); @@ -521,9 +515,9 @@ namespace ServiceLib.Services private async Task UpdateSrsFile(string type, string srsName, Config config, Action updateFunc) { - var srsUrl = string.IsNullOrEmpty(_config.ConstItem.SrsSourceUrl) + var srsUrl = string.IsNullOrEmpty(config.ConstItem.SrsSourceUrl) ? Global.SingboxRulesetUrl - : _config.ConstItem.SrsSourceUrl; + : config.ConstItem.SrsSourceUrl; var fileName = $"{type}-{srsName}.srs"; var targetPath = Path.Combine(Utils.GetBinPath("srss"), fileName); From c339aa349c49b90373154c91c2cdceaa1a92f8fb Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Sat, 2 Nov 2024 14:42:26 +0800 Subject: [PATCH 3/4] up PackageReference --- v2rayN/v2rayN.Desktop/v2rayN.Desktop.csproj | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/v2rayN/v2rayN.Desktop/v2rayN.Desktop.csproj b/v2rayN/v2rayN.Desktop/v2rayN.Desktop.csproj index fcdf3e0d..8ab9c55f 100644 --- a/v2rayN/v2rayN.Desktop/v2rayN.Desktop.csproj +++ b/v2rayN/v2rayN.Desktop/v2rayN.Desktop.csproj @@ -20,16 +20,16 @@ - - - - - - + + + + + + - - + + From 201cfaa922de7f297e60cea5eb2332454c71f8a8 Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Sat, 2 Nov 2024 15:02:30 +0800 Subject: [PATCH 4/4] Fix https://github.com/2dust/v2rayN/issues/5966 --- v2rayN/ServiceLib/Enums/EMsgCommand.cs | 3 ++- v2rayN/ServiceLib/Services/SpeedtestService.cs | 8 +++++--- v2rayN/ServiceLib/ViewModels/ProfilesViewModel.cs | 6 +++--- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/v2rayN/ServiceLib/Enums/EMsgCommand.cs b/v2rayN/ServiceLib/Enums/EMsgCommand.cs index 31d7556f..c955e830 100644 --- a/v2rayN/ServiceLib/Enums/EMsgCommand.cs +++ b/v2rayN/ServiceLib/Enums/EMsgCommand.cs @@ -5,6 +5,7 @@ ClearMsg, SendMsgView, SendSnackMsg, - RefreshProfiles + RefreshProfiles, + StopSpeedtest } } \ No newline at end of file diff --git a/v2rayN/ServiceLib/Services/SpeedtestService.cs b/v2rayN/ServiceLib/Services/SpeedtestService.cs index 61bfd7c1..d8411903 100644 --- a/v2rayN/ServiceLib/Services/SpeedtestService.cs +++ b/v2rayN/ServiceLib/Services/SpeedtestService.cs @@ -1,7 +1,7 @@ -using System.Diagnostics; +using ReactiveUI; +using System.Diagnostics; using System.Net; using System.Net.Sockets; - namespace ServiceLib.Services { public class SpeedtestService @@ -80,10 +80,12 @@ namespace ServiceLib.Services Task.Run(RunMixedtestAsync); break; } + MessageBus.Current.Listen(EMsgCommand.StopSpeedtest.ToString()).Subscribe(ExitLoop); } - public void ExitLoop() + private void ExitLoop(string x) { + if(_exitLoop) return; _exitLoop = true; UpdateFunc("", ResUI.SpeedtestingStop); } diff --git a/v2rayN/ServiceLib/ViewModels/ProfilesViewModel.cs b/v2rayN/ServiceLib/ViewModels/ProfilesViewModel.cs index 8249d6e8..66d38ddc 100644 --- a/v2rayN/ServiceLib/ViewModels/ProfilesViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/ProfilesViewModel.cs @@ -16,7 +16,6 @@ namespace ServiceLib.ViewModels private List _lstProfile; private string _serverFilter = string.Empty; private Dictionary _dicHeaderSort = new(); - private SpeedtestService? _speedtestHandler; #endregion private prop @@ -686,12 +685,13 @@ namespace ServiceLib.ViewModels } //ClearTestResult(); - _speedtestHandler = new SpeedtestService(_config, lstSelecteds, actionType, UpdateSpeedtestHandler); + _ = new SpeedtestService(_config, lstSelecteds, actionType, UpdateSpeedtestHandler); + } public void ServerSpeedtestStop() { - _speedtestHandler?.ExitLoop(); + MessageBus.Current.SendMessage("", EMsgCommand.StopSpeedtest.ToString()); } private async Task Export2ClientConfigAsync(bool blClipboard)