diff --git a/src/blazor/admin/BootStarpAdmin.DataAccess.FreeSql/Extensions/FreeSqlExtensions.cs b/src/blazor/admin/BootStarpAdmin.DataAccess.FreeSql/Extensions/FreeSqlExtensions.cs index cf6db7f97f5287934d82afc9039400901bc7068c..5ef93317742d6eb5a989b8789045c3b3251cc5de 100644 --- a/src/blazor/admin/BootStarpAdmin.DataAccess.FreeSql/Extensions/FreeSqlExtensions.cs +++ b/src/blazor/admin/BootStarpAdmin.DataAccess.FreeSql/Extensions/FreeSqlExtensions.cs @@ -24,6 +24,10 @@ static class FreeSqlExtensions i.Property(n => n.Period).IsIgnore(true); i.Property(n => n.IsReset).IsIgnore(true); }); + freeSql.CodeFirst.ConfigEntity(i => + { + i.Name("Traces"); + }); freeSql.CodeFirst.ConfigEntity(i => { i.Name("Groups"); diff --git a/src/blazor/admin/BootstrapAdmin.Web/Components/AdminTable.razor b/src/blazor/admin/BootstrapAdmin.Web/Components/AdminTable.razor index 3413080bc735f203152a69f00a1db8bfa91662e2..277e070767b24c3237024fd301775348809ca037 100644 --- a/src/blazor/admin/BootstrapAdmin.Web/Components/AdminTable.razor +++ b/src/blazor/admin/BootstrapAdmin.Web/Components/AdminTable.razor @@ -2,7 +2,7 @@ [Parameter] - public Func>>? OnTreeExpand { get; set; } + public Func>>>? OnTreeExpand { get; set; } + [Parameter] + public Func, Task>>>? TreeNodeConverter { get; set; } /// /// /// diff --git a/src/blazor/admin/BootstrapAdmin.Web/Pages/Admin/Menus.razor b/src/blazor/admin/BootstrapAdmin.Web/Pages/Admin/Menus.razor index 77fe74d5bad4a9baffc9904443fdb527bd4bc7d0..78f998a4b6dcc99320618c315a319bdf9c9d1f96 100644 --- a/src/blazor/admin/BootstrapAdmin.Web/Pages/Admin/Menus.razor +++ b/src/blazor/admin/BootstrapAdmin.Web/Pages/Admin/Menus.razor @@ -1,7 +1,7 @@ @page "/Admin/Menus" > OnTreeExpand(Navigation menu) + 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()); + return Task.FromResult(navs.Where(m => m.ParentId == menu.Id).OrderBy(m => m.Order).AsEnumerable().Select(i => new TableTreeNode(i))); + } + + public Task>> TreeNodeConverter(IEnumerable items) + { + var ret = BuildTreeNodes(items, "0"); + return Task.FromResult(ret); + + IEnumerable> BuildTreeNodes(IEnumerable items, string parentId) + { + var navs = NavigationService.GetAllMenus(AppContext.UserName); + + var ret = new List>(); + ret.AddRange(items.Where(i => i.ParentId == parentId).Select((nav, index) => new TableTreeNode(nav) + { + + HasChildren = navs.Any(i => i.ParentId == nav.Id), + + IsExpand = !navs.Any(i => i.ParentId == nav.Id), + // 获得子项集合 + Items = BuildTreeNodes(items.Where(i => i.ParentId == nav.Id), nav.Id) + })); + return ret; + } } } diff --git a/src/blazor/client/BootstrapClient.Shared/Components/AdminTable.razor b/src/blazor/client/BootstrapClient.Shared/Components/AdminTable.razor index 3413080bc735f203152a69f00a1db8bfa91662e2..277e070767b24c3237024fd301775348809ca037 100644 --- a/src/blazor/client/BootstrapClient.Shared/Components/AdminTable.razor +++ b/src/blazor/client/BootstrapClient.Shared/Components/AdminTable.razor @@ -2,7 +2,7 @@
[Parameter] - public Func>>? OnTreeExpand { get; set; } + public Func>>>? OnTreeExpand { get; set; } + + [Parameter] + public Func, Task>>>? TreeNodeConverter { get; set; } /// ///