CloudVaultclass / templates /login.html
lexlepty's picture
Create templates/login.html
871e6df verified
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>登录 - 云存储</title>
<style>
:root {
--primary-glow: #ff9580;
--secondary-glow: #ffd700;
--background: #ffffff;
--text: #333333;
--card-bg: #ffffff;
--border-color: #e0e0e0;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
background: var(--background);
color: var(--text);
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
}
.login-container {
background: var(--card-bg);
padding: 40px;
border-radius: 15px;
box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1);
width: 100%;
max-width: 400px;
transition: all 0.3s ease;
}
.login-container:hover {
transform: translateY(-5px);
box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}
.login-title {
text-align: center;
margin-bottom: 30px;
font-size: 24px;
color: var(--text);
}
.login-form {
display: flex;
flex-direction: column;
gap: 20px;
}
.password-input {
width: 100%;
padding: 12px 20px;
border: 2px solid var(--border-color);
border-radius: 25px;
font-size: 16px;
transition: all 0.3s ease;
}
.password-input:focus {
outline: none;
border-color: var(--primary-glow);
box-shadow: 0 0 10px rgba(255, 149, 128, 0.3);
}
.login-button {
width: 100%;
padding: 12px 20px;
border: none;
border-radius: 25px;
background: linear-gradient(45deg, var(--primary-glow), var(--secondary-glow));
color: white;
font-size: 16px;
cursor: pointer;
transition: all 0.3s ease;
}
.login-button:hover {
transform: translateY(-2px);
box-shadow: 0 5px 15px rgba(255, 149, 128, 0.4);
}
.error-message {
color: #ff4444;
text-align: center;
margin-top: 10px;
display: none;
}
</style>
</head>
<body>
<div class="login-container">
<h1 class="login-title"> Cloud Vault的登录界面</h1>
<p class="login-title">没错在这输一下密码,密码1234</p>
<form class="login-form" id="loginForm">
<input type="password" class="password-input" placeholder="请输入访问密码" required>
<button type="submit" class="login-button">登录</button>
</form>
<div class="error-message" id="errorMessage">密码错误,请重试</div>
</div>
<script>
document.getElementById('loginForm').addEventListener('submit', async (e) => {
e.preventDefault();
const password = document.querySelector('.password-input').value;
const errorMessage = document.getElementById('errorMessage');
try {
const response = await fetch('/login', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
body: `password=${encodeURIComponent(password)}`
});
if (response.ok) {
window.location.href = '/';
} else {
errorMessage.style.display = 'block';
}
} catch (error) {
console.error('Login failed:', error);
errorMessage.style.display = 'block';
}
});
</script>
</body>
</html>