Skip to content

Commit 2b7aecf

Browse files
committed
doc: 增加网络状态示例
1 parent 7276b02 commit 2b7aecf

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
@page "/network-monitor"
2+
@inject IStringLocalizer<NetworkMonitors> Localizer
3+
4+
<h3>@Localizer["NetworkMonitorTitle"]</h3>
5+
6+
<h4>@((MarkupString)Localizer["NetworkMonitorDescription"].Value)</h4>
7+
8+
<DemoBlock Title="@Localizer["NormalTitle"]"
9+
Introduction="@Localizer["NormalIntro"]"
10+
Name="Normal">
11+
<NetworkMonitor OnNetworkStateChanged="OnNetworkStateChanged"></NetworkMonitor>
12+
<section ignore>
13+
<ConsoleLogger @ref="_logger"></ConsoleLogger>
14+
</section>
15+
</DemoBlock>
16+
17+
<DemoBlock Title="@Localizer["IndicatorTitle"]"
18+
Introduction="@Localizer["IndicatorIntro"]"
19+
Name="Indicator">
20+
<NetworkMonitorIndicator></NetworkMonitorIndicator>
21+
</DemoBlock>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the Apache 2.0 License
3+
// See the LICENSE file in the project root for more information.
4+
// Maintainer: Argo Zhang([email protected]) Website: https://www.blazor.zone
5+
6+
namespace BootstrapBlazor.Server.Components.Samples;
7+
8+
/// <summary>
9+
/// NetworkMonitor Sample code
10+
/// </summary>
11+
public partial class NetworkMonitors
12+
{
13+
private ConsoleLogger _logger = null!;
14+
15+
private Task OnNetworkStateChanged(NetworkMonitorState state)
16+
{
17+
_logger.Log($"Online: {state.IsOnline} NetworkType: {state.NetworkType} Downlink: {state.Downlink} RTT: {state.RTT}");
18+
return Task.CompletedTask;
19+
}
20+
}

0 commit comments

Comments
 (0)