diff --git a/Localizer/TranslateText.cs b/Localizer/TranslateText.cs index a82667c..84015d1 100644 --- a/Localizer/TranslateText.cs +++ b/Localizer/TranslateText.cs @@ -22,7 +22,7 @@ public class TranslateText private static Dictionary _displayText = new(); private static Dictionary _fallbackDisplayText = new(); - private string _currentLanguage = FallbackLanguage; + private static string _currentLanguage = FallbackLanguage; public static event Action OnLanguageChange; @@ -56,6 +56,11 @@ public async Task LoadLanguageAsync(string language) OnLanguageChange?.Invoke(); } + public static string GetCurrentLanguage() + { + return _currentLanguage; + } + public static string GetTranslateText(string key) { return _displayText.TryGetValue(key, out var translateText) diff --git a/Shared/SharedHeader.razor b/Shared/SharedHeader.razor index 4b80fab..267907b 100644 --- a/Shared/SharedHeader.razor +++ b/Shared/SharedHeader.razor @@ -86,5 +86,13 @@ OnOk="@HandleOk" OnCancel="@HandleCancel" Footer="@ModelFooterTemplate"> -

@_modalContent

+ @_modalContent + +
    + @foreach (var item in _updateNotes) + { +
  • @item
  • + } +
+
\ No newline at end of file diff --git a/Shared/SharedHeader.razor.cs b/Shared/SharedHeader.razor.cs index 437c63f..6775ff2 100644 --- a/Shared/SharedHeader.razor.cs +++ b/Shared/SharedHeader.razor.cs @@ -1,4 +1,7 @@ -using System.Threading.Tasks; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; using AntDesign; using Microsoft.AspNetCore.Components; using Microsoft.JSInterop; @@ -18,6 +21,7 @@ public partial class SharedHeader private string _currentVersion = "Loading..."; private string _latestVersion; private string _modalContent = ""; + private string[] _updateNotes = Array.Empty(); private bool _visible = false; [Inject] private IJSRuntime JsRuntime { get; set; } @@ -88,9 +92,12 @@ protected Theme CurrentTheme } } - private void ShowVersionModal() + private void ShowVersionModal(string[] updateNotes) { - _modalContent = TranslateText.GetTranslateText("NewVersionFound").Replace("{_latestVersion}", _latestVersion); + _modalContent = TranslateText.GetTranslateText("NewVersionFound") + .Replace("{_latestVersion}", _latestVersion); + _updateNotes = updateNotes; + _visible = true; StateHasChanged(); } @@ -147,7 +154,11 @@ private async void OnClickChangeLanguage(string language) private async void CheckForUpdate() { _currentVersion = "Loading..."; - _latestVersion = await JsRuntime.InvokeAsync("FetchVersionFromServer"); + + // Fetch version and update notes + var versionData = await JsRuntime.InvokeAsync("FetchVersionFromServer"); + _latestVersion = versionData?.Version; + var updateNotes = versionData?.UpdateNotes; _currentVersion = await JsRuntime.InvokeAsync("localStorage.getItem", "PearlCalculatorBlazor_version"); await Task.Delay(1000); @@ -158,7 +169,12 @@ private async void CheckForUpdate() return; } - ShowVersionModal(); + // Fetch and display the update notes based on the current language + var currentLanguage = TranslateText.GetCurrentLanguage(); + if (updateNotes != null && updateNotes.TryGetValue(currentLanguage, out var note)) + ShowVersionModal(note); + else + ShowVersionModal(new[] { "No update notes found" }); } protected override async void OnInitialized() @@ -183,4 +199,10 @@ private void RefreshPage() { StateHasChanged(); } +} + +public class VersionData +{ + public string Version { get; init; } + public Dictionary UpdateNotes { get; init; } } \ No newline at end of file diff --git a/wwwroot/assets/i18n/en.json b/wwwroot/assets/i18n/en.json index 36c5610..44a465b 100644 --- a/wwwroot/assets/i18n/en.json +++ b/wwwroot/assets/i18n/en.json @@ -7,6 +7,7 @@ "CalculateTNTAmount": "Calculate TNT Amount", "CheckForUpdate": "Check for Update", "Coordinate": "Coordinate", + "CopyGeneralDataToManuallyData": "Copy General Data", "DefaultBlueTNTPos": "Default Blue TNT Position", "DefaultBlueTNTPosDesc": "Preset the position of the TNT duped from the blue array relative to the pearl without being changed by the slime block", "DefaultRedTNTPos": "Default Red TNT Position", diff --git a/wwwroot/assets/i18n/es_ES.json b/wwwroot/assets/i18n/es_ES.json index 2f973ef..9b26717 100644 --- a/wwwroot/assets/i18n/es_ES.json +++ b/wwwroot/assets/i18n/es_ES.json @@ -7,6 +7,7 @@ "CalculateTNTAmount": "Calcular Cantidades de TNT", "CheckForUpdate": "Buscar Actualizaciones", "Coordinate": "Coordenada", + "CopyGeneralDataToManuallyData": "Copiar Datos Generales", "DefaultBlueTNTPos": "Posición Predet. TNT Azul", "DefaultBlueTNTPosDesc": "La Posición de la TNT Azul (Respecto a la perla) si el Slime Block no la mueve", "DefaultRedTNTPos": "Posición Predet. TNT Roja", diff --git a/wwwroot/assets/i18n/zh_cn.json b/wwwroot/assets/i18n/zh_cn.json index 231ead2..42efe2e 100644 --- a/wwwroot/assets/i18n/zh_cn.json +++ b/wwwroot/assets/i18n/zh_cn.json @@ -8,6 +8,7 @@ "CheckForUpdate": "检查更新", "ConsoleHeader": "控制台", "Coordinate": "坐标", + "CopyGeneralDataToManuallyData": "复制一般数据", "DefaultBlueTNTPos": "预设蓝色TNT方位", "DefaultBlueTNTPosDesc": "预设从蓝色阵列复制的TNT\n在不被粘液块改位置下相对于珍珠的方位", "DefaultRedTNTPos": "预设红色TNT方位", diff --git a/wwwroot/assets/i18n/zh_tw.json b/wwwroot/assets/i18n/zh_tw.json index 0f1305c..8b5b5f5 100644 --- a/wwwroot/assets/i18n/zh_tw.json +++ b/wwwroot/assets/i18n/zh_tw.json @@ -8,6 +8,7 @@ "CheckForUpdate": "檢查更新", "ConsoleHeader": "控制台", "Coordinate": "座標", + "CopyGeneralDataToManuallyData": "複製一般設定", "DefaultBlueTNTPos": "預設藍色TNT方位", "DefaultBlueTNTPosDesc": "預設從藍色陣列複製的TNT\n在不被史萊姆方塊改位置下相對於珍珠的方位", "DefaultRedTNTPos": "預設紅色TNT方位", diff --git a/wwwroot/index.html b/wwwroot/index.html index e86d69d..75ccb4d 100644 --- a/wwwroot/index.html +++ b/wwwroot/index.html @@ -58,7 +58,7 @@ - + diff --git a/wwwroot/manifest.json b/wwwroot/manifest.json index 65aec6d..67632b5 100644 --- a/wwwroot/manifest.json +++ b/wwwroot/manifest.json @@ -7,9 +7,9 @@ "theme_color": "#03173d", "icons": [ { - "src": "icon-512.png", + "src": "Logo.png", "type": "image/png", - "sizes": "512x512" + "sizes": "308x308" } ] } diff --git a/wwwroot/scripts/version.js b/wwwroot/scripts/version.js index a57646c..1dd0942 100644 --- a/wwwroot/scripts/version.js +++ b/wwwroot/scripts/version.js @@ -4,7 +4,10 @@ const timestamp = new Date().getTime(); const response = await fetch(`${basePath}/version.json?t=${timestamp}`); const data = await response.json(); - return data.version; + return { + version: data.version, + updateNotes: data.updateNotes + }; } catch (error) { console.error('Error fetching version:', error); return null; diff --git a/wwwroot/version.json b/wwwroot/version.json index a916c53..5eb08ed 100644 --- a/wwwroot/version.json +++ b/wwwroot/version.json @@ -1,3 +1,25 @@ { - "version": "2.71.2" + "version": "2.71.3", + "updateNotes": { + "en": [ + "Added manual mode to copy data from general mode.", + "Fixed issue where previous calculation results were displayed if no direction angle was found in the updated calculation.", + "Added update log feature." + ], + "es_ES": [ + "Se añadió el modo manual para copiar datos del modo general.", + "Se corrigió un problema donde se mostraban los resultados de cálculos anteriores si no se encontraba un ángulo de dirección en el cálculo actualizado.", + "Se añadió la función de registro de actualizaciones." + ], + "zh_tw": [ + "新增手動模式複製一般模式資料。", + "修正更新計算後若不存在方向角則仍維持顯示前一計算結果。", + "新增更新日誌功能。" + ], + "zh_cn": [ + "新增手动模式复制一般模式资料。", + "修正更新计算后若不存在方向角则仍维持显示前一计算结果。", + "新增更新日志功能。" + ] + } }