From 58b9af1899a90207c7bbc7d6dbefd8999abd1bad Mon Sep 17 00:00:00 2001 From: Argo Zhang Date: Tue, 11 Feb 2025 11:40:06 +0800 Subject: [PATCH] =?UTF-8?q?doc:=20=E6=9B=B4=E6=96=B0=E5=BC=B9=E7=AA=97?= =?UTF-8?q?=E5=BB=B6=E6=97=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/Samples/Toasts.razor.cs | 31 ++++++++++++------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/src/BootstrapBlazor.Server/Components/Samples/Toasts.razor.cs b/src/BootstrapBlazor.Server/Components/Samples/Toasts.razor.cs index f9154087c81..58cf516cdaf 100644 --- a/src/BootstrapBlazor.Server/Components/Samples/Toasts.razor.cs +++ b/src/BootstrapBlazor.Server/Components/Samples/Toasts.razor.cs @@ -3,6 +3,8 @@ // See the LICENSE file in the project root for more information. // Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone +using Microsoft.Extensions.Options; + namespace BootstrapBlazor.Server.Components.Samples; /// @@ -32,6 +34,11 @@ public sealed partial class Toasts [NotNull] private ConsoleLogger? Logger { get; set; } + [Inject, NotNull] + private IOptions? Options { get; set; } + + private int _delayTs => Options.Value.ToastDelay / 1000; + /// /// OnInitialized /// @@ -39,10 +46,10 @@ protected override void OnInitialized() { base.OnInitialized(); - Options1 = new ToastOption { Title = "Save data", IsAutoHide = false, Content = "Save data successfully, automatically close after 4 seconds" }; - Options2 = new ToastOption { Category = ToastCategory.Error, Title = "Save data", IsAutoHide = false, Content = "Save data successfully, automatically close after 4 seconds" }; - Options3 = new ToastOption { Category = ToastCategory.Information, Title = "Prompt information", IsAutoHide = false, Content = "Information prompt pop-up window, automatically closes after 4 seconds" }; - Options4 = new ToastOption { Category = ToastCategory.Warning, Title = "Warning message", IsAutoHide = false, Content = "Information prompt pop-up window, automatically closes after 4 seconds" }; + Options1 = new ToastOption { Title = "Save data", IsAutoHide = false, Content = $"Save data successfully, automatically close after {_delayTs} seconds" }; + Options2 = new ToastOption { Category = ToastCategory.Error, Title = "Save data", IsAutoHide = false, Content = $"Save data successfully, automatically close after {_delayTs} seconds" }; + Options3 = new ToastOption { Category = ToastCategory.Information, Title = "Prompt information", IsAutoHide = false, Content = $"Information prompt pop-up window, automatically closes after {_delayTs} seconds" }; + Options4 = new ToastOption { Category = ToastCategory.Warning, Title = "Warning message", IsAutoHide = false, Content = $"Information prompt pop-up window, automatically closes after {_delayTs} seconds" }; ToastContainer = Root.ToastContainer; } @@ -55,7 +62,7 @@ await ToastService.Show(new ToastOption() PreventDuplicates = true, Category = ToastCategory.Success, Title = "Successfully saved", - Content = "Save data successfully, automatically close after 4 seconds" + Content = $"Save data successfully, automatically close after {_delayTs} seconds" }); } @@ -66,7 +73,7 @@ await ToastService.Show(new ToastOption() { Category = ToastCategory.Success, Title = "Successfully saved", - Content = "Save data successfully, automatically close after 4 seconds" + Content = $"Save data successfully, automatically close after {_delayTs} seconds" }); } @@ -77,7 +84,7 @@ await ToastService.Show(new ToastOption() { Category = ToastCategory.Error, Title = "Failed to save", - Content = "Failed to save data, automatically closes after 4 seconds" + Content = $"Failed to save data, automatically closes after {_delayTs} seconds" }); } @@ -88,7 +95,7 @@ await ToastService.Show(new ToastOption() { Category = ToastCategory.Information, Title = "Notification", - Content = "The system adds new components, it will automatically shut down after 4 seconds" + Content = $"The system adds new components, it will automatically shut down after {_delayTs} seconds" }); } @@ -99,7 +106,7 @@ await ToastService.Show(new ToastOption() { Category = ToastCategory.Warning, Title = "Warning", - Content = "If the system finds abnormality, please deal with it in time, and it will automatically shut down after 4 seconds" + Content = $"If the system finds abnormality, please deal with it in time, and it will automatically shut down after {_delayTs} seconds" }); } @@ -128,7 +135,7 @@ await ToastService.Show(new ToastOption() { Category = ToastCategory.Warning, ShowHeader = false, - Content = "The system adds new components, it will automatically shut down after 4 seconds" + Content = $"The system adds new components, it will automatically shut down after {_delayTs} seconds" }); } @@ -139,7 +146,7 @@ await ToastService.Show(new ToastOption() { Category = ToastCategory.Information, HeaderTemplate = RenderHeader, - Content = "The system adds new components, it will automatically shut down after 4 seconds" + Content = $"The system adds new components, it will automatically shut down after {_delayTs} seconds" }); } @@ -150,7 +157,7 @@ await ToastService.Show(new ToastOption() { Category = ToastCategory.Information, Title = "Notification", - Content = "Toast The component has changed position, it will automatically shut down after 4 seconds" + Content = $"Toast The component has changed position, it will automatically shut down after {_delayTs} seconds" }); }