feat: 母版页保存当前登录用户名与显示名称
This commit is contained in:
parent
61827b87eb
commit
0df111ee42
|
@ -1,4 +1,6 @@
|
|||
namespace BootstrapAdmin.Web.Services
|
||||
using Microsoft.AspNetCore.Components.Authorization;
|
||||
|
||||
namespace BootstrapAdmin.Web.Services
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
|
@ -13,8 +15,15 @@
|
|||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[NotNull]
|
||||
public string? UserName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[NotNull]
|
||||
public string? DisplayName { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using BootstrapAdmin.Web.Core;
|
||||
using BootstrapAdmin.Web.Extensions;
|
||||
using BootstrapAdmin.Web.Services;
|
||||
using Microsoft.AspNetCore.Components.Authorization;
|
||||
|
||||
namespace BootstrapAdmin.Web.Shared
|
||||
|
@ -27,6 +28,10 @@ namespace BootstrapAdmin.Web.Shared
|
|||
[NotNull]
|
||||
private IUsers? UsersService { get; set; }
|
||||
|
||||
[Inject]
|
||||
[NotNull]
|
||||
private BootstrapAppContext? Context { get; set; }
|
||||
|
||||
private string? Title { get; set; }
|
||||
|
||||
private string? Footer { get; set; }
|
||||
|
@ -55,7 +60,8 @@ namespace BootstrapAdmin.Web.Shared
|
|||
var state = await AuthenticationStateProvider.GetAuthenticationStateAsync();
|
||||
var userName = state.User.Identity?.Name;
|
||||
DisplayName = UsersService.GetDisplayName(userName);
|
||||
|
||||
Context.UserName = userName;
|
||||
Context.DisplayName = DisplayName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue