diff --git a/src/BootstrapBlazor/BootstrapBlazor.csproj b/src/BootstrapBlazor/BootstrapBlazor.csproj index 8b8a5b29cc1..09bea5114e3 100644 --- a/src/BootstrapBlazor/BootstrapBlazor.csproj +++ b/src/BootstrapBlazor/BootstrapBlazor.csproj @@ -1,7 +1,7 @@ - 8.3.4-beta04 + 8.3.4-beta05 diff --git a/src/BootstrapBlazor/Components/DateTimePicker/DatePickerBody.razor b/src/BootstrapBlazor/Components/DateTimePicker/DatePickerBody.razor index 8618fa9f2ef..72decad53a2 100644 --- a/src/BootstrapBlazor/Components/DateTimePicker/DatePickerBody.razor +++ b/src/BootstrapBlazor/Components/DateTimePicker/DatePickerBody.razor @@ -97,7 +97,7 @@ } else { - + } } diff --git a/src/BootstrapBlazor/Components/DateTimePicker/DatePickerBody.razor.cs b/src/BootstrapBlazor/Components/DateTimePicker/DatePickerBody.razor.cs index 1c599d79d43..2bdeea872e6 100644 --- a/src/BootstrapBlazor/Components/DateTimePicker/DatePickerBody.razor.cs +++ b/src/BootstrapBlazor/Components/DateTimePicker/DatePickerBody.razor.cs @@ -349,6 +349,12 @@ public bool AllowNull [Parameter] public bool ShowLunar { get; set; } + /// + /// 获得/设置 是否显示中国 24 节气 默认 false + /// + [Parameter] + public bool ShowSolarTerm { get; set; } + /// /// 获得/设置 是否为 Range 内使用 默认为 false /// @@ -839,5 +845,5 @@ protected static bool IsYearOverflow(DateTime dt, int year) return ret; } - private static string GetLunarText(DateTime dateTime) => dateTime.ToLunarText(); + private string GetLunarText(DateTime dateTime) => dateTime.ToLunarText(ShowSolarTerm); } diff --git a/src/BootstrapBlazor/Components/DateTimePicker/DatePickerCell.razor.cs b/src/BootstrapBlazor/Components/DateTimePicker/DatePickerCell.razor.cs index 048a769bfe4..416b09efb69 100644 --- a/src/BootstrapBlazor/Components/DateTimePicker/DatePickerCell.razor.cs +++ b/src/BootstrapBlazor/Components/DateTimePicker/DatePickerCell.razor.cs @@ -46,5 +46,11 @@ public sealed partial class DatePickerCell [Parameter] public bool ShowLunar { get; set; } - private static string GetLunarText(DateTime dateTime) => dateTime.ToLunarText(); + /// + /// 获得/设置 是否显示中国 24 节气 默认 false + /// + [Parameter] + public bool ShowSolarTerm { get; set; } + + private string GetLunarText(DateTime dateTime) => dateTime.ToLunarText(ShowSolarTerm); } diff --git a/src/BootstrapBlazor/Components/DateTimePicker/DateTimePicker.razor b/src/BootstrapBlazor/Components/DateTimePicker/DateTimePicker.razor index 9e630138445..c8a20c15519 100644 --- a/src/BootstrapBlazor/Components/DateTimePicker/DateTimePicker.razor +++ b/src/BootstrapBlazor/Components/DateTimePicker/DateTimePicker.razor @@ -14,7 +14,7 @@ } @ChildContent diff --git a/src/BootstrapBlazor/Components/DateTimePicker/DateTimePicker.razor.cs b/src/BootstrapBlazor/Components/DateTimePicker/DateTimePicker.razor.cs index c91b46cf789..c972722ef12 100644 --- a/src/BootstrapBlazor/Components/DateTimePicker/DateTimePicker.razor.cs +++ b/src/BootstrapBlazor/Components/DateTimePicker/DateTimePicker.razor.cs @@ -191,6 +191,12 @@ public string? Format [Parameter] public bool ShowLunar { get; set; } + /// + /// 获得/设置 是否显示中国 24 节气 默认 false + /// + [Parameter] + public bool ShowSolarTerm { get; set; } + [Inject] [NotNull] private IStringLocalizer>? Localizer { get; set; } diff --git a/src/BootstrapBlazor/Extensions/DateTimeExtensions.cs b/src/BootstrapBlazor/Extensions/DateTimeExtensions.cs index 9586bbdb681..eab39c51057 100644 --- a/src/BootstrapBlazor/Extensions/DateTimeExtensions.cs +++ b/src/BootstrapBlazor/Extensions/DateTimeExtensions.cs @@ -51,8 +51,11 @@ public static DateTime GetSafeMonthDateTime(this DateTime dt, int month) /// 获得阴历时间 /// /// + /// /// - public static string ToLunarText(this DateTime dt) => dt.GetSolarTermName() ?? dt.GetLunarMonthName(); + public static string ToLunarText(this DateTime dt, bool showSolarTerm = false) => showSolarTerm + ? dt.GetSolarTermName() ?? dt.GetLunarMonthName() + : dt.GetLunarMonthName(); static string GetLunarMonthName(this DateTime dt) { diff --git a/test/UnitTest/Components/DateTimePickerTest.cs b/test/UnitTest/Components/DateTimePickerTest.cs index 72ab2489201..5725cc2f451 100644 --- a/test/UnitTest/Components/DateTimePickerTest.cs +++ b/test/UnitTest/Components/DateTimePickerTest.cs @@ -323,6 +323,57 @@ public void ShowLunar_Ok() cut.Contains("闰二月"); } + [Fact] + public void ShowSolarTerm_Ok() + { + var cut = Context.RenderComponent>(pb => + { + pb.Add(a => a.ShowLunar, true); + pb.Add(a => a.ShowSolarTerm, true); + pb.Add(a => a.Value, new DateTime(2024, 3, 5)); + }); + + cut.Contains("惊蛰"); + + cut.SetParametersAndRender(pb => + { + pb.Add(a => a.Value, new DateTime(2023, 2, 20)); + }); + cut.Contains("二月"); + } + + [Fact] + public void DayTemplate_Ok() + { + var cut = Context.RenderComponent>(pb => + { + pb.Add(a => a.DayTemplate, dt => builder => + { + builder.AddContent(0, "day-template"); + }); + }); + + cut.Contains("day-template"); + } + + [Fact] + public void DayDisabledTemplate_Ok() + { + var cut = Context.RenderComponent>(pb => + { + pb.Add(a => a.DayDisabledTemplate, dt => builder => + { + builder.AddContent(0, "day-disabled-template"); + }); + pb.Add(a => a.MinValue, new DateTime(2024, 3, 7)); + pb.Add(a => a.MaxValue, new DateTime(2024, 3, 17)); + pb.Add(a => a.Value, new DateTime(2024, 3, 10)); + }); + + cut.Contains("day-disabled-template"); + cut.SetParametersAndRender(pb => pb.Add(a => a.ShowLunar, true)); + } + [Fact] public void DatePickerViewModel_Ok() { diff --git a/test/UnitTest/Components/LayoutTest.cs b/test/UnitTest/Components/LayoutTest.cs index a86b5867bb3..459c7ce3ca9 100644 --- a/test/UnitTest/Components/LayoutTest.cs +++ b/test/UnitTest/Components/LayoutTest.cs @@ -303,7 +303,7 @@ public void NotAuthorized_Ok() } [Fact] - public void OnUpdateAsync_Ok() + public async Task OnUpdateAsync_Ok() { var updated = false; var cut = Context.RenderComponent(pb => @@ -314,7 +314,7 @@ public void OnUpdateAsync_Ok() return Task.CompletedTask; }); }); - cut.InvokeAsync(() => cut.Instance.UpdateAsync("Test")); + await cut.InvokeAsync(() => cut.Instance.UpdateAsync("Test")); Assert.True(updated); }