177 lines
4.3 KiB
HTML
177 lines
4.3 KiB
HTML
<!DOCTYPE html>
|
||
<html lang="zh-CN">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
|
||
<title>紫微 · 登录</title>
|
||
<style>
|
||
* { margin:0; padding:0; box-sizing:border-box; }
|
||
body {
|
||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', sans-serif;
|
||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||
min-height: 100vh;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
padding: 20px;
|
||
}
|
||
.login-card {
|
||
background: #FFF;
|
||
border-radius: 16px;
|
||
padding: 40px 32px;
|
||
width: 100%;
|
||
max-width: 380px;
|
||
box-shadow: 0 20px 60px rgba(0,0,0,0.15);
|
||
}
|
||
.login-card h1 {
|
||
text-align: center;
|
||
font-size: 24px;
|
||
color: #4A6CF7;
|
||
margin-bottom: 4px;
|
||
}
|
||
.login-card .sub {
|
||
text-align: center;
|
||
font-size: 13px;
|
||
color: #9CA3AF;
|
||
margin-bottom: 28px;
|
||
}
|
||
.form-group {
|
||
margin-bottom: 18px;
|
||
}
|
||
.form-group label {
|
||
display: block;
|
||
font-size: 13px;
|
||
font-weight: 600;
|
||
color: #374151;
|
||
margin-bottom: 6px;
|
||
}
|
||
.form-group input {
|
||
width: 100%;
|
||
padding: 12px 14px;
|
||
border: 1px solid #E5E7EB;
|
||
border-radius: 10px;
|
||
font-size: 15px;
|
||
font-family: inherit;
|
||
transition: border-color .2s;
|
||
background: #F9FAFB;
|
||
}
|
||
.form-group input:focus {
|
||
outline: none;
|
||
border-color: #4A6CF7;
|
||
background: #FFF;
|
||
box-shadow: 0 0 0 3px rgba(74,108,247,0.1);
|
||
}
|
||
.remember-row {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 8px;
|
||
margin-bottom: 22px;
|
||
font-size: 13px;
|
||
color: #6B7280;
|
||
}
|
||
.remember-row input[type="checkbox"] {
|
||
width: 16px; height: 16px;
|
||
accent-color: #4A6CF7;
|
||
}
|
||
.btn-login {
|
||
width: 100%;
|
||
padding: 13px;
|
||
border: none;
|
||
background: #4A6CF7;
|
||
color: #FFF;
|
||
font-size: 16px;
|
||
font-weight: 600;
|
||
border-radius: 10px;
|
||
cursor: pointer;
|
||
transition: all .2s;
|
||
}
|
||
.btn-login:hover { opacity: 0.9; transform: translateY(-1px); }
|
||
.btn-login:active { transform: translateY(0); }
|
||
.btn-login.loading {
|
||
opacity: 0.7;
|
||
pointer-events: none;
|
||
}
|
||
.error-msg {
|
||
text-align: center;
|
||
color: #EF4444;
|
||
font-size: 13px;
|
||
margin-top: 12px;
|
||
display: none;
|
||
}
|
||
.error-msg.show { display: block; }
|
||
.footer-text {
|
||
text-align: center;
|
||
font-size: 12px;
|
||
color: #9CA3AF;
|
||
margin-top: 24px;
|
||
}
|
||
</style>
|
||
</head>
|
||
<body>
|
||
|
||
<div class="login-card">
|
||
<h1>⚡ 紫微 · 磁场管理</h1>
|
||
<p class="sub">立志不摇,责善不滥,改过不拖,勤学不辍</p>
|
||
|
||
<form id="login-form" onsubmit="doLogin(event)">
|
||
<div class="form-group">
|
||
<label>账号</label>
|
||
<input type="text" id="username" placeholder="请输入账号" autocomplete="username" required autofocus>
|
||
</div>
|
||
<div class="form-group">
|
||
<label>密码</label>
|
||
<input type="password" id="password" placeholder="请输入密码" autocomplete="current-password" required>
|
||
</div>
|
||
<div class="remember-row">
|
||
<input type="checkbox" id="remember" checked>
|
||
<label for="remember">记住登录(30 天有效)</label>
|
||
</div>
|
||
<button type="submit" class="btn-login" id="btn-login">登 录</button>
|
||
</form>
|
||
|
||
<div class="error-msg" id="error-msg"></div>
|
||
<p class="footer-text">紫微 · 天机阁磁场守护系统</p>
|
||
</div>
|
||
|
||
<script>
|
||
(function(){
|
||
'use strict';
|
||
window.doLogin = function(e) {
|
||
e.preventDefault();
|
||
var btn = document.getElementById('btn-login');
|
||
var err = document.getElementById('error-msg');
|
||
btn.classList.add('loading');
|
||
btn.textContent = '登录中…';
|
||
err.classList.remove('show');
|
||
|
||
var formData = new FormData();
|
||
formData.append('username', document.getElementById('username').value);
|
||
formData.append('password', document.getElementById('password').value);
|
||
if (document.getElementById('remember').checked) {
|
||
formData.append('remember', 'on');
|
||
}
|
||
|
||
fetch('/login', { method: 'POST', body: formData })
|
||
.then(function(r) { return r.json().then(function(d){ return {status: r.status, body: d}; }); })
|
||
.then(function(res) {
|
||
if (res.body.ok) {
|
||
window.location.href = res.body.next;
|
||
} else {
|
||
err.textContent = res.body.error || '登录失败';
|
||
err.classList.add('show');
|
||
}
|
||
})
|
||
.catch(function() {
|
||
err.textContent = '网络错误,请重试';
|
||
err.classList.add('show');
|
||
})
|
||
.finally(function() {
|
||
btn.classList.remove('loading');
|
||
btn.textContent = '登 录';
|
||
});
|
||
};
|
||
})();
|
||
</script>
|
||
</body>
|
||
</html>
|