feat(server.tests.test5): 新增 server 实验5
This commit is contained in:
82
Server/tests/test5/public/update.html
Normal file
82
Server/tests/test5/public/update.html
Normal file
@@ -0,0 +1,82 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Change Password</title>
|
||||
<style>
|
||||
body,
|
||||
html {
|
||||
margin: 0;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: 280px;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
input {
|
||||
padding: 8px;
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
button {
|
||||
padding: 10px;
|
||||
font-size: 16px;
|
||||
cursor: pointer;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<form id="changePwdForm">
|
||||
<input id="username" type="text" placeholder="用户名" required>
|
||||
<input id="currentPassword" type="password" placeholder="当前密码" required>
|
||||
<input id="newPassword" type="password" placeholder="新密码" required>
|
||||
<button type="button" id="changePwdBtn">修改密码</button>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
document.getElementById("changePwdBtn").addEventListener("click", changePassword);
|
||||
|
||||
async function changePassword() {
|
||||
const username = document.getElementById("username").value.trim();
|
||||
const currentPassword = document.getElementById("currentPassword").value.trim();
|
||||
const newPassword = document.getElementById("newPassword").value.trim();
|
||||
|
||||
if (!username || !currentPassword || !newPassword) {
|
||||
alert("请填写所有字段");
|
||||
return;
|
||||
}
|
||||
|
||||
const payload = {
|
||||
username,
|
||||
currentPassword,
|
||||
newPassword
|
||||
};
|
||||
|
||||
const res = await fetch("http://localhost:3000/update-password", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
body: JSON.stringify(payload)
|
||||
});
|
||||
|
||||
const data = await res.text(); // 返回字符串
|
||||
alert(data);
|
||||
}
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user