From 73bba5dd28bbb9f43ae39df55fcc526f3d13f04f Mon Sep 17 00:00:00 2001 From: Argo-AscioTech Date: Sun, 24 Mar 2024 00:05:09 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E7=8B=AC=E7=AB=8B=E6=88=90?= =?UTF-8?q?=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Components/Pages/Index.razor | 7 +---- Components/Pages/Index.razor.cs | 40 ---------------------------- Components/Pages/TestDemo.razor | 47 +++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 46 deletions(-) create mode 100644 Components/Pages/TestDemo.razor diff --git a/Components/Pages/Index.razor b/Components/Pages/Index.razor index fdb1c63..ce2e77d 100644 --- a/Components/Pages/Index.razor +++ b/Components/Pages/Index.razor @@ -13,12 +13,7 @@
- - - - - - +
diff --git a/Components/Pages/Index.razor.cs b/Components/Pages/Index.razor.cs index d1b1397..778f1e4 100644 --- a/Components/Pages/Index.razor.cs +++ b/Components/Pages/Index.razor.cs @@ -7,7 +7,6 @@ using BootstrapBlazorApp.Server.Data; using Microsoft.AspNetCore.Components; using Microsoft.Extensions.Localization; using System.Diagnostics.CodeAnalysis; -using System.Reflection; namespace BootstrapBlazorApp.Server.Components.Pages { @@ -22,8 +21,6 @@ namespace BootstrapBlazorApp.Server.Components.Pages private static IEnumerable PageItemsSource => [10, 20, 50]; - private Client? _selectClient; - private Task> OnQueryAsync(QueryPageOptions options) { if (Items == null) @@ -52,42 +49,5 @@ namespace BootstrapBlazorApp.Server.Components.Pages IsSearch = true }); } - - private static string? GetClientNameCallback(Client dto) - { - return dto.ClientName; - } - - private Task> OnClientsQueryAsync(QueryPageOptions options) - { - IEnumerable items = new List { - new() { ClientId=1,ClientName="测试一" }, - new() { ClientId=2,ClientName="测试二" }, - new() { ClientId=3,ClientName="测试三" }, - new() { ClientId=4,ClientName="测试四" }, - new() { ClientId=5,ClientName="测试五" }, - }; - - if (!string.IsNullOrEmpty(options.SortName)) - { - items = items.Sort(options.SortName, options.SortOrder); - } - - var count = items.Count(); - if (options.IsPage) - { - items = items.Skip((options.PageIndex - 1) * options.PageItems).Take(options.PageItems); - } - - return Task.FromResult(new QueryData() - { - Items = items.ToList(), - TotalCount = count, - IsAdvanceSearch = true, - IsFiltered = true, - IsSearch = true, - IsSorted = true - }); - } } } diff --git a/Components/Pages/TestDemo.razor b/Components/Pages/TestDemo.razor new file mode 100644 index 0000000..05b442c --- /dev/null +++ b/Components/Pages/TestDemo.razor @@ -0,0 +1,47 @@ + + + + + + + +@code { + private Client? _selectClient; + + private static string? GetClientNameCallback(Client dto) + { + return dto.ClientName; + } + + private Task> OnClientsQueryAsync(QueryPageOptions options) + { + IEnumerable items = new List { + new() { ClientId=1,ClientName="测试一" }, + new() { ClientId=2,ClientName="测试二" }, + new() { ClientId=3,ClientName="测试三" }, + new() { ClientId=4,ClientName="测试四" }, + new() { ClientId=5,ClientName="测试五" }, + }; + + if (!string.IsNullOrEmpty(options.SortName)) + { + items = items.Sort(options.SortName, options.SortOrder); + } + + var count = items.Count(); + if (options.IsPage) + { + items = items.Skip((options.PageIndex - 1) * options.PageItems).Take(options.PageItems); + } + + return Task.FromResult(new QueryData() + { + Items = items.ToList(), + TotalCount = count, + IsAdvanceSearch = true, + IsFiltered = true, + IsSearch = true, + IsSorted = true + }); + } +} -- Gitee