Files
StarlightRadio/public/login.html
T

142 lines
4.5 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>
<link rel="icon" href="/favicon.ico" type="image/x-icon" />
<style>
:root {
--bg: #0d1117;
--panel: #161b22;
--border: #30363d;
--text: #e6edf3;
--muted: #8b949e;
--accent: #1f6feb;
--accent-hover: #388bfd;
--danger: #f85149;
}
* { box-sizing: border-box; }
body {
margin: 0;
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
background: radial-gradient(circle at 30% 20%, #1a2332, var(--bg) 60%);
color: var(--text);
font-family: "Segoe UI", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
}
.card {
width: 100%;
max-width: 380px;
background: var(--panel);
border: 1px solid var(--border);
border-radius: 16px;
padding: 40px 32px;
box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.logo {
text-align: center;
font-size: 40px;
margin-bottom: 8px;
}
h1 {
text-align: center;
font-size: 20px;
margin: 0 0 4px;
font-weight: 600;
}
.sub {
text-align: center;
color: var(--muted);
font-size: 13px;
margin-bottom: 28px;
}
label {
display: block;
font-size: 13px;
color: var(--muted);
margin-bottom: 8px;
}
input[type="password"] {
width: 100%;
padding: 12px 14px;
background: var(--bg);
border: 1px solid var(--border);
border-radius: 8px;
color: var(--text);
font-size: 15px;
outline: none;
transition: border-color .15s;
}
input[type="password"]:focus { border-color: var(--accent); }
button {
width: 100%;
margin-top: 20px;
padding: 12px;
background: var(--accent);
border: none;
border-radius: 8px;
color: #fff;
font-size: 15px;
font-weight: 600;
cursor: pointer;
transition: background .15s;
}
button:hover { background: var(--accent-hover); }
button:disabled { opacity: .6; cursor: default; }
.error {
margin-top: 14px;
color: var(--danger);
font-size: 13px;
text-align: center;
min-height: 18px;
}
</style>
</head>
<body>
<div class="card">
<div class="logo">🎵</div>
<h1>音乐在线电台</h1>
<div class="sub">请输入访问密码</div>
<form id="loginForm">
<label for="password">密码</label>
<input type="password" id="password" autocomplete="current-password" autofocus />
<button type="submit" id="submitBtn">登录</button>
</form>
<div class="error" id="error"></div>
</div>
<script>
const form = document.getElementById("loginForm");
const input = document.getElementById("password");
const btn = document.getElementById("submitBtn");
const err = document.getElementById("error");
form.addEventListener("submit", async (e) => {
e.preventDefault();
const password = input.value;
if (!password) return;
btn.disabled = true;
err.textContent = "";
try {
const r = await fetch("/api/auth/login", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ password }),
});
const data = await r.json();
if (r.ok && data.ok) {
window.location.href = "/";
} else {
err.textContent = data.error || "登录失败";
btn.disabled = false;
}
} catch (e) {
err.textContent = "网络错误,请重试";
btn.disabled = false;
}
});
</script>
</body>
</html>