From 5b05c4b9ab888037f194d6fed4128ff7e187f11e Mon Sep 17 00:00:00 2001 From: Argo Window10 Date: Thu, 28 Nov 2019 11:49:13 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20Modal=20=E7=BB=84=E4=BB=B6=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Bootstrap.Admin/Components/ModalBase.cs | 60 +++++++++++++++++++ .../Bootstrap.Admin/Pages/Admin/Dicts.razor | 44 +++++++++++++- src/admin/Bootstrap.Admin/Shared/Modal.razor | 25 +++----- 3 files changed, 110 insertions(+), 19 deletions(-) create mode 100644 src/admin/Bootstrap.Admin/Components/ModalBase.cs diff --git a/src/admin/Bootstrap.Admin/Components/ModalBase.cs b/src/admin/Bootstrap.Admin/Components/ModalBase.cs new file mode 100644 index 00000000..7ef3b54b --- /dev/null +++ b/src/admin/Bootstrap.Admin/Components/ModalBase.cs @@ -0,0 +1,60 @@ +using Bootstrap.Admin.Extensions; +using Microsoft.AspNetCore.Components; +using Microsoft.JSInterop; + +namespace Bootstrap.Admin.Components +{ + /// + /// 模态框组件类 + /// + public class ModalBase : ComponentBase + { + /// + /// + /// + [Inject] + protected IJSRuntime? JSRuntime { get; set; } + + /// + /// + /// + [Parameter] + public string Id { get; set; } = ""; + + /// + /// + /// + [Parameter] + public string Title { get; set; } = "未设置"; + + /// + /// + /// + [Parameter] + public RenderFragment? ModalBody { get; set; } + + /// + /// + /// + [Parameter] + public bool Backdrop { get; set; } + + /// + /// + /// + [Parameter] + public RenderFragment? ModalFooter { get; set; } + + /// + /// + /// + /// + protected override void OnAfterRender(bool firstRender) + { + if (firstRender) + { + JSRuntime.InitModal(); + } + } + } +} diff --git a/src/admin/Bootstrap.Admin/Pages/Admin/Dicts.razor b/src/admin/Bootstrap.Admin/Pages/Admin/Dicts.razor index 67b70c64..a54886c4 100644 --- a/src/admin/Bootstrap.Admin/Pages/Admin/Dicts.razor +++ b/src/admin/Bootstrap.Admin/Pages/Admin/Dicts.razor @@ -57,7 +57,49 @@ - + + + + +
+
+ +
+ + +
+
+ + + +
+
+ + +
+
+ + +
+
+
+
+ + + + +
@code { diff --git a/src/admin/Bootstrap.Admin/Shared/Modal.razor b/src/admin/Bootstrap.Admin/Shared/Modal.razor index 8b4f0f1f..98a5e570 100644 --- a/src/admin/Bootstrap.Admin/Shared/Modal.razor +++ b/src/admin/Bootstrap.Admin/Shared/Modal.razor @@ -1,36 +1,25 @@ -@inject IJSRuntime JSRuntime - - +@inherits ModalBase -