194 lines
6.2 KiB
HTML
194 lines
6.2 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>登录 - 风铃认证服务</title>
|
|
<style>
|
|
* {
|
|
margin: 0;
|
|
padding: 0;
|
|
box-sizing: border-box;
|
|
}
|
|
body {
|
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
min-height: 100vh;
|
|
}
|
|
.container {
|
|
background: white;
|
|
border-radius: 8px;
|
|
box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
|
|
padding: 40px;
|
|
width: 100%;
|
|
max-width: 400px;
|
|
}
|
|
h1 {
|
|
text-align: center;
|
|
color: #333;
|
|
margin-bottom: 30px;
|
|
font-size: 24px;
|
|
}
|
|
.form-group {
|
|
margin-bottom: 20px;
|
|
}
|
|
label {
|
|
display: block;
|
|
margin-bottom: 8px;
|
|
color: #555;
|
|
font-weight: 500;
|
|
}
|
|
input[type="text"],
|
|
input[type="password"] {
|
|
width: 100%;
|
|
padding: 12px;
|
|
border: 1px solid #ddd;
|
|
border-radius: 4px;
|
|
font-size: 14px;
|
|
box-sizing: border-box;
|
|
}
|
|
input[type="text"]:focus,
|
|
input[type="password"]:focus {
|
|
outline: none;
|
|
border-color: #667eea;
|
|
}
|
|
.remember-me {
|
|
display: flex;
|
|
align-items: center;
|
|
margin-bottom: 20px;
|
|
}
|
|
.remember-me input {
|
|
margin-right: 8px;
|
|
}
|
|
button {
|
|
width: 100%;
|
|
padding: 12px;
|
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
color: white;
|
|
border: none;
|
|
border-radius: 4px;
|
|
font-size: 16px;
|
|
cursor: pointer;
|
|
font-weight: 600;
|
|
}
|
|
button:hover {
|
|
opacity: 0.9;
|
|
}
|
|
button:disabled {
|
|
opacity: 0.6;
|
|
cursor: not-allowed;
|
|
}
|
|
.error {
|
|
background: #fee;
|
|
color: #c33;
|
|
padding: 12px;
|
|
border-radius: 4px;
|
|
margin-bottom: 20px;
|
|
font-size: 14px;
|
|
}
|
|
.loading {
|
|
display: inline-block;
|
|
width: 14px;
|
|
height: 14px;
|
|
border: 2px solid rgba(255, 255, 255, 0.3);
|
|
border-radius: 50%;
|
|
border-top-color: white;
|
|
animation: spin 0.8s ease-in-out infinite;
|
|
margin-right: 8px;
|
|
vertical-align: middle;
|
|
}
|
|
@keyframes spin {
|
|
to { transform: rotate(360deg); }
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<h1>风铃认证服务</h1>
|
|
<div id="error-message" class="error" style="display: none;"></div>
|
|
<form id="login-form">
|
|
<input type="hidden" id="returnUrl" name="returnUrl">
|
|
<div class="form-group">
|
|
<label for="username">用户名</label>
|
|
<input type="text" id="username" name="username" required autofocus autocomplete="username">
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="password">密码</label>
|
|
<input type="password" id="password" name="password" required autocomplete="current-password">
|
|
</div>
|
|
<div class="remember-me">
|
|
<input type="checkbox" id="rememberMe" name="rememberMe">
|
|
<label for="rememberMe" style="margin-bottom: 0;">记住我</label>
|
|
</div>
|
|
<button type="submit" id="submit-btn">
|
|
<span id="btn-text">登录</span>
|
|
</button>
|
|
</form>
|
|
</div>
|
|
|
|
<script>
|
|
const form = document.getElementById('login-form');
|
|
const errorElement = document.getElementById('error-message');
|
|
const submitBtn = document.getElementById('submit-btn');
|
|
const btnText = document.getElementById('btn-text');
|
|
|
|
// Get returnUrl from query parameter
|
|
const urlParams = new URLSearchParams(window.location.search);
|
|
const returnUrl = urlParams.get('returnUrl') || '/';
|
|
document.getElementById('returnUrl').value = returnUrl;
|
|
|
|
form.addEventListener('submit', async (e) => {
|
|
e.preventDefault();
|
|
|
|
const username = document.getElementById('username').value;
|
|
const password = document.getElementById('password').value;
|
|
const rememberMe = document.getElementById('rememberMe').checked;
|
|
|
|
// Show loading state
|
|
submitBtn.disabled = true;
|
|
btnText.innerHTML = '<span class="loading"></span>登录中...';
|
|
|
|
try {
|
|
const response = await fetch('/account/login', {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
},
|
|
body: JSON.stringify({
|
|
username: username,
|
|
password: password,
|
|
rememberMe: rememberMe,
|
|
returnUrl: returnUrl
|
|
})
|
|
});
|
|
|
|
const data = await response.json();
|
|
|
|
if (response.ok) {
|
|
// Redirect to returnUrl
|
|
window.location.href = data.returnUrl;
|
|
} else {
|
|
// Show error
|
|
errorElement.textContent = data.error || '登录失败,请重试';
|
|
errorElement.style.display = 'block';
|
|
|
|
// Reset button
|
|
submitBtn.disabled = false;
|
|
btnText.textContent = '登录';
|
|
}
|
|
} catch (error) {
|
|
errorElement.textContent = '网络错误,请重试';
|
|
errorElement.style.display = 'block';
|
|
|
|
// Reset button
|
|
submitBtn.disabled = false;
|
|
btnText.textContent = '登录';
|
|
}
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|