diff --git a/src/BootstrapBlazor/Components/Layout/Layout.razor b/src/BootstrapBlazor/Components/Layout/Layout.razor
index 85ea8ffed8babf4ecfa46c73150c2430b66852c0..107a9d4d3bb30813729e47555632ba1435cb2826 100644
--- a/src/BootstrapBlazor/Components/Layout/Layout.razor
+++ b/src/BootstrapBlazor/Components/Layout/Layout.razor
@@ -2,38 +2,20 @@
@inherits LayoutBase
-
- @if (Side == null)
- {
- @RenderHeader.Invoke(false)
- @RenderMain
- @if (ShowFooter)
+ @if (IsAuthenticated)
+ {
+
+ @if (Side == null)
{
- @RenderFooter
- }
- }
- else if (IsFullSide)
- {
-
-
- @RenderHeader.Invoke(ShowCollapseBar)
+ @RenderHeader.Invoke(false)
@RenderMain
@if (ShowFooter)
{
@RenderFooter
}
-
- }
- else
- {
- @RenderHeader.Invoke(ShowCollapseBar);
-
- @if (ShowFooter)
+
+ @RenderHeader.Invoke(ShowCollapseBar)
+ @RenderMain
+ @if (ShowFooter)
+ {
+ @RenderFooter
+ }
+
+ }
+ else
{
- @RenderFooter
+ @RenderHeader.Invoke(ShowCollapseBar);
+
+ @if (ShowFooter)
+ {
+ @RenderFooter
+ }
}
- }
-
+
+ }
+ else
+ {
+ @Main
+ }
@code {
diff --git a/src/BootstrapBlazor/Components/Layout/Layout.razor.cs b/src/BootstrapBlazor/Components/Layout/Layout.razor.cs
index 293224085d186a913cb221d08d2a77bf4abdf04d..a0a49bcd4624afb40bce2a7ab7226d9e07453c12 100644
--- a/src/BootstrapBlazor/Components/Layout/Layout.razor.cs
+++ b/src/BootstrapBlazor/Components/Layout/Layout.razor.cs
@@ -18,6 +18,8 @@ namespace BootstrapBlazor.Components
{
private JSInterop? Interop { get; set; }
+ private bool IsAuthenticated { get; set; }
+
///
/// 获得 组件样式
///
@@ -93,6 +95,25 @@ namespace BootstrapBlazor.Components
TooltipText ??= Localizer[nameof(TooltipText)];
}
+ ///
+ ///
+ ///
+ ///
+ protected override async Task OnInitializedAsync()
+ {
+ await base.OnInitializedAsync();
+
+ if (AuthenticationStateTask != null)
+ {
+ var state = await AuthenticationStateTask;
+ IsAuthenticated = state.User.Identity?.IsAuthenticated ?? false;
+ }
+ else
+ {
+ IsAuthenticated = true;
+ }
+ }
+
///
/// OnAfterRenderAsync 方法
///
diff --git a/src/BootstrapBlazor/Components/Layout/LayoutBase.cs b/src/BootstrapBlazor/Components/Layout/LayoutBase.cs
index ddbf81a5f7b1493d8fdc583ab4064f9e53a2b26d..f857356a3ad5018b23261878631813690dea6bef 100644
--- a/src/BootstrapBlazor/Components/Layout/LayoutBase.cs
+++ b/src/BootstrapBlazor/Components/Layout/LayoutBase.cs
@@ -3,6 +3,7 @@
// Website: https://www.blazor.zone or https://argozhang.github.io/
using Microsoft.AspNetCore.Components;
+using Microsoft.AspNetCore.Components.Authorization;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
@@ -148,6 +149,12 @@ namespace BootstrapBlazor.Components
[Parameter]
public Func? OnCollapsed { get; set; }
+ ///
+ /// 获得 登录授权信息
+ ///
+ [CascadingParameter]
+ protected Task? AuthenticationStateTask { get; set; }
+
///
/// 点击 收缩展开按钮时回调此方法
///