feat: 任务日志增加最大数功能

This commit is contained in:
Argo-Lenovo 2022-01-29 16:03:57 +08:00
parent 188470bc1d
commit 41b0dce852
2 changed files with 28 additions and 3 deletions

View File

@ -10,7 +10,7 @@ namespace BootstrapAdmin.Web.Components;
/// <summary>
///
/// </summary>
public partial class TaskInfo
public partial class TaskInfo : IDisposable
{
/// <summary>
///
@ -20,7 +20,7 @@ public partial class TaskInfo
[EditorRequired]
public TasksModel? Model { get; set; }
private List<ConsoleMessageItem> Messages { get; } = new();
private List<ConsoleMessageItem> Messages { get; } = new(24);
/// <summary>
///
@ -47,6 +47,31 @@ public partial class TaskInfo
{
Message = message
});
if (Messages.Count > 20)
{
Messages.RemoveAt(0);
}
await InvokeAsync(StateHasChanged);
}
private void Dispose(bool disposing)
{
if (disposing)
{
var sche = TaskServicesManager.Get(Model.Name);
if (sche != null)
{
sche.Triggers.First().PulseCallback = null;
}
}
}
/// <summary>
///
/// </summary>
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
}

View File

@ -167,7 +167,7 @@ public partial class Tasks
var option = new DialogOption()
{
Class = "task-info",
Title = $"{model.Name} - 日志窗口(最新50条)",
Title = $"{model.Name} - 日志窗口(最新 20 条)",
Component = BootstrapDynamicComponent.CreateComponent<TaskInfo>(new Dictionary<string, object?>
{
[nameof(TaskInfo.Model)] = model