You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.1 KiB
50 lines
1.1 KiB
@implements IDisposable; |
|
|
|
@inject ISearchService searchService |
|
@inject IJSRuntime jsRuntime |
|
|
|
<SearchDialogComponent></SearchDialogComponent> |
|
|
|
@code { |
|
private string test = "Q"; |
|
|
|
protected override void OnInitialized() |
|
{ |
|
searchService.Subscribe(OnUpdate); |
|
} |
|
|
|
protected override async Task OnInitializedAsync() |
|
{ |
|
await searchService.Load(); |
|
await jsRuntime.InvokeVoidAsync("SetDotnetReference", DotNetObjectReference.Create(this)); |
|
} |
|
|
|
|
|
|
|
public void Dispose() |
|
{ |
|
searchService.Unsubscribe(OnUpdate); |
|
} |
|
|
|
void OnUpdate() |
|
{ |
|
StateHasChanged(); |
|
} |
|
|
|
[JSInvokable("OnKeyPress")] |
|
public async Task OnKeyPress(string code, bool ctrlKey, bool shiftKey, bool altKey, bool metaKey) |
|
{ |
|
if (code.ToLower().Equals("k") && (ctrlKey || shiftKey || altKey || metaKey)) |
|
{ |
|
if (searchService.IsVisible) |
|
{ |
|
searchService.Hide(); |
|
} |
|
else |
|
{ |
|
searchService.Show(); |
|
} |
|
} |
|
} |
|
|
|
} |