12345678910111213141516171819202122232425262728293031323334 |
- @if (_isRunning)
- {
- @ChildContent
- }
- else
- {
- <h1 class="loading">Dev Ejection Seat Working</h1>
- }
- @code
- {
- [Parameter]
- public RenderFragment? ChildContent { get; set; }
- private IJSObjectReference? module;
- private bool _isRunning = true;
- protected override async Task OnAfterRenderAsync(bool firstRender)
- {
- await base.OnAfterRenderAsync(firstRender);
- if (firstRender == false) return;
- module = await JS.InvokeAsync<IJSObjectReference>("import", "./Gui/Blazor/DevEjectionSeat.razor.js");
- await module.InvokeVoidAsync("SetBeforeUnloadEventHandler", DotNetObjectReference.Create(this), nameof(BeforeUnloadEventHandler));
- }
- [JSInvokable]
- public void BeforeUnloadEventHandler()
- {
- if (_isRunning == false) return;
- _isRunning = false;
- StateHasChanged();
- }
- }
|