using System; using System.Collections.Generic; using System.Text; using System.Threading.Tasks; using Microsoft.AspNetCore.Components; namespace AntDesign { public class ModalTemplate : TemplateComponentBase, IModalTemplate { [Parameter] public ModalRef ModalRef { get; set; } /// /// 确定并返回值 /// /// public async Task OnOkAsync(TResult result) { await ModalRef.OnOk?.Invoke(result); } /// /// 取消并返回值 /// /// public async Task OnCancelAsync(TResult result) { await ModalRef.OnCancel?.Invoke(result); } /// /// 关闭窗体 /// /// protected async Task CloseAsync() { await ModalRef.CloseAsync(); } protected override void OnInitialized() { base.OnInitialized(); ModalRef.ModalTemplate = this; } public virtual Task CancelAsync(ModalClosingEventArgs args) { return Task.CompletedTask; } public virtual Task OkAsync(ModalClosingEventArgs args) { return Task.CompletedTask; } } }