Files
FrontOffice/src/FrontOffice.Main/Shared/ReleaseNotesDialog.razor
T
2025-12-27 06:22:41 +03:30

173 lines
6.5 KiB
Plaintext

@using FrontOffice.Main.Utilities
@using MudBlazor
<MudDialog>
<TitleContent>
<MudStack Row="true" AlignItems="AlignItems.Center" Spacing="2">
@if (IsForceUpdate)
{
<MudIcon Icon="@Icons.Material.Filled.Warning" Color="Color.Warning" Size="Size.Large"/>
<MudText Typo="Typo.h6" Color="Color.Warning">بروزرسانی اجباری</MudText>
}
else
{
<MudIcon Icon="@Icons.Material.Filled.NewReleases" Color="Color.Success" Size="Size.Large"/>
<MudText Typo="Typo.h6">نسخه جدید موجود است 🎉</MudText>
}
</MudStack>
</TitleContent>
<DialogContent>
<MudStack Spacing="3">
@* اطلاعات نسخه با انیمیشن *@
<MudPaper Class="pa-4 rounded-lg" Elevation="0"
Style="">
<MudGrid Spacing="2">
<MudItem xs="6">
<MudStack AlignItems="AlignItems.Center" Spacing="1">
<MudIcon Icon="@Icons.Material.Outlined.History" Size="Size.Medium" Color="Color.Secondary"/>
<MudText Typo="Typo.caption" Color="Color.Secondary">نسخه فعلی</MudText>
<MudChip T="string" Size="Size.Small" Variant="Variant.Outlined" Color="Color.Secondary">
@(OldVersion ?? "---")
</MudChip>
</MudStack>
</MudItem>
<MudItem xs="6">
<MudStack AlignItems="AlignItems.Center" Spacing="1">
<MudIcon Icon="@Icons.Material.Filled.Verified" Size="Size.Medium" Color="Color.Success"/>
<MudText Typo="Typo.caption" Color="Color.Success">نسخه جدید</MudText>
<MudChip T="string" Size="Size.Small" Variant="Variant.Filled" Color="Color.Success">
@NewVersion
</MudChip>
</MudStack>
</MudItem>
</MudGrid>
</MudPaper>
@* پیام آپدیت *@
@if (!string.IsNullOrWhiteSpace(UpdateMessage))
{
<MudAlert Severity="@(IsForceUpdate ? Severity.Warning : Severity.Info)"
Variant="Variant.Text"
Dense="true"
Icon="@Icons.Material.Filled.Info"
Class="rounded-lg">
@UpdateMessage
</MudAlert>
}
@* یادداشت‌های انتشار *@
@if (!string.IsNullOrWhiteSpace(ReleaseNotes))
{
<MudStack Spacing="1">
<MudStack Row="true" AlignItems="AlignItems.Center" Spacing="1">
<MudIcon Icon="@Icons.Material.Filled.Article" Size="Size.Small" Color="Color.Primary"/>
<MudText Typo="Typo.subtitle2" Color="Color.Primary">تغییرات این نسخه:</MudText>
</MudStack>
<MudPaper Class="pa-3 rounded-lg release-notes-content" Elevation="0"
Style="max-height: 220px; overflow-y: auto; background-color: var(--mud-palette-background-grey); border: 1px solid var(--mud-palette-lines-default);">
@((MarkupString)ReleaseNotes)
</MudPaper>
</MudStack>
}
@if (IsForceUpdate)
{
<MudAlert Severity="Severity.Error" Variant="Variant.Filled" Dense="true" Class="rounded-lg">
<MudStack Row="true" AlignItems="AlignItems.Center" Spacing="1">
<MudIcon Icon="@Icons.Material.Filled.Error" Size="Size.Small"/>
<MudText Typo="Typo.body2">
این بروزرسانی اجباری است و باید انجام شود.
</MudText>
</MudStack>
</MudAlert>
}
</MudStack>
</DialogContent>
<DialogActions>
@if (!IsForceUpdate)
{
<MudButton OnClick="OnSkipClicked"
Color="Color.Default"
Variant="Variant.Text"
Size="Size.Medium">
بعداً یادآوری کن
</MudButton>
}
<MudButton OnClick="OnUpdateClicked"
Color="@(IsForceUpdate ? Color.Warning : Color.Success)"
Variant="Variant.Filled"
Size="Size.Medium"
StartIcon="@(_isUpdating ? null : Icons.Material.Filled.SystemUpdateAlt)"
Class="px-6">
@if (_isUpdating)
{
<MudProgressCircular Size="Size.Small" Indeterminate="true" Color="Color.Surface"/>
<span class="ms-2">در حال بروزرسانی...</span>
}
else
{
<span>بروزرسانی کن!</span>
}
</MudButton>
</DialogActions>
</MudDialog>
<style>
.release-notes-content {
font-size: 0.9rem;
line-height: 1.8;
}
.release-notes-content ul, .release-notes-content ol {
padding-right: 1.5rem;
margin: 0.5rem 0;
}
.release-notes-content li {
margin-bottom: 0.3rem;
}
.release-notes-content p {
margin: 0.5rem 0;
}
</style>
@code {
[CascadingParameter]
private IMudDialogInstance MudDialog { get; set; } = default!;
[Parameter]
public string? OldVersion { get; set; }
[Parameter]
public string NewVersion { get; set; } = string.Empty;
[Parameter]
public string? ReleaseNotes { get; set; }
[Parameter]
public string? UpdateMessage { get; set; }
[Parameter]
public bool IsForceUpdate { get; set; }
private bool _isUpdating;
private async Task OnUpdateClicked()
{
_isUpdating = true;
StateHasChanged();
// کمی صبر کنیم برای UI
await Task.Delay(500);
// برگردوندن نتیجه "آپدیت"
MudDialog.Close(DialogResult.Ok(true));
}
private void OnSkipClicked()
{
// برگردوندن نتیجه "بعداً"
MudDialog.Close(DialogResult.Ok(false));
}
}