Improved UI for routing rules

pull/5829/head
2dust 2024-10-03 13:56:06 +08:00
parent 5fbeb4b0fb
commit 3971318ffb
14 changed files with 204 additions and 102 deletions

View File

@ -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<string>? inboundTag { get; set; }
public string? outboundTag { get; set; }
public List<string>? ip { get; set; }
public List<string>? domain { get; set; }
public List<string>? protocol { get; set; }
public List<string>? process { get; set; }
public bool enabled { get; set; } = true;
public string? remarks { get; set; }
}
}

View File

@ -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; }
}
}

View File

@ -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"
}

View File

@ -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"
}

View File

@ -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"
}

View File

@ -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);
}

View File

@ -33,36 +33,56 @@
Grid.Column="0"
VerticalAlignment="Center"
Classes="Margin8"
Text="outboundTag" />
<ComboBox
x:Name="cmbOutboundTag"
Text="{x:Static resx:ResUI.LvRemarks}" />
<TextBox
x:Name="txtRemarks"
Grid.Row="0"
Grid.Column="1"
Width="200"
Classes="Margin8"
MaxDropDownHeight="1000" />
<TextBlock
HorizontalAlignment="Left"
Classes="Margin8" />
<ToggleSwitch
x:Name="togEnabled"
Grid.Row="0"
Grid.Column="2"
HorizontalAlignment="Left"
Classes="Margin8"
Text="{x:Static resx:ResUI.TbRuleMatchingTips}" />
Classes="Margin8" />
<TextBlock
Grid.Row="1"
Grid.Column="0"
VerticalAlignment="Center"
Classes="Margin8"
Text="outboundTag" />
<ComboBox
x:Name="cmbOutboundTag"
Grid.Row="1"
Grid.Column="1"
Width="200"
Classes="Margin8"
MaxDropDownHeight="1000" />
<TextBlock
Grid.Row="1"
Grid.Column="2"
HorizontalAlignment="Left"
Classes="Margin8"
Text="{x:Static resx:ResUI.TbRuleMatchingTips}" />
<TextBlock
Grid.Row="2"
Grid.Column="0"
VerticalAlignment="Center"
Classes="Margin8"
Text="port" />
<TextBox
x:Name="txtPort"
Grid.Row="1"
Grid.Row="2"
Grid.Column="1"
Width="200"
HorizontalAlignment="Left"
Classes="Margin8" />
<TextBlock
Grid.Row="1"
Grid.Row="2"
Grid.Column="2"
VerticalAlignment="Center"
Classes="Margin8">
@ -72,14 +92,14 @@
</TextBlock>
<TextBlock
Grid.Row="2"
Grid.Row="3"
Grid.Column="0"
VerticalAlignment="Center"
Classes="Margin8"
Text="protocol" />
<ListBox
x:Name="clbProtocol"
Grid.Row="2"
Grid.Row="3"
Grid.Column="1"
HorizontalAlignment="Left"
Classes="Margin8"
@ -87,46 +107,32 @@
Theme="{DynamicResource PureCardRadioGroupListBox}" />
<TextBlock
Grid.Row="3"
Grid.Row="4"
Grid.Column="0"
VerticalAlignment="Center"
Classes="Margin8"
Text="inboundTag" />
<ListBox
x:Name="clbInboundTag"
Grid.Row="3"
Grid.Row="4"
Grid.Column="1"
Classes="Margin8"
SelectionMode="Multiple"
Theme="{DynamicResource PureCardRadioGroupListBox}" />
<TextBlock
Grid.Row="4"
Grid.Row="5"
Grid.Column="0"
VerticalAlignment="Center"
Classes="Margin8"
Text="network" />
<ComboBox
x:Name="cmbNetwork"
Grid.Row="4"
Grid.Row="5"
Grid.Column="1"
Width="200"
Classes="Margin8"
MaxDropDownHeight="1000" />
<TextBlock
Grid.Row="5"
Grid.Column="0"
VerticalAlignment="Center"
Classes="Margin8"
Text="enabled" />
<ToggleSwitch
x:Name="togEnabled"
Grid.Row="5"
Grid.Column="1"
HorizontalAlignment="Left"
Classes="Margin8" />
<TextBlock
Grid.Row="5"
Grid.Column="2"
@ -169,25 +175,40 @@
<ColumnDefinition Width="10" />
<ColumnDefinition Width="1*" />
</Grid.ColumnDefinitions>
<HeaderedContentControl Grid.Column="0" Header="{x:Static resx:ResUI.TbRoutingRuleDomain}">
<HeaderedContentControl
Grid.Column="0"
BorderBrush="Gray"
BorderThickness="1"
Header="{x:Static resx:ResUI.TbRoutingRuleDomain}">
<TextBox
Name="txtDomain"
VerticalAlignment="Stretch"
Classes="TextArea"
MinLines="10"
TextWrapping="Wrap" />
</HeaderedContentControl>
<GridSplitter Grid.Column="1" HorizontalAlignment="Stretch" />
<HeaderedContentControl Grid.Column="2" Header="{x:Static resx:ResUI.TbRoutingRuleIP}">
<HeaderedContentControl
Grid.Column="2"
BorderBrush="Gray"
BorderThickness="1"
Header="{x:Static resx:ResUI.TbRoutingRuleIP}">
<TextBox
Name="txtIP"
VerticalAlignment="Stretch"
Classes="TextArea"
MinLines="10"
TextWrapping="Wrap" />
</HeaderedContentControl>
<GridSplitter Grid.Column="3" HorizontalAlignment="Stretch" />
<HeaderedContentControl Grid.Column="4" Header="{x:Static resx:ResUI.TbRoutingRuleProcess}">
<HeaderedContentControl
Grid.Column="4"
BorderBrush="Gray"
BorderThickness="1"
Header="{x:Static resx:ResUI.TbRoutingRuleProcess}">
<TextBox
Name="txtProcess"
VerticalAlignment="Stretch"
Classes="TextArea"
MinLines="10"
TextWrapping="Wrap" />

View File

@ -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);

View File

@ -206,20 +206,28 @@
</ContextMenu>
</DataGrid.ContextMenu>
<DataGrid.Columns>
<DataGridCheckBoxColumn
Width="60"
Binding="{Binding enabled}"
Header="" />
<DataGridTextColumn
Width="110"
Width="150"
Binding="{Binding remarks}"
Header="{x:Static resx:ResUI.LvRemarks}" />
<DataGridTextColumn
Width="120"
Binding="{Binding outboundTag}"
Header="outboundTag" />
<DataGridTextColumn
Width="80"
Width="100"
Binding="{Binding port}"
Header="port" />
<DataGridTextColumn
Width="80"
Width="100"
Binding="{Binding protocols}"
Header="protocol" />
<DataGridTextColumn
Width="110"
Width="120"
Binding="{Binding inboundTags}"
Header="inboundTag" />
<DataGridTextColumn
@ -227,17 +235,13 @@
Binding="{Binding network}"
Header="network" />
<DataGridTextColumn
Width="190"
Width="200"
Binding="{Binding domains}"
Header="domain" />
<DataGridTextColumn
Width="190"
Width="200"
Binding="{Binding ips}"
Header="ip" />
<DataGridTextColumn
Width="80"
Binding="{Binding enabled}"
Header="enabled" />
</DataGrid.Columns>
</DataGrid>
</TabItem>

View File

@ -50,7 +50,7 @@
Width="150"
Binding="{Binding url}"
Header="{x:Static resx:ResUI.LvUrl}" />
<DataGridTextColumn
<DataGridCheckBoxColumn
Width="100"
Binding="{Binding enabled}"
Header="{x:Static resx:ResUI.LvEnabled}" />

View File

@ -37,28 +37,28 @@
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock
Grid.Row="0"
Grid.Column="0"
Margin="4"
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}"
Text="outboundTag" />
<ComboBox
x:Name="cmbOutboundTag"
Text="{x:Static resx:ResUI.LvRemarks}" />
<TextBox
x:Name="txtRemarks"
Grid.Row="0"
Grid.Column="1"
Width="200"
Margin="4"
MaxDropDownHeight="1000"
Style="{StaticResource DefComboBox}" />
<TextBlock
HorizontalAlignment="Left"
Style="{StaticResource DefTextBox}" />
<ToggleButton
x:Name="togEnabled"
Grid.Row="0"
Grid.Column="2"
Margin="4"
HorizontalAlignment="Left"
Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.TbRuleMatchingTips}" />
HorizontalAlignment="Left" />
<TextBlock
Grid.Row="1"
@ -66,17 +66,40 @@
Margin="4"
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}"
Text="outboundTag" />
<ComboBox
x:Name="cmbOutboundTag"
Grid.Row="1"
Grid.Column="1"
Width="200"
Margin="4"
MaxDropDownHeight="1000"
Style="{StaticResource DefComboBox}" />
<TextBlock
Grid.Row="1"
Grid.Column="2"
Margin="4"
HorizontalAlignment="Left"
Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.TbRuleMatchingTips}" />
<TextBlock
Grid.Row="2"
Grid.Column="0"
Margin="4"
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}"
Text="port" />
<TextBox
x:Name="txtPort"
Grid.Row="1"
Grid.Row="2"
Grid.Column="1"
Width="200"
Margin="4"
HorizontalAlignment="Left"
Style="{StaticResource DefTextBox}" />
<TextBlock
Grid.Row="1"
Grid.Row="2"
Grid.Column="2"
Margin="4"
VerticalAlignment="Center"
@ -88,7 +111,7 @@
</TextBlock>
<TextBlock
Grid.Row="2"
Grid.Row="3"
Grid.Column="0"
Margin="4"
VerticalAlignment="Center"
@ -96,7 +119,7 @@
Text="protocol" />
<ListBox
x:Name="clbProtocol"
Grid.Row="2"
Grid.Row="3"
Grid.Column="1"
Margin="4"
HorizontalAlignment="Left"
@ -104,7 +127,7 @@
Style="{StaticResource MaterialDesignFilterChipPrimaryListBox}" />
<TextBlock
Grid.Row="3"
Grid.Row="4"
Grid.Column="0"
Margin="4"
VerticalAlignment="Center"
@ -112,14 +135,14 @@
Text="inboundTag" />
<ListBox
x:Name="clbInboundTag"
Grid.Row="3"
Grid.Row="4"
Grid.Column="1"
Margin="4"
FontSize="{DynamicResource StdFontSize}"
Style="{StaticResource MaterialDesignFilterChipPrimaryListBox}" />
<TextBlock
Grid.Row="4"
Grid.Row="5"
Grid.Column="0"
Margin="4"
VerticalAlignment="Center"
@ -127,27 +150,13 @@
Text="network" />
<ComboBox
x:Name="cmbNetwork"
Grid.Row="4"
Grid.Row="5"
Grid.Column="1"
Width="200"
Margin="4"
MaxDropDownHeight="1000"
Style="{StaticResource DefComboBox}" />
<TextBlock
Grid.Row="5"
Grid.Column="0"
Margin="4"
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}"
Text="enabled" />
<ToggleButton
x:Name="togEnabled"
Grid.Row="5"
Grid.Column="1"
Margin="4"
HorizontalAlignment="Left" />
<TextBlock
Grid.Row="5"
Grid.Column="2"
@ -155,6 +164,8 @@
HorizontalAlignment="Left"
Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.TbRoutingTips}" />
</Grid>
<StackPanel

View File

@ -46,6 +46,7 @@ namespace v2rayN.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.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);

View File

@ -297,20 +297,28 @@
</ContextMenu>
</DataGrid.ContextMenu>
<DataGrid.Columns>
<DataGridCheckBoxColumn
Width="60"
Binding="{Binding enabled}"
Header="" />
<DataGridTextColumn
Width="110"
Width="150"
Binding="{Binding remarks}"
Header="{x:Static resx:ResUI.LvRemarks}" />
<DataGridTextColumn
Width="120"
Binding="{Binding outboundTag}"
Header="outboundTag" />
<DataGridTextColumn
Width="80"
Width="100"
Binding="{Binding port}"
Header="port" />
<DataGridTextColumn
Width="80"
Width="100"
Binding="{Binding protocols}"
Header="protocol" />
<DataGridTextColumn
Width="110"
Width="120"
Binding="{Binding inboundTags}"
Header="inboundTag" />
<DataGridTextColumn
@ -318,17 +326,13 @@
Binding="{Binding network}"
Header="network" />
<DataGridTextColumn
Width="190"
Width="200"
Binding="{Binding domains}"
Header="domain" />
<DataGridTextColumn
Width="190"
Width="200"
Binding="{Binding ips}"
Header="ip" />
<DataGridTextColumn
Width="80"
Binding="{Binding enabled}"
Header="enabled" />
</DataGrid.Columns>
</DataGrid>
</TabItem>

View File

@ -105,7 +105,7 @@
Width="150"
Binding="{Binding url}"
Header="{x:Static resx:ResUI.LvUrl}" />
<DataGridTextColumn
<DataGridCheckBoxColumn
Width="100"
Binding="{Binding enabled}"
Header="{x:Static resx:ResUI.LvEnabled}" />