mirror of
https://github.com/lantean-code/qbtmud.git
synced 2025-10-23 04:52:22 +00:00
32 lines
1.1 KiB
C#
32 lines
1.1 KiB
C#
using Microsoft.JSInterop;
|
|
|
|
namespace Lantean.QBTMudBlade.Interop
|
|
{
|
|
public static class InteropHelper
|
|
{
|
|
public static async Task<BoundingClientRect?> GetBoundingClientRect(this IJSRuntime runtime, string id)
|
|
{
|
|
return await runtime.InvokeAsync<BoundingClientRect?>("qbt.getBoundingClientRect", id);
|
|
}
|
|
|
|
public static async Task FileDownload(this IJSRuntime runtime, string url, string? filename = null)
|
|
{
|
|
await runtime.InvokeVoidAsync("qbt.triggerFileDownload", url, filename);
|
|
}
|
|
|
|
public static async Task Open(this IJSRuntime runtime, string url, bool newTab = false)
|
|
{
|
|
string? target = null;
|
|
if (newTab)
|
|
{
|
|
target = url;
|
|
}
|
|
await runtime.InvokeVoidAsync("qbt.open", url, target);
|
|
}
|
|
|
|
public static async Task RenderPiecesBar(this IJSRuntime runtime, string id, string hash, int[] pieces)
|
|
{
|
|
await runtime.InvokeVoidAsync("qbt.renderPiecesBar", id, hash, pieces);
|
|
}
|
|
}
|
|
} |