mirror of
https://gitee.com/ant-design-blazor/ant-design-blazor.git
synced 2024-12-04 04:58:05 +08:00
refactor(module: modal): update ConfirmService to use interface (#3083)
* ConfirmService To Interface * backwards compatibility
This commit is contained in:
parent
881f66d402
commit
1b48d862e2
@ -32,6 +32,7 @@ namespace Microsoft.Extensions.DependencyInjection
|
||||
services.TryAddScoped<ModalService>();
|
||||
services.TryAddScoped<DrawerService>();
|
||||
services.TryAddScoped<ConfirmService>();
|
||||
services.TryAddScoped<IConfirmService>(provider => provider.GetRequiredService<ConfirmService>());
|
||||
services.TryAddScoped<ImageService>();
|
||||
services.TryAddScoped<ConfigService>();
|
||||
services.TryAddSingleton<ReuseTabsService>();
|
||||
|
@ -10,7 +10,7 @@ namespace AntDesign
|
||||
/// <summary>
|
||||
/// show a simple Confirm dialog like MessageBox of Windows, it's different from ModalService. ModalService can only create OK-Cancel Confirm dialog and return ConfirmRef, but ConfirmService return ConfirmResult
|
||||
/// </summary>
|
||||
public class ConfirmService
|
||||
public class ConfirmService : IConfirmService
|
||||
{
|
||||
internal event Func<ConfirmRef, Task> OnOpenEvent;
|
||||
|
||||
|
23
components/modal/confirmDialog/IConfirmService.cs
Normal file
23
components/modal/confirmDialog/IConfirmService.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using OneOf;
|
||||
|
||||
namespace AntDesign;
|
||||
|
||||
public interface IConfirmService
|
||||
{
|
||||
Task<ConfirmResult> Show(
|
||||
OneOf<string, RenderFragment> content,
|
||||
OneOf<string, RenderFragment> title,
|
||||
ConfirmButtons confirmButtons,
|
||||
ConfirmIcon confirmIcon,
|
||||
ConfirmButtonOptions options,
|
||||
ConfirmAutoFocusButton? autoFocusButton = ConfirmAutoFocusButton.Ok);
|
||||
|
||||
Task<ConfirmResult> Show
|
||||
(OneOf<string, RenderFragment> content,
|
||||
OneOf<string, RenderFragment> title,
|
||||
ConfirmButtons confirmButtons = ConfirmButtons.OKCancel,
|
||||
ConfirmIcon confirmIcon = ConfirmIcon.Info);
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
@inject DrawerService DrawerService
|
||||
@inject ConfirmService confirmService
|
||||
@inject IConfirmService confirmService
|
||||
|
||||
<Space Direction="DirectionVHType.Vertical">
|
||||
<SpaceItem>
|
||||
|
@ -1,5 +1,5 @@
|
||||
@inject IMessageService _message
|
||||
@inject ConfirmService _confirmService
|
||||
@inject IConfirmService _confirmService
|
||||
|
||||
|
||||
<Divider>Buttons</Divider>
|
||||
|
@ -1,4 +1,4 @@
|
||||
@inject ConfirmService _confirmService
|
||||
@inject IConfirmService _confirmService
|
||||
@inject ModalService _modalService
|
||||
|
||||
|
||||
|
@ -7,8 +7,8 @@ title:
|
||||
|
||||
## zh-CN
|
||||
|
||||
使用 `ConfirmService.Show` 可以快捷地弹出一个内置的确认框,类似于 Windows MessageBox。
|
||||
使用 `IConfirmService.Show` 可以快捷地弹出一个内置的确认框,类似于 Windows MessageBox。
|
||||
|
||||
## en-US
|
||||
|
||||
Use `ConfirmService.Show` to show a built-in confirm dialog, similar to Windows MessageBox.
|
||||
Use `IConfirmService.Show` to show a built-in confirm dialog, similar to Windows MessageBox.
|
||||
|
@ -87,7 +87,7 @@ There are some ways to display the information based on the content's nature:
|
||||
|
||||
### ConfirmService
|
||||
|
||||
`ConfirmService.Show` to show a simple Confirm dialog like MessageBox of Windows, it's different from ModalService. ModalService can only create OK-Cancel Confirm dialog and return ConfirmRef or OK button is clicked, but ConfirmService return ConfirmResult.
|
||||
`IConfirmService.Show` to show a simple Confirm dialog like MessageBox of Windows, it's different from ModalService. ModalService can only create OK-Cancel Confirm dialog and return ConfirmRef or OK button is clicked, but ConfirmService return ConfirmResult.
|
||||
|
||||
|
||||
#### ConfirmOptions
|
||||
|
@ -89,7 +89,7 @@ cover: https://gw.alipayobjects.com/zos/alicdn/3StSdUlSH/Modal.svg
|
||||
|
||||
### ConfirmService
|
||||
|
||||
`ConfirmService.Show` 用于弹出类似于在WinForm中使用 MessageBox 方式弹出的对话框。这和 ModalService 不同的是,ModalService 只可以创建 具有 OK-Cancel 按钮的对话框并返回 ConfirmRef 对象或者是否OK按钮被点击,而 ConfirmService 总是返回 ConfirmResult ,以指示哪个按钮被点击。
|
||||
`IConfirmService.Show` 用于弹出类似于在WinForm中使用 MessageBox 方式弹出的对话框。这和 ModalService 不同的是,ModalService 只可以创建 具有 OK-Cancel 按钮的对话框并返回 ConfirmRef 对象或者是否OK按钮被点击,而 ConfirmService 总是返回 ConfirmResult ,以指示哪个按钮被点击。
|
||||
|
||||
|
||||
#### ConfirmOptions
|
||||
|
@ -1,4 +1,4 @@
|
||||
@inject ConfirmService _confirmService
|
||||
@inject IConfirmService _confirmService
|
||||
|
||||
<div>
|
||||
<Tag Closable OnClosing="async e=>await onClosing(e)" OnClose="onClose">onClosing</Tag>
|
||||
|
Loading…
Reference in New Issue
Block a user