diff --git a/VideoAnalysis/Components/App.razor b/VideoAnalysis/Components/App.razor index d07604b..afc1961 100644 --- a/VideoAnalysis/Components/App.razor +++ b/VideoAnalysis/Components/App.razor @@ -7,8 +7,9 @@ - - + + + diff --git a/VideoAnalysis/Components/Layouts/BasicLayout.razor.cs b/VideoAnalysis/Components/Layouts/BasicLayout.razor.cs index d2ccff0..ada5451 100644 --- a/VideoAnalysis/Components/Layouts/BasicLayout.razor.cs +++ b/VideoAnalysis/Components/Layouts/BasicLayout.razor.cs @@ -1,6 +1,7 @@ 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; @@ -14,6 +15,7 @@ namespace VideoAnalysisRazor.Layouts [Inject] IHttpContextAccessor HttpContextAccessor { get; set; } = default!; [Inject] private ReuseTabsService TabService { get; set; } + [Inject] private ProtectedSessionStorage session { get; set; } = default!; bool collapsed; void Toggle() @@ -21,13 +23,16 @@ namespace VideoAnalysisRazor.Layouts collapsed = !collapsed; } - protected override async Task OnInitializedAsync() + + protected override async Task OnAfterRenderAsync(bool firstRender) { - if (!CheckLogin()) + if (!await CheckLogin()) { NavigationManager.NavigateTo("/Login"); - return; } + } + protected override async Task OnInitializedAsync() + { _menuData = [ new MenuDataItem { @@ -46,9 +51,9 @@ namespace VideoAnalysisRazor.Layouts ]; } - public bool CheckLogin() + public async Task CheckLogin() { - return HttpContextAccessor.HttpContext?.Session.GetInt32("Login") == 1; + return (await session.GetAsync("Login")).Value; } void Reload() { diff --git a/VideoAnalysis/Components/Pages/Login.razor b/VideoAnalysis/Components/Pages/Login.razor index 8aedc23..30df1ff 100644 --- a/VideoAnalysis/Components/Pages/Login.razor +++ b/VideoAnalysis/Components/Pages/Login.razor @@ -7,7 +7,7 @@ @using VideoAnalysisCore.Model.Dto - + @@ -22,7 +22,7 @@ - 登录 + 登录 视频分析平台 @@ -32,16 +32,18 @@ - LoginFunAsync()"> + LoginFunAsync()"> @* - 忘记密码? + 忘记密码? + 点击这里 - - - 没有账户? + *@ + @* + 没有账户? + 注册 *@ @@ -49,5 +51,4 @@ - - + diff --git a/VideoAnalysis/Components/Pages/Login.razor.cs b/VideoAnalysis/Components/Pages/Login.razor.cs index 784447e..49a8a11 100644 --- a/VideoAnalysis/Components/Pages/Login.razor.cs +++ b/VideoAnalysis/Components/Pages/Login.razor.cs @@ -1,6 +1,7 @@ using AntDesign; using AntDesign.TableModels; using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage; using Microsoft.AspNetCore.DataProtection.KeyManagement; using Microsoft.AspNetCore.Mvc; using SqlSugar; @@ -19,6 +20,7 @@ namespace Learn.VideoAnalysis.Components.Pages [Inject] private Repository taskDB { get; set; } = default!; [Inject] private NavigationManager NavigationManager { get; set; } = default!; [Inject] private INotificationService _notice { get; set; } = default!; + [Inject] private ProtectedSessionStorage session { get; set; } = default!; /// /// 输入的账号 @@ -51,8 +53,7 @@ namespace Learn.VideoAnalysis.Components.Pages } if (InputAccount == "admin" && InputPassword == "q1w2e3!@#") { - HttpContextAccessor.HttpContext?.Session - .SetInt32("Login", 1); + await session.SetAsync("Login", true); NavigationManager.NavigateTo("/"); } else diff --git a/VideoAnalysis/Components/Pages/Login.razor.css b/VideoAnalysis/Components/Pages/Login.razor.css index 78ee8be..eb2b892 100644 --- a/VideoAnalysis/Components/Pages/Login.razor.css +++ b/VideoAnalysis/Components/Pages/Login.razor.css @@ -142,6 +142,7 @@ section { position: relative; width: 400px; min-height: 400px; + height: 400px; background: rgba(255, 255, 255, 0.1); display: flex; justify-content: center; @@ -158,6 +159,7 @@ section { width: 100%; height: 100%; padding: 50px; + background: rgba(255, 255, 255, 0.1); } /* ¼ʽ */ @@ -218,14 +220,14 @@ section { /* ¼ťʽ */ - .form .inputBox input[type="submit"] { - background: #fff; - color: #666; - max-width: 100px; - margin-bottom: 20px; - font-weight: 600; - cursor: pointer; - } +.submit { + background: #fff !important; + color: #666 !important; + max-width: 100px; + margin-bottom: 20px; + font-weight: 600; + cursor: pointer !important; +} .forget { margin-top: 6px; diff --git a/VideoAnalysis/Components/Routes.razor b/VideoAnalysis/Components/Routes.razor index 919a0de..b888457 100644 --- a/VideoAnalysis/Components/Routes.razor +++ b/VideoAnalysis/Components/Routes.razor @@ -1,7 +1,15 @@ - +@using Learn.VideoAnalysis.Components.Pages + - + @if (routeData.PageType == typeof(Login)) + { + + } + else + { + + } diff --git a/VideoAnalysis/Program.cs b/VideoAnalysis/Program.cs index 970f82e..cda2602 100644 --- a/VideoAnalysis/Program.cs +++ b/VideoAnalysis/Program.cs @@ -51,9 +51,9 @@ namespace Learn.VideoAnalysis builder.Configuration.GetSection("AppConfig").Bind(AppCommon.Config); //ʼ - Speaker.Init(); - RedisExpand.Init(); - SenseVoice.Init(); + //Speaker.Init(); + //RedisExpand.Init(); + //SenseVoice.Init(); builder.Services.AddScoped(sp => @@ -81,13 +81,7 @@ namespace Learn.VideoAnalysis builder.Services.AddHttpClient(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); - builder.Services.AddSession(options => - { - options.IdleTimeout = TimeSpan.FromMinutes(30); - options.Cookie.HttpOnly = true; - options.Cookie.IsEssential = true; - }); - + var app = builder.Build();
- 忘记密码? + 忘记密码? + 点击这里 -
- 没有账户? +
+ 没有账户? + 注册