mirror of
https://gitee.com/ant-design-blazor/ant-design-blazor.git
synced 2024-12-14 08:51:27 +08:00
93310a1d14
* docs: fix anchor and improvement * fix docsearch * fix docsearch action
48 lines
1.0 KiB
C#
48 lines
1.0 KiB
C#
using System;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.JSInterop;
|
|
|
|
namespace AntDesign.JsInterop
|
|
{
|
|
public class InteropService
|
|
{
|
|
private readonly IJSRuntime _js;
|
|
|
|
public InteropService(IJSRuntime js)
|
|
{
|
|
_js = js;
|
|
}
|
|
|
|
public async ValueTask Copy(string text)
|
|
{
|
|
await this.JsInvokeAsync(JSInteropConstants.Copy, text);
|
|
}
|
|
|
|
public async Task<T> JsInvokeAsync<T>(string code, params object[] args)
|
|
{
|
|
try
|
|
{
|
|
return await _js.InvokeAsync<T>(code, args);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Console.WriteLine(e);
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public async Task JsInvokeAsync(string code, params object[] args)
|
|
{
|
|
try
|
|
{
|
|
await _js.InvokeVoidAsync(code, args);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Console.WriteLine(e);
|
|
throw;
|
|
}
|
|
}
|
|
}
|
|
}
|