diff --git a/src/blazor/Bootstrap.Client.Blazor/App.razor b/src/blazor/Bootstrap.Client.Blazor.Shared/App.razor similarity index 84% rename from src/blazor/Bootstrap.Client.Blazor/App.razor rename to src/blazor/Bootstrap.Client.Blazor.Shared/App.razor index 77e55051..429f8de2 100644 --- a/src/blazor/Bootstrap.Client.Blazor/App.razor +++ b/src/blazor/Bootstrap.Client.Blazor.Shared/App.razor @@ -1,5 +1,5 @@ - + diff --git a/src/blazor/Bootstrap.Client.Blazor.Shared/Bootstrap.Client.Blazor.Shared.csproj b/src/blazor/Bootstrap.Client.Blazor.Shared/Bootstrap.Client.Blazor.Shared.csproj index 13b04c7f..c568f450 100644 --- a/src/blazor/Bootstrap.Client.Blazor.Shared/Bootstrap.Client.Blazor.Shared.csproj +++ b/src/blazor/Bootstrap.Client.Blazor.Shared/Bootstrap.Client.Blazor.Shared.csproj @@ -5,7 +5,7 @@ - + diff --git a/src/blazor/Bootstrap.Client.Blazor.Shared/Pages/Index.razor b/src/blazor/Bootstrap.Client.Blazor.Shared/Pages/Index.razor index 448c2960..849c0252 100644 --- a/src/blazor/Bootstrap.Client.Blazor.Shared/Pages/Index.razor +++ b/src/blazor/Bootstrap.Client.Blazor.Shared/Pages/Index.razor @@ -1,4 +1,5 @@ -@page "/Home/Index" +@page "/" +@page "/Home/Index"

Hello, world!

diff --git a/src/blazor/Bootstrap.Client.Blazor.Shared/Shared/MainLayout.razor.cs b/src/blazor/Bootstrap.Client.Blazor.Shared/Shared/MainLayout.razor.cs index c527f126..4a46fc61 100644 --- a/src/blazor/Bootstrap.Client.Blazor.Shared/Shared/MainLayout.razor.cs +++ b/src/blazor/Bootstrap.Client.Blazor.Shared/Shared/MainLayout.razor.cs @@ -2,7 +2,6 @@ using BootstrapBlazor.Components; using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Authorization; -using Microsoft.AspNetCore.Components.Routing; using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; @@ -30,6 +29,8 @@ namespace Bootstrap.Client.Blazor.Shared.Shared private bool ShowFooter { get; set; } = true; + private bool IsAuthenticated { get; set; } + [NotNull] private List? Menus { get; set; } @@ -82,17 +83,19 @@ namespace Bootstrap.Client.Blazor.Shared.Shared { UserName = state.User.Identity.Name; DisplayName = UserHelper.RetrieveUserByUserName(UserName)?.DisplayName; + + // 模拟异步线程切换,正式代码中删除此行代码 + await Task.Yield(); + + // 菜单获取可以通过数据库获取,此处为示例直接拼装的菜单集合 + TabItemTextDictionary = new() + { + [""] = "Index" + }; + + // 获取登录用户菜单 + Menus = GetMenus(); } - - // 模拟异步线程切换,正式代码中删除此行代码 - await Task.Yield(); - - // 菜单获取可以通过数据库获取,此处为示例直接拼装的菜单集合 - TabItemTextDictionary = new() - { - [""] = "Index" - }; - Menus = GetMenus(); } private List GetMenus() diff --git a/src/blazor/Bootstrap.Client.Blazor.Shared/_Imports.razor b/src/blazor/Bootstrap.Client.Blazor.Shared/_Imports.razor index 77be90ad..19ab29c1 100644 --- a/src/blazor/Bootstrap.Client.Blazor.Shared/_Imports.razor +++ b/src/blazor/Bootstrap.Client.Blazor.Shared/_Imports.razor @@ -1,6 +1,8 @@ -@using BootstrapBlazor.Components +@using Bootstrap.Client.Blazor.Shared.Shared +@using BootstrapBlazor.Components @using Microsoft.AspNetCore.Authorization +@using Microsoft.AspNetCore.Components.Authorization @using Microsoft.AspNetCore.Components.Forms @using Microsoft.AspNetCore.Components.Routing @using Microsoft.AspNetCore.Components.Web diff --git a/src/blazor/Bootstrap.Client.Blazor/Pages/_Host.cshtml b/src/blazor/Bootstrap.Client.Blazor/Pages/_Host.cshtml index df3c9973..3936824a 100644 --- a/src/blazor/Bootstrap.Client.Blazor/Pages/_Host.cshtml +++ b/src/blazor/Bootstrap.Client.Blazor/Pages/_Host.cshtml @@ -1,4 +1,5 @@ @page "/" +@using Bootstrap.Client.Blazor.Shared @namespace Bootstrap.Client.Blazor.Pages @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers @{