From c633dd4a8127ce4a5a272a29ea4fe72479ac3158 Mon Sep 17 00:00:00 2001 From: Argo-Tianyi Date: Mon, 3 Jan 2022 00:15:56 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E5=81=A5=E5=BA=B7?= =?UTF-8?q?=E6=A3=80=E6=9F=A5=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Pages/Admin/Healths.razor.cs | 44 ++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/src/blazor/admin/BootstrapAdmin.Web/Pages/Admin/Healths.razor.cs b/src/blazor/admin/BootstrapAdmin.Web/Pages/Admin/Healths.razor.cs index 4d7246af..520e1ea5 100644 --- a/src/blazor/admin/BootstrapAdmin.Web/Pages/Admin/Healths.razor.cs +++ b/src/blazor/admin/BootstrapAdmin.Web/Pages/Admin/Healths.razor.cs @@ -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; } + + /// + /// OnInitializedAsync + /// + /// + 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(payload, serializeOption); + if (report != null) + { + foreach (var entry in report.Keys) + { + var item = report.Entries[entry]; + } + } + } }