mirror of
https://gitee.com/bookshelfplus/bookshelfplus
synced 2025-10-07 00:15:15 +08:00
优化服务器连接失败提示;优化登录界面输入框回车处理
This commit is contained in:
@@ -12,4 +12,5 @@ postRequest('/debug/status', { token: localStorage.token })
|
|||||||
}
|
}
|
||||||
}).catch(function (error) {
|
}).catch(function (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
|
alert("无法连接到服务器,请检查网络连接!");
|
||||||
});
|
});
|
@@ -60,5 +60,8 @@ function search({ tableElementId = "", searchText = "", categoryId = 0 }) {
|
|||||||
} else {
|
} else {
|
||||||
alert(`出错啦!${data.errMsg} (错误码: ${data.errCode}) `);
|
alert(`出错啦!${data.errMsg} (错误码: ${data.errCode}) `);
|
||||||
}
|
}
|
||||||
|
}).catch(function (error) {
|
||||||
|
console.log(error);
|
||||||
|
alert("无法连接到服务器,请检查网络连接!");
|
||||||
});
|
});
|
||||||
}
|
}
|
@@ -82,6 +82,7 @@
|
|||||||
}
|
}
|
||||||
}).catch(function (error) {
|
}).catch(function (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
|
alert("无法连接到服务器,请检查网络连接!");
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
@@ -69,6 +69,7 @@
|
|||||||
}
|
}
|
||||||
}).catch(function (error) {
|
}).catch(function (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
|
alert("无法连接到服务器,请检查网络连接!");
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
@@ -121,6 +121,7 @@
|
|||||||
}
|
}
|
||||||
}).catch(function (error) {
|
}).catch(function (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
|
alert("无法连接到服务器,请检查网络连接!");
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
@@ -18,6 +18,7 @@
|
|||||||
}
|
}
|
||||||
}).catch(function (error) {
|
}).catch(function (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
|
alert("无法连接到服务器,请检查网络连接!");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
@@ -37,7 +37,12 @@
|
|||||||
})
|
})
|
||||||
.catch(function (error) {
|
.catch(function (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
alert("退出登录失败");
|
var choice = confirm("服务器连接失败,无法正常退出登录,是否要强行退出登录?");
|
||||||
|
if(choice) {
|
||||||
|
localStorage.clear("token");
|
||||||
|
localStorage.clear("is_admin");
|
||||||
|
location.href = "/login";
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@@ -3,13 +3,39 @@
|
|||||||
<head>
|
<head>
|
||||||
<%- include("../component/header.html"); %>
|
<%- include("../component/header.html"); %>
|
||||||
<%- include("../component/header-user.html"); %>
|
<%- include("../component/header-user.html"); %>
|
||||||
|
<style>
|
||||||
|
#container {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
gap: 30px;
|
||||||
|
place-items: center;
|
||||||
|
margin-top: 40px;
|
||||||
|
}
|
||||||
|
.mainNav {
|
||||||
|
vertical-align: middle;
|
||||||
|
margin: 0 8px;
|
||||||
|
|
||||||
|
transition: 0.26s;
|
||||||
|
}
|
||||||
|
.mainNav:hover {
|
||||||
|
color: #fff;
|
||||||
|
background-color: black;
|
||||||
|
padding: 5px 8px;
|
||||||
|
border-radius: 4px;
|
||||||
|
transform: scale(1.2);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<%- include("../component/navbar.html"); %>
|
<%- include("../component/navbar.html"); %>
|
||||||
<main class="main">
|
<main class="main">
|
||||||
<h1><%= headText %></h1>
|
<h1><%= headText %></h1>
|
||||||
<div id="container">
|
<div id="container">
|
||||||
|
<% links.forEach(item=> { %>
|
||||||
|
<nobr>
|
||||||
|
<a class="mainNav" href="<%= item.url %>"><%= item.name %></a>
|
||||||
|
</nobr>
|
||||||
|
<% }); %>
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
<%- include("../component/footer-user.html"); %>
|
<%- include("../component/footer-user.html"); %>
|
||||||
|
@@ -41,6 +41,7 @@
|
|||||||
}
|
}
|
||||||
}).catch(function (error) {
|
}).catch(function (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
|
alert("无法连接到服务器,请检查网络连接!");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if(localStorage.token != null) {
|
if(localStorage.token != null) {
|
||||||
@@ -72,6 +73,7 @@
|
|||||||
}
|
}
|
||||||
}).catch(function (error) {
|
}).catch(function (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
|
alert("无法连接到服务器,请检查网络连接!");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@@ -86,10 +86,34 @@
|
|||||||
<!-- <script src="/assets/lib/cryptography/2.2/md5-min.js"></script> -->
|
<!-- <script src="/assets/lib/cryptography/2.2/md5-min.js"></script> -->
|
||||||
<!-- <script src="/assets/lib/cryptography/2.2/sha1-min.js"></script> -->
|
<!-- <script src="/assets/lib/cryptography/2.2/sha1-min.js"></script> -->
|
||||||
<script>
|
<script>
|
||||||
|
// 避免重复点击
|
||||||
|
var isOnLogin = false;
|
||||||
|
|
||||||
// 用户正常登录逻辑
|
// 用户正常登录逻辑
|
||||||
$("#username").val("xiaomo");
|
$("#username").val("xiaomo");
|
||||||
$("#password").val("123456");
|
$("#password").val("123456");
|
||||||
|
$("#username").keydown(function(event) {
|
||||||
|
if(event.keyCode === 13) {
|
||||||
|
if($("#password").val() === "") {
|
||||||
|
$("#password").focus();
|
||||||
|
} else {
|
||||||
|
$(".btn-submit").click();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$("#password").keydown(function(event) {
|
||||||
|
if(event.keyCode === 13) {
|
||||||
|
if($("#username").val() === "") {
|
||||||
|
$("#username").focus();
|
||||||
|
} else {
|
||||||
|
$(".btn-submit").click();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
$(".btn-submit").click(function() {
|
$(".btn-submit").click(function() {
|
||||||
|
if(isOnLogin) return;
|
||||||
|
isOnLogin= true;
|
||||||
|
|
||||||
var username = $("#username").val();
|
var username = $("#username").val();
|
||||||
var password = $("#password").val();
|
var password = $("#password").val();
|
||||||
// var encryptpwd = hex_sha1(password);
|
// var encryptpwd = hex_sha1(password);
|
||||||
@@ -125,6 +149,9 @@
|
|||||||
}
|
}
|
||||||
}).catch(function (error) {
|
}).catch(function (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
|
alert("无法连接到服务器,请检查网络连接!");
|
||||||
|
}).finally(function () {
|
||||||
|
isOnLogin = false;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
@@ -98,6 +98,7 @@
|
|||||||
}
|
}
|
||||||
}).catch(function (error) {
|
}).catch(function (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
|
alert("无法连接到服务器,请检查网络连接!");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
Reference in New Issue
Block a user