Add routing sort

pull/3301/head
2dust 2 years ago
parent b77827df90
commit 17bfe74ecf

@ -132,7 +132,7 @@ namespace v2rayN.Base
await downloader.DownloadFileTaskAsync(address: url, cancellationToken: cancellationToken.Token);
}
downloadOpt = null;
}

@ -43,7 +43,7 @@ namespace v2rayN.Handler
if (config == null)
{
config = new Config
{
{
};
}
if (config.coreBasicItem == null)
@ -92,7 +92,7 @@ namespace v2rayN.Handler
{
enableRoutingAdvanced = true
};
}
}
//路由规则
if (Utils.IsNullOrEmpty(config.routingBasicItem.domainStrategy))
{
@ -158,7 +158,7 @@ namespace v2rayN.Handler
if (Utils.IsNullOrEmpty(config.uiItem.currentLanguage))
{
config.uiItem.currentLanguage = Global.Languages[0];
}
}
if (config.constItem == null)
{
@ -310,7 +310,7 @@ namespace v2rayN.Handler
SqliteHelper.Instance.Replace(routing);
}
config = Utils.FromJson<Config>(Utils.ToJson(configOld));
config = Utils.FromJson<Config>(Utils.ToJson(configOld));
if (config.coreBasicItem == null)
{
@ -320,8 +320,8 @@ namespace v2rayN.Handler
loglevel = configOld.loglevel,
muxEnabled = configOld.muxEnabled,
};
}
}
if (config.routingBasicItem == null)
{
config.routingBasicItem = new()
@ -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)
{

@ -7,9 +7,9 @@
public class Config
{
#region property
public string indexId { get; set; }
public string remoteDNS { get; set; }
/// <summary>
/// Outbound Freedom domainStrategy

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

@ -94,7 +94,7 @@ namespace v2rayN.Views
private void menuMsgViewClear_Click(object sender, System.Windows.RoutedEventArgs e)
{
ClearMsg();
}
}
private void cmbMsgFilter_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e)
{
_config.uiItem.mainMsgFilter = cmbMsgFilter.Text.TrimEx();

@ -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…
Cancel
Save