From 945a0add968f0a5971ac286287f8a5c0663cc61c Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Tue, 19 Nov 2024 15:52:08 +0800 Subject: [PATCH] Code clean --- v2rayN/AmazTool/Assets/en-US.json | 24 +++++++++---------- v2rayN/AmazTool/Assets/zh-CN.json | 24 +++++++++---------- v2rayN/AmazTool/LocalizationHelper.cs | 4 ++-- v2rayN/AmazTool/UpgradeApp.cs | 2 +- .../ServiceLib/Handler/StatisticsHandler.cs | 2 ++ .../Handler/SysProxy/ProxySettingOSX.cs | 3 +-- v2rayN/ServiceLib/Models/Config.cs | 1 + .../Views/AddServerWindow.axaml.cs | 2 +- .../v2rayN.Desktop/Views/MainWindow.axaml.cs | 2 +- v2rayN/v2rayN/App.xaml | 2 +- v2rayN/v2rayN/Views/AddServerWindow.xaml.cs | 2 +- v2rayN/v2rayN/Views/ClashConnectionsView.xaml | 6 ++--- v2rayN/v2rayN/Views/ClashProxiesView.xaml | 8 +++---- .../Views/RoutingRuleDetailsWindow.xaml | 6 ++--- .../Views/RoutingRuleSettingWindow.xaml | 6 ++--- v2rayN/v2rayN/Views/SubEditWindow.xaml | 6 ++--- 16 files changed, 51 insertions(+), 49 deletions(-) diff --git a/v2rayN/AmazTool/Assets/en-US.json b/v2rayN/AmazTool/Assets/en-US.json index f4c0f600..8b94e7cb 100644 --- a/v2rayN/AmazTool/Assets/en-US.json +++ b/v2rayN/AmazTool/Assets/en-US.json @@ -1,14 +1,14 @@ { - "Restart_v2rayN": "Start v2rayN, please wait...", - "Guidelines": "Please run it from the main application.", - "Upgrade_File_Not_Found": "Upgrade failed, file not found.", - "In_Progress": "In progress, please wait...", - "Try_Terminate_Process": "Try to terminate the v2rayN process.", - "Failed_Terminate_Process": "Failed to terminate the v2rayN.Close it manually,or the upgrade may fail.", - "Start_Unzipping": "Start extracting the update package.", - "Success_Unzipping": "Successfully extracted the update package!", - "Failed_Unzipping": "Failed to extract the update package!", - "Failed_Upgrade": "Upgrade failed!", - "Success_Upgrade": "Upgrade success!", - "Information": "Information" + "Restart_v2rayN": "Start v2rayN, please wait...", + "Guidelines": "Please run it from the main application.", + "Upgrade_File_Not_Found": "Upgrade failed, file not found.", + "In_Progress": "In progress, please wait...", + "Try_Terminate_Process": "Try to terminate the v2rayN process.", + "Failed_Terminate_Process": "Failed to terminate the v2rayN.Close it manually,or the upgrade may fail.", + "Start_Unzipping": "Start extracting the update package.", + "Success_Unzipping": "Successfully extracted the update package!", + "Failed_Unzipping": "Failed to extract the update package!", + "Failed_Upgrade": "Upgrade failed!", + "Success_Upgrade": "Upgrade success!", + "Information": "Information" } \ No newline at end of file diff --git a/v2rayN/AmazTool/Assets/zh-CN.json b/v2rayN/AmazTool/Assets/zh-CN.json index a6b6a1b7..dd57bcdf 100644 --- a/v2rayN/AmazTool/Assets/zh-CN.json +++ b/v2rayN/AmazTool/Assets/zh-CN.json @@ -1,14 +1,14 @@ { - "Restart_v2rayN": "正在重启,请等待...", - "Guidelines": "请从主应用运行!", - "Upgrade_File_Not_Found": "升级失败,文件不存在!", - "In_Progress": "正在进行中,请等待...", - "Try_Terminate_Process": "尝试结束 v2rayN 进程...", - "Failed_Terminate_Process": "请手动关闭正在运行的v2rayN,否则可能升级失败。", - "Start_Unzipping": "开始解压缩更新包...", - "Success_Unzipping": "解压缩更新包成功!", - "Failed_Unzipping": "解压缩更新包失败!", - "Failed_Upgrade": "升级失败!", - "Success_Upgrade": "升级成功!", - "Information": "提示" + "Restart_v2rayN": "正在重启,请等待...", + "Guidelines": "请从主应用运行!", + "Upgrade_File_Not_Found": "升级失败,文件不存在!", + "In_Progress": "正在进行中,请等待...", + "Try_Terminate_Process": "尝试结束 v2rayN 进程...", + "Failed_Terminate_Process": "请手动关闭正在运行的v2rayN,否则可能升级失败。", + "Start_Unzipping": "开始解压缩更新包...", + "Success_Unzipping": "解压缩更新包成功!", + "Failed_Unzipping": "解压缩更新包失败!", + "Failed_Upgrade": "升级失败!", + "Success_Upgrade": "升级成功!", + "Information": "提示" } \ No newline at end of file diff --git a/v2rayN/AmazTool/LocalizationHelper.cs b/v2rayN/AmazTool/LocalizationHelper.cs index 4af352c6..f10b8e33 100644 --- a/v2rayN/AmazTool/LocalizationHelper.cs +++ b/v2rayN/AmazTool/LocalizationHelper.cs @@ -29,7 +29,7 @@ namespace AmazTool using var stream = assembly.GetManifestResourceStream(resourceName); if (stream == null) return; - + using StreamReader reader = new(stream); var json = reader.ReadToEnd(); if (!string.IsNullOrEmpty(json)) @@ -56,4 +56,4 @@ namespace AmazTool return _languageResources.TryGetValue(key, out var translation) ? translation : key; } } -} +} \ No newline at end of file diff --git a/v2rayN/AmazTool/UpgradeApp.cs b/v2rayN/AmazTool/UpgradeApp.cs index 98239961..e8ab76f2 100644 --- a/v2rayN/AmazTool/UpgradeApp.cs +++ b/v2rayN/AmazTool/UpgradeApp.cs @@ -9,7 +9,7 @@ namespace AmazTool public static void Upgrade(string fileName) { Console.WriteLine($"{LocalizationHelper.GetLocalizedValue("Start_Unzipping")}\n{fileName}"); - + Thread.Sleep(9000); if (!File.Exists(fileName)) diff --git a/v2rayN/ServiceLib/Handler/StatisticsHandler.cs b/v2rayN/ServiceLib/Handler/StatisticsHandler.cs index 377638cb..e9060cc3 100644 --- a/v2rayN/ServiceLib/Handler/StatisticsHandler.cs +++ b/v2rayN/ServiceLib/Handler/StatisticsHandler.cs @@ -9,8 +9,10 @@ private ServerStatItem? _serverStatItem; private List _lstServerStat; private Action? _updateFunc; + //private StatisticsV2rayService? _statisticsV2Ray; private StatisticsXrayService? _statisticsXray; + private StatisticsSingboxService? _statisticsSingbox; public List ServerStat => _lstServerStat; diff --git a/v2rayN/ServiceLib/Handler/SysProxy/ProxySettingOSX.cs b/v2rayN/ServiceLib/Handler/SysProxy/ProxySettingOSX.cs index 8ba1e043..6f19ffc8 100644 --- a/v2rayN/ServiceLib/Handler/SysProxy/ProxySettingOSX.cs +++ b/v2rayN/ServiceLib/Handler/SysProxy/ProxySettingOSX.cs @@ -5,6 +5,7 @@ /* * 仅测试了,MacOS 13.7.1 x86 版本,其他版本有待确认 */ + /// /// 应用接口类型 /// @@ -21,14 +22,12 @@ await ExecCmd(lstCmd); } - public static async Task UnsetProxy() { var lstCmd = GetUnsetCmds(); await ExecCmd(lstCmd); } - private static async Task ExecCmd(List lstCmd) { foreach (var cmd in lstCmd) diff --git a/v2rayN/ServiceLib/Models/Config.cs b/v2rayN/ServiceLib/Models/Config.cs index 075f5049..c0abe5c2 100644 --- a/v2rayN/ServiceLib/Models/Config.cs +++ b/v2rayN/ServiceLib/Models/Config.cs @@ -20,6 +20,7 @@ case ECoreType.Xray when RunningCoreType is ECoreType.Xray or ECoreType.v2fly or ECoreType.v2fly_v5: case ECoreType.sing_box when RunningCoreType is ECoreType.sing_box or ECoreType.mihomo: return true; + default: return false; } diff --git a/v2rayN/v2rayN.Desktop/Views/AddServerWindow.axaml.cs b/v2rayN/v2rayN.Desktop/Views/AddServerWindow.axaml.cs index f44d3926..65f79e0e 100644 --- a/v2rayN/v2rayN.Desktop/Views/AddServerWindow.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/AddServerWindow.axaml.cs @@ -209,7 +209,7 @@ namespace v2rayN.Desktop.Views this.Bind(ViewModel, vm => vm.SelectedSource.RequestHost, v => v.txtRequestHost.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.Path, v => v.txtPath.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.Extra, v => v.txtExtra.Text).DisposeWith(disposables); - + this.Bind(ViewModel, vm => vm.SelectedSource.StreamSecurity, v => v.cmbStreamSecurity.SelectedValue).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.Sni, v => v.txtSNI.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.AllowInsecure, v => v.cmbAllowInsecure.SelectedValue).DisposeWith(disposables); diff --git a/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml.cs b/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml.cs index a0ac88f8..eebc9362 100644 --- a/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/MainWindow.axaml.cs @@ -382,7 +382,7 @@ namespace v2rayN.Desktop.Views #endregion Event #region UI - + public void ShowHideWindow(bool? blShow) { var bl = blShow ?? !_config.UiItem.ShowInTaskbar; diff --git a/v2rayN/v2rayN/App.xaml b/v2rayN/v2rayN/App.xaml index b22ea83b..d78d082c 100644 --- a/v2rayN/v2rayN/App.xaml +++ b/v2rayN/v2rayN/App.xaml @@ -1,9 +1,9 @@  diff --git a/v2rayN/v2rayN/Views/AddServerWindow.xaml.cs b/v2rayN/v2rayN/Views/AddServerWindow.xaml.cs index 3d5985a4..7dd4651d 100644 --- a/v2rayN/v2rayN/Views/AddServerWindow.xaml.cs +++ b/v2rayN/v2rayN/Views/AddServerWindow.xaml.cs @@ -203,7 +203,7 @@ namespace v2rayN.Views this.Bind(ViewModel, vm => vm.SelectedSource.RequestHost, v => v.txtRequestHost.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.Path, v => v.txtPath.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.Extra, v => v.txtExtra.Text).DisposeWith(disposables); - + this.Bind(ViewModel, vm => vm.SelectedSource.StreamSecurity, v => v.cmbStreamSecurity.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.Sni, v => v.txtSNI.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.AllowInsecure, v => v.cmbAllowInsecure.Text).DisposeWith(disposables); diff --git a/v2rayN/v2rayN/Views/ClashConnectionsView.xaml b/v2rayN/v2rayN/Views/ClashConnectionsView.xaml index e5781abe..8ea9ca0b 100644 --- a/v2rayN/v2rayN/Views/ClashConnectionsView.xaml +++ b/v2rayN/v2rayN/Views/ClashConnectionsView.xaml @@ -1,11 +1,11 @@