From a0a515eb0bc795c69bbfb5353de9db70c9871c7c Mon Sep 17 00:00:00 2001 From: NewOnePerson Date: Tue, 5 Jul 2022 21:10:59 +0800 Subject: [PATCH 1/2] fix TreeNode && freesql Trace --- .../Extensions/FreeSqlExtensions.cs | 4 ++++ .../admin/BootstrapAdmin.Web/Components/AdminTable.razor.cs | 2 +- .../admin/BootstrapAdmin.Web/Pages/Admin/Menus.razor.cs | 4 ++-- .../BootstrapClient.Shared/Components/AdminTable.razor.cs | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/blazor/admin/BootStarpAdmin.DataAccess.FreeSql/Extensions/FreeSqlExtensions.cs b/src/blazor/admin/BootStarpAdmin.DataAccess.FreeSql/Extensions/FreeSqlExtensions.cs index cf6db7f9..5ef93317 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.cs b/src/blazor/admin/BootstrapAdmin.Web/Components/AdminTable.razor.cs index 76d34fd0..cc033eba 100644 --- a/src/blazor/admin/BootstrapAdmin.Web/Components/AdminTable.razor.cs +++ b/src/blazor/admin/BootstrapAdmin.Web/Components/AdminTable.razor.cs @@ -145,7 +145,7 @@ namespace BootstrapAdmin.Web.Components /// /// [Parameter] - public Func>>? OnTreeExpand { get; set; } + public Func>>>? OnTreeExpand { get; set; } /// /// 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 ea8e0fc9..11fc7b6b 100644 --- a/src/blazor/admin/BootstrapAdmin.Web/Pages/Admin/Menus.razor.cs +++ b/src/blazor/admin/BootstrapAdmin.Web/Pages/Admin/Menus.razor.cs @@ -123,9 +123,9 @@ public partial class Menus }); } - private Task> 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))); } } diff --git a/src/blazor/client/BootstrapClient.Shared/Components/AdminTable.razor.cs b/src/blazor/client/BootstrapClient.Shared/Components/AdminTable.razor.cs index a5e44eb1..ec131697 100644 --- a/src/blazor/client/BootstrapClient.Shared/Components/AdminTable.razor.cs +++ b/src/blazor/client/BootstrapClient.Shared/Components/AdminTable.razor.cs @@ -145,7 +145,7 @@ namespace BootstrapClient.Web.Shared.Components /// /// [Parameter] - public Func>>? OnTreeExpand { get; set; } + public Func>>>? OnTreeExpand { get; set; } /// /// -- Gitee From f52b99f7b1d15f5633e6c8c535f19fc4fbfc8c9a Mon Sep 17 00:00:00 2001 From: NewOnePerson Date: Tue, 5 Jul 2022 23:08:25 +0800 Subject: [PATCH 2/2] fix menus --- .../Components/AdminTable.razor | 2 +- .../Components/AdminTable.razor.cs | 2 ++ .../Pages/Admin/Menus.razor | 2 +- .../Pages/Admin/Menus.razor.cs | 23 +++++++++++++++++++ .../Components/AdminTable.razor | 2 +- .../Components/AdminTable.razor.cs | 3 +++ 6 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/blazor/admin/BootstrapAdmin.Web/Components/AdminTable.razor b/src/blazor/admin/BootstrapAdmin.Web/Components/AdminTable.razor index 3413080b..277e0707 100644 --- a/src/blazor/admin/BootstrapAdmin.Web/Components/AdminTable.razor +++ b/src/blazor/admin/BootstrapAdmin.Web/Components/AdminTable.razor @@ -2,7 +2,7 @@ >>>? 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 77fe74d5..78f998a4 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" 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 3413080b..277e0707 100644 --- a/src/blazor/client/BootstrapClient.Shared/Components/AdminTable.razor +++ b/src/blazor/client/BootstrapClient.Shared/Components/AdminTable.razor @@ -2,7 +2,7 @@
>>>? OnTreeExpand { get; set; } + [Parameter] + public Func, Task>>>? TreeNodeConverter { get; set; } + /// /// /// -- Gitee