feat: Blazor 增加访问日志功能
This commit is contained in:
parent
3a8621825d
commit
b2b4192d55
|
@ -0,0 +1,34 @@
|
|||
@inherits TracesBase
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<span>查询结果</span>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<Table Id="logs" TItem="Bootstrap.DataAccess.Trace" ShowToolBar="true" ShowSearch="true" ShowRefresh="true" QueryModel="QueryModel" EditModel="DataContext" OnQuery="Query" OnResetSearch="ResetSearch">
|
||||
<TableHeader>
|
||||
<LgbTableHeader TItem="string" @bind-Value="@context.UserName"></LgbTableHeader>
|
||||
<LgbTableHeader TItem="DateTime" @bind-Value="@context.LogTime"></LgbTableHeader>
|
||||
<LgbTableHeader TItem="string" @bind-Value="@context.Ip"></LgbTableHeader>
|
||||
<LgbTableHeader TItem="string" @bind-Value="@context.City"></LgbTableHeader>
|
||||
<LgbTableHeader TItem="string" @bind-Value="@context.Browser"></LgbTableHeader>
|
||||
<LgbTableHeader TItem="string" @bind-Value="@context.OS"></LgbTableHeader>
|
||||
<LgbTableHeader TItem="string" @bind-Value="@context.RequestUrl"></LgbTableHeader>
|
||||
<LgbTableHeader TItem="string" @bind-Value="@context.Referer"></LgbTableHeader>
|
||||
</TableHeader>
|
||||
<RowTemplate>
|
||||
<td>@context.UserName</td>
|
||||
<td>@context.LogTime</td>
|
||||
<td>@context.Ip</td>
|
||||
<td>@context.City</td>
|
||||
<td>@context.Browser</td>
|
||||
<td>@context.OS</td>
|
||||
<td>@context.RequestUrl</td>
|
||||
<td>@context.Referer</td>
|
||||
</RowTemplate>
|
||||
<SearchTemplate>
|
||||
<LgbInputText ColumnClass="col-12" @bind-Value="@context.Ip" maxlength="50" />
|
||||
</SearchTemplate>
|
||||
</Table>
|
||||
</div>
|
||||
</div>
|
|
@ -0,0 +1,53 @@
|
|||
using Bootstrap.Admin.Pages.Components;
|
||||
using Bootstrap.Admin.Pages.Extensions;
|
||||
using Bootstrap.DataAccess;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using System;
|
||||
|
||||
namespace Bootstrap.Admin.Pages.Views.Admin.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// 部门维护组件
|
||||
/// </summary>
|
||||
public class TracesBase : ComponentBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 获得/设置 编辑类型实例
|
||||
/// </summary>
|
||||
protected Trace DataContext { get; set; } = new Trace();
|
||||
|
||||
/// <summary>
|
||||
/// 获得/设置 查询绑定类型实例
|
||||
/// </summary>
|
||||
protected Trace QueryModel { get; set; } = new Trace();
|
||||
|
||||
/// <summary>
|
||||
/// 获得/设置 开始时间
|
||||
/// </summary>
|
||||
protected DateTime? StartTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获得/设置 开始时间
|
||||
/// </summary>
|
||||
protected DateTime? EndTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 数据查询方法
|
||||
/// </summary>
|
||||
/// <param name="options"></param>
|
||||
/// <returns></returns>
|
||||
protected QueryData<Trace> Query(QueryPageOptions options)
|
||||
{
|
||||
var data = TraceHelper.Retrieves(options.ToPaginationOption(), StartTime, EndTime, QueryModel.Ip);
|
||||
return data.ToQueryData();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重置搜索方法
|
||||
/// </summary>
|
||||
protected void ResetSearch()
|
||||
{
|
||||
QueryModel.Ip = "";
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue