Optimize the ruletype UI

This commit is contained in:
2dust 2025-10-08 14:12:16 +08:00
parent 31b5b4ca0c
commit 1607525539
13 changed files with 146 additions and 56 deletions

View file

@ -7,4 +7,5 @@ public class RulesItemModel : RulesItem
public string Ips { get; set; } public string Ips { get; set; }
public string Domains { get; set; } public string Domains { get; set; }
public string Protocols { get; set; } public string Protocols { get; set; }
public string RuleTypeName { get; set; }
} }

View file

@ -3156,6 +3156,24 @@ namespace ServiceLib.Resx {
} }
} }
/// <summary>
/// 查找类似 Rule Type 的本地化字符串。
/// </summary>
public static string TbRuleType {
get {
return ResourceManager.GetString("TbRuleType", resourceCulture);
}
}
/// <summary>
/// 查找类似 You can set separate rules for Routing and DNS, or select &quot;ALL&quot; to apply to both 的本地化字符串。
/// </summary>
public static string TbRuleTypeTips {
get {
return ResourceManager.GetString("TbRuleTypeTips", resourceCulture);
}
}
/// <summary> /// <summary>
/// 查找类似 Bootstrap DNS (sing-box) 的本地化字符串。 /// 查找类似 Bootstrap DNS (sing-box) 的本地化字符串。
/// </summary> /// </summary>

View file

@ -1596,4 +1596,10 @@
<data name="TbSettingsHide2TrayWhenCloseTip" xml:space="preserve"> <data name="TbSettingsHide2TrayWhenCloseTip" xml:space="preserve">
<value>If the system does not have a tray function, please do not enable it</value> <value>If the system does not have a tray function, please do not enable it</value>
</data> </data>
<data name="TbRuleType" xml:space="preserve">
<value>Rule Type</value>
</data>
<data name="TbRuleTypeTips" xml:space="preserve">
<value>You can set separate rules for Routing and DNS, or select "ALL" to apply to both</value>
</data>
</root> </root>

View file

@ -1596,4 +1596,10 @@
<data name="TbSettingsHide2TrayWhenCloseTip" xml:space="preserve"> <data name="TbSettingsHide2TrayWhenCloseTip" xml:space="preserve">
<value>If the system does not have a tray function, please do not enable it</value> <value>If the system does not have a tray function, please do not enable it</value>
</data> </data>
<data name="TbRuleTypeTips" xml:space="preserve">
<value>You can set separate rules for Routing and DNS, or select "ALL" to apply to both</value>
</data>
<data name="TbRuleType" xml:space="preserve">
<value>Rule Type</value>
</data>
</root> </root>

View file

@ -1596,4 +1596,10 @@
<data name="TbSettingsHide2TrayWhenCloseTip" xml:space="preserve"> <data name="TbSettingsHide2TrayWhenCloseTip" xml:space="preserve">
<value>If the system does not have a tray function, please do not enable it</value> <value>If the system does not have a tray function, please do not enable it</value>
</data> </data>
<data name="TbRuleTypeTips" xml:space="preserve">
<value>You can set separate rules for Routing and DNS, or select "ALL" to apply to both</value>
</data>
<data name="TbRuleType" xml:space="preserve">
<value>Rule Type</value>
</data>
</root> </root>

View file

@ -1596,4 +1596,10 @@
<data name="TbSettingsHide2TrayWhenCloseTip" xml:space="preserve"> <data name="TbSettingsHide2TrayWhenCloseTip" xml:space="preserve">
<value>If the system does not have a tray function, please do not enable it</value> <value>If the system does not have a tray function, please do not enable it</value>
</data> </data>
<data name="TbRuleTypeTips" xml:space="preserve">
<value>You can set separate rules for Routing and DNS, or select "ALL" to apply to both</value>
</data>
<data name="TbRuleType" xml:space="preserve">
<value>Rule Type</value>
</data>
</root> </root>

View file

@ -1593,4 +1593,10 @@
<data name="TbSettingsHide2TrayWhenCloseTip" xml:space="preserve"> <data name="TbSettingsHide2TrayWhenCloseTip" xml:space="preserve">
<value>如果系统没有托盘功能,请不要开启</value> <value>如果系统没有托盘功能,请不要开启</value>
</data> </data>
<data name="TbRuleType" xml:space="preserve">
<value>规则类型</value>
</data>
<data name="TbRuleTypeTips" xml:space="preserve">
<value>可对 Routing 和 DNS 单独设定规则ALL 则都生效</value>
</data>
</root> </root>

View file

@ -1593,4 +1593,10 @@
<data name="TbSettingsHide2TrayWhenCloseTip" xml:space="preserve"> <data name="TbSettingsHide2TrayWhenCloseTip" xml:space="preserve">
<value>如果系統沒有托盤功能,請不要開啟</value> <value>如果系統沒有托盤功能,請不要開啟</value>
</data> </data>
<data name="TbRuleType" xml:space="preserve">
<value>规则类型</value>
</data>
<data name="TbRuleTypeTips" xml:space="preserve">
<value>可对 Routing 和 DNS 单独设定规则ALL 则都生效</value>
</data>
</root> </root>

View file

@ -107,13 +107,13 @@ public class RoutingRuleSettingViewModel : MyReactiveObject
var it = new RulesItemModel() var it = new RulesItemModel()
{ {
Id = item.Id, Id = item.Id,
RuleTypeName = item.RuleType?.ToString(),
OutboundTag = item.OutboundTag, OutboundTag = item.OutboundTag,
Port = item.Port, Port = item.Port,
Network = item.Network, Network = item.Network,
Protocols = Utils.List2String(item.Protocol), Protocols = Utils.List2String(item.Protocol),
InboundTags = Utils.List2String(item.InboundTag), InboundTags = Utils.List2String(item.InboundTag),
Domains = Utils.List2String(item.Domain), Domains = Utils.List2String((item.Domain ?? []).Concat(item.Ip ?? []).ToList()),
Ips = Utils.List2String(item.Ip),
Enabled = item.Enabled, Enabled = item.Enabled,
Remarks = item.Remarks, Remarks = item.Remarks,
}; };

View file

@ -18,7 +18,7 @@
Margin="{StaticResource Margin4}" Margin="{StaticResource Margin4}"
ColumnDefinitions="Auto,Auto,Auto" ColumnDefinitions="Auto,Auto,Auto"
DockPanel.Dock="Top" DockPanel.Dock="Top"
RowDefinitions="Auto,Auto,Auto,Auto,Auto,Auto"> RowDefinitions="Auto,Auto,Auto,Auto,Auto,Auto,Auto">
<TextBlock <TextBlock
Grid.Row="0" Grid.Row="0"
Grid.Column="0" Grid.Column="0"
@ -44,11 +44,6 @@
Margin="{StaticResource Margin4}" Margin="{StaticResource Margin4}"
HorizontalAlignment="Left" HorizontalAlignment="Left"
VerticalAlignment="Center" /> VerticalAlignment="Center" />
<ComboBox
x:Name="cmbRuleType"
Width="300"
Margin="{StaticResource Margin4}"
MaxDropDownHeight="1000" />
</StackPanel> </StackPanel>
@ -57,16 +52,37 @@
Grid.Column="0" Grid.Column="0"
Margin="{StaticResource Margin4}" Margin="{StaticResource Margin4}"
VerticalAlignment="Center" VerticalAlignment="Center"
Text="{x:Static resx:ResUI.TbRuleType}" />
<ComboBox
x:Name="cmbRuleType"
Grid.Row="1"
Grid.Column="1"
Width="300"
Margin="{StaticResource Margin4}"
MaxDropDownHeight="1000" />
<TextBlock
Grid.Row="1"
Grid.Column="2"
Margin="{StaticResource Margin4}"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Text="{x:Static resx:ResUI.TbRuleTypeTips}" />
<TextBlock
Grid.Row="2"
Grid.Column="0"
Margin="{StaticResource Margin4}"
VerticalAlignment="Center"
Text="outboundTag" /> Text="outboundTag" />
<ComboBox <ComboBox
Name="cmbOutboundTag" Name="cmbOutboundTag"
Grid.Row="1" Grid.Row="2"
Grid.Column="1" Grid.Column="1"
Width="300" Width="300"
Margin="{StaticResource Margin4}" Margin="{StaticResource Margin4}"
IsEditable="True" /> IsEditable="True" />
<StackPanel <StackPanel
Grid.Row="1" Grid.Row="2"
Grid.Column="2" Grid.Column="2"
Margin="{StaticResource Margin4}" Margin="{StaticResource Margin4}"
HorizontalAlignment="Left" HorizontalAlignment="Left"
@ -81,20 +97,20 @@
</StackPanel> </StackPanel>
<TextBlock <TextBlock
Grid.Row="2" Grid.Row="3"
Grid.Column="0" Grid.Column="0"
Margin="{StaticResource Margin4}" Margin="{StaticResource Margin4}"
VerticalAlignment="Center" VerticalAlignment="Center"
Text="port" /> Text="port" />
<TextBox <TextBox
x:Name="txtPort" x:Name="txtPort"
Grid.Row="2" Grid.Row="3"
Grid.Column="1" Grid.Column="1"
Width="300" Width="300"
Margin="{StaticResource Margin4}" Margin="{StaticResource Margin4}"
HorizontalAlignment="Left" /> HorizontalAlignment="Left" />
<TextBlock <TextBlock
Grid.Row="2" Grid.Row="3"
Grid.Column="2" Grid.Column="2"
Margin="{StaticResource Margin4}" Margin="{StaticResource Margin4}"
HorizontalAlignment="Left" HorizontalAlignment="Left"
@ -102,21 +118,21 @@
Text="{x:Static resx:ResUI.TbRuleMatchingTips}" /> Text="{x:Static resx:ResUI.TbRuleMatchingTips}" />
<TextBlock <TextBlock
Grid.Row="3" Grid.Row="4"
Grid.Column="0" Grid.Column="0"
Margin="{StaticResource Margin4}" Margin="{StaticResource Margin4}"
VerticalAlignment="Center" VerticalAlignment="Center"
Text="protocol" /> Text="protocol" />
<ListBox <ListBox
x:Name="clbProtocol" x:Name="clbProtocol"
Grid.Row="3" Grid.Row="4"
Grid.Column="1" Grid.Column="1"
Margin="{StaticResource Margin4}" Margin="{StaticResource Margin4}"
HorizontalAlignment="Left" HorizontalAlignment="Left"
SelectionMode="Multiple,Toggle" SelectionMode="Multiple,Toggle"
Theme="{DynamicResource CardCheckGroupListBox}" /> Theme="{DynamicResource CardCheckGroupListBox}" />
<TextBlock <TextBlock
Grid.Row="3" Grid.Row="4"
Grid.Column="2" Grid.Column="2"
Margin="{StaticResource Margin4}" Margin="{StaticResource Margin4}"
VerticalAlignment="Center"> VerticalAlignment="Center">
@ -126,20 +142,20 @@
</TextBlock> </TextBlock>
<TextBlock <TextBlock
Grid.Row="4" Grid.Row="5"
Grid.Column="0" Grid.Column="0"
Margin="{StaticResource Margin4}" Margin="{StaticResource Margin4}"
VerticalAlignment="Center" VerticalAlignment="Center"
Text="inboundTag" /> Text="inboundTag" />
<ListBox <ListBox
x:Name="clbInboundTag" x:Name="clbInboundTag"
Grid.Row="4" Grid.Row="5"
Grid.Column="1" Grid.Column="1"
Margin="{StaticResource Margin4}" Margin="{StaticResource Margin4}"
SelectionMode="Multiple,Toggle" SelectionMode="Multiple,Toggle"
Theme="{DynamicResource CardCheckGroupListBox}" /> Theme="{DynamicResource CardCheckGroupListBox}" />
<TextBlock <TextBlock
Grid.Row="4" Grid.Row="5"
Grid.Column="2" Grid.Column="2"
Margin="{StaticResource Margin4}" Margin="{StaticResource Margin4}"
HorizontalAlignment="Left" HorizontalAlignment="Left"
@ -147,20 +163,20 @@
Text="{x:Static resx:ResUI.TbRoutingInboundTagTips}" /> Text="{x:Static resx:ResUI.TbRoutingInboundTagTips}" />
<TextBlock <TextBlock
Grid.Row="5" Grid.Row="6"
Grid.Column="0" Grid.Column="0"
Margin="{StaticResource Margin4}" Margin="{StaticResource Margin4}"
VerticalAlignment="Center" VerticalAlignment="Center"
Text="network" /> Text="network" />
<ComboBox <ComboBox
x:Name="cmbNetwork" x:Name="cmbNetwork"
Grid.Row="5" Grid.Row="6"
Grid.Column="1" Grid.Column="1"
Width="300" Width="300"
Margin="{StaticResource Margin4}" Margin="{StaticResource Margin4}"
MaxDropDownHeight="1000" /> MaxDropDownHeight="1000" />
<TextBlock <TextBlock
Grid.Row="5" Grid.Row="6"
Grid.Column="2" Grid.Column="2"
Margin="{StaticResource Margin4}" Margin="{StaticResource Margin4}"
HorizontalAlignment="Left" HorizontalAlignment="Left"

View file

@ -209,7 +209,11 @@
Binding="{Binding Remarks}" Binding="{Binding Remarks}"
Header="{x:Static resx:ResUI.LvRemarks}" /> Header="{x:Static resx:ResUI.LvRemarks}" />
<DataGridTextColumn <DataGridTextColumn
Width="120" Width="100"
Binding="{Binding RuleTypeName}"
Header="{x:Static resx:ResUI.TbRuleType}" />
<DataGridTextColumn
Width="130"
Binding="{Binding OutboundTag}" Binding="{Binding OutboundTag}"
Header="outboundTag" /> Header="outboundTag" />
<DataGridTextColumn <DataGridTextColumn
@ -225,17 +229,13 @@
Binding="{Binding InboundTags}" Binding="{Binding InboundTags}"
Header="inboundTag" /> Header="inboundTag" />
<DataGridTextColumn <DataGridTextColumn
Width="90" Width="100"
Binding="{Binding Network}" Binding="{Binding Network}"
Header="network" /> Header="network" />
<DataGridTextColumn <DataGridTextColumn
Width="*" Width="*"
Binding="{Binding Domains}" Binding="{Binding Domains}"
Header="domain" /> Header="domain / ip" />
<DataGridTextColumn
Width="*"
Binding="{Binding Ips}"
Header="ip" />
</DataGrid.Columns> </DataGrid.Columns>
</DataGrid> </DataGrid>
</TabItem> </TabItem>

View file

@ -26,6 +26,7 @@
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" />
@ -60,12 +61,6 @@
Margin="{StaticResource Margin4}" Margin="{StaticResource Margin4}"
HorizontalAlignment="Left" HorizontalAlignment="Left"
VerticalAlignment="Center" /> VerticalAlignment="Center" />
<ComboBox
x:Name="cmbRuleType"
Width="200"
Margin="{StaticResource Margin4}"
MaxDropDownHeight="1000"
Style="{StaticResource DefComboBox}" />
</StackPanel> </StackPanel>
<TextBlock <TextBlock
@ -74,10 +69,34 @@
Margin="{StaticResource Margin4}" Margin="{StaticResource Margin4}"
VerticalAlignment="Center" VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}" Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.TbRuleType}" />
<ComboBox
x:Name="cmbRuleType"
Grid.Row="1"
Grid.Column="1"
Width="200"
Margin="{StaticResource Margin4}"
MaxDropDownHeight="1000"
Style="{StaticResource DefComboBox}" />
<TextBlock
Grid.Row="1"
Grid.Column="2"
Margin="{StaticResource Margin4}"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.TbRuleTypeTips}" />
<TextBlock
Grid.Row="2"
Grid.Column="0"
Margin="{StaticResource Margin4}"
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}"
Text="outboundTag" /> Text="outboundTag" />
<ComboBox <ComboBox
x:Name="cmbOutboundTag" x:Name="cmbOutboundTag"
Grid.Row="1" Grid.Row="2"
Grid.Column="1" Grid.Column="1"
Width="200" Width="200"
Margin="{StaticResource Margin4}" Margin="{StaticResource Margin4}"
@ -85,7 +104,7 @@
MaxDropDownHeight="1000" MaxDropDownHeight="1000"
Style="{StaticResource DefComboBox}" /> Style="{StaticResource DefComboBox}" />
<StackPanel <StackPanel
Grid.Row="1" Grid.Row="2"
Grid.Column="2" Grid.Column="2"
Margin="{StaticResource Margin4}" Margin="{StaticResource Margin4}"
HorizontalAlignment="Left" HorizontalAlignment="Left"
@ -104,7 +123,7 @@
</StackPanel> </StackPanel>
<TextBlock <TextBlock
Grid.Row="2" Grid.Row="3"
Grid.Column="0" Grid.Column="0"
Margin="{StaticResource Margin4}" Margin="{StaticResource Margin4}"
VerticalAlignment="Center" VerticalAlignment="Center"
@ -112,14 +131,14 @@
Text="port" /> Text="port" />
<TextBox <TextBox
x:Name="txtPort" x:Name="txtPort"
Grid.Row="2" Grid.Row="3"
Grid.Column="1" Grid.Column="1"
Width="200" Width="200"
Margin="{StaticResource Margin4}" Margin="{StaticResource Margin4}"
HorizontalAlignment="Left" HorizontalAlignment="Left"
Style="{StaticResource DefTextBox}" /> Style="{StaticResource DefTextBox}" />
<TextBlock <TextBlock
Grid.Row="2" Grid.Row="3"
Grid.Column="2" Grid.Column="2"
Margin="{StaticResource Margin4}" Margin="{StaticResource Margin4}"
HorizontalAlignment="Left" HorizontalAlignment="Left"
@ -128,7 +147,7 @@
Text="{x:Static resx:ResUI.TbRuleMatchingTips}" /> Text="{x:Static resx:ResUI.TbRuleMatchingTips}" />
<TextBlock <TextBlock
Grid.Row="3" Grid.Row="4"
Grid.Column="0" Grid.Column="0"
Margin="{StaticResource Margin4}" Margin="{StaticResource Margin4}"
VerticalAlignment="Center" VerticalAlignment="Center"
@ -136,14 +155,14 @@
Text="protocol" /> Text="protocol" />
<ListBox <ListBox
x:Name="clbProtocol" x:Name="clbProtocol"
Grid.Row="3" Grid.Row="4"
Grid.Column="1" Grid.Column="1"
Margin="{StaticResource Margin4}" Margin="{StaticResource Margin4}"
HorizontalAlignment="Left" HorizontalAlignment="Left"
FontSize="{DynamicResource StdFontSize}" FontSize="{DynamicResource StdFontSize}"
Style="{StaticResource MaterialDesignFilterChipPrimaryListBox}" /> Style="{StaticResource MaterialDesignFilterChipPrimaryListBox}" />
<TextBlock <TextBlock
Grid.Row="3" Grid.Row="4"
Grid.Column="2" Grid.Column="2"
Margin="{StaticResource Margin4}" Margin="{StaticResource Margin4}"
VerticalAlignment="Center" VerticalAlignment="Center"
@ -155,7 +174,7 @@
</TextBlock> </TextBlock>
<TextBlock <TextBlock
Grid.Row="4" Grid.Row="5"
Grid.Column="0" Grid.Column="0"
Margin="{StaticResource Margin4}" Margin="{StaticResource Margin4}"
VerticalAlignment="Center" VerticalAlignment="Center"
@ -163,13 +182,13 @@
Text="inboundTag" /> Text="inboundTag" />
<ListBox <ListBox
x:Name="clbInboundTag" x:Name="clbInboundTag"
Grid.Row="4" Grid.Row="5"
Grid.Column="1" Grid.Column="1"
Margin="{StaticResource Margin4}" Margin="{StaticResource Margin4}"
FontSize="{DynamicResource StdFontSize}" FontSize="{DynamicResource StdFontSize}"
Style="{StaticResource MaterialDesignFilterChipPrimaryListBox}" /> Style="{StaticResource MaterialDesignFilterChipPrimaryListBox}" />
<TextBlock <TextBlock
Grid.Row="4" Grid.Row="5"
Grid.Column="2" Grid.Column="2"
Margin="{StaticResource Margin4}" Margin="{StaticResource Margin4}"
HorizontalAlignment="Left" HorizontalAlignment="Left"
@ -178,7 +197,7 @@
Text="{x:Static resx:ResUI.TbRoutingInboundTagTips}" /> Text="{x:Static resx:ResUI.TbRoutingInboundTagTips}" />
<TextBlock <TextBlock
Grid.Row="5" Grid.Row="6"
Grid.Column="0" Grid.Column="0"
Margin="{StaticResource Margin4}" Margin="{StaticResource Margin4}"
VerticalAlignment="Center" VerticalAlignment="Center"
@ -186,7 +205,7 @@
Text="network" /> Text="network" />
<ComboBox <ComboBox
x:Name="cmbNetwork" x:Name="cmbNetwork"
Grid.Row="5" Grid.Row="6"
Grid.Column="1" Grid.Column="1"
Width="200" Width="200"
Margin="{StaticResource Margin4}" Margin="{StaticResource Margin4}"
@ -194,7 +213,7 @@
Style="{StaticResource DefComboBox}" /> Style="{StaticResource DefComboBox}" />
<TextBlock <TextBlock
Grid.Row="5" Grid.Row="6"
Grid.Column="2" Grid.Column="2"
Margin="{StaticResource Margin4}" Margin="{StaticResource Margin4}"
HorizontalAlignment="Left" HorizontalAlignment="Left"

View file

@ -301,7 +301,11 @@
Binding="{Binding Remarks}" Binding="{Binding Remarks}"
Header="{x:Static resx:ResUI.LvRemarks}" /> Header="{x:Static resx:ResUI.LvRemarks}" />
<DataGridTextColumn <DataGridTextColumn
Width="120" Width="100"
Binding="{Binding RuleTypeName}"
Header="{x:Static resx:ResUI.TbRuleType}" />
<DataGridTextColumn
Width="130"
Binding="{Binding OutboundTag}" Binding="{Binding OutboundTag}"
Header="outboundTag" /> Header="outboundTag" />
<DataGridTextColumn <DataGridTextColumn
@ -317,17 +321,13 @@
Binding="{Binding InboundTags}" Binding="{Binding InboundTags}"
Header="inboundTag" /> Header="inboundTag" />
<DataGridTextColumn <DataGridTextColumn
Width="90" Width="100"
Binding="{Binding Network}" Binding="{Binding Network}"
Header="network" /> Header="network" />
<DataGridTextColumn <DataGridTextColumn
Width="*" Width="*"
Binding="{Binding Domains}" Binding="{Binding Domains}"
Header="domain" /> Header="domain / ip" />
<DataGridTextColumn
Width="*"
Binding="{Binding Ips}"
Header="ip" />
</DataGrid.Columns> </DataGrid.Columns>
</DataGrid> </DataGrid>
</TabItem> </TabItem>