From b1eefcadb22344ccb63a64658e0983655f2fc749 Mon Sep 17 00:00:00 2001 From: Thorsten Sommer Date: Fri, 30 May 2025 11:04:16 +0200 Subject: [PATCH] Preselect the correct tab according to the current CPU architecture --- .../Dialogs/PandocDialog.razor | 8 ++-- .../Dialogs/PandocDialog.razor.cs | 38 ++++++++++++++++++- 2 files changed, 41 insertions(+), 5 deletions(-) diff --git a/app/MindWork AI Studio/Dialogs/PandocDialog.razor b/app/MindWork AI Studio/Dialogs/PandocDialog.razor index 3e5472c8..e228acda 100644 --- a/app/MindWork AI Studio/Dialogs/PandocDialog.razor +++ b/app/MindWork AI Studio/Dialogs/PandocDialog.razor @@ -54,7 +54,7 @@ Accept the terms of the GPL license and download the latest installer with the download button below. Eventually you need to allow the download of the installer in the download window. - + pandoc-@(PANDOC_VERSION)-windows-x86_64.msi pandoc-@(PANDOC_VERSION)-arm64-macOS.pkg pandoc-@(PANDOC_VERSION)-x86_64-macOS.pkg @@ -83,7 +83,7 @@ Extract the archive to a folder of your choice. - + C:\Users\%USERNAME%\pandoc /usr/local/bin/pandoc /usr/local/bin/pandoc @@ -93,7 +93,7 @@ Open the folder and copy the full path to the @PandocProcessBuilder.PandocExecutableName file into your clipboard. - + C:\Users\%USERNAME%\pandoc\pandoc-@(PANDOC_VERSION) /usr/local/bin/pandoc/pandoc-@(PANDOC_VERSION) /usr/local/bin/pandoc/pandoc-@(PANDOC_VERSION) @@ -104,7 +104,7 @@ Add the copied path to your systems environment variables and check the installation by typing
pandoc --version into your command line interface. - + > pandoc.exe --version
> pandoc @(PANDOC_VERSION)
> pandoc --version
> pandoc @(PANDOC_VERSION)
> pandoc --version
> pandoc @(PANDOC_VERSION)
diff --git a/app/MindWork AI Studio/Dialogs/PandocDialog.razor.cs b/app/MindWork AI Studio/Dialogs/PandocDialog.razor.cs index 1408f656..4d63ebb0 100644 --- a/app/MindWork AI Studio/Dialogs/PandocDialog.razor.cs +++ b/app/MindWork AI Studio/Dialogs/PandocDialog.razor.cs @@ -1,10 +1,19 @@ -using AIStudio.Tools.Services; +using System.Reflection; + +using AIStudio.Tools.Metadata; +using AIStudio.Tools.Services; using Microsoft.AspNetCore.Components; +using SharedTools; + namespace AIStudio.Dialogs; public partial class PandocDialog : ComponentBase { + private static readonly Assembly ASSEMBLY = Assembly.GetExecutingAssembly(); + private static readonly MetaDataArchitectureAttribute META_DATA_ARCH = ASSEMBLY.GetCustomAttribute()!; + private static readonly RID CPU_ARCHITECTURE = META_DATA_ARCH.Architecture.ToRID(); + [Inject] private HttpClient HttpClient { get; set; } = null!; @@ -136,4 +145,31 @@ public partial class PandocDialog : ComponentBase return await response.Content.ReadAsStringAsync(); } + + // ReSharper disable RedundantSwitchExpressionArms + private int SelectInstallerIndex() => CPU_ARCHITECTURE switch + { + RID.OSX_ARM64 => 1, + RID.OSX_X64 => 2, + + RID.WIN_ARM64 => 0, + RID.WIN_X64 => 0, + + _ => 0, + }; + + private int SelectArchiveIndex() => CPU_ARCHITECTURE switch + { + RID.OSX_ARM64 => 1, + RID.OSX_X64 => 1, + + RID.WIN_ARM64 => 0, + RID.WIN_X64 => 0, + + RID.LINUX_ARM64 => 2, + RID.LINUX_X64 => 2, + + _ => 0, + }; + // ReSharper restore RedundantSwitchExpressionArms } \ No newline at end of file