-
-
-
@DisplayName
+
+
+
+ @DisplayName
+
+
-
-
-
-
- @Body
-
-
-
-
-
-
+
+
+ @Body
+
+
+
+
+
+
+}
\ No newline at end of file
diff --git a/src/blazor/admin/BootstrapAdmin.Web/Shared/MainLayout.razor.cs b/src/blazor/admin/BootstrapAdmin.Web/Shared/MainLayout.razor.cs
index 73956421..e00be754 100644
--- a/src/blazor/admin/BootstrapAdmin.Web/Shared/MainLayout.razor.cs
+++ b/src/blazor/admin/BootstrapAdmin.Web/Shared/MainLayout.razor.cs
@@ -33,10 +33,6 @@ namespace BootstrapAdmin.Web.Shared
[NotNull]
private BootstrapAppContext? Context { get; set; }
- [Inject]
- [NotNull]
- private NavigationManager? Navigation { get; set; }
-
[Inject]
[NotNull]
private IBootstrapAdminService? SecurityService { get; set; }
@@ -47,30 +43,30 @@ namespace BootstrapAdmin.Web.Shared
private string? DisplayName { get; set; }
- ///
- ///
- ///
- protected override void OnInitialized()
- {
- base.OnInitialized();
-
- MenuItems = NavigationsService.GetAllMenus("Admin").ToAdminMenus();
-
- Title = DictsService.GetWebTitle();
- Footer = DictsService.GetWebFooter();
- }
+ private bool Login { get; set; }
///
- ///
+ /// OnInitializedAsync 方法
///
///
protected override async Task OnInitializedAsync()
{
var state = await AuthenticationStateProvider.GetAuthenticationStateAsync();
var userName = state.User.Identity?.Name;
- DisplayName = UsersService.GetDisplayName(userName);
- Context.UserName = userName;
- Context.DisplayName = DisplayName;
+
+ if (!string.IsNullOrEmpty(userName))
+ {
+ DisplayName = UsersService.GetDisplayName(userName);
+ Context.UserName = userName;
+ Context.DisplayName = DisplayName;
+
+ MenuItems = NavigationsService.GetAllMenus("Admin").ToAdminMenus();
+ }
+
+ Title = DictsService.GetWebTitle();
+ Footer = DictsService.GetWebFooter();
+
+ Login = true;
}
private Task
OnAuthorizing(string url) => SecurityService.AuhorizingNavigation(Context.UserName, url);