v1.8.0: 模块化重构 + 后台登录认证
This commit is contained in:
156
templates/login.html
Normal file
156
templates/login.html
Normal file
@@ -0,0 +1,156 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>登录 - ParamHub 后台管理</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, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
.login-box {
|
||||
background: rgba(255,255,255,0.05);
|
||||
backdrop-filter: blur(20px);
|
||||
border: 1px solid rgba(255,255,255,0.1);
|
||||
border-radius: 20px;
|
||||
padding: 48px 40px;
|
||||
width: 400px;
|
||||
max-width: 90vw;
|
||||
box-shadow: 0 25px 60px rgba(0,0,0,0.4);
|
||||
}
|
||||
.login-box h1 {
|
||||
color: #fff;
|
||||
font-size: 28px;
|
||||
text-align: center;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
.login-box .subtitle {
|
||||
color: rgba(255,255,255,0.5);
|
||||
text-align: center;
|
||||
font-size: 14px;
|
||||
margin-bottom: 36px;
|
||||
}
|
||||
.input-group {
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
.input-group label {
|
||||
color: rgba(255,255,255,0.7);
|
||||
font-size: 13px;
|
||||
display: block;
|
||||
margin-bottom: 8px;
|
||||
font-weight: 500;
|
||||
}
|
||||
.input-group input {
|
||||
width: 100%;
|
||||
padding: 14px 16px;
|
||||
background: rgba(255,255,255,0.08);
|
||||
border: 1px solid rgba(255,255,255,0.15);
|
||||
border-radius: 12px;
|
||||
color: #fff;
|
||||
font-size: 16px;
|
||||
outline: none;
|
||||
transition: all 0.3s;
|
||||
}
|
||||
.input-group input:focus {
|
||||
border-color: #4fc3f7;
|
||||
background: rgba(255,255,255,0.12);
|
||||
box-shadow: 0 0 0 3px rgba(79,195,247,0.15);
|
||||
}
|
||||
.btn {
|
||||
width: 100%;
|
||||
padding: 14px;
|
||||
background: linear-gradient(135deg, #4fc3f7, #29b6f6);
|
||||
border: none;
|
||||
border-radius: 12px;
|
||||
color: #1a1a2e;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s;
|
||||
}
|
||||
.btn:hover {
|
||||
transform: translateY(-1px);
|
||||
box-shadow: 0 8px 25px rgba(79,195,247,0.3);
|
||||
}
|
||||
.btn:disabled {
|
||||
opacity: 0.6;
|
||||
cursor: not-allowed;
|
||||
transform: none;
|
||||
}
|
||||
.error-msg {
|
||||
color: #ff5252;
|
||||
font-size: 13px;
|
||||
text-align: center;
|
||||
margin-top: 16px;
|
||||
min-height: 20px;
|
||||
}
|
||||
.back-link {
|
||||
display: block;
|
||||
text-align: center;
|
||||
color: rgba(255,255,255,0.4);
|
||||
font-size: 13px;
|
||||
margin-top: 24px;
|
||||
text-decoration: none;
|
||||
transition: color 0.3s;
|
||||
}
|
||||
.back-link:hover { color: rgba(255,255,255,0.7); }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="login-box">
|
||||
<h1>🔐 ParamHub</h1>
|
||||
<p class="subtitle">后台管理登录</p>
|
||||
<form id="loginForm">
|
||||
<div class="input-group">
|
||||
<label for="password">管理员密码</label>
|
||||
<input type="password" id="password" name="password"
|
||||
placeholder="请输入密码" autocomplete="current-password" autofocus>
|
||||
</div>
|
||||
<button type="submit" class="btn" id="submitBtn">登 录</button>
|
||||
<div class="error-msg" id="errorMsg"></div>
|
||||
</form>
|
||||
<a href="/" class="back-link">← 返回首页</a>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const form = document.getElementById('loginForm');
|
||||
const btn = document.getElementById('submitBtn');
|
||||
const error = document.getElementById('errorMsg');
|
||||
const pwd = document.getElementById('password');
|
||||
|
||||
form.addEventListener('submit', async (e) => {
|
||||
e.preventDefault();
|
||||
error.textContent = '';
|
||||
btn.disabled = true;
|
||||
btn.textContent = '验证中...';
|
||||
|
||||
try {
|
||||
const res = await fetch('/login', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ password: pwd.value })
|
||||
});
|
||||
const data = await res.json();
|
||||
if (data.success) {
|
||||
window.location.href = data.redirect || '/admin';
|
||||
} else {
|
||||
error.textContent = data.error || '登录失败';
|
||||
pwd.value = '';
|
||||
pwd.focus();
|
||||
}
|
||||
} catch (err) {
|
||||
error.textContent = '网络错误,请重试';
|
||||
} finally {
|
||||
btn.disabled = false;
|
||||
btn.textContent = '登 录';
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user