using AntDesign.Extensions.Localization; using AntDesign.ProLayout; using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage; using Microsoft.AspNetCore.Mvc; using Microsoft.Identity.Client.Extensions.Msal; using Microsoft.JSInterop; 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 IJSRuntime JSRuntime { get; set; } [Inject] private ProtectedSessionStorage session { get; set; } = default!; bool collapsed; void Toggle() { collapsed = !collapsed; } protected override async Task OnAfterRenderAsync(bool firstRender) { } protected override async Task OnInitializedAsync() { if (!await CheckLogin()) { NavigationManager.NavigateTo("/Login"); } _menuData = [ new MenuDataItem { Path = "/", Name = "任务队列", Key = "VideoTaskPage", Icon = "unordered-list", }, new MenuDataItem { Path = "/Project", Name = "课堂指标", Key = "EvaluationProject", Icon = "question-circle", HideInMenu = true, }, new MenuDataItem { Path = "/Login", Name = "登录页", Key = "Login", HideInMenu = true, }, new MenuDataItem { Path = "/VideoTaskShow", Name = "视频任务预览", Key = "VideoTaskShow", HideInMenu = true, }, new MenuDataItem { Path = "/NodeSubscriptionPage", Name = "文件订阅", Key = "NodeSubscriptionPage", Icon="clock-circle", HideInMenu = false, } ]; } public async Task CheckLogin() { try { return (await session.GetAsync("Login")).Value; } catch { return false; } } void Reload() { TabService.ReloadPage(); } async Task ToSwagger() { await JSRuntime.InvokeVoidAsync("open", "/swagger/index.html", "_blank"); } public void Dispose() { } } }