Preselect the correct tab according to the current CPU architecture

This commit is contained in:
Thorsten Sommer 2025-05-30 11:04:16 +02:00
parent c2c60d723d
commit b1eefcadb2
Signed by: tsommer
GPG Key ID: 371BBA77A02C0108
2 changed files with 41 additions and 5 deletions

View File

@ -54,7 +54,7 @@
<MudListItem T="string" Class="mb-2"> <MudListItem T="string" Class="mb-2">
Accept the terms of the GPL license and download the latest installer with the download button below. 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. Eventually you need to allow the download of the installer in the download window.
<CodeTabs> <CodeTabs SelectedIndex="this.SelectInstallerIndex()">
<CodeBlock Title="Windows">pandoc-@(PANDOC_VERSION)-windows-x86_64.msi</CodeBlock> <CodeBlock Title="Windows">pandoc-@(PANDOC_VERSION)-windows-x86_64.msi</CodeBlock>
<CodeBlock Title="macOS ARM">pandoc-@(PANDOC_VERSION)-arm64-macOS.pkg</CodeBlock> <CodeBlock Title="macOS ARM">pandoc-@(PANDOC_VERSION)-arm64-macOS.pkg</CodeBlock>
<CodeBlock Title="macOS x86">pandoc-@(PANDOC_VERSION)-x86_64-macOS.pkg</CodeBlock> <CodeBlock Title="macOS x86">pandoc-@(PANDOC_VERSION)-x86_64-macOS.pkg</CodeBlock>
@ -83,7 +83,7 @@
<MudListItem T="string" Class="mb-2"> <MudListItem T="string" Class="mb-2">
Extract the archive to a folder of your choice. Extract the archive to a folder of your choice.
<CodeTabs> <CodeTabs SelectedIndex="this.SelectArchiveIndex()">
<CodeBlock Title="Windows">C:\Users\%USERNAME%\pandoc</CodeBlock> <CodeBlock Title="Windows">C:\Users\%USERNAME%\pandoc</CodeBlock>
<CodeBlock Title="macOS">/usr/local/bin/pandoc</CodeBlock> <CodeBlock Title="macOS">/usr/local/bin/pandoc</CodeBlock>
<CodeBlock Title="Linux">/usr/local/bin/pandoc</CodeBlock> <CodeBlock Title="Linux">/usr/local/bin/pandoc</CodeBlock>
@ -93,7 +93,7 @@
<MudListItem T="string" Class="mb-2"> <MudListItem T="string" Class="mb-2">
Open the folder and copy the full path to the <CodeBlock IsInline="true">@PandocProcessBuilder.PandocExecutableName</CodeBlock> file into your Open the folder and copy the full path to the <CodeBlock IsInline="true">@PandocProcessBuilder.PandocExecutableName</CodeBlock> file into your
clipboard. clipboard.
<CodeTabs> <CodeTabs SelectedIndex="this.SelectArchiveIndex()">
<CodeBlock Title="Windows">C:\Users\%USERNAME%\pandoc\pandoc-@(PANDOC_VERSION)</CodeBlock> <CodeBlock Title="Windows">C:\Users\%USERNAME%\pandoc\pandoc-@(PANDOC_VERSION)</CodeBlock>
<CodeBlock Title="macOS">/usr/local/bin/pandoc/pandoc-@(PANDOC_VERSION)</CodeBlock> <CodeBlock Title="macOS">/usr/local/bin/pandoc/pandoc-@(PANDOC_VERSION)</CodeBlock>
<CodeBlock Title="Linux">/usr/local/bin/pandoc/pandoc-@(PANDOC_VERSION)</CodeBlock> <CodeBlock Title="Linux">/usr/local/bin/pandoc/pandoc-@(PANDOC_VERSION)</CodeBlock>
@ -104,7 +104,7 @@
Add the copied path to your systems environment variables and check the installation Add the copied path to your systems environment variables and check the installation
by typing <br/><CodeBlock IsInline="@true">pandoc --version</CodeBlock> by typing <br/><CodeBlock IsInline="@true">pandoc --version</CodeBlock>
into your command line interface. into your command line interface.
<CodeTabs> <CodeTabs SelectedIndex="this.SelectArchiveIndex()">
<CodeBlock Title="Windows">> pandoc.exe --version<br/>> pandoc @(PANDOC_VERSION)</CodeBlock> <CodeBlock Title="Windows">> pandoc.exe --version<br/>> pandoc @(PANDOC_VERSION)</CodeBlock>
<CodeBlock Title="macOS">> pandoc --version<br/>> pandoc @(PANDOC_VERSION)</CodeBlock> <CodeBlock Title="macOS">> pandoc --version<br/>> pandoc @(PANDOC_VERSION)</CodeBlock>
<CodeBlock Title="Linux">> pandoc --version<br/>> pandoc @(PANDOC_VERSION)</CodeBlock> <CodeBlock Title="Linux">> pandoc --version<br/>> pandoc @(PANDOC_VERSION)</CodeBlock>

View File

@ -1,10 +1,19 @@
using AIStudio.Tools.Services; using System.Reflection;
using AIStudio.Tools.Metadata;
using AIStudio.Tools.Services;
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
using SharedTools;
namespace AIStudio.Dialogs; namespace AIStudio.Dialogs;
public partial class PandocDialog : ComponentBase public partial class PandocDialog : ComponentBase
{ {
private static readonly Assembly ASSEMBLY = Assembly.GetExecutingAssembly();
private static readonly MetaDataArchitectureAttribute META_DATA_ARCH = ASSEMBLY.GetCustomAttribute<MetaDataArchitectureAttribute>()!;
private static readonly RID CPU_ARCHITECTURE = META_DATA_ARCH.Architecture.ToRID();
[Inject] [Inject]
private HttpClient HttpClient { get; set; } = null!; private HttpClient HttpClient { get; set; } = null!;
@ -136,4 +145,31 @@ public partial class PandocDialog : ComponentBase
return await response.Content.ReadAsStringAsync(); 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
} }