Learn.VideoAnalysis/VideoAnalysis/Components/Layouts/BasicLayout.razor.cs

70 lines
1.9 KiB
C#

using AntDesign.Extensions.Localization;
using AntDesign.ProLayout;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage;
using Microsoft.Identity.Client.Extensions.Msal;
using System.Globalization;
using System.Net.Http.Json;
namespace VideoAnalysisRazor.Layouts
{
public partial class BasicLayout : LayoutComponentBase, IDisposable
{
private MenuDataItem[] _menuData;
[Inject] private NavigationManager NavigationManager { get; set; } = default!;
[Inject] IHttpContextAccessor HttpContextAccessor { get; set; } = default!;
[Inject] private ReuseTabsService TabService { get; set; }
[Inject] private ProtectedSessionStorage session { get; set; } = default!;
bool collapsed;
void Toggle()
{
collapsed = !collapsed;
}
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (!await CheckLogin())
{
NavigationManager.NavigateTo("/Login");
}
}
protected override async Task OnInitializedAsync()
{
_menuData = [
new MenuDataItem
{
Path = "/Project",
Name = "课堂指标",
Key = "EvaluationProject",
Icon = "question-circle",
},
new MenuDataItem
{
Path = "/",
Name = "任务队列",
Key = "VideoTaskPage",
Icon = "unordered-list",
}
];
}
public async Task<bool> CheckLogin()
{
return (await session.GetAsync<bool>("Login")).Value;
}
void Reload()
{
TabService.ReloadPage();
}
public void Dispose()
{
}
}
}