This commit is contained in:
2025-11-28 21:20:40 +08:00
commit f940b95b67
73 changed files with 15721 additions and 0 deletions

161
templates/admin_login.html Normal file
View File

@@ -0,0 +1,161 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>管理员登录 - JieXi Admin</title>
<link rel="stylesheet" href="/static/css/ui-components.css">
<link rel="stylesheet" href="/static/css/admin.css">
<style>
body {
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
background: linear-gradient(135deg, var(--primary-50) 0%, var(--secondary-100) 100%);
}
.login-container {
width: 100%;
max-width: 400px;
padding: 1rem;
}
.login-card {
background: white;
border-radius: var(--radius-xl);
box-shadow: var(--shadow-xl);
padding: 2.5rem;
}
.login-header {
text-align: center;
margin-bottom: 2rem;
}
.login-header .logo {
font-size: 2.5rem;
margin-bottom: 0.5rem;
}
.login-header h1 {
font-size: 1.5rem;
color: var(--secondary-900);
margin-bottom: 0.25rem;
}
.login-header p {
color: var(--text-muted);
font-size: 0.875rem;
}
.login-form .form-group {
margin-bottom: 1.25rem;
}
.login-form label {
display: block;
font-size: 0.875rem;
font-weight: 500;
color: var(--secondary-800);
margin-bottom: 0.5rem;
}
.login-form .ui-input {
width: 100%;
}
.login-form .submit-btn {
width: 100%;
margin-top: 0.5rem;
}
.login-footer {
text-align: center;
margin-top: 1.5rem;
padding-top: 1.5rem;
border-top: 1px solid var(--border-color);
}
.login-footer a {
color: var(--primary-600);
text-decoration: none;
font-size: 0.875rem;
}
.login-footer a:hover {
text-decoration: underline;
}
</style>
</head>
<body>
<div class="login-container">
<div class="login-card">
<div class="login-header">
<div class="logo"></div>
<h1>JieXi Admin</h1>
<p>管理员登录</p>
</div>
<form id="loginForm" class="login-form">
<div class="form-group">
<label for="username">用户名</label>
<input type="text" id="username" class="ui-input" placeholder="请输入用户名" required>
</div>
<div class="form-group">
<label for="password">密码</label>
<input type="password" id="password" class="ui-input" placeholder="请输入密码" required>
</div>
<div class="form-group" id="2faGroup" style="display:none;">
<label for="code_2fa">2FA 验证码</label>
<input type="text" id="code_2fa" class="ui-input" placeholder="请输入6位验证码" maxlength="6">
</div>
<button type="submit" class="ui-btn ui-btn-primary submit-btn">登录</button>
</form>
<div class="login-footer">
<a href="/">返回首页</a>
</div>
</div>
</div>
<script src="/static/js/ui-components.js"></script>
<script>
document.getElementById('loginForm').addEventListener('submit', async (e) => {
e.preventDefault();
const username = document.getElementById('username').value;
const password = document.getElementById('password').value;
const code_2fa = document.getElementById('code_2fa').value;
try {
const response = await fetch('/admin/login', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ username, password, code_2fa })
});
const data = await response.json();
if (data.success) {
UI.notify('登录成功!跳转中...', 'success');
setTimeout(() => {
window.location.href = '/admin/dashboard';
}, 1000);
} else {
if (data.require_2fa) {
document.getElementById('2faGroup').style.display = 'block';
document.getElementById('code_2fa').focus();
}
UI.notify(data.message, 'error');
}
} catch (error) {
UI.notify('登录失败,请重试', 'error');
}
});
</script>
</body>
</html>