mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2025-08-21 04:12:56 +00:00
Refactored download code
Unfortunately, we had to change the download code. The initial solution worked on Windows 11, but not on macOS. We are now using the user's browser for the download.
This commit is contained in:
parent
564ec1db98
commit
3f07436e8f
@ -18,7 +18,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<MudExpansionPanels Class="mb-3" MultiExpansion="@false" Outlined="false" Elevation="0">
|
<MudExpansionPanels Class="mb-3" MultiExpansion="@false" Outlined="false" Elevation="0">
|
||||||
<ExpansionPanel HeaderIcon="@Icons.Material.Filled.Verified" HeaderText="View GNU General Public License v2 (GPL)" MaxHeight="300" ExpandedChanged="this.OnExpandedChanged">
|
<ExpansionPanel HeaderIcon="@Icons.Material.Filled.Verified" HeaderText="View GNU General Public License v2 (GPL)" MaxHeight="300" ExpandedChanged="this.WhenExpandingLicence">
|
||||||
@if (this.isLoading)
|
@if (this.isLoading)
|
||||||
{
|
{
|
||||||
<MudSkeleton />
|
<MudSkeleton />
|
||||||
@ -43,7 +43,7 @@
|
|||||||
</MudButton>
|
</MudButton>
|
||||||
</ExpansionPanel>
|
</ExpansionPanel>
|
||||||
|
|
||||||
<ExpansionPanel HeaderIcon="@Icons.Material.Filled.Build" HeaderText="Manual installation">
|
<ExpansionPanel HeaderIcon="@Icons.Material.Filled.Build" HeaderText="Manual installation" ExpandedChanged="this.WhenExpandingManualInstallation">
|
||||||
<MudText Class="mb-2">
|
<MudText Class="mb-2">
|
||||||
If you prefer to install Pandoc yourself, please follow one of these two guides. Installers are only available for Windows and macOS.
|
If you prefer to install Pandoc yourself, please follow one of these two guides. Installers are only available for Windows and macOS.
|
||||||
</MudText>
|
</MudText>
|
||||||
@ -70,7 +70,7 @@
|
|||||||
By clicking "Accept GPL and download installer", you agree to the terms of the GPL license. Software under GPL is <strong>free of charge</strong> and free to use.<br/>
|
By clicking "Accept GPL and download installer", you agree to the terms of the GPL license. Software under GPL is <strong>free of charge</strong> and free to use.<br/>
|
||||||
</MudText>
|
</MudText>
|
||||||
|
|
||||||
<MudButton OnClick="@this.GetInstaller" Color="Color.Primary" Class="mt-4" Variant="Variant.Filled" Size="Size.Small" StartIcon="@Icons.Material.Filled.Downloading">
|
<MudButton Href="@this.downloadUrlInstaller" Target="_blank" Color="Color.Primary" Class="mt-4" Variant="Variant.Filled" Size="Size.Small" StartIcon="@Icons.Material.Filled.Downloading">
|
||||||
Accept GPL and download installer
|
Accept GPL and download installer
|
||||||
</MudButton>
|
</MudButton>
|
||||||
</ExpansionPanel>
|
</ExpansionPanel>
|
||||||
@ -116,7 +116,7 @@
|
|||||||
By clicking "Accept GPL and archive", you agree to the terms of the GPL license. Software under GPL is <strong>free of charge</strong> and free to use.<br/>
|
By clicking "Accept GPL and archive", you agree to the terms of the GPL license. Software under GPL is <strong>free of charge</strong> and free to use.<br/>
|
||||||
</MudText>
|
</MudText>
|
||||||
|
|
||||||
<MudButton OnClick="@this.GetArchive" Color="Color.Primary" Class="mt-4" Variant="Variant.Filled" Size="Size.Small" StartIcon="@Icons.Material.Filled.Downloading">
|
<MudButton Href="@this.downloadUrlArchive" Target="_blank" Color="Color.Primary" Class="mt-4" Variant="Variant.Filled" Size="Size.Small" StartIcon="@Icons.Material.Filled.Downloading">
|
||||||
Accept GPL and download archive
|
Accept GPL and download archive
|
||||||
</MudButton>
|
</MudButton>
|
||||||
</ExpansionPanel>
|
</ExpansionPanel>
|
||||||
|
@ -39,6 +39,8 @@ public partial class PandocDialog : ComponentBase
|
|||||||
private string? licenseText;
|
private string? licenseText;
|
||||||
private bool isLoading;
|
private bool isLoading;
|
||||||
private int selectedArchiveIndex = SelectArchiveIndex();
|
private int selectedArchiveIndex = SelectArchiveIndex();
|
||||||
|
private string downloadUrlArchive = string.Empty;
|
||||||
|
private string downloadUrlInstaller = string.Empty;
|
||||||
|
|
||||||
#region Overrides of ComponentBase
|
#region Overrides of ComponentBase
|
||||||
|
|
||||||
@ -74,22 +76,6 @@ public partial class PandocDialog : ComponentBase
|
|||||||
|
|
||||||
private void ProceedToInstallation() => this.showInstallPage = true;
|
private void ProceedToInstallation() => this.showInstallPage = true;
|
||||||
|
|
||||||
private async Task GetInstaller()
|
|
||||||
{
|
|
||||||
var uri = await Pandoc.GenerateInstallerUriAsync();
|
|
||||||
var filename = this.FilenameFromUri(uri);
|
|
||||||
|
|
||||||
await this.JsRuntime.InvokeVoidAsync("triggerDownload", uri, filename);
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task GetArchive()
|
|
||||||
{
|
|
||||||
var uri = await Pandoc.GenerateArchiveUriAsync();
|
|
||||||
var filename = this.FilenameFromUri(uri);
|
|
||||||
|
|
||||||
await this.JsRuntime.InvokeVoidAsync("triggerDownload", uri, filename);
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task RejectLicense()
|
private async Task RejectLicense()
|
||||||
{
|
{
|
||||||
var message = "Pandoc is open-source and free of charge, but if you reject Pandoc's license, it can not be installed and some of AIStudios data retrieval features will be disabled (e.g. using Office files like Word)." +
|
var message = "Pandoc is open-source and free of charge, but if you reject Pandoc's license, it can not be installed and some of AIStudios data retrieval features will be disabled (e.g. using Office files like Word)." +
|
||||||
@ -108,13 +94,16 @@ public partial class PandocDialog : ComponentBase
|
|||||||
this.Cancel();
|
this.Cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
private string FilenameFromUri(string uri)
|
private async Task WhenExpandingManualInstallation(bool isExpanded)
|
||||||
{
|
{
|
||||||
var index = uri.LastIndexOf('/');
|
if(string.IsNullOrWhiteSpace(this.downloadUrlArchive))
|
||||||
return uri[(index + 1)..];
|
this.downloadUrlArchive = await Pandoc.GenerateArchiveUriAsync();
|
||||||
|
|
||||||
|
if(string.IsNullOrWhiteSpace(this.downloadUrlInstaller))
|
||||||
|
this.downloadUrlInstaller = await Pandoc.GenerateInstallerUriAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task OnExpandedChanged(bool isExpanded)
|
private async Task WhenExpandingLicence(bool isExpanded)
|
||||||
{
|
{
|
||||||
if (isExpanded)
|
if (isExpanded)
|
||||||
{
|
{
|
||||||
|
@ -26,13 +26,3 @@ window.clearDiv = function (divName) {
|
|||||||
window.scrollToBottom = function(element) {
|
window.scrollToBottom = function(element) {
|
||||||
element.scrollIntoView({ behavior: 'smooth', block: 'end', inline: 'nearest' });
|
element.scrollIntoView({ behavior: 'smooth', block: 'end', inline: 'nearest' });
|
||||||
}
|
}
|
||||||
|
|
||||||
window.triggerDownload = function(url, filename) {
|
|
||||||
const a = document.createElement('a');
|
|
||||||
a.href = url;
|
|
||||||
a.setAttribute('download', filename);
|
|
||||||
a.style.display = 'none';
|
|
||||||
document.body.appendChild(a);
|
|
||||||
a.click();
|
|
||||||
document.body.removeChild(a);
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user