diff --git a/LTEMvcApp/Views/Home/Index.cshtml b/LTEMvcApp/Views/Home/Index.cshtml index 8f9f1f1..3e92a9a 100644 --- a/LTEMvcApp/Views/Home/Index.cshtml +++ b/LTEMvcApp/Views/Home/Index.cshtml @@ -485,6 +485,9 @@ } if (!confirm('确定要启动该网络吗?')) return; + // 显示等待对话框 + showLoadingDialog('正在启动网络,请稍候...'); + // 显示等待状态 row.find('td').eq(6).html('等待中...'); @@ -494,6 +497,8 @@ contentType: 'application/json', data: JSON.stringify({ ip: ip, port: port, key: key }), success: function(response) { + // 关闭等待对话框 + hideLoadingDialog(); showToast('网络启动成功', 'success'); // 解析嵌套的response字段 if (response && response.response) { @@ -510,6 +515,8 @@ updateNetworkInfo(ip, port, key); }, error: function(xhr) { + // 关闭等待对话框 + hideLoadingDialog(); // 恢复原状态 row.find('td').eq(6).html('停止'); var errorMsg = '启动失败'; @@ -536,6 +543,9 @@ } if (!confirm('确定要停止该网络吗?')) return; + // 显示等待对话框 + showLoadingDialog('正在停止网络,请稍候...'); + // 显示等待状态 row.find('td').eq(6).html('等待中...'); @@ -545,6 +555,8 @@ contentType: 'application/json', data: JSON.stringify({ ip: ip, port: port, key: key }), success: function(response) { + // 关闭等待对话框 + hideLoadingDialog(); showToast('网络停止成功', 'success'); // 解析嵌套的response字段 if (response && response.response) { @@ -561,6 +573,8 @@ updateNetworkInfo(ip, port, key); }, error: function(xhr) { + // 关闭等待对话框 + hideLoadingDialog(); // 恢复原状态 row.find('td').eq(6).html('运行'); var errorMsg = '停止失败'; @@ -607,6 +621,42 @@ }, 3000); } + function showLoadingDialog(message) { + // 创建等待对话框 + var dialogHtml = ''; + + // 移除已存在的对话框 + $('#loadingDialog').remove(); + + // 添加新对话框并显示 + $('body').append(dialogHtml); + var dialog = new bootstrap.Modal(document.getElementById('loadingDialog')); + dialog.show(); + } + + function hideLoadingDialog() { + // 关闭等待对话框 + var dialog = bootstrap.Modal.getInstance(document.getElementById('loadingDialog')); + if (dialog) { + dialog.hide(); + } + // 移除对话框元素 + setTimeout(function() { + $('#loadingDialog').remove(); + }, 150); + } + $(function () { $('[title]').tooltip({trigger: 'hover'}); });