feat: implement version check and update dialog; add browser cache clearing functionality
Build and Deploy / build (push) Successful in 1m40s

This commit is contained in:
masoodafar-web
2025-12-27 04:47:27 +03:30
parent 51129704a0
commit 9cd275a777
6 changed files with 510 additions and 46 deletions
@@ -0,0 +1,130 @@
@using FrontOffice.Main.Utilities
@using MudBlazor
<MudDialog>
<TitleContent>
<MudStack Row="true" AlignItems="AlignItems.Center" Spacing="2">
<MudIcon Icon="@Icons.Material.Filled.SystemUpdateAlt" Color="Color.Primary" Size="Size.Large"/>
<MudText Typo="Typo.h6">
@if (IsForceUpdate)
{
<span>بروزرسانی اجباری</span>
}
else
{
<span>نسخه جدید موجود است</span>
}
</MudText>
</MudStack>
</TitleContent>
<DialogContent>
<MudStack Spacing="3">
@* اطلاعات نسخه *@
<MudPaper Class="pa-3" Elevation="0" Style="background-color: var(--mud-palette-background-grey);">
<MudStack Row="true" Justify="Justify.SpaceBetween">
<MudText>نسخه فعلی:</MudText>
<MudText Color="Color.Secondary">@(OldVersion ?? "---")</MudText>
</MudStack>
<MudDivider Class="my-2"/>
<MudStack Row="true" Justify="Justify.SpaceBetween">
<MudText>نسخه جدید:</MudText>
<MudText Color="Color.Primary"><b>@NewVersion</b></MudText>
</MudStack>
</MudPaper>
@* پیام آپدیت *@
@if (!string.IsNullOrWhiteSpace(UpdateMessage))
{
<MudAlert Severity="@(IsForceUpdate ? Severity.Warning : Severity.Info)"
Variant="Variant.Outlined"
Dense="true">
@UpdateMessage
</MudAlert>
}
@* یادداشت‌های انتشار *@
@if (!string.IsNullOrWhiteSpace(ReleaseNotes))
{
<MudText Typo="Typo.subtitle2" Color="Color.Primary">تغییرات این نسخه:</MudText>
<MudPaper Class="pa-3" Elevation="1" Style="max-height: 250px; overflow-y: auto;">
@((MarkupString)ReleaseNotes)
</MudPaper>
}
@if (IsForceUpdate)
{
<MudAlert Severity="Severity.Error" Variant="Variant.Filled" Dense="true">
<MudText Typo="Typo.body2">
این بروزرسانی اجباری است و باید انجام شود.
</MudText>
</MudAlert>
}
</MudStack>
</DialogContent>
<DialogActions>
@if (!IsForceUpdate)
{
<MudButton OnClick="OnSkipClicked"
Color="Color.Default"
Variant="Variant.Text">
بعداً
</MudButton>
}
<MudButton OnClick="OnUpdateClicked"
Color="Color.Primary"
Variant="Variant.Filled"
StartIcon="@Icons.Material.Filled.Update">
@if (_isUpdating)
{
<MudProgressCircular Size="Size.Small" Indeterminate="true" Color="Color.Surface"/>
<span class="ms-2">در حال بروزرسانی...</span>
}
else
{
<span>بروزرسانی</span>
}
</MudButton>
</DialogActions>
</MudDialog>
@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));
}
}