152 lines
4.6 KiB
HTML
152 lines
4.6 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: #f8f2ec;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
height: 100vh;
|
|
}
|
|
.login-card {
|
|
width: 360px;
|
|
padding: 32px 28px;
|
|
background: #fffefc;
|
|
border-radius: 18px;
|
|
box-shadow: 0 16px 45px rgba(118, 103, 84, 0.18);
|
|
text-align: center;
|
|
}
|
|
h1 {
|
|
margin-top: 0;
|
|
font-size: 1.5rem;
|
|
color: #4b392c;
|
|
}
|
|
.form-group {
|
|
text-align: left;
|
|
margin-top: 18px;
|
|
}
|
|
label {
|
|
font-size: 0.85rem;
|
|
color: #6c5a4a;
|
|
display: block;
|
|
margin-bottom: 6px;
|
|
}
|
|
input[type="text"],
|
|
input[type="password"],
|
|
input[type="email"] {
|
|
width: 100%;
|
|
min-height: 48px;
|
|
padding: 12px 14px;
|
|
border-radius: 12px;
|
|
border: 1px solid rgba(118, 103, 84, 0.3);
|
|
font-size: 0.95rem;
|
|
box-sizing: border-box;
|
|
transition: border-color 0.2s ease, box-shadow 0.2s ease;
|
|
}
|
|
input[type="text"]:focus,
|
|
input[type="password"]:focus,
|
|
input[type="email"]:focus {
|
|
outline: none;
|
|
border-color: #d8894c;
|
|
box-shadow: 0 0 0 3px rgba(216, 137, 76, 0.2);
|
|
}
|
|
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="login-card">
|
|
<h1>AI Agent 登录</h1>
|
|
<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="current-password" />
|
|
</div>
|
|
<button id="login-btn">登录</button>
|
|
<div class="error" id="error"></div>
|
|
<div class="link">
|
|
还没有账号?<a href="/register">点击注册</a>
|
|
</div>
|
|
</div>
|
|
<script>
|
|
const btn = document.getElementById('login-btn');
|
|
const errorEl = document.getElementById('error');
|
|
|
|
btn.addEventListener('click', async () => {
|
|
const email = document.getElementById('email').value.trim();
|
|
const password = document.getElementById('password').value;
|
|
if (!email || !password) {
|
|
errorEl.textContent = '请输入邮箱和密码';
|
|
return;
|
|
}
|
|
btn.disabled = true;
|
|
errorEl.textContent = '';
|
|
try {
|
|
const resp = await fetch('/login', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ email, password })
|
|
});
|
|
if (resp.status === 503) {
|
|
window.location.href = '/resource_busy';
|
|
return;
|
|
}
|
|
const data = await resp.json();
|
|
if (data.success) {
|
|
window.location.href = '/';
|
|
} else {
|
|
errorEl.textContent = data.error || '登录失败';
|
|
}
|
|
} catch (err) {
|
|
errorEl.textContent = '网络错误,请重试';
|
|
} finally {
|
|
btn.disabled = false;
|
|
}
|
|
});
|
|
|
|
document.addEventListener('keydown', (e) => {
|
|
if (e.key === 'Enter') {
|
|
btn.click();
|
|
}
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|