update `Spectre.Console` #229
This commit is contained in:
parent
56839edb0c
commit
5144f387df
|
@ -10,7 +10,7 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Spectre.Console" Version="0.44.1-preview.0.34" />
|
||||
<PackageReference Include="Spectre.Console" Version="0.47.1-preview.0.11" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -15,7 +15,6 @@ namespace N_m3u8DL_RE.Column
|
|||
{
|
||||
private long _stopSpeed = 0;
|
||||
private ConcurrentDictionary<int, string> DateTimeStringDic = new();
|
||||
private ConcurrentDictionary<int, string> SpeedDic = new();
|
||||
protected override bool NoWrap => true;
|
||||
private ConcurrentDictionary<int, SpeedContainer> SpeedContainerDic { get; set; }
|
||||
|
||||
|
@ -26,7 +25,7 @@ namespace N_m3u8DL_RE.Column
|
|||
|
||||
public Style MyStyle { get; set; } = new Style(foreground: Color.Green);
|
||||
|
||||
public override IRenderable Render(RenderContext context, ProgressTask task, TimeSpan deltaTime)
|
||||
public override IRenderable Render(RenderOptions options, ProgressTask task, TimeSpan deltaTime)
|
||||
{
|
||||
var taskId = task.Id;
|
||||
var speedContainer = SpeedContainerDic[taskId];
|
||||
|
@ -41,16 +40,15 @@ namespace N_m3u8DL_RE.Column
|
|||
//一秒汇报一次即可
|
||||
if (DateTimeStringDic.TryGetValue(taskId, out var oldTime) && oldTime != now && !flag)
|
||||
{
|
||||
SpeedDic[taskId] = FormatFileSize(speedContainer.Downloaded);
|
||||
speedContainer.NowSpeed = speedContainer.Downloaded;
|
||||
//速度为0,计数增加
|
||||
if (speedContainer.Downloaded <= _stopSpeed) { speedContainer.AddLowSpeedCount(); SpeedDic[taskId] += $"({speedContainer.LowSpeedCount})"; }
|
||||
if (speedContainer.Downloaded <= _stopSpeed) { speedContainer.AddLowSpeedCount(); }
|
||||
else speedContainer.ResetLowSpeedCount();
|
||||
speedContainer.Reset();
|
||||
}
|
||||
DateTimeStringDic[taskId] = now;
|
||||
var style = flag ? Style.Plain : MyStyle;
|
||||
SpeedDic.TryGetValue(taskId, out var speed);
|
||||
return flag ? new Text("-", style).Centered() : new Text(speed ?? "0Bps", style).Centered();
|
||||
return flag ? new Text("-", style).Centered() : new Text(FormatFileSize(speedContainer.NowSpeed) + (speedContainer.LowSpeedCount > 0 ? $"({speedContainer.LowSpeedCount})" : ""), style).Centered();
|
||||
}
|
||||
|
||||
private static string FormatFileSize(double fileSize)
|
||||
|
|
|
@ -24,9 +24,9 @@ namespace N_m3u8DL_RE.Column
|
|||
this.SpeedContainerDic = speedContainerDic;
|
||||
}
|
||||
|
||||
public override IRenderable Render(RenderContext context, ProgressTask task, TimeSpan deltaTime)
|
||||
public override IRenderable Render(RenderOptions options, ProgressTask task, TimeSpan deltaTime)
|
||||
{
|
||||
if (task.Value == 0) return new Text("-", MyStyle).RightAligned();
|
||||
if (task.Value == 0) return new Text("-", MyStyle).RightJustified();
|
||||
var now = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
var speedContainer = SpeedContainerDic[task.Id];
|
||||
|
@ -43,7 +43,7 @@ namespace N_m3u8DL_RE.Column
|
|||
|
||||
if (task.IsFinished) sizeStr = GlobalUtil.FormatFileSize(size);
|
||||
|
||||
return new Text(sizeStr ?? "-", MyStyle).RightAligned();
|
||||
return new Text(sizeStr ?? "-", MyStyle).RightJustified();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,11 +21,11 @@ namespace N_m3u8DL_RE.Column
|
|||
public Style CompletedStyle { get; set; } = new Style(foreground: Color.Green);
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override IRenderable Render(RenderContext context, ProgressTask task, TimeSpan deltaTime)
|
||||
public override IRenderable Render(RenderOptions options, ProgressTask task, TimeSpan deltaTime)
|
||||
{
|
||||
var percentage = task.Percentage;
|
||||
var style = percentage == 100 ? CompletedStyle : Style ?? Style.Plain;
|
||||
return new Text($"{task.Value}/{task.MaxValue} {percentage:F2}%", style).RightAligned();
|
||||
return new Text($"{task.Value}/{task.MaxValue} {percentage:F2}%", style).RightJustified();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,10 +26,10 @@ namespace N_m3u8DL_RE.Column
|
|||
_recodingDurDic = recodingDurDic;
|
||||
_refreshedDurDic = refreshedDurDic;
|
||||
}
|
||||
public override IRenderable Render(RenderContext context, ProgressTask task, TimeSpan deltaTime)
|
||||
public override IRenderable Render(RenderOptions options, ProgressTask task, TimeSpan deltaTime)
|
||||
{
|
||||
if (_refreshedDurDic == null)
|
||||
return new Text($"{GlobalUtil.FormatTime(_recodingDurDic[task.Id])}", MyStyle).LeftAligned();
|
||||
return new Text($"{GlobalUtil.FormatTime(_recodingDurDic[task.Id])}", MyStyle).LeftJustified();
|
||||
else
|
||||
{
|
||||
return new Text($"{GlobalUtil.FormatTime(_recodingDurDic[task.Id])}/{GlobalUtil.FormatTime(_refreshedDurDic[task.Id])}", GreyStyle);
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace N_m3u8DL_RE.Column
|
|||
{
|
||||
_recodingSizeDic = recodingSizeDic;
|
||||
}
|
||||
public override IRenderable Render(RenderContext context, ProgressTask task, TimeSpan deltaTime)
|
||||
public override IRenderable Render(RenderOptions options, ProgressTask task, TimeSpan deltaTime)
|
||||
{
|
||||
var now = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
var taskId = task.Id;
|
||||
|
@ -33,7 +33,7 @@ namespace N_m3u8DL_RE.Column
|
|||
}
|
||||
DateTimeStringDic[taskId] = now;
|
||||
var flag = RecodingSizeDic.TryGetValue(taskId, out var size);
|
||||
return new Text(GlobalUtil.FormatFileSize(flag ? size : 0), MyStyle).LeftAligned();
|
||||
return new Text(GlobalUtil.FormatFileSize(flag ? size : 0), MyStyle).LeftJustified();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,11 +13,11 @@ namespace N_m3u8DL_RE.Column
|
|||
protected override bool NoWrap => true;
|
||||
public Style MyStyle { get; set; } = new Style(foreground: Color.Default);
|
||||
public Style FinishedStyle { get; set; } = new Style(foreground: Color.Yellow);
|
||||
public override IRenderable Render(RenderContext context, ProgressTask task, TimeSpan deltaTime)
|
||||
public override IRenderable Render(RenderOptions options, ProgressTask task, TimeSpan deltaTime)
|
||||
{
|
||||
if (task.IsFinished)
|
||||
return new Text($"{task.Value}/{task.MaxValue} Waiting ", FinishedStyle).LeftAligned();
|
||||
return new Text($"{task.Value}/{task.MaxValue} Recording", MyStyle).LeftAligned();
|
||||
return new Text($"{task.Value}/{task.MaxValue} Waiting ", FinishedStyle).LeftJustified();
|
||||
return new Text($"{task.Value}/{task.MaxValue} Recording", MyStyle).LeftJustified();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ namespace N_m3u8DL_RE.Entity
|
|||
internal class SpeedContainer
|
||||
{
|
||||
public bool SingleSegment { get; set; } = false;
|
||||
public long NowSpeed { get; set; } = 0L; //当前每秒速度
|
||||
public long? ResponseLength { get; set; }
|
||||
public long RDownloaded { get => _Rdownloaded; }
|
||||
private int _zeroSpeedCount = 0;
|
||||
|
|
Loading…
Reference in New Issue