AI-optimized code

This commit is contained in:
2dust 2025-03-06 14:34:31 +08:00
parent 3869148fc8
commit 50d7912f62
4 changed files with 19 additions and 19 deletions

View file

@ -42,7 +42,7 @@ namespace ServiceLib.ViewModels
private async Task SaveServerAsync()
{
string remarks = SelectedSource.Remarks;
var remarks = SelectedSource.Remarks;
if (remarks.IsNullOrEmpty())
{
NoticeHandler.Instance.Enqueue(ResUI.PleaseFillRemarks);

View file

@ -72,8 +72,7 @@ namespace ServiceLib.ViewModels
return;
}
}
if (SelectedSource.ConfigType != EConfigType.SOCKS
&& SelectedSource.ConfigType != EConfigType.HTTP)
if (SelectedSource.ConfigType is not EConfigType.SOCKS and not EConfigType.HTTP)
{
if (SelectedSource.Id.IsNullOrEmpty())
{

View file

@ -50,7 +50,7 @@ namespace ServiceLib.ViewModels
{
DisplayOperationMsg();
_config.WebDavItem = SelectedSource;
await ConfigHandler.SaveConfig(_config);
_ = await ConfigHandler.SaveConfig(_config);
var result = await WebDavHandler.Instance.CheckConnection();
if (result)
@ -151,7 +151,7 @@ namespace ServiceLib.ViewModels
{
if (Utils.UpgradeAppExists(out var upgradeFileName))
{
ProcUtils.ProcessStart(upgradeFileName, Global.RebootAs, Utils.StartupPath());
_ = ProcUtils.ProcessStart(upgradeFileName, Global.RebootAs, Utils.StartupPath());
}
}
service?.Shutdown(true);

View file

@ -53,7 +53,7 @@ namespace ServiceLib.ViewModels
private async Task Init()
{
Task.Run(async () =>
_ = Task.Run(async () =>
{
var numOfExecuted = 1;
while (true)
@ -89,7 +89,7 @@ namespace ServiceLib.ViewModels
return;
}
_updateView?.Invoke(EViewAction.DispatcherRefreshConnections, ret?.connections);
_ = _updateView?.Invoke(EViewAction.DispatcherRefreshConnections, ret?.connections);
}
public void RefreshConnections(List<ConnectionItem>? connections)
@ -106,22 +106,23 @@ namespace ServiceLib.ViewModels
continue;
}
ClashConnectionModel model = new();
model.Id = item.id;
model.Network = item.metadata.network;
model.Type = item.metadata.type;
model.Host = host;
var sp = (dtNow - item.start);
model.Time = sp.TotalSeconds < 0 ? 1 : sp.TotalSeconds;
model.Elapsed = sp.ToString(@"hh\:mm\:ss");
item.chains?.Reverse();
model.Chain = $"{item.rule} , {string.Join("->", item.chains ?? new())}";
var model = new ClashConnectionModel
{
Id = item.id,
Network = item.metadata.network,
Type = item.metadata.type,
Host = host,
Time = (dtNow - item.start).TotalSeconds < 0 ? 1 : (dtNow - item.start).TotalSeconds,
Elapsed = (dtNow - item.start).ToString(@"hh\:mm\:ss"),
Chain = $"{item.rule} , {string.Join("->", item.chains ?? new())}"
};
lstModel.Add(model);
}
if (lstModel.Count <= 0)
{ return; }
{
return;
}
_connectionItems.AddRange(lstModel);
}