feat: 增加登录首页切换功能

This commit is contained in:
Argo-Tianyi 2022-01-27 13:42:48 +08:00
parent 6e881fbff4
commit 2674c6278d
3 changed files with 25 additions and 1 deletions

View File

@ -1,4 +1,4 @@
<div class="wrap">
<div class="@LoginClassString">
<div class="container">
<form method="post" class="form-signin" action="@PostUrl" @ref="LoginForm">
<h2 class="form-signin-heading">@Title</h2>

View File

@ -3,6 +3,7 @@
// Website: https://admin.blazor.zone
using BootstrapAdmin.Web.Core;
using BootstrapAdmin.Web.Utils;
using Microsoft.JSInterop;
namespace BootstrapAdmin.Web.Components;
@ -66,10 +67,16 @@ public partial class AdminLogin : IDisposable
[NotNull]
private IIPLocatorProvider? IPLocatorProvider { get; set; }
private string? LoginView { get; set; }
private string? ClassString => CssBuilder.Default("login-wrap")
.AddClass("is-mobile", UseMobileLogin)
.Build();
private string? LoginClassString => CssBuilder.Default("wrap")
.AddClass(LoginView)
.Build();
/// <summary>
///
/// </summary>
@ -77,6 +84,7 @@ public partial class AdminLogin : IDisposable
{
base.OnInitialized();
LoginView = LoginHelper.GetCurrentLoginTheme(DictsService.GetCurrentLogin());
Title = DictsService.GetWebTitle();
PostUrl = QueryHelper.AddQueryString("Account/Login", new Dictionary<string, string?>
{

View File

@ -50,4 +50,20 @@ public static class LoginHelper
return returnUrl ?? "/Admin/Index";
}
/// <summary>
/// 将字典表中的配置 1-Login-Gitee 转化为 gitee
/// </summary>
/// <param name="loginTheme"></param>
/// <returns></returns>
public static string? GetCurrentLoginTheme(string loginTheme)
{
string? ret = null;
var segs = loginTheme.Split('-');
if (segs.Length == 3)
{
ret = segs[2].ToLowerInvariant();
}
return ret;
}
}