72 lines
2.6 KiB
HTML
72 lines
2.6 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="zh-CN">
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
<title>登录 · 复盘系统中控</title>
|
|
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
|
<link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&family=Orbitron:wght@500;600;700&display=swap" rel="stylesheet" />
|
|
<link rel="stylesheet" href="/assets/app.css" />
|
|
</head>
|
|
<body class="login-page">
|
|
<div class="login-bg" aria-hidden="true"></div>
|
|
<div class="login-panel">
|
|
<div class="login-brand">
|
|
<span class="brand-mark"></span>
|
|
<div>
|
|
<div class="login-title">复盘系统中控</div>
|
|
<div class="login-sub">CRYPTO MONITOR · COMMAND</div>
|
|
</div>
|
|
</div>
|
|
<form id="login-form" class="login-form" autocomplete="on">
|
|
<label class="field">
|
|
<span>访问密码</span>
|
|
<input type="password" name="password" id="login-password" required autofocus placeholder="HUB_PASSWORD" />
|
|
</label>
|
|
<button type="submit" class="primary login-submit">进入系统</button>
|
|
<p id="login-err" class="login-err" hidden></p>
|
|
</form>
|
|
<p class="login-foot">反代暴露公网时请在 hub <code>.env</code> 设置 <code>HUB_PASSWORD</code></p>
|
|
</div>
|
|
<script>
|
|
(function () {
|
|
const form = document.getElementById("login-form");
|
|
const err = document.getElementById("login-err");
|
|
const params = new URLSearchParams(location.search);
|
|
const next = params.get("next") || "/monitor";
|
|
|
|
form.onsubmit = async (e) => {
|
|
e.preventDefault();
|
|
err.hidden = true;
|
|
const pwd = document.getElementById("login-password").value;
|
|
try {
|
|
const r = await fetch("/api/auth/login", {
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json" },
|
|
body: JSON.stringify({ password: pwd }),
|
|
});
|
|
const j = await r.json();
|
|
if (j.ok) {
|
|
location.href = next.startsWith("/") ? next : "/monitor";
|
|
return;
|
|
}
|
|
err.textContent = j.detail || j.msg || "密码错误";
|
|
err.hidden = false;
|
|
} catch (ex) {
|
|
err.textContent = String(ex);
|
|
err.hidden = false;
|
|
}
|
|
};
|
|
|
|
fetch("/api/auth/status")
|
|
.then((r) => r.json())
|
|
.then((s) => {
|
|
if (!s.required || s.logged_in) location.href = next;
|
|
})
|
|
.catch(() => {});
|
|
})();
|
|
</script>
|
|
</body>
|
|
</html>
|