1
0
mirror of https://gitee.com/bookshelfplus/bookshelfplus synced 2025-09-13 04:01:40 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee

优化服务器连接失败提示;优化登录界面输入框回车处理

This commit is contained in:
2022-04-05 12:56:17 +08:00
parent 3d2d0c42fb
commit 412ec19cf2
11 changed files with 71 additions and 2 deletions

View File

@@ -12,4 +12,5 @@ postRequest('/debug/status', { token: localStorage.token })
}
}).catch(function (error) {
console.log(error);
alert("无法连接到服务器,请检查网络连接!");
});

View File

@@ -60,5 +60,8 @@ function search({ tableElementId = "", searchText = "", categoryId = 0 }) {
} else {
alert(`出错啦!${data.errMsg} (错误码: ${data.errCode}) `);
}
}).catch(function (error) {
console.log(error);
alert("无法连接到服务器,请检查网络连接!");
});
}

View File

@@ -82,6 +82,7 @@
}
}).catch(function (error) {
console.log(error);
alert("无法连接到服务器,请检查网络连接!");
});
</script>
</body>

View File

@@ -69,6 +69,7 @@
}
}).catch(function (error) {
console.log(error);
alert("无法连接到服务器,请检查网络连接!");
});
</script>
</body>

View File

@@ -121,6 +121,7 @@
}
}).catch(function (error) {
console.log(error);
alert("无法连接到服务器,请检查网络连接!");
});
</script>
</body>

View File

@@ -18,6 +18,7 @@
}
}).catch(function (error) {
console.log(error);
alert("无法连接到服务器,请检查网络连接!");
});
}
</script>

View File

@@ -37,7 +37,12 @@
})
.catch(function (error) {
console.log(error);
alert("退出登录失败");
var choice = confirm("服务器连接失败,无法正常退出登录,是否要强行退出登录?");
if(choice) {
localStorage.clear("token");
localStorage.clear("is_admin");
location.href = "/login";
}
});
}
</script>

View File

@@ -3,13 +3,39 @@
<head>
<%- include("../component/header.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>
<body>
<%- include("../component/navbar.html"); %>
<main class="main">
<h1><%= headText %></h1>
<div id="container">
<% links.forEach(item=> { %>
<nobr>
<a class="mainNav" href="<%= item.url %>"><%= item.name %></a>
</nobr>
<% }); %>
</div>
</main>
<%- include("../component/footer-user.html"); %>

View File

@@ -41,6 +41,7 @@
}
}).catch(function (error) {
console.log(error);
alert("无法连接到服务器,请检查网络连接!");
});
}
if(localStorage.token != null) {
@@ -72,6 +73,7 @@
}
}).catch(function (error) {
console.log(error);
alert("无法连接到服务器,请检查网络连接!");
});
}
</script>

View File

@@ -86,10 +86,34 @@
<!-- <script src="/assets/lib/cryptography/2.2/md5-min.js"></script> -->
<!-- <script src="/assets/lib/cryptography/2.2/sha1-min.js"></script> -->
<script>
// 避免重复点击
var isOnLogin = false;
// 用户正常登录逻辑
$("#username").val("xiaomo");
$("#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() {
if(isOnLogin) return;
isOnLogin= true;
var username = $("#username").val();
var password = $("#password").val();
// var encryptpwd = hex_sha1(password);
@@ -125,6 +149,9 @@
}
}).catch(function (error) {
console.log(error);
alert("无法连接到服务器,请检查网络连接!");
}).finally(function () {
isOnLogin = false;
});
});
</script>

View File

@@ -98,6 +98,7 @@
}
}).catch(function (error) {
console.log(error);
alert("无法连接到服务器,请检查网络连接!");
});
});
</script>