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 Domains { 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>
/// 查找类似 Bootstrap DNS (sing-box) 的本地化字符串。
/// </summary>

View file

@ -1596,4 +1596,10 @@
<data name="TbSettingsHide2TrayWhenCloseTip" xml:space="preserve">
<value>If the system does not have a tray function, please do not enable it</value>
</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>

View file

@ -1596,4 +1596,10 @@
<data name="TbSettingsHide2TrayWhenCloseTip" xml:space="preserve">
<value>If the system does not have a tray function, please do not enable it</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>
<data name="TbRuleType" xml:space="preserve">
<value>Rule Type</value>
</data>
</root>

View file

@ -1596,4 +1596,10 @@
<data name="TbSettingsHide2TrayWhenCloseTip" xml:space="preserve">
<value>If the system does not have a tray function, please do not enable it</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>
<data name="TbRuleType" xml:space="preserve">
<value>Rule Type</value>
</data>
</root>

View file

@ -1596,4 +1596,10 @@
<data name="TbSettingsHide2TrayWhenCloseTip" xml:space="preserve">
<value>If the system does not have a tray function, please do not enable it</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>
<data name="TbRuleType" xml:space="preserve">
<value>Rule Type</value>
</data>
</root>

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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