refactor: 重构 Modal 弹窗逻辑
This commit is contained in:
parent
11a121cc63
commit
c3cee0dc58
|
@ -1,6 +1,7 @@
|
|||
using Bootstrap.Admin.Extensions;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.JSInterop;
|
||||
using System;
|
||||
|
||||
namespace Bootstrap.Admin.Components
|
||||
{
|
||||
|
@ -71,10 +72,18 @@ namespace Bootstrap.Admin.Components
|
|||
{
|
||||
if (firstRender)
|
||||
{
|
||||
JSRuntime.InitModal();
|
||||
JSRuntime.InitModal(Id);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// OnParametersSet 方法
|
||||
/// </summary>
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
if (string.IsNullOrEmpty(Id)) throw new InvalidOperationException("Modal Component Id property must be set");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 输出窗口大小样式
|
||||
/// </summary>
|
||||
|
|
|
@ -51,7 +51,8 @@ namespace Bootstrap.Admin.Extensions
|
|||
/// 修复 Modal 组件
|
||||
/// </summary>
|
||||
/// <param name="jSRuntime"></param>
|
||||
public static void InitModal(this IJSRuntime? jSRuntime) => jSRuntime.InvokeVoidAsync("$.initModal");
|
||||
/// <param name="id"></param>
|
||||
public static void InitModal(this IJSRuntime? jSRuntime, string id) => jSRuntime.InvokeVoidAsync("$.initModal", id);
|
||||
|
||||
/// <summary>
|
||||
/// 修复 Modal 组件
|
||||
|
|
|
@ -108,8 +108,8 @@
|
|||
$('[data-toggle="tooltip"]').tooltip();
|
||||
$('.sidebar').addNiceScroll().autoScrollSidebar();
|
||||
},
|
||||
initModal: function () {
|
||||
$('.modal').appendTo($('body'));
|
||||
initModal: function (id) {
|
||||
$('#' + id).appendTo($('body'));
|
||||
},
|
||||
initToast: function (id) {
|
||||
$('#' + id).appendTo($('body'));
|
||||
|
|
Loading…
Reference in New Issue