mirror of
https://github.com/2dust/v2rayN.git
synced 2025-04-19 13:42:24 +00:00
AI-optimized code
This commit is contained in:
parent
3869148fc8
commit
50d7912f62
4 changed files with 19 additions and 19 deletions
|
@ -42,7 +42,7 @@ namespace ServiceLib.ViewModels
|
||||||
|
|
||||||
private async Task SaveServerAsync()
|
private async Task SaveServerAsync()
|
||||||
{
|
{
|
||||||
string remarks = SelectedSource.Remarks;
|
var remarks = SelectedSource.Remarks;
|
||||||
if (remarks.IsNullOrEmpty())
|
if (remarks.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.PleaseFillRemarks);
|
NoticeHandler.Instance.Enqueue(ResUI.PleaseFillRemarks);
|
||||||
|
|
|
@ -72,8 +72,7 @@ namespace ServiceLib.ViewModels
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (SelectedSource.ConfigType != EConfigType.SOCKS
|
if (SelectedSource.ConfigType is not EConfigType.SOCKS and not EConfigType.HTTP)
|
||||||
&& SelectedSource.ConfigType != EConfigType.HTTP)
|
|
||||||
{
|
{
|
||||||
if (SelectedSource.Id.IsNullOrEmpty())
|
if (SelectedSource.Id.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
|
|
|
@ -50,7 +50,7 @@ namespace ServiceLib.ViewModels
|
||||||
{
|
{
|
||||||
DisplayOperationMsg();
|
DisplayOperationMsg();
|
||||||
_config.WebDavItem = SelectedSource;
|
_config.WebDavItem = SelectedSource;
|
||||||
await ConfigHandler.SaveConfig(_config);
|
_ = await ConfigHandler.SaveConfig(_config);
|
||||||
|
|
||||||
var result = await WebDavHandler.Instance.CheckConnection();
|
var result = await WebDavHandler.Instance.CheckConnection();
|
||||||
if (result)
|
if (result)
|
||||||
|
@ -151,7 +151,7 @@ namespace ServiceLib.ViewModels
|
||||||
{
|
{
|
||||||
if (Utils.UpgradeAppExists(out var upgradeFileName))
|
if (Utils.UpgradeAppExists(out var upgradeFileName))
|
||||||
{
|
{
|
||||||
ProcUtils.ProcessStart(upgradeFileName, Global.RebootAs, Utils.StartupPath());
|
_ = ProcUtils.ProcessStart(upgradeFileName, Global.RebootAs, Utils.StartupPath());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
service?.Shutdown(true);
|
service?.Shutdown(true);
|
||||||
|
|
|
@ -53,7 +53,7 @@ namespace ServiceLib.ViewModels
|
||||||
|
|
||||||
private async Task Init()
|
private async Task Init()
|
||||||
{
|
{
|
||||||
Task.Run(async () =>
|
_ = Task.Run(async () =>
|
||||||
{
|
{
|
||||||
var numOfExecuted = 1;
|
var numOfExecuted = 1;
|
||||||
while (true)
|
while (true)
|
||||||
|
@ -89,7 +89,7 @@ namespace ServiceLib.ViewModels
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_updateView?.Invoke(EViewAction.DispatcherRefreshConnections, ret?.connections);
|
_ = _updateView?.Invoke(EViewAction.DispatcherRefreshConnections, ret?.connections);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RefreshConnections(List<ConnectionItem>? connections)
|
public void RefreshConnections(List<ConnectionItem>? connections)
|
||||||
|
@ -106,22 +106,23 @@ namespace ServiceLib.ViewModels
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
ClashConnectionModel model = new();
|
var model = new ClashConnectionModel
|
||||||
|
{
|
||||||
model.Id = item.id;
|
Id = item.id,
|
||||||
model.Network = item.metadata.network;
|
Network = item.metadata.network,
|
||||||
model.Type = item.metadata.type;
|
Type = item.metadata.type,
|
||||||
model.Host = host;
|
Host = host,
|
||||||
var sp = (dtNow - item.start);
|
Time = (dtNow - item.start).TotalSeconds < 0 ? 1 : (dtNow - item.start).TotalSeconds,
|
||||||
model.Time = sp.TotalSeconds < 0 ? 1 : sp.TotalSeconds;
|
Elapsed = (dtNow - item.start).ToString(@"hh\:mm\:ss"),
|
||||||
model.Elapsed = sp.ToString(@"hh\:mm\:ss");
|
Chain = $"{item.rule} , {string.Join("->", item.chains ?? new())}"
|
||||||
item.chains?.Reverse();
|
};
|
||||||
model.Chain = $"{item.rule} , {string.Join("->", item.chains ?? new())}";
|
|
||||||
|
|
||||||
lstModel.Add(model);
|
lstModel.Add(model);
|
||||||
}
|
}
|
||||||
if (lstModel.Count <= 0)
|
if (lstModel.Count <= 0)
|
||||||
{ return; }
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
_connectionItems.AddRange(lstModel);
|
_connectionItems.AddRange(lstModel);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue