refactor: Table 组件移除 OnDataSourceQuery 方法
#Comment 统一使用 OnQuery 方法
This commit is contained in:
parent
729fb3bde0
commit
a34d621f42
|
@ -161,12 +161,6 @@ namespace Bootstrap.Admin.Pages.Components
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public Func<QueryPageOptions, QueryData<TItem>>? OnQuery { get; set; }
|
public Func<QueryPageOptions, QueryData<TItem>>? OnQuery { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 点击翻页回调方法
|
|
||||||
/// </summary>
|
|
||||||
[Parameter]
|
|
||||||
public Func<IEnumerable<TItem>>? OnDataSourceQuery { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 新建按钮回调方法
|
/// 新建按钮回调方法
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -280,10 +274,6 @@ namespace Bootstrap.Admin.Pages.Components
|
||||||
Query();
|
Query();
|
||||||
});
|
});
|
||||||
if (EditModel == null && OnAdd != null) EditModel = OnAdd.Invoke();
|
if (EditModel == null && OnAdd != null) EditModel = OnAdd.Invoke();
|
||||||
if (OnDataSourceQuery != null)
|
|
||||||
{
|
|
||||||
Items = OnDataSourceQuery();
|
|
||||||
}
|
|
||||||
if (OnQuery != null)
|
if (OnQuery != null)
|
||||||
{
|
{
|
||||||
var queryData = OnQuery(new QueryPageOptions() { PageItems = DefaultPageItems, SearchText = SearchText, SortName = SortName, SortOrder = SortOrder });
|
var queryData = OnQuery(new QueryPageOptions() { PageItems = DefaultPageItems, SearchText = SearchText, SortName = SortName, SortOrder = SortOrder });
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<Table Id="online" EditModel="EditModel" ShowToolBar="true" ShowRefresh="true" TItem="Longbow.Web.OnlineUser" OnDataSourceQuery="QueryData">
|
<Table Id="online" EditModel="EditModel" ShowToolBar="true" ShowRefresh="true" TItem="Longbow.Web.OnlineUser" OnQuery="QueryData">
|
||||||
<TableHeader>
|
<TableHeader>
|
||||||
<LgbTableHeader TItem="string" @bind-Value="@context.ConnectionId"></LgbTableHeader>
|
<LgbTableHeader TItem="string" @bind-Value="@context.ConnectionId"></LgbTableHeader>
|
||||||
<LgbTableHeader TItem="string" @bind-Value="@context.UserName"></LgbTableHeader>
|
<LgbTableHeader TItem="string" @bind-Value="@context.UserName"></LgbTableHeader>
|
||||||
|
|
|
@ -193,7 +193,7 @@
|
||||||
<span>网站缓存</span>
|
<span>网站缓存</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<Table Id="settings-cache" TItem="Longbow.Cache.ICacheItem" EditModel="ConsoleCaCheModel" OnDataSourceQuery="QueryData">
|
<Table Id="settings-cache" TItem="Longbow.Cache.ICacheItem" EditModel="ConsoleCaCheModel" OnQuery="QueryData">
|
||||||
<TableHeader>
|
<TableHeader>
|
||||||
<LgbTableHeader TItem="string" @bind-Value="@context.Desc"></LgbTableHeader>
|
<LgbTableHeader TItem="string" @bind-Value="@context.Desc"></LgbTableHeader>
|
||||||
<LgbTableHeader TItem="int" @bind-Value="@context.Interval"></LgbTableHeader>
|
<LgbTableHeader TItem="int" @bind-Value="@context.Interval"></LgbTableHeader>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
using Longbow.Web;
|
using Bootstrap.Admin.Pages.Components;
|
||||||
|
using Longbow.Web;
|
||||||
using Microsoft.AspNetCore.Components;
|
using Microsoft.AspNetCore.Components;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace Bootstrap.Admin.Pages.Views.Admin.Components
|
namespace Bootstrap.Admin.Pages.Views.Admin.Components
|
||||||
|
@ -24,6 +24,14 @@ namespace Bootstrap.Admin.Pages.Views.Admin.Components
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// QueryData 方法
|
/// QueryData 方法
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected IEnumerable<OnlineUser> QueryData() => (OnlineUSers?.OnlineUsers ?? new OnlineUser[0]).OrderByDescending(u => u.LastAccessTime);
|
protected QueryData<OnlineUser> QueryData(QueryPageOptions options)
|
||||||
|
{
|
||||||
|
var data = OnlineUSers?.OnlineUsers ?? new OnlineUser[0];
|
||||||
|
return new QueryData<OnlineUser>()
|
||||||
|
{
|
||||||
|
Items = data,
|
||||||
|
TotalCount = data.Count()
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
using Bootstrap.Admin.Pages.Components;
|
using Bootstrap.Admin.Pages.Components;
|
||||||
using Bootstrap.Admin.Pages.Extensions;
|
|
||||||
using Bootstrap.Admin.Pages.Shared;
|
using Bootstrap.Admin.Pages.Shared;
|
||||||
using Bootstrap.DataAccess;
|
using Bootstrap.DataAccess;
|
||||||
using Bootstrap.Security;
|
using Bootstrap.Security;
|
||||||
using Longbow.Cache;
|
using Longbow.Cache;
|
||||||
using Microsoft.AspNetCore.Components;
|
using Microsoft.AspNetCore.Components;
|
||||||
using Microsoft.JSInterop;
|
using Microsoft.JSInterop;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace Bootstrap.Admin.Pages.Views.Admin.Components
|
namespace Bootstrap.Admin.Pages.Views.Admin.Components
|
||||||
{
|
{
|
||||||
|
@ -72,7 +71,15 @@ namespace Bootstrap.Admin.Pages.Views.Admin.Components
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// QueryData 方法
|
/// QueryData 方法
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected IEnumerable<ICacheItem> QueryData() => CacheManager.ToList();
|
protected QueryData<ICacheItem> QueryData(QueryPageOptions options)
|
||||||
|
{
|
||||||
|
var data = CacheManager.ToList();
|
||||||
|
return new QueryData<ICacheItem>()
|
||||||
|
{
|
||||||
|
Items = data,
|
||||||
|
TotalCount = data.Count()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 清除指定键值的方法
|
/// 清除指定键值的方法
|
||||||
|
|
Loading…
Reference in New Issue