From 1360051f0c1858c43806b2d067740e240661b715 Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Tue, 15 Jul 2025 20:17:01 +0800 Subject: [PATCH] Improve and optimize --- v2rayN/ServiceLib/Global.cs | 7 +++++++ .../Services/CoreConfig/CoreConfigSingboxService.cs | 2 +- .../Services/CoreConfig/CoreConfigV2rayService.cs | 2 +- .../Views/RoutingRuleDetailsWindow.axaml.cs | 3 ++- v2rayN/v2rayN/Views/RoutingRuleDetailsWindow.xaml.cs | 8 +++++--- 5 files changed, 16 insertions(+), 6 deletions(-) diff --git a/v2rayN/ServiceLib/Global.cs b/v2rayN/ServiceLib/Global.cs index 4ea57a20..5592fa2e 100644 --- a/v2rayN/ServiceLib/Global.cs +++ b/v2rayN/ServiceLib/Global.cs @@ -528,5 +528,12 @@ public class Global @"" ]; + public static readonly List OutboundTags = + [ + ProxyTag, + DirectTag, + BlockTag + ]; + #endregion const } diff --git a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs index 44d45ab2..fdc03058 100644 --- a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs +++ b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs @@ -1369,7 +1369,7 @@ public class CoreConfigSingboxService private async Task GenRoutingUserRuleOutbound(string outboundTag, SingboxConfig singboxConfig) { - if (outboundTag is Global.ProxyTag or Global.DirectTag or Global.BlockTag) + if (Global.OutboundTags.Contains(outboundTag)) { return outboundTag; } diff --git a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs index 73e638d0..9be1acf0 100644 --- a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs +++ b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs @@ -631,7 +631,7 @@ public class CoreConfigV2rayService private async Task GenRoutingUserRuleOutbound(string outboundTag, V2rayConfig v2rayConfig) { - if (outboundTag is Global.ProxyTag or Global.DirectTag or Global.BlockTag) + if (Global.OutboundTags.Contains(outboundTag)) { return outboundTag; } diff --git a/v2rayN/v2rayN.Desktop/Views/RoutingRuleDetailsWindow.axaml.cs b/v2rayN/v2rayN.Desktop/Views/RoutingRuleDetailsWindow.axaml.cs index c78e30cb..35791788 100644 --- a/v2rayN/v2rayN.Desktop/Views/RoutingRuleDetailsWindow.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/RoutingRuleDetailsWindow.axaml.cs @@ -23,7 +23,8 @@ public partial class RoutingRuleDetailsWindow : WindowBase { Global.ProxyTag, Global.DirectTag, Global.BlockTag }; + + cmbOutboundTag.ItemsSource = Global.OutboundTags; Global.RuleProtocols.ForEach(it => { clbProtocol.Items.Add(it); diff --git a/v2rayN/v2rayN/Views/RoutingRuleDetailsWindow.xaml.cs b/v2rayN/v2rayN/Views/RoutingRuleDetailsWindow.xaml.cs index 72146781..b04f9df2 100644 --- a/v2rayN/v2rayN/Views/RoutingRuleDetailsWindow.xaml.cs +++ b/v2rayN/v2rayN/Views/RoutingRuleDetailsWindow.xaml.cs @@ -16,9 +16,11 @@ public partial class RoutingRuleDetailsWindow clbInboundTag.SelectionChanged += ClbInboundTag_SelectionChanged; ViewModel = new RoutingRuleDetailsViewModel(rulesItem, UpdateViewHandler); - cmbOutboundTag.Items.Add(Global.ProxyTag); - cmbOutboundTag.Items.Add(Global.DirectTag); - cmbOutboundTag.Items.Add(Global.BlockTag); + + Global.OutboundTags.ForEach(it => + { + cmbOutboundTag.Items.Add(it); + }); Global.RuleProtocols.ForEach(it => { clbProtocol.Items.Add(it);