mirror of
https://github.com/2dust/v2rayN.git
synced 2026-11-09 22:15:00 +03:00
Perf Policy Group generate (#8855)
* Perf Policy Group generate * Scroll to new group node * Add region group * I18n * Fix * Fix * Move default filter to Global * Default Filter List * Increase UI column widths for AddGroupServerWindow --------- Co-authored-by: 2dust <31833384+2dust@users.noreply.github.com>
This commit is contained in:
@@ -8,6 +8,7 @@ public class ProfilesViewModel : MyReactiveObject
|
||||
private string _serverFilter = string.Empty;
|
||||
private Dictionary<string, bool> _dicHeaderSort = new();
|
||||
private SpeedtestService? _speedtestService;
|
||||
private string? _pendingSelectIndexId;
|
||||
|
||||
#endregion private prop
|
||||
|
||||
@@ -43,13 +44,8 @@ public class ProfilesViewModel : MyReactiveObject
|
||||
public ReactiveCommand<Unit, Unit> CopyServerCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> SetDefaultServerCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> ShareServerCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> GenGroupMultipleServerXrayRandomCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> GenGroupMultipleServerXrayRoundRobinCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> GenGroupMultipleServerXrayLeastPingCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> GenGroupMultipleServerXrayLeastLoadCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> GenGroupMultipleServerXrayFallbackCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> GenGroupMultipleServerSingBoxLeastPingCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> GenGroupMultipleServerSingBoxFallbackCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> GenGroupAllServerCmd { get; }
|
||||
public ReactiveCommand<Unit, Unit> GenGroupRegionServerCmd { get; }
|
||||
|
||||
//servers move
|
||||
public ReactiveCommand<Unit, Unit> MoveTopCmd { get; }
|
||||
@@ -134,33 +130,13 @@ public class ProfilesViewModel : MyReactiveObject
|
||||
{
|
||||
await ShareServerAsync();
|
||||
}, canEditRemove);
|
||||
GenGroupMultipleServerXrayRandomCmd = ReactiveCommand.CreateFromTask(async () =>
|
||||
GenGroupAllServerCmd = ReactiveCommand.CreateFromTask(async () =>
|
||||
{
|
||||
await GenGroupMultipleServer(ECoreType.Xray, EMultipleLoad.Random);
|
||||
await GenGroupAllServer();
|
||||
}, canEditRemove);
|
||||
GenGroupMultipleServerXrayRoundRobinCmd = ReactiveCommand.CreateFromTask(async () =>
|
||||
GenGroupRegionServerCmd = ReactiveCommand.CreateFromTask(async () =>
|
||||
{
|
||||
await GenGroupMultipleServer(ECoreType.Xray, EMultipleLoad.RoundRobin);
|
||||
}, canEditRemove);
|
||||
GenGroupMultipleServerXrayLeastPingCmd = ReactiveCommand.CreateFromTask(async () =>
|
||||
{
|
||||
await GenGroupMultipleServer(ECoreType.Xray, EMultipleLoad.LeastPing);
|
||||
}, canEditRemove);
|
||||
GenGroupMultipleServerXrayLeastLoadCmd = ReactiveCommand.CreateFromTask(async () =>
|
||||
{
|
||||
await GenGroupMultipleServer(ECoreType.Xray, EMultipleLoad.LeastLoad);
|
||||
}, canEditRemove);
|
||||
GenGroupMultipleServerXrayFallbackCmd = ReactiveCommand.CreateFromTask(async () =>
|
||||
{
|
||||
await GenGroupMultipleServer(ECoreType.Xray, EMultipleLoad.Fallback);
|
||||
}, canEditRemove);
|
||||
GenGroupMultipleServerSingBoxLeastPingCmd = ReactiveCommand.CreateFromTask(async () =>
|
||||
{
|
||||
await GenGroupMultipleServer(ECoreType.sing_box, EMultipleLoad.LeastPing);
|
||||
}, canEditRemove);
|
||||
GenGroupMultipleServerSingBoxFallbackCmd = ReactiveCommand.CreateFromTask(async () =>
|
||||
{
|
||||
await GenGroupMultipleServer(ECoreType.sing_box, EMultipleLoad.Fallback);
|
||||
await GenGroupRegionServer();
|
||||
}, canEditRemove);
|
||||
|
||||
//servers move
|
||||
@@ -392,15 +368,14 @@ public class ProfilesViewModel : MyReactiveObject
|
||||
ProfileItems.AddRange(lstModel);
|
||||
if (lstModel.Count > 0)
|
||||
{
|
||||
var selected = lstModel.FirstOrDefault(t => t.IndexId == _config.IndexId);
|
||||
if (selected != null)
|
||||
ProfileItemModel? selected = null;
|
||||
if (!_pendingSelectIndexId.IsNullOrEmpty())
|
||||
{
|
||||
SelectedProfile = selected;
|
||||
}
|
||||
else
|
||||
{
|
||||
SelectedProfile = lstModel.First();
|
||||
selected = lstModel.FirstOrDefault(t => t.IndexId == _pendingSelectIndexId);
|
||||
_pendingSelectIndexId = null;
|
||||
}
|
||||
selected ??= lstModel.FirstOrDefault(t => t.IndexId == _config.IndexId);
|
||||
SelectedProfile = selected ?? lstModel.First();
|
||||
}
|
||||
|
||||
await _updateView?.Invoke(EViewAction.DispatcherRefreshServersBiz, null);
|
||||
@@ -641,29 +616,29 @@ public class ProfilesViewModel : MyReactiveObject
|
||||
await _updateView?.Invoke(EViewAction.ShareServer, url);
|
||||
}
|
||||
|
||||
private async Task GenGroupMultipleServer(ECoreType coreType, EMultipleLoad multipleLoad)
|
||||
private async Task GenGroupAllServer()
|
||||
{
|
||||
var lstSelected = await GetProfileItems(true);
|
||||
if (lstSelected == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var ret = await ConfigHandler.AddGroupServer4Multiple(_config, lstSelected, coreType, multipleLoad, SelectedSub?.Id);
|
||||
var ret = await ConfigHandler.AddGroupAllServer(_config, SelectedSub);
|
||||
if (ret.Success != true)
|
||||
{
|
||||
NoticeManager.Instance.Enqueue(ResUI.OperationFailed);
|
||||
return;
|
||||
}
|
||||
if (ret?.Data?.ToString() == _config.IndexId)
|
||||
_pendingSelectIndexId = ret.Data?.ToString();
|
||||
await RefreshServers();
|
||||
}
|
||||
|
||||
private async Task GenGroupRegionServer()
|
||||
{
|
||||
var ret = await ConfigHandler.AddGroupRegionServer(_config, SelectedSub);
|
||||
if (ret.Success != true)
|
||||
{
|
||||
await RefreshServers();
|
||||
Reload();
|
||||
}
|
||||
else
|
||||
{
|
||||
await SetDefaultServer(ret?.Data?.ToString());
|
||||
NoticeManager.Instance.Enqueue(ResUI.OperationFailed);
|
||||
return;
|
||||
}
|
||||
var indexIdList = ret.Data as List<string>;
|
||||
_pendingSelectIndexId = indexIdList?.FirstOrDefault();
|
||||
await RefreshServers();
|
||||
}
|
||||
|
||||
public async Task SortServer(string colName)
|
||||
|
||||
Reference in New Issue
Block a user