- 基于OpenResty的RESTful API服务 - 支持Cookie/Token等数据类型的存储和管理 - 登录认证保护 - Web管理界面 - 数据过期管理
96 lines
2.8 KiB
HTML
96 lines
2.8 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="zh-CN">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>登录 - 数据同步服务</title>
|
|
<style>
|
|
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
body {
|
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
min-height: 100vh;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
}
|
|
.login-box {
|
|
background: white;
|
|
border-radius: 12px;
|
|
padding: 40px;
|
|
box-shadow: 0 4px 20px rgba(0,0,0,0.2);
|
|
width: 400px;
|
|
max-width: 90%;
|
|
}
|
|
h1 {
|
|
color: #667eea;
|
|
font-size: 28px;
|
|
margin-bottom: 30px;
|
|
text-align: center;
|
|
}
|
|
input {
|
|
width: 100%;
|
|
padding: 12px;
|
|
border: 1px solid #ddd;
|
|
border-radius: 6px;
|
|
font-size: 16px;
|
|
margin-bottom: 20px;
|
|
}
|
|
button {
|
|
width: 100%;
|
|
padding: 12px;
|
|
background: #667eea;
|
|
color: white;
|
|
border: none;
|
|
border-radius: 6px;
|
|
font-size: 16px;
|
|
cursor: pointer;
|
|
}
|
|
button:hover {
|
|
background: #5568d3;
|
|
}
|
|
.error {
|
|
color: #e53e3e;
|
|
margin-bottom: 15px;
|
|
text-align: center;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="login-box">
|
|
<h1>数据同步服务</h1>
|
|
<div id="error" class="error"></div>
|
|
<input type="password" id="password" placeholder="请输入密码" />
|
|
<button onclick="login()">登录</button>
|
|
</div>
|
|
<script>
|
|
async function login() {
|
|
const password = document.getElementById('password').value;
|
|
const error = document.getElementById('error');
|
|
|
|
try {
|
|
const response = await fetch('/api/login', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ password })
|
|
});
|
|
|
|
const data = await response.json();
|
|
|
|
if (data.success) {
|
|
window.location.href = '/';
|
|
} else {
|
|
error.textContent = '密码错误';
|
|
}
|
|
} catch (e) {
|
|
error.textContent = '登录失败,请重试';
|
|
}
|
|
}
|
|
|
|
document.getElementById('password').addEventListener('keypress', function(e) {
|
|
if (e.key === 'Enter') login();
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|