Skip to content

Commit a25b6dc

Browse files
committed
refactor: 精简代码
1 parent aeb989e commit a25b6dc

File tree

2 files changed

+1
-17
lines changed

2 files changed

+1
-17
lines changed

src/BootstrapBlazor/Components/Message/Message.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<div id="@Id" class="@ClassString" style="@StyleName" role="alert">
66
@foreach (var item in GetMessages())
77
{
8-
<div @key="item" id="@GetItemId(item)" role="alertdialog" class="@GetItemClassString(item)" data-bb-autohide="@GetAutoHideString(item)" data-bb-delay="@GetDelayString(item)">
8+
<div @key="item" id="@GetItemId(item)" role="alertdialog" class="@GetItemClassString(item)" data-bb-autohide="@GetAutoHideString(item)" data-bb-delay="@item.Delay">
99
@if (!string.IsNullOrEmpty(item.Icon))
1010
{
1111
<i class="@item.Icon"></i>

src/BootstrapBlazor/Components/Message/Message.razor.cs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
// See the LICENSE file in the project root for more information.
44
// Maintainer: Argo Zhang([email protected]) Website: https://www.blazor.zone
55

6-
using System.Globalization;
7-
86
namespace BootstrapBlazor.Components;
97

108
/// <summary>
@@ -42,10 +40,6 @@ public partial class Message
4240
[NotNull]
4341
public MessageService? MessageService { get; set; }
4442

45-
[Inject]
46-
[NotNull]
47-
private IOptionsMonitor<BootstrapBlazorOptions>? Options { get; set; }
48-
4943
/// <summary>
5044
/// <inheritdoc/>
5145
/// </summary>
@@ -72,16 +66,6 @@ protected override void OnInitialized()
7266
.AddClass("alert-bar", option.ShowBar)
7367
.Build();
7468

75-
private string GetDelayString(MessageOption option) => GetDelay(option).ToString(CultureInfo.InvariantCulture);
76-
77-
private int GetDelay(MessageOption option) => option.ForceDelay
78-
? option.Delay
79-
: GetOptionsDelay(option);
80-
81-
private int GetOptionsDelay(MessageOption option) => Options.CurrentValue.MessageDelay == 0
82-
? option.Delay
83-
: Options.CurrentValue.MessageDelay;
84-
8569
private string GetItemId(MessageOption option) => $"{Id}_{option.GetHashCode()}";
8670

8771
private string? _msgId;

0 commit comments

Comments
 (0)