mirror of
https://github.com/2dust/v2rayN.git
synced 2025-05-03 13:48:52 +00:00
Add routing sort
This commit is contained in:
parent
b77827df90
commit
17bfe74ecf
10 changed files with 45 additions and 15 deletions
|
@ -1509,13 +1509,16 @@ namespace v2rayN.Handler
|
|||
|
||||
public static int InitBuiltinRouting(ref Config config, bool blImportAdvancedRules = false)
|
||||
{
|
||||
if (blImportAdvancedRules || LazyConfig.Instance.RoutingItems().Count <= 0)
|
||||
var items = LazyConfig.Instance.RoutingItems();
|
||||
if (blImportAdvancedRules || items.Count <= 0)
|
||||
{
|
||||
var maxSort = items.Max(t => t.sort);
|
||||
//Bypass the mainland
|
||||
var item2 = new RoutingItem()
|
||||
{
|
||||
remarks = "绕过大陆(Whitelist)",
|
||||
url = string.Empty,
|
||||
sort = maxSort + 1,
|
||||
};
|
||||
AddBatchRoutingRules(ref item2, Utils.GetEmbedText(Global.CustomRoutingFileName + "white"));
|
||||
|
||||
|
@ -1524,6 +1527,7 @@ namespace v2rayN.Handler
|
|||
{
|
||||
remarks = "黑名单(Blacklist)",
|
||||
url = string.Empty,
|
||||
sort = maxSort + 2,
|
||||
};
|
||||
AddBatchRoutingRules(ref item3, Utils.GetEmbedText(Global.CustomRoutingFileName + "black"));
|
||||
|
||||
|
@ -1532,6 +1536,7 @@ namespace v2rayN.Handler
|
|||
{
|
||||
remarks = "全局(Global)",
|
||||
url = string.Empty,
|
||||
sort = maxSort + 3,
|
||||
};
|
||||
AddBatchRoutingRules(ref item1, Utils.GetEmbedText(Global.CustomRoutingFileName + "global"));
|
||||
|
||||
|
|
|
@ -139,7 +139,7 @@ namespace v2rayN.Handler
|
|||
|
||||
public List<RoutingItem> RoutingItems()
|
||||
{
|
||||
return SqliteHelper.Instance.Table<RoutingItem>().Where(it => it.locked == false).ToList();
|
||||
return SqliteHelper.Instance.Table<RoutingItem>().Where(it => it.locked == false).OrderBy(t => t.sort).ToList();
|
||||
}
|
||||
public RoutingItem GetRoutingItem(string id)
|
||||
{
|
||||
|
|
|
@ -15,6 +15,7 @@ namespace v2rayN.Mode
|
|||
public bool locked { get; set; }
|
||||
public string customIcon { get; set; }
|
||||
public string domainStrategy { get; set; }
|
||||
public int sort { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -176,6 +176,7 @@ namespace v2rayN.ViewModels
|
|||
remarks = item.remarks,
|
||||
url = item.url,
|
||||
customIcon = item.customIcon,
|
||||
sort = item.sort,
|
||||
};
|
||||
_routingItems.Add(it);
|
||||
}
|
||||
|
|
|
@ -92,6 +92,7 @@
|
|||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
|
@ -177,6 +178,23 @@
|
|||
Content="{x:Static resx:ResUI.TbBrowse}"
|
||||
Style="{StaticResource DefButton}" />
|
||||
|
||||
<TextBlock
|
||||
Grid.Row="4"
|
||||
Grid.Column="0"
|
||||
Margin="4"
|
||||
VerticalAlignment="Center"
|
||||
Style="{StaticResource ToolbarTextBlock}"
|
||||
Text="{x:Static resx:ResUI.LvSort}" />
|
||||
<TextBox
|
||||
x:Name="txtSort"
|
||||
Grid.Row="4"
|
||||
Grid.Column="1"
|
||||
Width="200"
|
||||
Margin="4"
|
||||
HorizontalAlignment="Left"
|
||||
AcceptsReturn="True"
|
||||
Style="{StaticResource DefTextBox}" />
|
||||
|
||||
</Grid>
|
||||
|
||||
<TabControl x:Name="tabAdvanced">
|
||||
|
|
|
@ -33,6 +33,7 @@ namespace v2rayN.Views
|
|||
this.Bind(ViewModel, vm => vm.SelectedRouting.domainStrategy, v => v.cmbdomainStrategy.Text).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.SelectedRouting.url, v => v.txtUrl.Text).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.SelectedRouting.customIcon, v => v.txtCustomIcon.Text).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.SelectedRouting.sort, v => v.txtSort.Text).DisposeWith(disposables);
|
||||
|
||||
this.BindCommand(ViewModel, vm => vm.RuleAddCmd, v => v.menuRuleAdd).DisposeWith(disposables);
|
||||
this.BindCommand(ViewModel, vm => vm.ImportRulesFromFileCmd, v => v.menuImportRulesFromFile).DisposeWith(disposables);
|
||||
|
|
|
@ -197,15 +197,19 @@
|
|||
Binding="{Binding remarks}"
|
||||
Header="{x:Static resx:ResUI.LvAlias}" />
|
||||
<DataGridTextColumn
|
||||
Width="70"
|
||||
Width="60"
|
||||
Binding="{Binding ruleNum}"
|
||||
Header="{x:Static resx:ResUI.LvCount}" />
|
||||
<DataGridTextColumn
|
||||
Width="280"
|
||||
Width="60"
|
||||
Binding="{Binding sort}"
|
||||
Header="{x:Static resx:ResUI.LvSort}" />
|
||||
<DataGridTextColumn
|
||||
Width="260"
|
||||
Binding="{Binding url}"
|
||||
Header="{x:Static resx:ResUI.LvUrl}" />
|
||||
<DataGridTextColumn
|
||||
Width="280"
|
||||
Width="260"
|
||||
Binding="{Binding customIcon}"
|
||||
Header="{x:Static resx:ResUI.LvCustomIcon}" />
|
||||
</DataGrid.Columns>
|
||||
|
|
Loading…
Reference in a new issue