mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-15 17:30:27 +08:00
feat: 优化下载速度显示 (#11541)
* feat: 优化下载速度显示 下载速度超过1MiB/s时以MiB/s为单位显示下载速度 * feat: apply review * style: format --------- Co-authored-by: status102 <102887808+status102@users.noreply.github.com>
This commit is contained in:
@@ -882,8 +882,21 @@ public class VersionUpdateViewModel : Screen
|
||||
|
||||
public static void OutputDownloadProgress(long value = 0, long maximum = 1, int len = 0, double ts = 1)
|
||||
{
|
||||
OutputDownloadProgress(
|
||||
$"[{value / 1048576.0:F}MiB/{maximum / 1048576.0:F}MiB({100 * value / maximum}%) {len / ts / 1024.0:F} KiB/s]");
|
||||
string progress = $"[{value / 1048576.0:F}MiB/{maximum / 1048576.0:F}MiB ({value * 100.0 / maximum:F}%)";
|
||||
|
||||
double speedInKiBPerSecond = len / ts / 1024.0;
|
||||
string speedDisplay;
|
||||
|
||||
if (speedInKiBPerSecond >= 1024)
|
||||
{
|
||||
speedDisplay = $"{speedInKiBPerSecond / 1024.0:F} MiB/s";
|
||||
}
|
||||
else
|
||||
{
|
||||
speedDisplay = $"{speedInKiBPerSecond:F} KiB/s";
|
||||
}
|
||||
|
||||
OutputDownloadProgress(progress + $" {speedDisplay}");
|
||||
}
|
||||
|
||||
private static void OutputDownloadProgress(string output, bool downloading = true)
|
||||
|
||||
Reference in New Issue
Block a user