feat: 网站设置增加缓存列表与清除功能
This commit is contained in:
parent
e8b824c6a0
commit
54835998dc
|
@ -161,6 +161,12 @@ namespace Bootstrap.Admin.Components
|
|||
[Parameter]
|
||||
public Func<int, int, string, QueryData<TItem>>? OnQuery { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 点击翻页回调方法
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public Func<IEnumerable<TItem>>? OnDataSourceQuery { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 新建按钮回调方法
|
||||
/// </summary>
|
||||
|
@ -226,7 +232,8 @@ namespace Bootstrap.Admin.Components
|
|||
/// <summary>
|
||||
/// 获得/设置 EditModel 实例
|
||||
/// </summary>
|
||||
protected TItem EditModel { get; set; }
|
||||
[Parameter]
|
||||
public TItem EditModel { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获得/设置 QueryModel 实例
|
||||
|
@ -251,10 +258,14 @@ namespace Bootstrap.Admin.Components
|
|||
/// </summary>
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
if (OnAdd != null) EditModel = OnAdd.Invoke();
|
||||
if (EditModel == null && OnAdd != null) EditModel = OnAdd.Invoke();
|
||||
if (OnDataSourceQuery != null)
|
||||
{
|
||||
Items = OnDataSourceQuery();
|
||||
}
|
||||
if (OnQuery != null)
|
||||
{
|
||||
var queryData = OnQuery.Invoke(1, DefaultPageItems, SearchText);
|
||||
var queryData = OnQuery(1, DefaultPageItems, SearchText);
|
||||
Items = queryData.Items;
|
||||
TotalCount = queryData.TotalCount;
|
||||
}
|
||||
|
@ -388,7 +399,7 @@ namespace Bootstrap.Admin.Components
|
|||
/// </summary>
|
||||
protected void Query()
|
||||
{
|
||||
if (OnQuery != null) Query(OnQuery.Invoke(PageIndex, PageItems, SearchText));
|
||||
if (OnQuery != null) Query(OnQuery(PageIndex, PageItems, SearchText));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using Bootstrap.DataAccess;
|
||||
using Bootstrap.Security;
|
||||
using Longbow.Cache;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
|
@ -43,6 +44,12 @@ namespace Microsoft.AspNetCore.Builder
|
|||
_displayNameCache.TryAdd((typeof(BootstrapMenu), nameof(BootstrapMenu.IsResource)), "菜单类型");
|
||||
_displayNameCache.TryAdd((typeof(BootstrapMenu), nameof(BootstrapMenu.Application)), "所属应用");
|
||||
|
||||
// 缓存显示名称
|
||||
_displayNameCache.TryAdd((typeof(CacheItem), nameof(CacheItem.Key)), "缓存 Key");
|
||||
_displayNameCache.TryAdd((typeof(CacheItem), nameof(CacheItem.Value)), "缓存值");
|
||||
_displayNameCache.TryAdd((typeof(CacheItem), nameof(CacheItem.Interval)), "缓存时长(秒)");
|
||||
_displayNameCache.TryAdd((typeof(CacheItem), nameof(CacheItem.ElapsedSeconds)), "已过时长(秒)");
|
||||
_displayNameCache.TryAdd((typeof(CacheItem), nameof(CacheItem.Desc)), "缓存说明");
|
||||
return services;
|
||||
}
|
||||
|
||||
|
|
|
@ -192,13 +192,31 @@
|
|||
<div class="card-header">
|
||||
<div class="d-flex align-items-center">
|
||||
<span class="flex-fill">网站缓存</span>
|
||||
<ConditionComponent AuthKey="clearAllCache">
|
||||
<a href="#" class="fa fa-times-circle-o" title="全部清除" data-toggle="tooltip" data-placement="left" asp-auth=""></a>
|
||||
</ConditionComponent>
|
||||
<a href="#" class="fa fa-refresh ml-3" title="点击刷新" data-toggle="tooltip"></a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<Table @ref="Table" Id="settings-cache" TItem="Longbow.Cache.ICacheItem" EditModel="ConsoleCaCheModel" OnDataSourceQuery="QueryData">
|
||||
<TableHeader>
|
||||
<LgbTableHeader TItem="string" @bind-Value="@context.Desc"></LgbTableHeader>
|
||||
<LgbTableHeader TItem="int" @bind-Value="@context.Interval"></LgbTableHeader>
|
||||
<LgbTableHeader TItem="string" @bind-Value="@context.Key"></LgbTableHeader>
|
||||
<LgbTableHeader TItem="string" @bind-Value="@context.Value"></LgbTableHeader>
|
||||
<LgbTableHeader TItem="int" @bind-Value="@context.ElapsedSeconds"></LgbTableHeader>
|
||||
</TableHeader>
|
||||
<RowTemplate>
|
||||
<td>@context.Desc</td>
|
||||
<td>@(context.Interval / 1000)</td>
|
||||
<td>@context.Key</td>
|
||||
<td>@context.Value</td>
|
||||
<td>@context.ElapsedSeconds</td>
|
||||
</RowTemplate>
|
||||
<TableToolbarTemplate>
|
||||
<TableToolbarButton class="btn btn-danger" Icon="fa fa-trash-o" Title="一键清除" OnClick="ClearCache" />
|
||||
</TableToolbarTemplate>
|
||||
<ButtonTemplate>
|
||||
<button class='btn btn-sm btn-danger' asp-auth="del" @onclick="e => DeleteCache(context.Key)"><i class='fa fa-remove'></i><span>删除</span></button>
|
||||
</ButtonTemplate>
|
||||
</Table>
|
||||
</div>
|
||||
</div>
|
||||
<Toast @ref="Toast" Id="toast_settings"></Toast>
|
||||
|
|
|
@ -3,7 +3,9 @@ using Bootstrap.Admin.Extensions;
|
|||
using Bootstrap.Admin.Shared;
|
||||
using Bootstrap.DataAccess;
|
||||
using Bootstrap.Security;
|
||||
using Longbow.Cache;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Bootstrap.Pages.Admin.Components
|
||||
|
@ -18,12 +20,27 @@ namespace Bootstrap.Pages.Admin.Components
|
|||
/// </summary>
|
||||
protected EditModel Model { get; set; } = new EditModel();
|
||||
|
||||
/// <summary>
|
||||
/// 获得 CacheItem 实例
|
||||
/// </summary>
|
||||
protected ICacheItem ConsoleCaCheModel { get; set; } = new CacheItem("");
|
||||
|
||||
/// <summary>
|
||||
/// 获得 CacheItem 实例
|
||||
/// </summary>
|
||||
protected ICacheItem ClientCaCheModel { get; set; } = new CacheItem("");
|
||||
|
||||
/// <summary>
|
||||
/// 获得/设置 默认母版页实例
|
||||
/// </summary>
|
||||
[CascadingParameter(Name = "Default")]
|
||||
public DefaultLayout? RootLayout { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获得/设置 Table 实例
|
||||
/// </summary>
|
||||
protected Table<ICacheItem>? Table { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Toast 组件实例
|
||||
/// </summary>
|
||||
|
@ -56,6 +73,21 @@ namespace Bootstrap.Pages.Admin.Components
|
|||
Model.Themes = DictHelper.RetrieveThemes();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// QueryData 方法
|
||||
/// </summary>
|
||||
protected IEnumerable<ICacheItem> QueryData() => CacheManager.ToList();
|
||||
|
||||
/// <summary>
|
||||
/// 清除指定键值的方法
|
||||
/// </summary>
|
||||
protected void DeleteCache(string key) => CacheManager.Clear(key);
|
||||
|
||||
/// <summary>
|
||||
/// 清除所有缓存方法
|
||||
/// </summary>
|
||||
protected void ClearCache() => CacheManager.Clear();
|
||||
|
||||
/// <summary>
|
||||
/// 保存 Balzor 方法
|
||||
/// </summary>
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
@inherits TableBase<TItem>
|
||||
|
||||
<div class="bootstrap-table">
|
||||
<div class="fixed-table-toolbar">
|
||||
<div class="float-left bs-bars">
|
||||
@if(ShowToolBar)
|
||||
{
|
||||
@if(ShowToolBar)
|
||||
{
|
||||
<div class="fixed-table-toolbar">
|
||||
<div class="float-left bs-bars">
|
||||
<TableToolbar>
|
||||
<TableToolbarContent />
|
||||
@if(ShowDefaultButtons)
|
||||
|
@ -16,40 +16,36 @@
|
|||
}
|
||||
@TableToolbarTemplate
|
||||
</TableToolbar>
|
||||
}
|
||||
</div>
|
||||
<div class="float-right columns columns-right">
|
||||
@if(ShowToolBar)
|
||||
{
|
||||
</div>
|
||||
<div class="float-right columns columns-right">
|
||||
@if(ShowRefresh)
|
||||
{
|
||||
<button class="btn btn-secondary" type="button" title="刷新" @onclick="Query">
|
||||
<i class="fa fa-refresh"></i><span>刷新</span>
|
||||
</button>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
@if(ShowSearch)
|
||||
{
|
||||
<div class="float-right search btn-group">
|
||||
<div class="input-group">
|
||||
<input class="form-control search-input" type="text" placeholder="搜索" @bind="SearchText" />
|
||||
<div class="input-group-append">
|
||||
<button class="btn btn-secondary" type="button" title="搜索" @onclick="SearchClick">
|
||||
<i class="fa fa-search"></i><span>搜索</span>
|
||||
</button>
|
||||
<button class="btn btn-secondary" type="button" title="清空过滤" @onclick="ClearSearchClick">
|
||||
<i class="fa fa-trash"></i> <span>清空过滤</span>
|
||||
</button>
|
||||
<button class="btn btn-secondary" type="button" title="高级搜索" @onclick="AdvancedSearchClick">
|
||||
<i class="fa fa-search-plus"></i><span>高级搜索</span>
|
||||
</button>
|
||||
</div>
|
||||
@if(ShowSearch)
|
||||
{
|
||||
<div class="float-right search btn-group">
|
||||
<div class="input-group">
|
||||
<input class="form-control search-input" type="text" placeholder="搜索" @bind="SearchText" />
|
||||
<div class="input-group-append">
|
||||
<button class="btn btn-secondary" type="button" title="搜索" @onclick="SearchClick">
|
||||
<i class="fa fa-search"></i><span>搜索</span>
|
||||
</button>
|
||||
<button class="btn btn-secondary" type="button" title="清空过滤" @onclick="ClearSearchClick">
|
||||
<i class="fa fa-trash"></i> <span>清空过滤</span>
|
||||
</button>
|
||||
<button class="btn btn-secondary" type="button" title="高级搜索" @onclick="AdvancedSearchClick">
|
||||
<i class="fa fa-search-plus"></i><span>高级搜索</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
}
|
||||
</div>
|
||||
}
|
||||
<div class="@(FixedHeader ? "table-wrapper table-fixed-header table-fixed" : "table-wrapper")">
|
||||
@if(FixedHeader)
|
||||
{
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<PackageReference Include="Bootstrap.Security.DataAccess" Version="3.1.1" />
|
||||
<PackageReference Include="Bootstrap.Security.Mvc" Version="3.1.1" />
|
||||
<PackageReference Include="Longbow" Version="3.1.0" />
|
||||
<PackageReference Include="Longbow.Cache" Version="3.1.1" />
|
||||
<PackageReference Include="Longbow.Cache" Version="3.1.2-beta-01" />
|
||||
<PackageReference Include="Longbow.Data" Version="3.1.0" />
|
||||
<PackageReference Include="Longbow.GiteeAuth" Version="3.1.0" />
|
||||
<PackageReference Include="Longbow.GitHubAuth" Version="3.1.0" />
|
||||
|
|
Loading…
Reference in New Issue