66 lines
2.2 KiB
HTML
66 lines
2.2 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>管理登录 - ResLib License</title>
|
||
|
|
<link rel="stylesheet" href="/static/css/style.css">
|
||
|
|
<link rel="icon" href="/static/img/logo.svg" type="image/svg+xml">
|
||
|
|
</head>
|
||
|
|
<body style="background: #f4f8fd;">
|
||
|
|
|
||
|
|
<main style="display:flex; align-items:center; justify-content:center; min-height:100vh;">
|
||
|
|
<div style="width:100%; max-width:360px; padding:0 20px;">
|
||
|
|
<div style="text-align:center; margin-bottom:22px;">
|
||
|
|
<img src="/static/img/logo.svg" alt="ResLib" style="width:48px; height:48px;">
|
||
|
|
<h1 style="font-size:1.25rem; color:var(--blue-dark); margin-top:10px;">ResLib License 管理后台</h1>
|
||
|
|
</div>
|
||
|
|
<div class="form-card" style="margin-top:0;">
|
||
|
|
<div class="form-group">
|
||
|
|
<label for="password">管理密码</label>
|
||
|
|
<input type="password" id="password" autocomplete="current-password">
|
||
|
|
</div>
|
||
|
|
<button type="button" id="login" class="btn btn-primary btn-block">登 录</button>
|
||
|
|
<div id="result"></div>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
</main>
|
||
|
|
|
||
|
|
<script>
|
||
|
|
(function () {
|
||
|
|
var btn = document.getElementById("login");
|
||
|
|
var result = document.getElementById("result");
|
||
|
|
|
||
|
|
btn.addEventListener("click", async function () {
|
||
|
|
var password = document.getElementById("password").value;
|
||
|
|
btn.disabled = true;
|
||
|
|
btn.textContent = "登录中…";
|
||
|
|
try {
|
||
|
|
var resp = await fetch("/api/admin/login", {
|
||
|
|
method: "POST",
|
||
|
|
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
||
|
|
body: "password=" + encodeURIComponent(password)
|
||
|
|
});
|
||
|
|
var data = await resp.json();
|
||
|
|
if (resp.ok) {
|
||
|
|
window.location.href = "/admin";
|
||
|
|
} else {
|
||
|
|
result.className = "alert show alert-err";
|
||
|
|
result.textContent = data.detail || "登录失败";
|
||
|
|
}
|
||
|
|
} catch (e) {
|
||
|
|
result.className = "alert show alert-err";
|
||
|
|
result.textContent = "网络错误:" + e.message;
|
||
|
|
}
|
||
|
|
btn.disabled = false;
|
||
|
|
btn.textContent = "登 录";
|
||
|
|
});
|
||
|
|
|
||
|
|
document.getElementById("password").addEventListener("keydown", function (e) {
|
||
|
|
if (e.key === "Enter") btn.click();
|
||
|
|
});
|
||
|
|
})();
|
||
|
|
</script>
|
||
|
|
</body>
|
||
|
|
</html>
|