From 3971318ffb1c425f808fa71e86bf1f6cbf9fdb27 Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Thu, 3 Oct 2024 13:56:06 +0800 Subject: [PATCH] Improved UI for routing rules --- v2rayN/ServiceLib/Models/RulesItem.cs | 9 +- v2rayN/ServiceLib/Models/RulesItemModel.cs | 3 - v2rayN/ServiceLib/Sample/custom_routing_black | 29 ++++++- .../ServiceLib/Sample/custom_routing_global | 23 +++++ v2rayN/ServiceLib/Sample/custom_routing_white | 27 +++++- .../ViewModels/RoutingRuleSettingViewModel.cs | 1 + .../Views/RoutingRuleDetailsWindow.axaml | 87 ++++++++++++------- .../Views/RoutingRuleDetailsWindow.axaml.cs | 1 + .../Views/RoutingRuleSettingWindow.axaml | 24 ++--- .../Views/SubSettingWindow.axaml | 2 +- .../Views/RoutingRuleDetailsWindow.xaml | 73 +++++++++------- .../Views/RoutingRuleDetailsWindow.xaml.cs | 1 + .../Views/RoutingRuleSettingWindow.xaml | 24 ++--- v2rayN/v2rayN/Views/SubSettingWindow.xaml | 2 +- 14 files changed, 204 insertions(+), 102 deletions(-) diff --git a/v2rayN/ServiceLib/Models/RulesItem.cs b/v2rayN/ServiceLib/Models/RulesItem.cs index 7581d435..39ddd4ea 100644 --- a/v2rayN/ServiceLib/Models/RulesItem.cs +++ b/v2rayN/ServiceLib/Models/RulesItem.cs @@ -5,22 +5,15 @@ { public string id { get; set; } public string? type { get; set; } - public string? port { get; set; } public string? network { get; set; } - public List? inboundTag { get; set; } - public string? outboundTag { get; set; } - public List? ip { get; set; } - public List? domain { get; set; } - public List? protocol { get; set; } - public List? process { get; set; } - public bool enabled { get; set; } = true; + public string? remarks { get; set; } } } \ No newline at end of file diff --git a/v2rayN/ServiceLib/Models/RulesItemModel.cs b/v2rayN/ServiceLib/Models/RulesItemModel.cs index adffb011..0bbdb9cf 100644 --- a/v2rayN/ServiceLib/Models/RulesItemModel.cs +++ b/v2rayN/ServiceLib/Models/RulesItemModel.cs @@ -4,11 +4,8 @@ public class RulesItemModel : RulesItem { public string inboundTags { get; set; } - public string ips { get; set; } - public string domains { get; set; } - public string protocols { get; set; } } } \ No newline at end of file diff --git a/v2rayN/ServiceLib/Sample/custom_routing_black b/v2rayN/ServiceLib/Sample/custom_routing_black index 05ff79d5..c10156a3 100644 --- a/v2rayN/ServiceLib/Sample/custom_routing_black +++ b/v2rayN/ServiceLib/Sample/custom_routing_black @@ -1,30 +1,56 @@ [ { + "remarks": "绕过bittorrent", "outboundTag": "direct", "protocol": [ "bittorrent" ] }, { + "remarks": "Google cn", + "outboundTag": "proxy", + "domain": [ + "domain:googleapis.cn", + "domain:gstatic.com" + ] + }, + { + "remarks": "阻断udp443", "outboundTag": "block", "port": "443", "network": "udp" }, { + "remarks": "阻断广告", "outboundTag": "block", "domain": [ "geosite:category-ads-all" ] }, { + "remarks": "绕过局域网IP", + "outboundTag": "direct", + "ip": [ + "geoip:private" + ] + }, + { + "remarks": "绕过局域网域名", + "outboundTag": "direct", + "domain": [ + "geosite:private" + ] + }, + { + "remarks": "代理GFW", "outboundTag": "proxy", - "domain": [ "geosite:gfw", "geosite:greatfire" ] }, { + "remarks": "代理Google等", "outboundTag": "proxy", "ip": [ "1.0.0.1", @@ -40,6 +66,7 @@ ] }, { + "remarks": "最终直连", "port": "0-65535", "outboundTag": "direct" } diff --git a/v2rayN/ServiceLib/Sample/custom_routing_global b/v2rayN/ServiceLib/Sample/custom_routing_global index 55c341a4..896ff5b9 100644 --- a/v2rayN/ServiceLib/Sample/custom_routing_global +++ b/v2rayN/ServiceLib/Sample/custom_routing_global @@ -1,10 +1,33 @@ [ { + "remarks": "阻断udp443", "outboundTag": "block", "port": "443", "network": "udp" }, { + "remarks": "阻断广告", + "outboundTag": "block", + "domain": [ + "geosite:category-ads-all" + ] + }, + { + "remarks": "绕过局域网IP", + "outboundTag": "direct", + "ip": [ + "geoip:private" + ] + }, + { + "remarks": "绕过局域网域名", + "outboundTag": "direct", + "domain": [ + "geosite:private" + ] + }, + { + "remarks": "最终代理", "port": "0-65535", "outboundTag": "proxy" } diff --git a/v2rayN/ServiceLib/Sample/custom_routing_white b/v2rayN/ServiceLib/Sample/custom_routing_white index f688fb2e..892fd19a 100644 --- a/v2rayN/ServiceLib/Sample/custom_routing_white +++ b/v2rayN/ServiceLib/Sample/custom_routing_white @@ -1,23 +1,41 @@ [ { - "outboundTag": "direct", + "remarks": "Google cn", + "outboundTag": "proxy", "domain": [ - "domain:example-example.com", - "domain:example-example2.com" + "domain:googleapis.cn", + "domain:gstatic.com" ] }, { + "remarks": "阻断udp443", "outboundTag": "block", "port": "443", "network": "udp" }, { + "remarks": "阻断广告", "outboundTag": "block", "domain": [ "geosite:category-ads-all" ] }, { + "remarks": "绕过局域网IP", + "outboundTag": "direct", + "ip": [ + "geoip:private" + ] + }, + { + "remarks": "绕过局域网域名", + "outboundTag": "direct", + "domain": [ + "geosite:private" + ] + }, + { + "remarks": "绕过中国域名", "outboundTag": "direct", "domain": [ "domain:dns.alidns.com", @@ -30,6 +48,7 @@ ] }, { + "remarks": "绕过中国IP", "outboundTag": "direct", "ip": [ "223.5.5.5/32", @@ -51,11 +70,11 @@ "218.30.118.6/32", "123.125.81.6/32", "140.207.198.6/32", - "geoip:private", "geoip:cn" ] }, { + "remarks": "最终代理", "port": "0-65535", "outboundTag": "proxy" } diff --git a/v2rayN/ServiceLib/ViewModels/RoutingRuleSettingViewModel.cs b/v2rayN/ServiceLib/ViewModels/RoutingRuleSettingViewModel.cs index fa0a57ef..3adfa633 100644 --- a/v2rayN/ServiceLib/ViewModels/RoutingRuleSettingViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/RoutingRuleSettingViewModel.cs @@ -124,6 +124,7 @@ namespace ServiceLib.ViewModels domains = Utils.List2String(item.domain), ips = Utils.List2String(item.ip), enabled = item.enabled, + remarks = item.remarks, }; _rulesItems.Add(it); } diff --git a/v2rayN/v2rayN.Desktop/Views/RoutingRuleDetailsWindow.axaml b/v2rayN/v2rayN.Desktop/Views/RoutingRuleDetailsWindow.axaml index 565e766a..b11ce805 100644 --- a/v2rayN/v2rayN.Desktop/Views/RoutingRuleDetailsWindow.axaml +++ b/v2rayN/v2rayN.Desktop/Views/RoutingRuleDetailsWindow.axaml @@ -33,36 +33,56 @@ Grid.Column="0" VerticalAlignment="Center" Classes="Margin8" - Text="outboundTag" /> - + - + + Classes="Margin8" /> + + + + @@ -72,14 +92,14 @@ - - - - - + - + - + diff --git a/v2rayN/v2rayN.Desktop/Views/RoutingRuleDetailsWindow.axaml.cs b/v2rayN/v2rayN.Desktop/Views/RoutingRuleDetailsWindow.axaml.cs index cd9359cd..a4ac7696 100644 --- a/v2rayN/v2rayN.Desktop/Views/RoutingRuleDetailsWindow.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/RoutingRuleDetailsWindow.axaml.cs @@ -53,6 +53,7 @@ namespace v2rayN.Desktop.Views this.WhenActivated(disposables => { + this.Bind(ViewModel, vm => vm.SelectedSource.remarks, v => v.txtRemarks.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.outboundTag, v => v.cmbOutboundTag.SelectedValue).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.port, v => v.txtPort.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.network, v => v.cmbNetwork.SelectedValue).DisposeWith(disposables); diff --git a/v2rayN/v2rayN.Desktop/Views/RoutingRuleSettingWindow.axaml b/v2rayN/v2rayN.Desktop/Views/RoutingRuleSettingWindow.axaml index 440404be..c8867854 100644 --- a/v2rayN/v2rayN.Desktop/Views/RoutingRuleSettingWindow.axaml +++ b/v2rayN/v2rayN.Desktop/Views/RoutingRuleSettingWindow.axaml @@ -206,20 +206,28 @@ + + - diff --git a/v2rayN/v2rayN.Desktop/Views/SubSettingWindow.axaml b/v2rayN/v2rayN.Desktop/Views/SubSettingWindow.axaml index 3d579d5a..929ca75c 100644 --- a/v2rayN/v2rayN.Desktop/Views/SubSettingWindow.axaml +++ b/v2rayN/v2rayN.Desktop/Views/SubSettingWindow.axaml @@ -50,7 +50,7 @@ Width="150" Binding="{Binding url}" Header="{x:Static resx:ResUI.LvUrl}" /> - diff --git a/v2rayN/v2rayN/Views/RoutingRuleDetailsWindow.xaml b/v2rayN/v2rayN/Views/RoutingRuleDetailsWindow.xaml index 4de2a494..86740dcd 100644 --- a/v2rayN/v2rayN/Views/RoutingRuleDetailsWindow.xaml +++ b/v2rayN/v2rayN/Views/RoutingRuleDetailsWindow.xaml @@ -37,28 +37,28 @@ + - + - + + HorizontalAlignment="Left" /> + + + + - - - + + { + this.Bind(ViewModel, vm => vm.SelectedSource.remarks, v => v.txtRemarks.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.outboundTag, v => v.cmbOutboundTag.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.port, v => v.txtPort.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.network, v => v.cmbNetwork.Text).DisposeWith(disposables); diff --git a/v2rayN/v2rayN/Views/RoutingRuleSettingWindow.xaml b/v2rayN/v2rayN/Views/RoutingRuleSettingWindow.xaml index cf2d4654..9edd2287 100644 --- a/v2rayN/v2rayN/Views/RoutingRuleSettingWindow.xaml +++ b/v2rayN/v2rayN/Views/RoutingRuleSettingWindow.xaml @@ -297,20 +297,28 @@ + + - diff --git a/v2rayN/v2rayN/Views/SubSettingWindow.xaml b/v2rayN/v2rayN/Views/SubSettingWindow.xaml index 65177272..7042ce32 100644 --- a/v2rayN/v2rayN/Views/SubSettingWindow.xaml +++ b/v2rayN/v2rayN/Views/SubSettingWindow.xaml @@ -105,7 +105,7 @@ Width="150" Binding="{Binding url}" Header="{x:Static resx:ResUI.LvUrl}" /> -