Applied optimizations

This commit is contained in:
Thorsten Sommer 2025-05-29 12:17:19 +02:00
parent 175a3e0402
commit 314a7876d3
Signed by: tsommer
GPG Key ID: 371BBA77A02C0108
3 changed files with 14 additions and 10 deletions

View File

@ -12,7 +12,7 @@ public partial class CodeBlock : ComponentBase
public string? Title { get; set; } = string.Empty;
[Parameter]
public bool IsInline { get; set; } = false;
public bool IsInline { get; set; }
[CascadingParameter]
public CodeTabs? ParentTabs { get; set; }
@ -21,14 +21,15 @@ public partial class CodeBlock : ComponentBase
{
if (this.ParentTabs is not null && this.Title is not null)
{
RenderFragment blockSelf = builder =>
void BlockSelf(RenderTreeBuilder builder)
{
builder.OpenComponent<CodeBlock>(0);
builder.AddAttribute(1, "Title", this.Title);
builder.AddAttribute(2, "ChildContent", this.ChildContent);
builder.CloseComponent();
};
this.ParentTabs.RegisterBlock(this.Title, blockSelf);
}
this.ParentTabs.RegisterBlock(this.Title, BlockSelf);
}
}

View File

@ -7,8 +7,8 @@ public partial class CodeTabs : ComponentBase
[Parameter]
public RenderFragment? ChildContent { get; set; }
private List<CodeTabItem> blocks = new();
private int selectedIndex = 0;
private readonly List<CodeTabItem> blocks = new();
private int selectedIndex;
internal void RegisterBlock(string title, RenderFragment fragment)
{
@ -17,12 +17,14 @@ public partial class CodeTabs : ComponentBase
Title = title,
Fragment = fragment,
});
this.StateHasChanged();
}
private class CodeTabItem
{
public string Title { get; init; } = string.Empty;
public RenderFragment Fragment { get; init; } = null!;
}
}

View File

@ -9,12 +9,13 @@ namespace AIStudio.Tools;
public static partial class Pandoc
{
private const string CPU_ARCHITECTURE = "win-x64";
private const string DOWNLOAD_URL = "https://github.com/jgm/pandoc/releases/download";
private const string LATEST_URL = "https://github.com/jgm/pandoc/releases/latest";
private static readonly ILogger LOG = Program.LOGGER_FACTORY.CreateLogger("PandocService");
private static readonly string DOWNLOAD_URL = "https://github.com/jgm/pandoc/releases/download";
private static readonly string LATEST_URL = "https://github.com/jgm/pandoc/releases/latest";
private static readonly Version MINIMUM_REQUIRED_VERSION = new (3, 6);
private static readonly Version FALLBACK_VERSION = new (3, 7, 0, 1);
private static readonly string CPU_ARCHITECTURE = "win-x64";
/// <summary>
/// Checks if pandoc is available on the system and can be started as a process or present in AiStudio's data dir