49 lines
1.4 KiB
C#
49 lines
1.4 KiB
C#
using Microsoft.AspNetCore.Components;
|
|
using Microsoft.AspNetCore.Components.Routing;
|
|
using Front.Program.Views.Project;
|
|
using Front.Program.Services;
|
|
|
|
namespace Front.Program.Layout;
|
|
|
|
public partial class MainLayout : LayoutComponentBase, IDisposable
|
|
{
|
|
[Inject]
|
|
NavigationManager Navigation { get; set; } = default!;
|
|
|
|
[Inject]
|
|
LoadingService LoadingService { get; set; } = default!;
|
|
|
|
// protected bool isHideTop => Navigation.Uri.Contains("/auth");
|
|
protected bool isHideTop => Navigation.ToBaseRelativePath(Navigation.Uri).Equals("auth", StringComparison.OrdinalIgnoreCase);
|
|
|
|
public static bool IsLoading { get; set; }
|
|
public static IndicateType CurrentType { get; set; } = IndicateType.Page;
|
|
|
|
protected override void OnInitialized()
|
|
{
|
|
LoadingService.OnChange += StateHasChanged;
|
|
Navigation.LocationChanged += HandleLocationChanged;
|
|
}
|
|
|
|
private void HandleLocationChanged(object? sender, LocationChangedEventArgs e)
|
|
{
|
|
LoadingService.HideNavigationLoading();
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
LoadingService.OnChange -= StateHasChanged;
|
|
Navigation.LocationChanged -= HandleLocationChanged;
|
|
}
|
|
|
|
public static void ShowLoading(IndicateType type = IndicateType.Page)
|
|
{
|
|
IsLoading = true;
|
|
CurrentType = type;
|
|
}
|
|
|
|
public static void HideLoading()
|
|
{
|
|
IsLoading = false;
|
|
}
|
|
} |