mirror of
https://github.com/2dust/v2rayN.git
synced 2025-05-02 21:28:51 +00:00
Optimize
This commit is contained in:
parent
4ff1dc2982
commit
6f181053b2
4 changed files with 25 additions and 10 deletions
|
@ -403,8 +403,14 @@ namespace v2rayN.Handler
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static int CopyServer(ref Config config, List<ProfileItem> indexs)
|
public static int CopyServer(ref Config config, List<ProfileItem> indexs)
|
||||||
{
|
{
|
||||||
foreach (var item in indexs)
|
foreach (var it in indexs)
|
||||||
{
|
{
|
||||||
|
var item = LazyConfig.Instance.GetProfileItem(it.indexId);
|
||||||
|
if (item is null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
ProfileItem profileItem = Utils.DeepCopy(item);
|
ProfileItem profileItem = Utils.DeepCopy(item);
|
||||||
profileItem.indexId = string.Empty;
|
profileItem.indexId = string.Empty;
|
||||||
profileItem.remarks = $"{item.remarks}-clone";
|
profileItem.remarks = $"{item.remarks}-clone";
|
||||||
|
|
|
@ -112,7 +112,7 @@ namespace v2rayN.Handler
|
||||||
{
|
{
|
||||||
filter = filter.Replace("'", "");
|
filter = filter.Replace("'", "");
|
||||||
}
|
}
|
||||||
sql += $" and a.remarks like '%{filter}%'";
|
sql += String.Format(" and (a.remarks like '%{0}%' or a.address like '%{0}%') ", filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
return SqliteHelper.Instance.Query<ProfileItemModel>(sql).ToList();
|
return SqliteHelper.Instance.Query<ProfileItemModel>(sql).ToList();
|
||||||
|
|
|
@ -700,7 +700,7 @@ namespace v2rayN.ViewModels
|
||||||
_subId = SelectedSub?.id;
|
_subId = SelectedSub?.id;
|
||||||
_config.subIndexId = _subId;
|
_config.subIndexId = _subId;
|
||||||
|
|
||||||
RefreshServers();
|
RefreshServers(false);
|
||||||
|
|
||||||
_updateView("ProfilesFocus");
|
_updateView("ProfilesFocus");
|
||||||
}
|
}
|
||||||
|
@ -715,11 +715,13 @@ namespace v2rayN.ViewModels
|
||||||
RefreshServers();
|
RefreshServers();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RefreshServers()
|
private void RefreshServers(bool blCheckDefault = true)
|
||||||
{
|
{
|
||||||
List<ProfileItemModel> lstModel = LazyConfig.Instance.ProfileItems(_subId, _serverFilter);
|
List<ProfileItemModel> lstModel = LazyConfig.Instance.ProfileItems(_subId, _serverFilter);
|
||||||
ConfigHandler.SetDefaultServer(_config, lstModel);
|
if (blCheckDefault)
|
||||||
|
{
|
||||||
|
ConfigHandler.SetDefaultServer(_config, lstModel);
|
||||||
|
}
|
||||||
List<ServerStatItem> lstServerStat = new();
|
List<ServerStatItem> lstServerStat = new();
|
||||||
if (_statistics != null && _statistics.Enable)
|
if (_statistics != null && _statistics.Enable)
|
||||||
{
|
{
|
||||||
|
@ -782,6 +784,11 @@ namespace v2rayN.ViewModels
|
||||||
RunningServerDisplay = $"{ResUI.menuServers}:{runningSummary}";
|
RunningServerDisplay = $"{ResUI.menuServers}:{runningSummary}";
|
||||||
RunningServerToolTipText = runningSummary;
|
RunningServerToolTipText = runningSummary;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
RunningServerDisplay =
|
||||||
|
RunningServerToolTipText = ResUI.CheckServerSettings;
|
||||||
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -838,9 +845,11 @@ namespace v2rayN.ViewModels
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var orderProfiles = SelectedProfiles?.OrderBy(t => t.sort);
|
||||||
if (latest)
|
if (latest)
|
||||||
{
|
{
|
||||||
foreach (var profile in SelectedProfiles)
|
foreach (var profile in orderProfiles)
|
||||||
{
|
{
|
||||||
var item = LazyConfig.Instance.GetProfileItem(profile.indexId);
|
var item = LazyConfig.Instance.GetProfileItem(profile.indexId);
|
||||||
if (item is not null)
|
if (item is not null)
|
||||||
|
@ -851,7 +860,7 @@ namespace v2rayN.ViewModels
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
lstSelecteds = Utils.FromJson<List<ProfileItem>>(Utils.ToJson(SelectedProfiles));
|
lstSelecteds = Utils.FromJson<List<ProfileItem>>(Utils.ToJson(orderProfiles));
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -971,7 +980,7 @@ namespace v2rayN.ViewModels
|
||||||
}
|
}
|
||||||
private void CopyServer()
|
private void CopyServer()
|
||||||
{
|
{
|
||||||
if (GetProfileItems(out List<ProfileItem> lstSelecteds, true) < 0)
|
if (GetProfileItems(out List<ProfileItem> lstSelecteds, false) < 0)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -617,7 +617,7 @@
|
||||||
</Style>
|
</Style>
|
||||||
</DataGrid.Resources>
|
</DataGrid.Resources>
|
||||||
<DataGrid.Columns>
|
<DataGrid.Columns>
|
||||||
<DataGridTemplateColumn Width="50">
|
<DataGridTemplateColumn Width="40">
|
||||||
<DataGridTemplateColumn.CellTemplate>
|
<DataGridTemplateColumn.CellTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<Border
|
<Border
|
||||||
|
|
Loading…
Reference in a new issue