diff --git a/src/blazor/admin/BootstrapAdmin.Web/Pages/Admin/Menus.razor.cs b/src/blazor/admin/BootstrapAdmin.Web/Pages/Admin/Menus.razor.cs index daa8887c..202108cf 100644 --- a/src/blazor/admin/BootstrapAdmin.Web/Pages/Admin/Menus.razor.cs +++ b/src/blazor/admin/BootstrapAdmin.Web/Pages/Admin/Menus.razor.cs @@ -32,9 +32,6 @@ public partial class Menus [NotNull] private BootstrapAppContext? AppContext { get; set; } - [NotNull] - private List? Navigations { get; set; } - [NotNull] private List? Targets { get; set; } @@ -52,15 +49,6 @@ public partial class Menus Apps = LookupHelper.GetApps(DictService); } - /// - /// OnInitializedAsync 方法 - /// - /// - protected override Task OnInitializedAsync() => Task.Run(() => - { - Navigations = NavigationService.GetAllMenus(AppContext.UserName); - }); - private async Task OnAssignmentRoles(DataAccess.Models.Navigation menu) { var roles = RoleService.GetAll().ToSelectedItemList(); @@ -75,10 +63,11 @@ public partial class Menus private Task> OnQueryAsync(QueryPageOptions options) { - var menus = Navigations.Where(m => m.ParentId == "0").OrderBy(m => m.Order); + var navs = NavigationService.GetAllMenus(AppContext.UserName); + var menus = navs.Where(m => m.ParentId == "0").OrderBy(m => m.Order); foreach (var item in menus) { - item.HasChildren = Navigations.Any(i => i.ParentId == item.Id); + item.HasChildren = navs.Any(i => i.ParentId == item.Id); } return Task.FromResult(new QueryData() @@ -87,5 +76,9 @@ public partial class Menus }); } - private Task> OnTreeExpand(Navigation menu) => Task.FromResult(Navigations.Where(m => m.ParentId == menu.Id).OrderBy(m => m.Order).AsEnumerable()); + private Task> OnTreeExpand(Navigation menu) + { + var navs = NavigationService.GetAllMenus(AppContext.UserName); + return Task.FromResult(navs.Where(m => m.ParentId == menu.Id).OrderBy(m => m.Order).AsEnumerable()); + } }