306 lines
9.7 KiB
HTML
306 lines
9.7 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>用户注册 - JieXi Pro</title>
|
|
<link rel="stylesheet" href="/static/css/ui-components.css">
|
|
<style>
|
|
body {
|
|
background: linear-gradient(135deg, #f0f9ff 0%, #e0e7ff 100%);
|
|
min-height: 100vh;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
padding: 20px;
|
|
}
|
|
|
|
.auth-container {
|
|
background: rgba(255, 255, 255, 0.9);
|
|
backdrop-filter: blur(20px);
|
|
border-radius: 24px;
|
|
padding: 3rem;
|
|
box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
|
|
width: 100%;
|
|
max-width: 450px;
|
|
border: 1px solid rgba(255, 255, 255, 0.5);
|
|
}
|
|
|
|
.auth-header {
|
|
text-align: center;
|
|
margin-bottom: 2rem;
|
|
}
|
|
|
|
.auth-title {
|
|
font-size: 1.75rem;
|
|
font-weight: 700;
|
|
background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
|
|
-webkit-background-clip: text;
|
|
-webkit-text-fill-color: transparent;
|
|
margin-bottom: 0.5rem;
|
|
}
|
|
|
|
.auth-subtitle {
|
|
color: var(--secondary-500);
|
|
font-size: 0.875rem;
|
|
}
|
|
|
|
.form-group {
|
|
margin-bottom: 1.5rem;
|
|
}
|
|
|
|
.form-label {
|
|
display: block;
|
|
font-size: 0.875rem;
|
|
font-weight: 500;
|
|
color: var(--secondary-700);
|
|
margin-bottom: 0.5rem;
|
|
}
|
|
|
|
.form-input {
|
|
width: 100%;
|
|
padding: 0.875rem 1rem;
|
|
font-size: 0.9375rem;
|
|
border: 2px solid transparent;
|
|
border-radius: 12px;
|
|
background: #f1f5f9;
|
|
transition: all 0.3s ease;
|
|
}
|
|
|
|
.form-input:focus {
|
|
outline: none;
|
|
background: white;
|
|
border-color: var(--primary-500);
|
|
box-shadow: 0 0 0 4px var(--primary-100);
|
|
}
|
|
|
|
.code-group {
|
|
display: flex;
|
|
gap: 0.75rem;
|
|
}
|
|
|
|
.code-input {
|
|
flex: 1;
|
|
}
|
|
|
|
.code-btn {
|
|
padding: 0.875rem 1.5rem;
|
|
white-space: nowrap;
|
|
}
|
|
|
|
.submit-btn {
|
|
width: 100%;
|
|
padding: 1rem;
|
|
font-size: 1rem;
|
|
font-weight: 600;
|
|
border-radius: 12px;
|
|
background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
|
|
color: white;
|
|
border: none;
|
|
cursor: pointer;
|
|
transition: all 0.3s ease;
|
|
box-shadow: 0 10px 20px -5px rgba(79, 70, 229, 0.4);
|
|
}
|
|
|
|
.submit-btn:hover:not(:disabled) {
|
|
transform: translateY(-2px);
|
|
box-shadow: 0 15px 30px -5px rgba(79, 70, 229, 0.5);
|
|
}
|
|
|
|
.submit-btn:disabled {
|
|
opacity: 0.6;
|
|
cursor: not-allowed;
|
|
transform: none;
|
|
}
|
|
|
|
.auth-footer {
|
|
text-align: center;
|
|
margin-top: 1.5rem;
|
|
padding-top: 1.5rem;
|
|
border-top: 1px solid var(--secondary-200);
|
|
}
|
|
|
|
.auth-link {
|
|
color: var(--primary-600);
|
|
text-decoration: none;
|
|
font-weight: 500;
|
|
transition: color 0.2s;
|
|
}
|
|
|
|
.auth-link:hover {
|
|
color: var(--primary-700);
|
|
}
|
|
|
|
.back-home {
|
|
display: inline-block;
|
|
margin-top: 1rem;
|
|
color: var(--secondary-500);
|
|
text-decoration: none;
|
|
font-size: 0.875rem;
|
|
}
|
|
|
|
.back-home:hover {
|
|
color: var(--secondary-700);
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="auth-container">
|
|
<div class="auth-header">
|
|
<h1 class="auth-title">创建账号</h1>
|
|
<p class="auth-subtitle">注册后享受更多解析次数</p>
|
|
</div>
|
|
|
|
<form id="registerForm">
|
|
<div class="form-group">
|
|
<label class="form-label">用户名</label>
|
|
<input type="text" id="username" class="form-input" placeholder="请输入用户名" required>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label class="form-label">邮箱地址</label>
|
|
<input type="email" id="email" class="form-input" placeholder="your@email.com" required>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label class="form-label">邮箱验证码</label>
|
|
<div class="code-group">
|
|
<input type="text" id="code" class="form-input code-input" placeholder="请输入验证码" required>
|
|
<button type="button" class="ui-btn ui-btn-secondary code-btn" id="sendCodeBtn" onclick="sendCode()">
|
|
发送验证码
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label class="form-label">密码</label>
|
|
<input type="password" id="password" class="form-input" placeholder="至少6位字符" required>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label class="form-label">确认密码</label>
|
|
<input type="password" id="confirmPassword" class="form-input" placeholder="再次输入密码" required>
|
|
</div>
|
|
|
|
<button type="submit" class="submit-btn">立即注册</button>
|
|
</form>
|
|
|
|
<div class="auth-footer">
|
|
<span class="text-muted text-sm">已有账号?</span>
|
|
<a href="/auth/login" class="auth-link">立即登录</a>
|
|
<br>
|
|
<a href="/" class="back-home">← 返回首页</a>
|
|
</div>
|
|
</div>
|
|
|
|
<script src="/static/js/ui-components.js"></script>
|
|
<script>
|
|
let countdown = 0;
|
|
let timer = null;
|
|
|
|
async function sendCode() {
|
|
const email = document.getElementById('email').value.trim();
|
|
if (!email) {
|
|
UI.notify('请先输入邮箱地址', 'warning');
|
|
return;
|
|
}
|
|
|
|
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
if (!emailRegex.test(email)) {
|
|
UI.notify('邮箱格式不正确', 'error');
|
|
return;
|
|
}
|
|
|
|
const btn = document.getElementById('sendCodeBtn');
|
|
btn.disabled = true;
|
|
|
|
try {
|
|
const response = await fetch('/auth/send-code', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ email, purpose: 'register' })
|
|
});
|
|
|
|
const result = await response.json();
|
|
|
|
if (result.success) {
|
|
UI.notify('验证码已发送,请查收邮件', 'success');
|
|
startCountdown();
|
|
} else {
|
|
UI.notify(result.message || '发送失败', 'error');
|
|
btn.disabled = false;
|
|
}
|
|
} catch (error) {
|
|
UI.notify('网络错误,请稍后重试', 'error');
|
|
btn.disabled = false;
|
|
}
|
|
}
|
|
|
|
function startCountdown() {
|
|
countdown = 60;
|
|
const btn = document.getElementById('sendCodeBtn');
|
|
|
|
timer = setInterval(() => {
|
|
countdown--;
|
|
btn.textContent = `${countdown}秒后重试`;
|
|
|
|
if (countdown <= 0) {
|
|
clearInterval(timer);
|
|
btn.textContent = '发送验证码';
|
|
btn.disabled = false;
|
|
}
|
|
}, 1000);
|
|
}
|
|
|
|
document.getElementById('registerForm').addEventListener('submit', async (e) => {
|
|
e.preventDefault();
|
|
|
|
const username = document.getElementById('username').value.trim();
|
|
const email = document.getElementById('email').value.trim();
|
|
const code = document.getElementById('code').value.trim();
|
|
const password = document.getElementById('password').value;
|
|
const confirmPassword = document.getElementById('confirmPassword').value;
|
|
|
|
if (password !== confirmPassword) {
|
|
UI.notify('两次输入的密码不一致', 'error');
|
|
return;
|
|
}
|
|
|
|
if (password.length < 6) {
|
|
UI.notify('密码长度至少6位', 'error');
|
|
return;
|
|
}
|
|
|
|
const submitBtn = e.target.querySelector('.submit-btn');
|
|
submitBtn.disabled = true;
|
|
submitBtn.textContent = '注册中...';
|
|
|
|
try {
|
|
const response = await fetch('/auth/register', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ username, email, password, code })
|
|
});
|
|
|
|
const result = await response.json();
|
|
|
|
if (result.success) {
|
|
UI.notify('注册成功!即将跳转到登录页...', 'success');
|
|
setTimeout(() => {
|
|
window.location.href = '/auth/login';
|
|
}, 1500);
|
|
} else {
|
|
UI.notify(result.message || '注册失败', 'error');
|
|
submitBtn.disabled = false;
|
|
submitBtn.textContent = '立即注册';
|
|
}
|
|
} catch (error) {
|
|
UI.notify('网络错误,请稍后重试', 'error');
|
|
submitBtn.disabled = false;
|
|
submitBtn.textContent = '立即注册';
|
|
}
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|