mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-10-17 09:37:59 +00:00
Finished the Pandoc integration (#487)
This commit is contained in:
1 parent
5b685193ef
commit
437da0fd9b
30 files changed
+1600
-349
No files matched your search
@@ -19,13 +19,19 @@
|
||||
<MudListItem T="string" Icon="@Icons.Material.Outlined.Memory" Text="@VersionDotnetRuntime"/>
|
||||
<MudListItem T="string" Icon="@Icons.Material.Outlined.Build" Text="@VersionRust"/>
|
||||
<MudListItem T="string" Icon="@Icons.Material.Outlined.DocumentScanner" Text="@VersionPdfium"/>
|
||||
<MudListItem T="string" Icon="@Icons.Material.Outlined.Article" Text="@this.versionPandoc"/>
|
||||
<MudListItem T="string" Icon="@Icons.Material.Outlined.Widgets" Text="@MudBlazorVersion"/>
|
||||
<MudListItem T="string" Icon="@Icons.Material.Outlined.Memory" Text="@TauriVersion"/>
|
||||
<MudListItem T="string" Icon="@Icons.Material.Outlined.Translate" Text="@this.OSLanguage"/>
|
||||
</MudList>
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Info" StartIcon="@Icons.Material.Filled.Update" OnClick="() => this.CheckForUpdate()">
|
||||
@T("Check for updates")
|
||||
</MudButton>
|
||||
<MudStack Row="true">
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Info" StartIcon="@Icons.Material.Filled.Update" OnClick="() => this.CheckForUpdate()">
|
||||
@T("Check for updates")
|
||||
</MudButton>
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Default" StartIcon="@Icons.Material.Filled.Download" OnClick="async () => await this.ShowPandocDialog()">
|
||||
@this.PandocButtonText
|
||||
</MudButton>
|
||||
</MudStack>
|
||||
</ExpansionPanel>
|
||||
|
||||
<ExpansionPanel HeaderIcon="@Icons.Custom.Brands.GitHub" HeaderText="@T("Community & Code")">
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Reflection;
|
||||
|
||||
using AIStudio.Components;
|
||||
using AIStudio.Dialogs;
|
||||
using AIStudio.Tools.Metadata;
|
||||
using AIStudio.Tools.Rust;
|
||||
using AIStudio.Tools.Services;
|
||||
@@ -9,6 +10,8 @@ using Microsoft.AspNetCore.Components;
|
||||
|
||||
using SharedTools;
|
||||
|
||||
using DialogOptions = AIStudio.Dialogs.DialogOptions;
|
||||
|
||||
namespace AIStudio.Pages;
|
||||
|
||||
public partial class About : MSGComponentBase
|
||||
@@ -16,6 +19,9 @@ public partial class About : MSGComponentBase
|
||||
[Inject]
|
||||
private RustService RustService { get; init; } = null!;
|
||||
|
||||
[Inject]
|
||||
private IDialogService DialogService { get; init; } = null!;
|
||||
|
||||
[Inject]
|
||||
private ISnackbar Snackbar { get; init; } = null!;
|
||||
|
||||
@@ -23,6 +29,8 @@ public partial class About : MSGComponentBase
|
||||
private static readonly MetaDataAttribute META_DATA = ASSEMBLY.GetCustomAttribute<MetaDataAttribute>()!;
|
||||
private static readonly MetaDataArchitectureAttribute META_DATA_ARCH = ASSEMBLY.GetCustomAttribute<MetaDataArchitectureAttribute>()!;
|
||||
private static readonly MetaDataLibrariesAttribute META_DATA_LIBRARIES = ASSEMBLY.GetCustomAttribute<MetaDataLibrariesAttribute>()!;
|
||||
|
||||
private static string TB(string fallbackEN) => Tools.PluginSystem.I18N.I.T(fallbackEN, typeof(About).Namespace, nameof(About));
|
||||
|
||||
private string osLanguage = string.Empty;
|
||||
|
||||
@@ -43,6 +51,9 @@ public partial class About : MSGComponentBase
|
||||
private string BuildTime => $"{T("Build time")}: {META_DATA.BuildTime}";
|
||||
|
||||
private string VersionPdfium => $"{T("Used PDFium version")}: v{META_DATA_LIBRARIES.PdfiumVersion}";
|
||||
|
||||
private string versionPandoc = TB("Determine Pandoc version, please wait...");
|
||||
private PandocInstallation pandocInstallation;
|
||||
|
||||
private GetLogPathsResponse logPaths;
|
||||
|
||||
@@ -52,11 +63,59 @@ public partial class About : MSGComponentBase
|
||||
{
|
||||
this.osLanguage = await this.RustService.ReadUserLanguage();
|
||||
this.logPaths = await this.RustService.GetLogPaths();
|
||||
|
||||
await base.OnInitializedAsync();
|
||||
await this.DeterminePandocVersion();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private async Task DeterminePandocVersion()
|
||||
{
|
||||
this.pandocInstallation = await Pandoc.CheckAvailabilityAsync(this.RustService, false);
|
||||
var pandocInstallationType = this.pandocInstallation.IsLocalInstallation
|
||||
? T("installed by AI Studio")
|
||||
: T("installation provided by the system");
|
||||
|
||||
switch (this.pandocInstallation)
|
||||
{
|
||||
case { CheckWasSuccessful: true, IsAvailable: true }:
|
||||
this.versionPandoc = $"{this.T("Installed Pandoc version")}: v{this.pandocInstallation.Version} ({pandocInstallationType}) - {T("OK")}";
|
||||
break;
|
||||
|
||||
case { CheckWasSuccessful: true, IsAvailable: false }:
|
||||
this.versionPandoc = $"{this.T("Installed Pandoc version")}: v{this.pandocInstallation.Version} ({pandocInstallationType}) - {T("this version does not met the requirements")}";
|
||||
break;
|
||||
|
||||
default:
|
||||
this.versionPandoc = TB("Installed Pandoc version: Pandoc is not installed or not available.");
|
||||
break;
|
||||
}
|
||||
|
||||
await this.InvokeAsync(this.StateHasChanged);
|
||||
}
|
||||
|
||||
private string PandocButtonText
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.pandocInstallation switch
|
||||
{
|
||||
{ IsAvailable: true, CheckWasSuccessful: true } => this.T("Check Pandoc Installation"),
|
||||
{ IsAvailable: false, CheckWasSuccessful: true } => this.T("Update Pandoc"),
|
||||
|
||||
_ => this.T("Install Pandoc")
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private async Task ShowPandocDialog()
|
||||
{
|
||||
var dialogReference = await this.DialogService.ShowAsync<PandocDialog>(T("Pandoc Installation"), DialogOptions.FULLSCREEN);
|
||||
await dialogReference.Result;
|
||||
await this.DeterminePandocVersion();
|
||||
}
|
||||
|
||||
private async Task CopyStartupLogPath()
|
||||
{
|
||||
await this.RustService.CopyText2Clipboard(this.Snackbar, this.logPaths.LogStartupPath);
|
||||
|
||||
Reference in new issue
Block a user