refactor: 移除 Modal Toast 等组件移动代码

This commit is contained in:
Argo Zhang 2020-03-03 15:58:30 +08:00
parent 5c3aaea05d
commit bd2c4823ae
No known key found for this signature in database
GPG Key ID: 152E398953DDF19F
13 changed files with 206 additions and 258 deletions

View File

@ -64,18 +64,6 @@ namespace Bootstrap.Admin.Pages.Components
[Parameter] [Parameter]
public bool ShowFooter { get; set; } = true; public bool ShowFooter { get; set; } = true;
/// <summary>
/// OnAfterRender 方法
/// </summary>
/// <param name="firstRender"></param>
protected override void OnAfterRender(bool firstRender)
{
if (firstRender)
{
JSRuntime.InitModal(Id);
}
}
/// <summary> /// <summary>
/// SetParametersAsync 方法 /// SetParametersAsync 方法
/// </summary> /// </summary>

View File

@ -63,10 +63,6 @@ namespace Bootstrap.Admin.Pages.Components
/// <param name="firstRender"></param> /// <param name="firstRender"></param>
protected override void OnAfterRender(bool firstRender) protected override void OnAfterRender(bool firstRender)
{ {
if (firstRender)
{
JSRuntime.InitToast(Id);
}
if (_show) if (_show)
{ {
_show = false; _show = false;

View File

@ -46,20 +46,6 @@ namespace Microsoft.JSInterop
/// <param name="jSRuntime"></param> /// <param name="jSRuntime"></param>
public static void InitDocument(this IJSRuntime? jSRuntime) => jSRuntime.InvokeVoidAsync("$.initDocument"); public static void InitDocument(this IJSRuntime? jSRuntime) => jSRuntime.InvokeVoidAsync("$.initDocument");
/// <summary>
/// 修复 Modal 组件
/// </summary>
/// <param name="jSRuntime"></param>
/// <param name="id"></param>
public static void InitModal(this IJSRuntime? jSRuntime, string id) => jSRuntime.InvokeVoidAsync("$.initModal", id);
/// <summary>
/// 修复 Modal 组件
/// </summary>
/// <param name="jSRuntime"></param>
/// <param name="id"></param>
public static void InitToast(this IJSRuntime? jSRuntime, string id) => jSRuntime.InvokeVoidAsync("$.initToast", id);
/// <summary> /// <summary>
/// 弹出 Modal 组件 /// 弹出 Modal 组件
/// </summary> /// </summary>

View File

@ -52,7 +52,6 @@
<table></table> <table></table>
</div> </div>
</div> </div>
@section modal {
<div class="modal fade" id="dialogNew" tabindex="-1" role="dialog" data-backdrop="static" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal fade" id="dialogNew" tabindex="-1" role="dialog" data-backdrop="static" aria-labelledby="myModalLabel" aria-hidden="true">
<div id="errorList" class="modal-dialog modal-dialog-centered modal-lg" role="document"> <div id="errorList" class="modal-dialog modal-dialog-centered modal-lg" role="document">
<div class="modal-content"> <div class="modal-content">
@ -139,4 +138,3 @@
</div> </div>
</div> </div>
</div> </div>
}

View File

@ -37,7 +37,6 @@
</environment> </environment>
<script src="~/js/healths.js" asp-append-version="true"></script> <script src="~/js/healths.js" asp-append-version="true"></script>
} }
@section modal {
<div class="modal fade" id="dialogNew" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal fade" id="dialogNew" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered modal-lg" role="document"> <div class="modal-dialog modal-dialog-centered modal-lg" role="document">
<div class="modal-content"> <div class="modal-content">
@ -57,7 +56,6 @@
</div> </div>
</div> </div>
</div> </div>
}
<div class="card"> <div class="card">
<div class="card-header"> <div class="card-header">
健康检查结果 健康检查结果

View File

@ -78,7 +78,6 @@
<table></table> <table></table>
</div> </div>
</div> </div>
@section modal {
<div class="modal fade" id="dialogRequestData" tabindex="-1" role="dialog" data-backdrop="static" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal fade" id="dialogRequestData" tabindex="-1" role="dialog" data-backdrop="static" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered modal-lg" role="document"> <div class="modal-dialog modal-dialog-centered modal-lg" role="document">
<div class="modal-content"> <div class="modal-content">
@ -104,4 +103,3 @@
</div> </div>
</div> </div>
</div> </div>
}

View File

@ -25,47 +25,6 @@
<script src="~/lib/longbow/longbow.validate.js"></script> <script src="~/lib/longbow/longbow.validate.js"></script>
<script src="~/js/settings.js" asp-append-version="true"></script> <script src="~/js/settings.js" asp-append-version="true"></script>
} }
@section modal {
<div class="modal fade" id="dialogNew" tabindex="-1" role="dialog" data-backdrop="static" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered modal-lg" role="document">
<div class="modal-content" data-toggle="LgbValidate" data-valid-button="[data-method='saveNewApp']" data-valid-modal="#dialogNew">
<div class="modal-header">
<h5 class="modal-title" id="myModalLabel">前台应用设置</h5>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
</div>
<div class="modal-body">
<form class="form-inline">
<div class="row">
<div class="form-group col-sm-6">
<label class="control-label" for="appKey">应用ID</label>
<input type="text" class="form-control" id="appKey" placeholder="不可为空50字以内" maxlength="50" data-valid="true" />
</div>
<div class="form-group col-sm-6">
<input type="hidden" id="roleID" />
<label class="control-label" for="appName">应用名称</label>
<input type="text" class="form-control" id="appName" placeholder="不可为空50字以内" maxlength="50" data-valid="true" />
</div>
<div class="form-group col-sm-12">
<label class="control-label" for="appUrl">应用首页</label>
<input type="text" class="form-control flex-fill" id="appUrl" placeholder="不可为空2000字以内" maxlength="2000" data-valid="true" />
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">
<i class="fa fa-times"></i>
<span>关闭</span>
</button>
<button type="button" class="btn btn-primary" data-method="saveNewApp">
<i class="fa fa-save"></i>
<span>保存</span>
</button>
</div>
</div>
</div>
</div>
}
<div class="card" asp-auth="saveTitle"> <div class="card" asp-auth="saveTitle">
<div class="card-header">网站名称设置</div> <div class="card-header">网站名称设置</div>
<div class="card-body" data-toggle="LgbValidate" data-valid-button="[data-method='title']"> <div class="card-body" data-toggle="LgbValidate" data-valid-button="[data-method='title']">
@ -357,3 +316,42 @@
<div class="card-body" id="sortable"> <div class="card-body" id="sortable">
</div> </div>
</div> </div>
<div class="modal fade" id="dialogNew" tabindex="-1" role="dialog" data-backdrop="static" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered modal-lg" role="document">
<div class="modal-content" data-toggle="LgbValidate" data-valid-button="[data-method='saveNewApp']" data-valid-modal="#dialogNew">
<div class="modal-header">
<h5 class="modal-title" id="myModalLabel">前台应用设置</h5>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
</div>
<div class="modal-body">
<form class="form-inline">
<div class="row">
<div class="form-group col-sm-6">
<label class="control-label" for="appKey">应用ID</label>
<input type="text" class="form-control" id="appKey" placeholder="不可为空50字以内" maxlength="50" data-valid="true" />
</div>
<div class="form-group col-sm-6">
<input type="hidden" id="roleID" />
<label class="control-label" for="appName">应用名称</label>
<input type="text" class="form-control" id="appName" placeholder="不可为空50字以内" maxlength="50" data-valid="true" />
</div>
<div class="form-group col-sm-12">
<label class="control-label" for="appUrl">应用首页</label>
<input type="text" class="form-control flex-fill" id="appUrl" placeholder="不可为空2000字以内" maxlength="2000" data-valid="true" />
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">
<i class="fa fa-times"></i>
<span>关闭</span>
</button>
<button type="button" class="btn btn-primary" data-method="saveNewApp">
<i class="fa fa-save"></i>
<span>保存</span>
</button>
</div>
</div>
</div>
</div>

View File

@ -78,7 +78,6 @@
<table></table> <table></table>
</div> </div>
</div> </div>
@section modal {
<div class="modal fade" id="dialogRequestData" tabindex="-1" role="dialog" data-backdrop="static" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal fade" id="dialogRequestData" tabindex="-1" role="dialog" data-backdrop="static" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered modal-lg" role="document"> <div class="modal-dialog modal-dialog-centered modal-lg" role="document">
<div class="modal-content"> <div class="modal-content">
@ -104,4 +103,3 @@
</div> </div>
</div> </div>
</div> </div>
}

View File

@ -46,6 +46,3 @@
</div> </div>
@RenderBody() @RenderBody()
</section> </section>
@section modal {
@RenderSection("modal", false)
}

View File

@ -34,4 +34,3 @@
@await Html.PartialAsync("Header") @await Html.PartialAsync("Header")
@RenderBody() @RenderBody()
@await Html.PartialAsync("Footer") @await Html.PartialAsync("Footer")
@RenderSection("modal", false)

View File

@ -34,7 +34,40 @@
<script src="~/lib/longbow/longbow.validate.js" asp-append-version="true"></script> <script src="~/lib/longbow/longbow.validate.js" asp-append-version="true"></script>
@RenderSection("javascript", false) @RenderSection("javascript", false)
} }
@section modal { <div id="toolbar" class="d-none">
<div class="gear btn-group">
<button class="btn btn-secondary dropdown-toggle" data-toggle="dropdown" type="button"><i class="fa fa-gear"></i></button>
<div class="dropdown-menu">
<a id="tb_add" href="#" title="新增" asp-auth="add"><i class="fa fa-plus"></i></a>
<a id="tb_delete" href="#" title="删除" asp-auth="del"><i class="fa fa-remove"></i></a>
<a id="tb_edit" href="#" title="编辑" asp-auth="edit"><i class="fa fa-pencil"></i></a>
@await RenderSectionAsync("gear", false)
</div>
</div>
<div class="toolbar btn-group">
<button id="btn_add" type="button" class="btn btn-success" asp-auth="add"><i class="fa fa-plus" aria-hidden="true"></i><span>新增</span></button>
<button id="btn_delete" type="button" class="btn btn-danger" asp-auth="del"><i class="fa fa-remove" aria-hidden="true"></i><span>删除</span></button>
<button id="btn_edit" type="button" class="btn btn-primary" asp-auth="edit"><i class="fa fa-pencil" aria-hidden="true"></i><span>编辑</span></button>
@RenderSection("toolbar", false)
</div>
</div>
<div class="card">
<div class="card-header">
查询结果
</div>
<div class="card-body">
@await RenderSectionAsync("cardbody", false)
<table data-Header="@(Model.FixedTableHeader ? "fixed" : "scroll")"></table>
</div>
</div>
<div id="tableButtons" class="d-none">
<div class='btn-group'>
<button class='edit btn btn-sm btn-success' asp-auth="edit"><i class='fa fa-edit'></i><span>编辑</span></button>
<button class='del btn btn-sm btn-danger' asp-auth="del"><i class='fa fa-remove'></i><span>删除</span></button>
@RenderSection("tableButtons", false)
</div>
</div>
@await RenderSectionAsync("body", false)
<div class="modal fade" id="dialogNew" tabindex="-1" role="dialog" data-backdrop="static" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal fade" id="dialogNew" tabindex="-1" role="dialog" data-backdrop="static" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered modal-lg" role="document"> <div class="modal-dialog modal-dialog-centered modal-lg" role="document">
<div class="modal-content" data-toggle="LgbValidate" data-valid-button="#btnSubmit" data-valid-modal="#dialogNew"> <div class="modal-content" data-toggle="LgbValidate" data-valid-button="#btnSubmit" data-valid-modal="#dialogNew">
@ -70,38 +103,3 @@
</div> </div>
</div> </div>
@RenderSection("customModal", false) @RenderSection("customModal", false)
}
<div id="toolbar" class="d-none">
<div class="gear btn-group">
<button class="btn btn-secondary dropdown-toggle" data-toggle="dropdown" type="button"><i class="fa fa-gear"></i></button>
<div class="dropdown-menu">
<a id="tb_add" href="#" title="新增" asp-auth="add"><i class="fa fa-plus"></i></a>
<a id="tb_delete" href="#" title="删除" asp-auth="del"><i class="fa fa-remove"></i></a>
<a id="tb_edit" href="#" title="编辑" asp-auth="edit"><i class="fa fa-pencil"></i></a>
@await RenderSectionAsync("gear", false)
</div>
</div>
<div class="toolbar btn-group">
<button id="btn_add" type="button" class="btn btn-success" asp-auth="add"><i class="fa fa-plus" aria-hidden="true"></i><span>新增</span></button>
<button id="btn_delete" type="button" class="btn btn-danger" asp-auth="del"><i class="fa fa-remove" aria-hidden="true"></i><span>删除</span></button>
<button id="btn_edit" type="button" class="btn btn-primary" asp-auth="edit"><i class="fa fa-pencil" aria-hidden="true"></i><span>编辑</span></button>
@RenderSection("toolbar", false)
</div>
</div>
<div class="card">
<div class="card-header">
查询结果
</div>
<div class="card-body">
@await RenderSectionAsync("cardbody", false)
<table data-Header="@(Model.FixedTableHeader ? "fixed" : "scroll")"></table>
</div>
</div>
<div id="tableButtons" class="d-none">
<div class='btn-group'>
<button class='edit btn btn-sm btn-success' asp-auth="edit"><i class='fa fa-edit'></i><span>编辑</span></button>
<button class='del btn btn-sm btn-danger' asp-auth="del"><i class='fa fa-remove'></i><span>删除</span></button>
@RenderSection("tableButtons", false)
</div>
</div>
@await RenderSectionAsync("body", false)

View File

@ -25,7 +25,7 @@
@media (min-width: 768px) { @media (min-width: 768px) {
.main-content { .main-content {
position: fixed; position: absolute;
overflow: auto; overflow: auto;
-ms-overflow-style: auto; -ms-overflow-style: auto;
} }

View File

@ -108,12 +108,6 @@
$('[data-toggle="tooltip"]').tooltip(); $('[data-toggle="tooltip"]').tooltip();
$('.sidebar').addNiceScroll().autoScrollSidebar(); $('.sidebar').addNiceScroll().autoScrollSidebar();
}, },
initModal: function (id) {
$('#' + id).appendTo($('body'));
},
initToast: function (id) {
$('#' + id).appendTo($('body'));
},
toggleModal: function (modalId) { toggleModal: function (modalId) {
$(modalId).modal('toggle'); $(modalId).modal('toggle');
}, },