feat: 增加健康检查页面
This commit is contained in:
parent
490c8f87eb
commit
c633dd4a81
|
@ -1,5 +1,47 @@
|
|||
namespace BootstrapAdmin.Web.Pages.Admin;
|
||||
using BootstrapAdmin.Web.Services;
|
||||
using Microsoft.Extensions.Diagnostics.HealthChecks;
|
||||
using System;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace BootstrapAdmin.Web.Pages.Admin;
|
||||
|
||||
public partial class Healths
|
||||
{
|
||||
[Inject]
|
||||
[NotNull]
|
||||
private IHttpClientFactory? HttpClientFactory { get; set; }
|
||||
|
||||
[Inject]
|
||||
[NotNull]
|
||||
private NavigationManager? NavigationManager { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// OnInitializedAsync
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await base.OnInitializedAsync();
|
||||
|
||||
var client = HttpClientFactory.CreateClient();
|
||||
client.BaseAddress = new Uri(NavigationManager.BaseUri);
|
||||
var payload = await client.GetStringAsync("/Healths");
|
||||
|
||||
var serializeOption = new JsonSerializerOptions
|
||||
{
|
||||
PropertyNamingPolicy = null,
|
||||
PropertyNameCaseInsensitive = true
|
||||
};
|
||||
serializeOption.Converters.Add(new StringToTimeSpanConverter());
|
||||
|
||||
var report = JsonSerializer.Deserialize<dynamic>(payload, serializeOption);
|
||||
if (report != null)
|
||||
{
|
||||
foreach (var entry in report.Keys)
|
||||
{
|
||||
var item = report.Entries[entry];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue