diff --git a/src/MaaWpfGui/Helper/LocalizationHelper.cs b/src/MaaWpfGui/Helper/LocalizationHelper.cs index b8d8e3f9fa..124afca8c0 100644 --- a/src/MaaWpfGui/Helper/LocalizationHelper.cs +++ b/src/MaaWpfGui/Helper/LocalizationHelper.cs @@ -254,15 +254,15 @@ namespace MaaWpfGui.Helper return cheersBuilder.ToString(); } - public static string FormatResourceVersion(string? resourceVersion, DateTime resourceDateTime) + public static string FormatVersion(string? version, DateTime dateTime) { - resourceDateTime = resourceDateTime.ToLocalTime(); + dateTime = dateTime.ToLocalTime(); return CustomCultureInfo.Name.ToLowerInvariant() switch { - "zh-cn" => $"{resourceVersion}{resourceDateTime:#MMdd}", - "zh-tw" => $"{resourceVersion}{resourceDateTime:#MMdd}", - "en-us" => $"{resourceDateTime:dd/MM} {resourceVersion}", - _ => $"{resourceDateTime.ToString(CustomCultureInfo.DateTimeFormat.ShortDatePattern.Replace("yyyy", string.Empty).Trim('/', '.'))} {resourceVersion}", + "zh-cn" => $"{version}{dateTime:#MMdd}", + "zh-tw" => $"{version}{dateTime:#MMdd}", + "en-us" => $"{dateTime:dd/MM} {version}", + _ => $"{dateTime.ToString(CustomCultureInfo.DateTimeFormat.ShortDatePattern.Replace("yyyy", string.Empty).Trim('/', '.'))} {version}", }; } diff --git a/src/MaaWpfGui/Models/ResourceUpdater.cs b/src/MaaWpfGui/Models/ResourceUpdater.cs index d7fcb40645..7bd42c32d5 100644 --- a/src/MaaWpfGui/Models/ResourceUpdater.cs +++ b/src/MaaWpfGui/Models/ResourceUpdater.cs @@ -216,7 +216,7 @@ namespace MaaWpfGui.Models var releaseNote = data["data"]?["release_note"]?.ToString(); _logger.Information("New version found: {DateTime:yyyy-MM-dd+HH:mm:ss.fff}, {ReleaseNote}", version, releaseNote); - releaseNote = LocalizationHelper.FormatResourceVersion(releaseNote, version); + releaseNote = LocalizationHelper.FormatVersion(releaseNote, version); SettingsViewModel.VersionUpdateSettings.NewResourceFoundInfo = string.Format(LocalizationHelper.GetString("MirrorChyanResourceUpdateShortTip"), releaseNote); diff --git a/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs b/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs index 9702d76a1b..f932bb4fde 100644 --- a/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs +++ b/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs @@ -776,11 +776,12 @@ namespace MaaWpfGui.ViewModels.UI } } - string resourceVersion = !string.IsNullOrEmpty(VersionUpdateSettings.ResourceVersion) - ? $" - {LocalizationHelper.FormatResourceVersion(VersionUpdateSettings.ResourceVersion, VersionUpdateSettings.ResourceDateTime)}" + string resourceVersionDisplay = !string.IsNullOrEmpty(VersionUpdateSettings.ResourceVersion) + ? $" - {LocalizationHelper.FormatVersion(VersionUpdateSettings.ResourceVersion, VersionUpdateSettings.ResourceDateTime)}" : string.Empty; + string uiVersionDisplay = LocalizationHelper.FormatVersion(uiVersion, VersionUpdateSettingsUserControlModel.BuildDateTime); rvm.WindowUpdateInfo = updateTip.Trim(); - rvm.WindowTitle = $"{prefix}MAA{currentConfiguration} - {uiVersion}{resourceVersion}{connectConfigName}{connectAddress}{clientName}"; + rvm.WindowTitle = $"{prefix}MAA{currentConfiguration} - {uiVersionDisplay}{resourceVersionDisplay}{connectConfigName}{connectAddress}{clientName}"; } /// diff --git a/src/MaaWpfGui/ViewModels/UserControl/Settings/VersionUpdateSettingsUserControlModel.cs b/src/MaaWpfGui/ViewModels/UserControl/Settings/VersionUpdateSettingsUserControlModel.cs index 1d22abf6a1..fd1ef8e2fe 100644 --- a/src/MaaWpfGui/ViewModels/UserControl/Settings/VersionUpdateSettingsUserControlModel.cs +++ b/src/MaaWpfGui/ViewModels/UserControl/Settings/VersionUpdateSettingsUserControlModel.cs @@ -211,7 +211,7 @@ public class VersionUpdateSettingsUserControlModel : PropertyChangedBase private UpdateVersionType _versionType = (UpdateVersionType)Enum.Parse( typeof(UpdateVersionType), - ConfigurationHelper.GetGlobalValue(ConfigurationKeys.VersionType, UpdateVersionType.Stable.ToString())); + ConfigurationHelper.GetGlobalValue(ConfigurationKeys.VersionType, nameof(UpdateVersionType.Stable))); /// /// Gets or sets the type of version to update.