150 lines
4.7 KiB
HTML
150 lines
4.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>注册 - AI Agent</title>
|
|
<style>
|
|
body {
|
|
margin: 0;
|
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
|
|
background: #f5f0eb;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
min-height: 100vh;
|
|
}
|
|
.register-card {
|
|
width: 380px;
|
|
padding: 32px 30px;
|
|
background: #fffefc;
|
|
border-radius: 18px;
|
|
box-shadow: 0 16px 45px rgba(118, 103, 84, 0.18);
|
|
text-align: center;
|
|
}
|
|
h1 {
|
|
margin: 0;
|
|
font-size: 1.4rem;
|
|
color: #4b392c;
|
|
}
|
|
.form-group {
|
|
text-align: left;
|
|
margin-top: 16px;
|
|
}
|
|
label {
|
|
font-size: 0.85rem;
|
|
color: #6c5a4a;
|
|
display: block;
|
|
margin-bottom: 6px;
|
|
}
|
|
input {
|
|
width: 100%;
|
|
padding: 10px 12px;
|
|
border-radius: 10px;
|
|
border: 1px solid rgba(118, 103, 84, 0.3);
|
|
font-size: 0.95rem;
|
|
box-sizing: border-box;
|
|
}
|
|
button {
|
|
margin-top: 22px;
|
|
width: 100%;
|
|
padding: 12px;
|
|
border: none;
|
|
border-radius: 999px;
|
|
background: #d8894c;
|
|
color: #fff;
|
|
font-size: 1rem;
|
|
cursor: pointer;
|
|
}
|
|
button:disabled {
|
|
opacity: 0.6;
|
|
cursor: not-allowed;
|
|
}
|
|
.error {
|
|
margin-top: 14px;
|
|
color: #c0392b;
|
|
font-size: 0.85rem;
|
|
min-height: 1em;
|
|
}
|
|
.link {
|
|
margin-top: 18px;
|
|
font-size: 0.85rem;
|
|
color: #6c5a4a;
|
|
}
|
|
.link a {
|
|
color: #d8894c;
|
|
text-decoration: none;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="register-card">
|
|
<h1>创建账号</h1>
|
|
<div class="form-group">
|
|
<label for="username">用户名</label>
|
|
<input type="text" id="username" placeholder="仅限小写字母/数字/下划线" autocomplete="username" />
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="email">邮箱</label>
|
|
<input type="email" id="email" autocomplete="email" />
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="password">密码</label>
|
|
<input type="password" id="password" autocomplete="new-password" />
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="invite">邀请码</label>
|
|
<input type="text" id="invite" placeholder="必填" autocomplete="off" />
|
|
</div>
|
|
<button id="register-btn">注册</button>
|
|
<div class="error" id="error"></div>
|
|
<div class="link">
|
|
已有账号?<a href="/login">返回登录</a>
|
|
</div>
|
|
</div>
|
|
<script>
|
|
const btn = document.getElementById('register-btn');
|
|
const errorEl = document.getElementById('error');
|
|
|
|
async function register() {
|
|
const username = document.getElementById('username').value.trim();
|
|
const email = document.getElementById('email').value.trim();
|
|
const password = document.getElementById('password').value;
|
|
const invite = document.getElementById('invite').value.trim();
|
|
|
|
if (!username || !email || !password || !invite) {
|
|
errorEl.textContent = '请完整填写所有字段';
|
|
return;
|
|
}
|
|
|
|
btn.disabled = true;
|
|
errorEl.textContent = '';
|
|
try {
|
|
const resp = await fetch('/register', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ username, email, password, invite_code: invite })
|
|
});
|
|
const data = await resp.json();
|
|
if (data.success) {
|
|
window.location.href = '/login';
|
|
} else {
|
|
errorEl.textContent = data.error || '注册失败';
|
|
}
|
|
} catch (err) {
|
|
errorEl.textContent = '网络错误,请稍后再试';
|
|
} finally {
|
|
btn.disabled = false;
|
|
}
|
|
}
|
|
|
|
btn.addEventListener('click', register);
|
|
document.addEventListener('keydown', (e) => {
|
|
if (e.key === 'Enter') {
|
|
register();
|
|
}
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|