Skip to content

Commit fae1200

Browse files
committed
添加接口
1 parent 184b491 commit fae1200

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

src/BootstrapBlazor/Extensions/BootstrapBlazorServiceCollectionExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public static IServiceCollection AddBootstrapBlazor(this IServiceCollection serv
105105
services.AddScoped<PrintService>();
106106
services.AddScoped<TitleService>();
107107
services.AddScoped<DownloadService>();
108-
services.AddScoped<WebClientService>();
108+
services.AddScoped<IWebClientService, WebClientService>();
109109
services.AddScoped<AjaxService>();
110110
services.AddScoped(typeof(DragDropService<>));
111111
services.AddScoped<ClipboardService>();
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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.Components;
7+
8+
/// <summary>
9+
/// WebClient 服务类
10+
/// </summary>
11+
public interface IWebClientService : IAsyncDisposable
12+
{
13+
/// <summary>
14+
/// 获得 ClientInfo 实例方法
15+
/// </summary>
16+
/// <returns></returns>
17+
Task<ClientInfo> GetClientInfo();
18+
/// <summary>
19+
/// SetData 方法由 JS 调用
20+
/// </summary>
21+
/// <param name="client"></param>
22+
void SetData(ClientInfo client);
23+
}

src/BootstrapBlazor/Services/WebClientService.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// Maintainer: Argo Zhang([email protected]) Website: https://www.blazor.zone
55

66
using Microsoft.Extensions.Logging;
7+
78
using System.Text.Json.Serialization;
89

910
namespace BootstrapBlazor.Components;
@@ -20,7 +21,7 @@ public class WebClientService(IIpLocatorFactory ipLocatorFactory,
2021
IOptionsMonitor<BootstrapBlazorOptions> options,
2122
IJSRuntime runtime,
2223
NavigationManager navigation,
23-
ILogger<WebClientService> logger) : IAsyncDisposable
24+
ILogger<WebClientService> logger) : IAsyncDisposable, IWebClientService
2425
{
2526
private TaskCompletionSource? _taskCompletionSource;
2627
private JSModule? _jsModule;

0 commit comments

Comments
 (0)