Skip to content

Commit

Permalink
重构 PluginDetailViewModel,移除未使用的代码和API调用
Browse files Browse the repository at this point in the history
  • Loading branch information
MakesYT committed Feb 19, 2025
1 parent e4bb768 commit 6df3d83
Showing 1 changed file with 1 addition and 45 deletions.
46 changes: 1 addition & 45 deletions Core/ViewModel/Pages/plugin/PluginDetailViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,54 +8,10 @@ namespace Core.ViewModel.Pages.plugin;

public partial class PluginDetailViewModel : ObservableObject
{
internal class ApiResponse
{
public bool flag { get; set; }
public OnlinePluginInfo? data { get; set; }
}
public string PluginStr;
[ObservableProperty] private bool _remote = false;
[ObservableProperty] private bool _loading = true;
private bool avatarLocalFirst = true;
[ObservableProperty]
public PluginInfoUiHelper? _pluginInfo;
public PluginInfoUiHelper? PluginInfo { get; init; }
public PluginDetailViewModel(PluginInfoUiHelper pluginStr)
{
PluginInfo = pluginStr;
//Task.Run(GetInfo);
}

private async Task GetInfo()
{
await GetOnlinePluginInfo();
Loading = false;
}
private async Task GetOnlinePluginInfo()
{
var request = new HttpRequestMessage()
{
RequestUri = new Uri($"{ConfigManger.ApiUrl}/api/plugin/{PluginStr}"),
Method = HttpMethod.Get
};
var async =await PluginManager._httpClient.SendAsync(request);
var stringAsync =await async.Content.ReadAsStringAsync();
var options = new JsonSerializerOptions
{
PropertyNameCaseInsensitive = true
};
var apiResponse = JsonSerializer.Deserialize<ApiResponse>(stringAsync, options);
if (apiResponse is { data: not null })
{
PluginInfo = new PluginInfoUiHelper()
{
PluginBaseInfo = apiResponse.data.ToPluginBaseInfo(),
OnlinePluginInfo = apiResponse.data,
IsLocal = false
};
Remote = true;

}

}


Expand Down

0 comments on commit 6df3d83

Please sign in to comment.