138 wiersze
4.4 KiB
HTML
138 wiersze
4.4 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>登录 - 网络拓扑发现系统</title>
|
|
<style>
|
|
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
body {
|
|
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
min-height: 100vh;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
}
|
|
.login-card {
|
|
background: white;
|
|
border-radius: 12px;
|
|
box-shadow: 0 20px 60px rgba(0,0,0,0.3);
|
|
padding: 50px 40px;
|
|
width: 400px;
|
|
max-width: 90vw;
|
|
}
|
|
.login-card h1 {
|
|
text-align: center;
|
|
margin-bottom: 10px;
|
|
font-size: 24px;
|
|
color: #333;
|
|
}
|
|
.login-card p {
|
|
text-align: center;
|
|
color: #999;
|
|
margin-bottom: 30px;
|
|
font-size: 14px;
|
|
}
|
|
.form-group {
|
|
margin-bottom: 20px;
|
|
}
|
|
.form-group label {
|
|
display: block;
|
|
margin-bottom: 6px;
|
|
color: #555;
|
|
font-weight: 500;
|
|
}
|
|
.form-group input {
|
|
width: 100%;
|
|
padding: 12px 16px;
|
|
border: 2px solid #e0e0e0;
|
|
border-radius: 8px;
|
|
font-size: 15px;
|
|
transition: border-color 0.3s;
|
|
outline: none;
|
|
}
|
|
.form-group input:focus {
|
|
border-color: #667eea;
|
|
}
|
|
.login-btn {
|
|
width: 100%;
|
|
padding: 14px;
|
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
color: white;
|
|
border: none;
|
|
border-radius: 8px;
|
|
font-size: 16px;
|
|
font-weight: 600;
|
|
cursor: pointer;
|
|
transition: opacity 0.3s;
|
|
}
|
|
.login-btn:hover {
|
|
opacity: 0.9;
|
|
}
|
|
.login-btn:disabled {
|
|
opacity: 0.6;
|
|
cursor: not-allowed;
|
|
}
|
|
.error-msg {
|
|
color: #f44336;
|
|
text-align: center;
|
|
margin-top: 15px;
|
|
font-size: 14px;
|
|
display: none;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="login-card">
|
|
<h1>🌐 网络拓扑发现系统</h1>
|
|
<p>请登录以继续</p>
|
|
<form id="login-form">
|
|
<div class="form-group">
|
|
<label for="username">用户名</label>
|
|
<input type="text" id="username" name="username" required autofocus placeholder="请输入用户名">
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="password">密码</label>
|
|
<input type="password" id="password" name="password" required placeholder="请输入密码">
|
|
</div>
|
|
<button type="submit" class="login-btn" id="login-btn">登 录</button>
|
|
<div class="error-msg" id="error-msg"></div>
|
|
</form>
|
|
</div>
|
|
<script>
|
|
document.getElementById('login-form').addEventListener('submit', async function(e) {
|
|
e.preventDefault();
|
|
var btn = document.getElementById('login-btn');
|
|
var errEl = document.getElementById('error-msg');
|
|
btn.disabled = true;
|
|
btn.textContent = '登录中...';
|
|
errEl.style.display = 'none';
|
|
|
|
var username = document.getElementById('username').value;
|
|
var password = document.getElementById('password').value;
|
|
|
|
try {
|
|
var resp = await fetch('/api/login', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ username: username, password: password })
|
|
});
|
|
var data = await resp.json();
|
|
if (resp.ok && data.success) {
|
|
window.location.href = '/';
|
|
} else {
|
|
errEl.textContent = data.message || '登录失败';
|
|
errEl.style.display = 'block';
|
|
}
|
|
} catch (err) {
|
|
errEl.textContent = '网络错误,请重试';
|
|
errEl.style.display = 'block';
|
|
}
|
|
btn.disabled = false;
|
|
btn.textContent = '登 录';
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|