diff --git a/v2rayN/ServiceLib/Handler/ConfigHandler.cs b/v2rayN/ServiceLib/Handler/ConfigHandler.cs index abe245b6..5142f37c 100644 --- a/v2rayN/ServiceLib/Handler/ConfigHandler.cs +++ b/v2rayN/ServiceLib/Handler/ConfigHandler.cs @@ -94,10 +94,7 @@ namespace ServiceLib.Handler EnableTun = false, Mtu = 9000, }; - config.GuiItem ??= new() - { - EnableStatistics = false, - }; + config.GuiItem ??= new(); config.MsgUIItem ??= new(); config.UiItem ??= new UIItem() diff --git a/v2rayN/ServiceLib/Handler/StatisticsHandler.cs b/v2rayN/ServiceLib/Handler/StatisticsHandler.cs index 89f47b92..8b900b0a 100644 --- a/v2rayN/ServiceLib/Handler/StatisticsHandler.cs +++ b/v2rayN/ServiceLib/Handler/StatisticsHandler.cs @@ -19,15 +19,13 @@ { _config = config; _updateFunc = updateFunc; - if (!config.GuiItem.EnableStatistics) + if (config.GuiItem.EnableStatistics || _config.GuiItem.DisplayRealTimeSpeed) { - return; + await InitData(); + + _statisticsXray = new StatisticsXrayService(config, UpdateServerStatHandler); + _statisticsSingbox = new StatisticsSingboxService(config, UpdateServerStatHandler); } - - await InitData(); - - _statisticsXray = new StatisticsXrayService(config, UpdateServerStatHandler); - _statisticsSingbox = new StatisticsSingboxService(config, UpdateServerStatHandler); } public void Close() diff --git a/v2rayN/ServiceLib/Models/ConfigItems.cs b/v2rayN/ServiceLib/Models/ConfigItems.cs index dda1f770..05d08c3d 100644 --- a/v2rayN/ServiceLib/Models/ConfigItems.cs +++ b/v2rayN/ServiceLib/Models/ConfigItems.cs @@ -67,21 +67,13 @@ public class GUIItem { public bool AutoRun { get; set; } - public bool EnableStatistics { get; set; } - + public bool DisplayRealTimeSpeed { get; set; } public bool KeepOlderDedupl { get; set; } - - public bool IgnoreGeoUpdateCore { get; set; } = true; - public int AutoUpdateInterval { get; set; } - public bool EnableSecurityProtocolTls13 { get; set; } - public int TrayMenuServersLimit { get; set; } = 20; - public bool EnableHWA { get; set; } = false; - public bool EnableLog { get; set; } = true; } diff --git a/v2rayN/ServiceLib/Resx/ResUI.Designer.cs b/v2rayN/ServiceLib/Resx/ResUI.Designer.cs index a7d57db9..2d6d8a4d 100644 --- a/v2rayN/ServiceLib/Resx/ResUI.Designer.cs +++ b/v2rayN/ServiceLib/Resx/ResUI.Designer.cs @@ -2914,6 +2914,15 @@ namespace ServiceLib.Resx { } } + /// + /// 查找类似 Display real-time speed 的本地化字符串。 + /// + public static string TbSettingsDisplayRealTimeSpeed { + get { + return ResourceManager.GetString("TbSettingsDisplayRealTimeSpeed", resourceCulture); + } + } + /// /// 查找类似 Outbound DNS address 的本地化字符串。 /// @@ -3112,15 +3121,6 @@ namespace ServiceLib.Resx { } } - /// - /// 查找类似 Ignore Geo files when updating core 的本地化字符串。 - /// - public static string TbSettingsIgnoreGeoUpdateCore { - get { - return ResourceManager.GetString("TbSettingsIgnoreGeoUpdateCore", resourceCulture); - } - } - /// /// 查找类似 Keep older when deduplication 的本地化字符串。 /// @@ -3401,7 +3401,7 @@ namespace ServiceLib.Resx { } /// - /// 查找类似 Enable Statistics (Require restart) 的本地化字符串。 + /// 查找类似 Enable traffic statistics (Require restart) 的本地化字符串。 /// public static string TbSettingsStatistics { get { diff --git a/v2rayN/ServiceLib/Resx/ResUI.fa-Ir.resx b/v2rayN/ServiceLib/Resx/ResUI.fa-Ir.resx index 02970de4..79a130b9 100644 --- a/v2rayN/ServiceLib/Resx/ResUI.fa-Ir.resx +++ b/v2rayN/ServiceLib/Resx/ResUI.fa-Ir.resx @@ -718,8 +718,8 @@ پورت Http - - هنگام به‌روزرسانی هسته، فایل‌های Geo را نادیده بگیرید + + Display real-time speed هنگام کپی برداری، نگه داری قدیمی تر ها @@ -1393,4 +1393,4 @@ کپی کردن دستور پروکسی در کلیپ بورد - + \ No newline at end of file diff --git a/v2rayN/ServiceLib/Resx/ResUI.hu.resx b/v2rayN/ServiceLib/Resx/ResUI.hu.resx index f332718a..dc69d9a5 100644 --- a/v2rayN/ServiceLib/Resx/ResUI.hu.resx +++ b/v2rayN/ServiceLib/Resx/ResUI.hu.resx @@ -718,8 +718,8 @@ HTTP Port - - Geo fájlok figyelmen kívül hagyása a yalap frissítésekor + + Display real-time speed Régi megőrzése a deduplikáció során diff --git a/v2rayN/ServiceLib/Resx/ResUI.resx b/v2rayN/ServiceLib/Resx/ResUI.resx index fb3ebdb9..1ba12c74 100644 --- a/v2rayN/ServiceLib/Resx/ResUI.resx +++ b/v2rayN/ServiceLib/Resx/ResUI.resx @@ -718,8 +718,8 @@ HTTP Port - - Ignore Geo files when updating core + + Display real-time speed (Require restart) Keep older when deduplication @@ -755,7 +755,7 @@ Start on boot - Enable Statistics (Require restart) + Enable traffic statistics (Require restart) Subscription conversion URL diff --git a/v2rayN/ServiceLib/Resx/ResUI.ru.resx b/v2rayN/ServiceLib/Resx/ResUI.ru.resx index 53532b8a..190b9fed 100644 --- a/v2rayN/ServiceLib/Resx/ResUI.ru.resx +++ b/v2rayN/ServiceLib/Resx/ResUI.ru.resx @@ -724,8 +724,8 @@ HTTP порт - - Игнорировать файлы Geo при обновлении ядра + + Display real-time speed Сохранить старые при удалении дублей diff --git a/v2rayN/ServiceLib/Resx/ResUI.zh-Hans.resx b/v2rayN/ServiceLib/Resx/ResUI.zh-Hans.resx index 0aa7a08c..0d62bc6e 100644 --- a/v2rayN/ServiceLib/Resx/ResUI.zh-Hans.resx +++ b/v2rayN/ServiceLib/Resx/ResUI.zh-Hans.resx @@ -718,8 +718,8 @@ 本地http监听端口 - - 更新Core时忽略Geo文件 + + 显示实时速度(需重启) 去重时保留序号较小的项 @@ -755,7 +755,7 @@ 开机启动(可能会不成功) - 启用统计(实时网速显示,需重启) + 启用流量统计(需重启) 订阅转换网址(可选) diff --git a/v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx b/v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx index c1818cce..12f0887c 100644 --- a/v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx +++ b/v2rayN/ServiceLib/Resx/ResUI.zh-Hant.resx @@ -719,8 +719,8 @@ 本機HTTP偵聽埠 - - 更新Core時忽略Geo檔案 + + 顯示即時速度(需重啟) 去重時保留序號較小的項 @@ -756,7 +756,7 @@ 開機啟動(可能會不成功) - 啟用統計(即時網速顯示,需重啟) + 啟用流量統計(需重啟) 訂閱轉換網址(可選) diff --git a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs index 565ef72c..998002cf 100644 --- a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs +++ b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs @@ -1108,7 +1108,7 @@ namespace ServiceLib.Services.CoreConfig private async Task GenStatistic(V2rayConfig v2rayConfig) { - if (_config.GuiItem.EnableStatistics) + if (_config.GuiItem.EnableStatistics || _config.GuiItem.DisplayRealTimeSpeed) { string tag = EInboundProtocol.api.ToString(); Metrics4Ray apiObj = new(); diff --git a/v2rayN/ServiceLib/ViewModels/CheckUpdateViewModel.cs b/v2rayN/ServiceLib/ViewModels/CheckUpdateViewModel.cs index f4e31c09..d8483f8a 100644 --- a/v2rayN/ServiceLib/ViewModels/CheckUpdateViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/CheckUpdateViewModel.cs @@ -259,7 +259,7 @@ namespace ServiceLib.ViewModels } else { - FileManager.ZipExtractToFile(fileName, toPath, _config.GuiItem.IgnoreGeoUpdateCore ? "geo" : ""); + FileManager.ZipExtractToFile(fileName, toPath, "geo"); } if (Utils.IsNonWindows()) diff --git a/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs b/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs index 5b36e9a6..8f60b5b1 100644 --- a/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs @@ -219,7 +219,7 @@ namespace ServiceLib.ViewModels await CoreHandler.Instance.Init(_config, UpdateHandler); TaskHandler.Instance.RegUpdateTask(_config, UpdateTaskHandler); - if (_config.GuiItem.EnableStatistics) + if (_config.GuiItem.EnableStatistics || _config.GuiItem.DisplayRealTimeSpeed) { await StatisticsHandler.Instance.Init(_config, UpdateStatisticsHandler); } @@ -272,16 +272,13 @@ namespace ServiceLib.ViewModels public void SetStatisticsResult(ServerSpeedItem update) { - try + if (_config.GuiItem.DisplayRealTimeSpeed) { Locator.Current.GetService()?.UpdateStatistics(update); - if ((update.ProxyUp + update.ProxyDown) > 0 && DateTime.Now.Second % 9 == 0) - { - Locator.Current.GetService()?.UpdateStatistics(update); - } } - catch + if (_config.GuiItem.EnableStatistics && (update.ProxyUp + update.ProxyDown) > 0 && DateTime.Now.Second % 9 == 0) { + Locator.Current.GetService()?.UpdateStatistics(update); } } diff --git a/v2rayN/ServiceLib/ViewModels/OptionSettingViewModel.cs b/v2rayN/ServiceLib/ViewModels/OptionSettingViewModel.cs index 722e52d8..955adcbe 100644 --- a/v2rayN/ServiceLib/ViewModels/OptionSettingViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/OptionSettingViewModel.cs @@ -49,7 +49,7 @@ namespace ServiceLib.ViewModels [Reactive] public bool AutoRun { get; set; } [Reactive] public bool EnableStatistics { get; set; } [Reactive] public bool KeepOlderDedupl { get; set; } - [Reactive] public bool IgnoreGeoUpdateCore { get; set; } + [Reactive] public bool DisplayRealTimeSpeed { get; set; } [Reactive] public bool EnableAutoAdjustMainLvColWidth { get; set; } [Reactive] public bool EnableUpdateSubOnlyRemarksExist { get; set; } [Reactive] public bool EnableSecurityProtocolTls13 { get; set; } @@ -164,8 +164,8 @@ namespace ServiceLib.ViewModels AutoRun = _config.GuiItem.AutoRun; EnableStatistics = _config.GuiItem.EnableStatistics; + DisplayRealTimeSpeed = _config.GuiItem.DisplayRealTimeSpeed; KeepOlderDedupl = _config.GuiItem.KeepOlderDedupl; - IgnoreGeoUpdateCore = _config.GuiItem.IgnoreGeoUpdateCore; EnableAutoAdjustMainLvColWidth = _config.UiItem.EnableAutoAdjustMainLvColWidth; EnableUpdateSubOnlyRemarksExist = _config.UiItem.EnableUpdateSubOnlyRemarksExist; EnableSecurityProtocolTls13 = _config.GuiItem.EnableSecurityProtocolTls13; @@ -273,6 +273,7 @@ namespace ServiceLib.ViewModels return; } var needReboot = (EnableStatistics != _config.GuiItem.EnableStatistics + || DisplayRealTimeSpeed != _config.GuiItem.DisplayRealTimeSpeed || EnableDragDropSort != _config.UiItem.EnableDragDropSort || EnableHWA != _config.GuiItem.EnableHWA || CurrentFontFamily != _config.UiItem.CurrentFontFamily @@ -318,8 +319,8 @@ namespace ServiceLib.ViewModels _config.GuiItem.AutoRun = AutoRun; _config.GuiItem.EnableStatistics = EnableStatistics; + _config.GuiItem.DisplayRealTimeSpeed = DisplayRealTimeSpeed; _config.GuiItem.KeepOlderDedupl = KeepOlderDedupl; - _config.GuiItem.IgnoreGeoUpdateCore = IgnoreGeoUpdateCore; _config.UiItem.EnableAutoAdjustMainLvColWidth = EnableAutoAdjustMainLvColWidth; _config.UiItem.EnableUpdateSubOnlyRemarksExist = EnableUpdateSubOnlyRemarksExist; _config.GuiItem.EnableSecurityProtocolTls13 = EnableSecurityProtocolTls13; diff --git a/v2rayN/ServiceLib/ViewModels/StatusBarViewModel.cs b/v2rayN/ServiceLib/ViewModels/StatusBarViewModel.cs index 865e3fb4..99cf95f2 100644 --- a/v2rayN/ServiceLib/ViewModels/StatusBarViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/StatusBarViewModel.cs @@ -484,8 +484,14 @@ namespace ServiceLib.ViewModels public void UpdateStatistics(ServerSpeedItem update) { - SpeedProxyDisplay = string.Format(ResUI.SpeedDisplayText, Global.ProxyTag, Utils.HumanFy(update.ProxyUp), Utils.HumanFy(update.ProxyDown)); - SpeedDirectDisplay = string.Format(ResUI.SpeedDisplayText, Global.DirectTag, Utils.HumanFy(update.DirectUp), Utils.HumanFy(update.DirectDown)); + try + { + SpeedProxyDisplay = string.Format(ResUI.SpeedDisplayText, Global.ProxyTag, Utils.HumanFy(update.ProxyUp), Utils.HumanFy(update.ProxyDown)); + SpeedDirectDisplay = string.Format(ResUI.SpeedDisplayText, Global.DirectTag, Utils.HumanFy(update.DirectUp), Utils.HumanFy(update.DirectDown)); + } + catch + { + } } #endregion UI diff --git a/v2rayN/v2rayN.Desktop/Views/OptionSettingWindow.axaml b/v2rayN/v2rayN.Desktop/Views/OptionSettingWindow.axaml index ecb22925..88c8e2aa 100644 --- a/v2rayN/v2rayN.Desktop/Views/OptionSettingWindow.axaml +++ b/v2rayN/v2rayN.Desktop/Views/OptionSettingWindow.axaml @@ -385,9 +385,9 @@ Grid.Column="0" VerticalAlignment="Center" Classes="Margin8" - Text="{x:Static resx:ResUI.TbSettingsKeepOlderDedupl}" /> + Text="{x:Static resx:ResUI.TbSettingsDisplayRealTimeSpeed}" /> + Text="{x:Static resx:ResUI.TbSettingsKeepOlderDedupl}" /> vm.AutoRun, v => v.togAutoRun.IsChecked).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.EnableStatistics, v => v.togEnableStatistics.IsChecked).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.DisplayRealTimeSpeed, v => v.togDisplayRealTimeSpeed.IsChecked).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.KeepOlderDedupl, v => v.togKeepOlderDedupl.IsChecked).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.IgnoreGeoUpdateCore, v => v.togIgnoreGeoUpdateCore.IsChecked).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.EnableAutoAdjustMainLvColWidth, v => v.togEnableAutoAdjustMainLvColWidth.IsChecked).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.EnableUpdateSubOnlyRemarksExist, v => v.togEnableUpdateSubOnlyRemarksExist.IsChecked).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.EnableSecurityProtocolTls13, v => v.togEnableSecurityProtocolTls13.IsChecked).DisposeWith(disposables); diff --git a/v2rayN/v2rayN/Views/OptionSettingWindow.xaml b/v2rayN/v2rayN/Views/OptionSettingWindow.xaml index a6f21c58..606b91d2 100644 --- a/v2rayN/v2rayN/Views/OptionSettingWindow.xaml +++ b/v2rayN/v2rayN/Views/OptionSettingWindow.xaml @@ -601,9 +601,9 @@ Margin="{StaticResource Margin8}" VerticalAlignment="Center" Style="{StaticResource ToolbarTextBlock}" - Text="{x:Static resx:ResUI.TbSettingsKeepOlderDedupl}" /> + Text="{x:Static resx:ResUI.TbSettingsDisplayRealTimeSpeed}" /> + Text="{x:Static resx:ResUI.TbSettingsKeepOlderDedupl}" /> vm.AutoRun, v => v.togAutoRun.IsChecked).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.EnableStatistics, v => v.togEnableStatistics.IsChecked).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.DisplayRealTimeSpeed, v => v.togDisplayRealTimeSpeed.IsChecked).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.KeepOlderDedupl, v => v.togKeepOlderDedupl.IsChecked).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.IgnoreGeoUpdateCore, v => v.togIgnoreGeoUpdateCore.IsChecked).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.EnableAutoAdjustMainLvColWidth, v => v.togEnableAutoAdjustMainLvColWidth.IsChecked).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.EnableUpdateSubOnlyRemarksExist, v => v.togEnableUpdateSubOnlyRemarksExist.IsChecked).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.EnableSecurityProtocolTls13, v => v.togEnableSecurityProtocolTls13.IsChecked).DisposeWith(disposables);