施工(HEL-226): 实现登录门户与本机免密切换账号
用设备 Cookie 和授权表记住本机已验证账号,登录页按确认样图做成门户,不再把密码写进浏览器。 Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
co-authored by
Cursor
multica-agent
parent
8a5e78f022
commit
f0a1adf52f
+4
-2
@@ -25,8 +25,10 @@ async function initialize() {
|
||||
try {
|
||||
const session = await apiRequest("/api/auth/me");
|
||||
if (!session.authenticated) {
|
||||
if (session.registration_required) selectAuthMode("register");
|
||||
showAuthGate();
|
||||
const params = new URLSearchParams();
|
||||
if (session.registration_required) params.set("mode", "register");
|
||||
const query = params.toString();
|
||||
window.location.replace("/login/" + (query ? `?${query}` : ""));
|
||||
return;
|
||||
}
|
||||
await applyAuthenticatedSession(session);
|
||||
|
||||
+6
-4
@@ -24,7 +24,9 @@
|
||||
(() => {
|
||||
let theme = "light";
|
||||
try {
|
||||
theme = localStorage.getItem("xiaobaiTheme") === "dark" ? "dark" : "light";
|
||||
const stored = localStorage.getItem("xiaobaiTheme");
|
||||
if (stored === "dark" || stored === "light") theme = stored;
|
||||
else if (window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches) theme = "dark";
|
||||
} catch (_error) {
|
||||
theme = "light";
|
||||
}
|
||||
@@ -32,10 +34,10 @@
|
||||
document.documentElement.style.colorScheme = theme;
|
||||
})();
|
||||
</script>
|
||||
<link rel="stylesheet" href="/shared/tokens.css?v=20260820-3">
|
||||
<link rel="stylesheet" href="/shared/tokens.css?v=20260829-1">
|
||||
<link rel="stylesheet" href="/shared/base.css?v=20260806-1">
|
||||
<link rel="stylesheet" href="/shared/shell.css?v=20260820-8">
|
||||
<link rel="stylesheet" href="/shared/auth.css?v=20260820-5">
|
||||
<link rel="stylesheet" href="/shared/auth.css?v=20260829-1">
|
||||
<link rel="stylesheet" href="/shared/components/controls.css?v=20260820-2">
|
||||
<link rel="stylesheet" href="/shared/components/navigation.css?v=20260820-1">
|
||||
<link rel="stylesheet" href="/shared/components/cards.css?v=20260820-1">
|
||||
@@ -57,7 +59,7 @@
|
||||
<link rel="stylesheet" href="/pages/review/foundation.css?v=20260820-4">
|
||||
</head>
|
||||
<body>
|
||||
<section id="authGate" class="auth-gate" aria-label="账号登录">
|
||||
<section id="authGate" class="auth-gate" aria-label="账号登录" hidden>
|
||||
<div class="auth-shell">
|
||||
<div class="auth-brand">
|
||||
<div class="brand-mark" aria-hidden="true"><span class="brand-glyph">复</span></div>
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
<!doctype html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="color-scheme" content="light dark">
|
||||
<title>登录 · 小白复盘</title>
|
||||
<script>
|
||||
(() => {
|
||||
let theme = "light";
|
||||
try {
|
||||
const stored = localStorage.getItem("xiaobaiTheme");
|
||||
if (stored === "dark" || stored === "light") theme = stored;
|
||||
else if (window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches) theme = "dark";
|
||||
} catch (_error) {
|
||||
theme = "light";
|
||||
}
|
||||
document.documentElement.dataset.theme = theme;
|
||||
document.documentElement.style.colorScheme = theme;
|
||||
})();
|
||||
</script>
|
||||
<link rel="stylesheet" href="/shared/tokens.css?v=20260829-1">
|
||||
<link rel="stylesheet" href="/shared/base.css?v=20260806-1">
|
||||
<link rel="stylesheet" href="/shared/auth.css?v=20260829-1">
|
||||
<link rel="stylesheet" href="/shared/components/controls.css?v=20260820-2">
|
||||
</head>
|
||||
<body class="login-portal">
|
||||
<button id="loginThemeToggle" class="login-theme-toggle" type="button">🌙 夜间</button>
|
||||
<aside class="login-brand" aria-hidden="true">
|
||||
<div class="login-brand-mark"><span class="login-brand-glyph">复</span></div>
|
||||
<p class="login-brand-kicker">收盘之后 · 复盘开始</p>
|
||||
<h1 class="login-brand-title">小白复盘</h1>
|
||||
<p class="login-brand-lead">看懂情绪周期,把复盘变成下一次的先手。</p>
|
||||
<dl class="login-brand-stats">
|
||||
<div class="login-stat">
|
||||
<dt>市场情绪</dt>
|
||||
<dd>72 <span class="login-stat-tag">高热</span></dd>
|
||||
</div>
|
||||
<div class="login-stat">
|
||||
<dt>涨停</dt>
|
||||
<dd>63</dd>
|
||||
</div>
|
||||
<div class="login-stat">
|
||||
<dt>跌停</dt>
|
||||
<dd>4</dd>
|
||||
</div>
|
||||
<div class="login-stat">
|
||||
<dt>两市成交</dt>
|
||||
<dd>1.02万亿</dd>
|
||||
</div>
|
||||
</dl>
|
||||
</aside>
|
||||
<main class="login-stage">
|
||||
<section class="login-card" id="loginCard" aria-live="polite"></section>
|
||||
</main>
|
||||
<script src="/shared/api.js?v=20260803-2"></script>
|
||||
<script src="/login/page.js?v=20260829-1"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,273 @@
|
||||
(function bootLoginPortal(global) {
|
||||
"use strict";
|
||||
|
||||
const THEME_KEY = "xiaobaiTheme";
|
||||
const api = global.XiaobaiAPI;
|
||||
const card = document.querySelector("#loginCard");
|
||||
const themeButton = document.querySelector("#loginThemeToggle");
|
||||
const state = {
|
||||
view: "first",
|
||||
mode: "login",
|
||||
accounts: [],
|
||||
currentUserId: null,
|
||||
loading: false,
|
||||
confirmingId: null,
|
||||
error: "",
|
||||
};
|
||||
|
||||
function escapeHtml(value) {
|
||||
return String(value ?? "").replace(/[&<>"']/g, (ch) => (
|
||||
{ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" }[ch]
|
||||
));
|
||||
}
|
||||
|
||||
function preferredTheme() {
|
||||
try {
|
||||
const stored = global.localStorage.getItem(THEME_KEY);
|
||||
if (stored === "dark" || stored === "light") return stored;
|
||||
} catch (_error) {
|
||||
// Fall through to the system preference.
|
||||
}
|
||||
return global.matchMedia && global.matchMedia("(prefers-color-scheme: dark)").matches
|
||||
? "dark"
|
||||
: "light";
|
||||
}
|
||||
|
||||
function applyTheme(theme, persist) {
|
||||
const normalized = theme === "dark" ? "dark" : "light";
|
||||
document.documentElement.dataset.theme = normalized;
|
||||
document.documentElement.style.colorScheme = normalized;
|
||||
themeButton.textContent = normalized === "dark" ? "☀ 日间" : "🌙 夜间";
|
||||
themeButton.setAttribute("aria-label", normalized === "dark" ? "切换到日间模式" : "切换到夜间模式");
|
||||
if (persist) {
|
||||
try {
|
||||
global.localStorage.setItem(THEME_KEY, normalized);
|
||||
} catch (_error) {
|
||||
// Theme still applies for the current page when storage is unavailable.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function setError(message) {
|
||||
state.error = message || "";
|
||||
}
|
||||
|
||||
function membershipLabel(account) {
|
||||
if (account.role === "admin") return account.membership?.subscribed ? "管理员 · 会员" : "管理员";
|
||||
return account.membership?.subscribed ? "会员" : "普通用户";
|
||||
}
|
||||
|
||||
function enterApp() {
|
||||
const next = new URLSearchParams(global.location.search).get("next");
|
||||
global.location.replace(next && next.startsWith("/") ? next : "/");
|
||||
}
|
||||
|
||||
function formMarkup(options) {
|
||||
const registering = state.mode === "register";
|
||||
const submitLabel = options.submitLabel
|
||||
|| (state.loading ? "正在登录..." : registering ? "注册并进入" : options.add ? "添加并进入" : "登录");
|
||||
return [
|
||||
options.back
|
||||
? '<button class="login-back" type="button" data-login-action="picker">返回账号列表</button>'
|
||||
: "",
|
||||
`<h2 class="login-card-title">${escapeHtml(options.title)}</h2>`,
|
||||
`<p class="login-card-lead">${escapeHtml(options.lead)}</p>`,
|
||||
'<div class="login-tabs" role="tablist">',
|
||||
`<button class="login-tab${state.mode === "login" ? " is-active" : ""}" type="button" data-auth-mode="login">登录</button>`,
|
||||
`<button class="login-tab${state.mode === "register" ? " is-active" : ""}" type="button" data-auth-mode="register">注册</button>`,
|
||||
"</div>",
|
||||
'<form class="login-form" id="loginForm">',
|
||||
'<label class="form-field"><span>账号名</span><input id="loginUsername" type="text" minlength="3" maxlength="30" autocomplete="username" required></label>',
|
||||
`<label class="form-field"><span>密码</span><input id="loginPassword" type="password" minlength="8" maxlength="128" autocomplete="${registering ? "new-password" : "current-password"}" required></label>`,
|
||||
`<label class="form-field" id="loginConfirmField"${registering ? "" : " hidden"}><span>确认密码</span><input id="loginPasswordConfirm" type="password" minlength="8" maxlength="128" autocomplete="new-password"${registering ? " required" : ""}></label>`,
|
||||
state.error ? `<p class="login-error">${escapeHtml(state.error)}</p>` : '<p class="login-error" hidden></p>',
|
||||
`<button class="button primary login-submit" type="submit"${state.loading ? " disabled" : ""}>`,
|
||||
state.loading ? '<span class="login-spinner" aria-hidden="true"></span>' : "",
|
||||
`<span>${escapeHtml(submitLabel)}</span></button>`,
|
||||
"</form>",
|
||||
'<p class="login-hint">密码连续输错 5 次将锁定 10 分钟。还没有账号?切换到「注册」创建。</p>',
|
||||
].join("");
|
||||
}
|
||||
|
||||
function accountRow(account) {
|
||||
const current = Number(account.user_id) === Number(state.currentUserId);
|
||||
const confirming = Number(state.confirmingId) === Number(account.user_id);
|
||||
const classes = `login-account-row${current ? " is-current" : ""}${confirming ? " is-confirming" : ""}`;
|
||||
if (state.view === "manage" && confirming) {
|
||||
return [
|
||||
`<div class="${classes}" data-user-id="${account.user_id}">`,
|
||||
`<p class="login-confirm-copy">移除「${escapeHtml(account.username)}」的本机记录?</p>`,
|
||||
'<div class="login-confirm-actions">',
|
||||
`<button class="button danger-button" type="button" data-forget-id="${account.user_id}">移除</button>`,
|
||||
'<button class="button" type="button" data-login-action="cancel-forget">取消</button>',
|
||||
"</div></div>",
|
||||
].join("");
|
||||
}
|
||||
const action = state.view === "manage"
|
||||
? `<button class="login-account-remove" type="button" data-confirm-id="${account.user_id}">移除</button>`
|
||||
: current
|
||||
? '<span class="login-account-check" aria-hidden="true">✓</span>'
|
||||
: `<button class="login-account-enter" type="button" data-switch-id="${account.user_id}">进入</button>`;
|
||||
return [
|
||||
`<div class="${classes}" data-user-id="${account.user_id}">`,
|
||||
'<div class="login-account-meta">',
|
||||
`<strong>${escapeHtml(account.username)}</strong>`,
|
||||
`<span>${escapeHtml(membershipLabel(account))}${current ? " · 当前" : ""}</span>`,
|
||||
"</div>",
|
||||
action,
|
||||
"</div>",
|
||||
].join("");
|
||||
}
|
||||
|
||||
function pickerMarkup() {
|
||||
const count = state.accounts.length;
|
||||
const managing = state.view === "manage";
|
||||
return [
|
||||
`<h2 class="login-card-title">${managing ? "管理账号记录" : "选择账号"}</h2>`,
|
||||
`<p class="login-card-lead">这台电脑已记录 ${count} 个账号,可直接进入,无需再次输入密码。</p>`,
|
||||
managing
|
||||
? '<button class="login-manage" type="button" data-login-action="picker">完成</button>'
|
||||
: "",
|
||||
`<div class="login-account-list">${state.accounts.map(accountRow).join("")}</div>`,
|
||||
managing
|
||||
? ""
|
||||
: '<button class="login-add" type="button" data-login-action="add">+ 添加账号</button>',
|
||||
managing
|
||||
? ""
|
||||
: '<button class="login-manage" type="button" data-login-action="manage">管理已记录的账号</button>',
|
||||
state.error ? `<p class="login-error">${escapeHtml(state.error)}</p>` : "",
|
||||
'<p class="login-privacy"><span class="login-lock" aria-hidden="true">🔒</span>账号记录仅保存在这台电脑的浏览器中</p>',
|
||||
].join("");
|
||||
}
|
||||
|
||||
function render() {
|
||||
card.classList.toggle("is-loading", state.loading);
|
||||
if (state.view === "first" || state.view === "add") {
|
||||
card.innerHTML = formMarkup({
|
||||
title: state.view === "add" ? "添加账号" : "欢迎回来",
|
||||
lead: "登录后进入你的复盘空间",
|
||||
add: state.view === "add",
|
||||
back: state.view === "add",
|
||||
});
|
||||
} else {
|
||||
card.innerHTML = pickerMarkup();
|
||||
}
|
||||
bindCard();
|
||||
}
|
||||
|
||||
function bindCard() {
|
||||
card.querySelectorAll("[data-auth-mode]").forEach((button) => {
|
||||
button.addEventListener("click", () => {
|
||||
state.mode = button.dataset.authMode === "register" ? "register" : "login";
|
||||
setError("");
|
||||
render();
|
||||
});
|
||||
});
|
||||
card.querySelectorAll("[data-login-action]").forEach((button) => {
|
||||
button.addEventListener("click", () => {
|
||||
const action = button.dataset.loginAction;
|
||||
if (action === "picker") {
|
||||
state.view = state.accounts.length ? "picker" : "first";
|
||||
state.confirmingId = null;
|
||||
} else if (action === "add") {
|
||||
state.view = "add";
|
||||
state.mode = "login";
|
||||
} else if (action === "manage") {
|
||||
state.view = "manage";
|
||||
} else if (action === "cancel-forget") {
|
||||
state.confirmingId = null;
|
||||
}
|
||||
setError("");
|
||||
render();
|
||||
});
|
||||
});
|
||||
card.querySelectorAll("[data-switch-id]").forEach((button) => {
|
||||
button.addEventListener("click", () => switchAccount(Number(button.dataset.switchId)));
|
||||
});
|
||||
card.querySelectorAll("[data-confirm-id]").forEach((button) => {
|
||||
button.addEventListener("click", () => {
|
||||
state.confirmingId = Number(button.dataset.confirmId);
|
||||
render();
|
||||
});
|
||||
});
|
||||
card.querySelectorAll("[data-forget-id]").forEach((button) => {
|
||||
button.addEventListener("click", () => forgetAccount(Number(button.dataset.forgetId)));
|
||||
});
|
||||
const form = card.querySelector("#loginForm");
|
||||
if (form) form.addEventListener("submit", submitCredentials);
|
||||
}
|
||||
|
||||
async function loadAccounts() {
|
||||
const payload = await api.request("/api/auth/accounts");
|
||||
state.accounts = payload.accounts || [];
|
||||
state.currentUserId = payload.current_user_id ?? null;
|
||||
const params = new URLSearchParams(global.location.search);
|
||||
if (params.get("mode") === "register") state.mode = "register";
|
||||
if (params.get("notice")) setError(params.get("notice"));
|
||||
if (state.accounts.length) state.view = "picker";
|
||||
else state.view = "first";
|
||||
}
|
||||
|
||||
async function submitCredentials(event) {
|
||||
event.preventDefault();
|
||||
const username = document.querySelector("#loginUsername").value.trim();
|
||||
const password = document.querySelector("#loginPassword").value;
|
||||
if (state.mode === "register" && password !== document.querySelector("#loginPasswordConfirm").value) {
|
||||
setError("两次输入的密码不一致。");
|
||||
render();
|
||||
return;
|
||||
}
|
||||
state.loading = true;
|
||||
setError("");
|
||||
render();
|
||||
try {
|
||||
await api.request(`/api/auth/${state.mode}`, "POST", { username, password });
|
||||
enterApp();
|
||||
} catch (error) {
|
||||
state.loading = false;
|
||||
setError(error.message || "账号操作失败");
|
||||
render();
|
||||
}
|
||||
}
|
||||
|
||||
async function switchAccount(userId) {
|
||||
state.loading = true;
|
||||
setError("");
|
||||
render();
|
||||
try {
|
||||
await api.request("/api/auth/switch", "POST", { user_id: userId });
|
||||
enterApp();
|
||||
} catch (error) {
|
||||
state.loading = false;
|
||||
setError(error.message || "该账号需重新验证");
|
||||
render();
|
||||
}
|
||||
}
|
||||
|
||||
async function forgetAccount(userId) {
|
||||
try {
|
||||
await api.request("/api/auth/forget", "POST", { user_id: userId });
|
||||
state.accounts = state.accounts.filter((item) => Number(item.user_id) !== Number(userId));
|
||||
state.confirmingId = null;
|
||||
if (!state.accounts.length) state.view = "first";
|
||||
setError("");
|
||||
render();
|
||||
} catch (error) {
|
||||
setError(error.message || "移除失败");
|
||||
render();
|
||||
}
|
||||
}
|
||||
|
||||
themeButton.addEventListener("click", () => {
|
||||
applyTheme(document.documentElement.dataset.theme === "dark" ? "light" : "dark", true);
|
||||
});
|
||||
applyTheme(preferredTheme(), false);
|
||||
|
||||
loadAccounts()
|
||||
.then(render)
|
||||
.catch((error) => {
|
||||
setError(error.message || "无法连接本地服务");
|
||||
state.view = "first";
|
||||
render();
|
||||
});
|
||||
})(window);
|
||||
@@ -246,6 +246,29 @@ body {
|
||||
padding-top: 8px;
|
||||
}
|
||||
|
||||
.m-auth-accounts {
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.m-auth-account {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
min-height: 48px;
|
||||
padding: 0 14px;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 10px;
|
||||
background: var(--surface);
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.m-auth-account span {
|
||||
color: var(--action);
|
||||
font-size: var(--font-size-label);
|
||||
}
|
||||
|
||||
.m-auth-brand {
|
||||
text-align: center;
|
||||
margin: 24px 0 20px;
|
||||
|
||||
@@ -15,7 +15,9 @@
|
||||
(() => {
|
||||
let theme = "light";
|
||||
try {
|
||||
theme = localStorage.getItem("xiaobaiTheme") === "dark" ? "dark" : "light";
|
||||
const stored = localStorage.getItem("xiaobaiTheme");
|
||||
if (stored === "dark" || stored === "light") theme = stored;
|
||||
else if (window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches) theme = "dark";
|
||||
} catch (_error) {
|
||||
theme = "light";
|
||||
}
|
||||
|
||||
@@ -5,10 +5,15 @@
|
||||
|
||||
function readTheme() {
|
||||
try {
|
||||
return global.localStorage.getItem(THEME_KEY) === "dark" ? "dark" : "light";
|
||||
const stored = global.localStorage.getItem(THEME_KEY);
|
||||
if (stored === "dark" || stored === "light") return stored;
|
||||
} catch (_error) {
|
||||
return "light";
|
||||
}
|
||||
if (global.matchMedia && global.matchMedia("(prefers-color-scheme: dark)").matches) {
|
||||
return "dark";
|
||||
}
|
||||
return "light";
|
||||
}
|
||||
|
||||
function applyTheme(theme) {
|
||||
|
||||
@@ -250,6 +250,7 @@
|
||||
'<h2>小白复盘</h2>',
|
||||
'<p>登录后进入你的复盘空间</p>',
|
||||
"</div>",
|
||||
'<div class="m-auth-accounts" id="m-auth-accounts" hidden></div>',
|
||||
'<div class="m-auth-tabs">',
|
||||
'<button class="m-auth-tab active" type="button" data-auth-mode="login">登录</button>',
|
||||
'<button class="m-auth-tab" type="button" data-auth-mode="register">注册</button>',
|
||||
@@ -265,6 +266,7 @@
|
||||
].join("");
|
||||
authMode = "login";
|
||||
bindAuth();
|
||||
loadMobileAccounts();
|
||||
}
|
||||
|
||||
function setAuthMode(mode) {
|
||||
@@ -287,6 +289,34 @@
|
||||
document.getElementById("m-auth-form").addEventListener("submit", submitAuth);
|
||||
}
|
||||
|
||||
async function loadMobileAccounts() {
|
||||
const host = document.getElementById("m-auth-accounts");
|
||||
if (!host || !global.MobileSession.listAccounts) return;
|
||||
try {
|
||||
const payload = await global.MobileSession.listAccounts();
|
||||
const accounts = payload.accounts || [];
|
||||
if (!accounts.length) return;
|
||||
host.hidden = false;
|
||||
host.innerHTML = accounts.map(function (account) {
|
||||
return '<button class="m-auth-account" type="button" data-switch-id="' + account.user_id + '">' +
|
||||
'<strong>' + escapeHtml(account.username) + '</strong>' +
|
||||
'<span>直接进入</span></button>';
|
||||
}).join("");
|
||||
host.querySelectorAll("[data-switch-id]").forEach(function (button) {
|
||||
button.addEventListener("click", async function () {
|
||||
try {
|
||||
await global.MobileSession.switchAccount(Number(button.dataset.switchId));
|
||||
replace(DEFAULT_HASH);
|
||||
} catch (error) {
|
||||
showAuthError(document.getElementById("m-auth-error"), error.message || "该账号需重新验证");
|
||||
}
|
||||
});
|
||||
});
|
||||
} catch (_error) {
|
||||
host.hidden = true;
|
||||
}
|
||||
}
|
||||
|
||||
function showAuthError(element, message) {
|
||||
element.textContent = message;
|
||||
element.classList.remove("m-motion-fade-in");
|
||||
|
||||
@@ -47,5 +47,30 @@
|
||||
return Boolean(state.user && state.user.role === "admin");
|
||||
}
|
||||
|
||||
global.MobileSession = { state: state, me: me, login: login, register: register, logout: logout, isAdmin: isAdmin };
|
||||
async function listAccounts() {
|
||||
return global.MobileAPI.request("/api/auth/accounts");
|
||||
}
|
||||
|
||||
async function switchAccount(userId) {
|
||||
const payload = await global.MobileAPI.request("/api/auth/switch", "POST", {
|
||||
user_id: userId
|
||||
});
|
||||
return applySession(payload);
|
||||
}
|
||||
|
||||
async function forgetAccount(userId) {
|
||||
await global.MobileAPI.request("/api/auth/forget", "POST", { user_id: userId });
|
||||
}
|
||||
|
||||
global.MobileSession = {
|
||||
state: state,
|
||||
me: me,
|
||||
login: login,
|
||||
register: register,
|
||||
logout: logout,
|
||||
listAccounts: listAccounts,
|
||||
switchAccount: switchAccount,
|
||||
forgetAccount: forgetAccount,
|
||||
isAdmin: isAdmin
|
||||
};
|
||||
})(window);
|
||||
|
||||
@@ -1667,3 +1667,445 @@ button.account-role-badge:focus-visible {
|
||||
display: inline-flex;
|
||||
}
|
||||
}
|
||||
|
||||
.login-portal {
|
||||
min-height: 100vh;
|
||||
|
||||
display: flex;
|
||||
|
||||
background: var(--canvas);
|
||||
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.login-theme-toggle {
|
||||
position: fixed;
|
||||
|
||||
z-index: 2;
|
||||
|
||||
top: 16px;
|
||||
|
||||
right: 20px;
|
||||
|
||||
min-height: 32px;
|
||||
|
||||
padding: 0 12px;
|
||||
|
||||
border: 1px solid var(--border-strong);
|
||||
|
||||
border-radius: var(--size-radius-md);
|
||||
|
||||
background: var(--surface);
|
||||
|
||||
color: var(--text-secondary);
|
||||
|
||||
font-size: var(--font-size-label);
|
||||
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.login-brand {
|
||||
width: clamp(420px, 34vw, 560px);
|
||||
|
||||
flex: 0 0 auto;
|
||||
|
||||
padding: 44px 48px 36px;
|
||||
|
||||
background: var(--login-brand-gradient);
|
||||
|
||||
color: #f4f7ff;
|
||||
}
|
||||
|
||||
.login-brand-mark {
|
||||
display: flex;
|
||||
|
||||
align-items: center;
|
||||
|
||||
justify-content: center;
|
||||
|
||||
width: 56px;
|
||||
|
||||
height: 56px;
|
||||
|
||||
border-radius: 16px;
|
||||
|
||||
background: rgba(255, 255, 255, 0.12);
|
||||
}
|
||||
|
||||
.login-brand-glyph {
|
||||
font-size: 24px;
|
||||
|
||||
font-weight: var(--font-weight-semibold);
|
||||
}
|
||||
|
||||
.login-brand-kicker {
|
||||
margin: 28px 0 8px;
|
||||
|
||||
font-size: var(--font-size-caption);
|
||||
|
||||
letter-spacing: 0.08em;
|
||||
|
||||
opacity: 0.78;
|
||||
}
|
||||
|
||||
.login-brand-title {
|
||||
margin: 0;
|
||||
|
||||
font-size: 36px;
|
||||
|
||||
font-weight: var(--font-weight-semibold);
|
||||
}
|
||||
|
||||
.login-brand-lead {
|
||||
margin: 12px 0 0;
|
||||
|
||||
max-width: 18em;
|
||||
|
||||
font-size: var(--font-size-body);
|
||||
|
||||
line-height: 1.7;
|
||||
|
||||
opacity: 0.86;
|
||||
}
|
||||
|
||||
.login-brand-stats {
|
||||
display: grid;
|
||||
|
||||
grid-template-columns: 1fr 1fr;
|
||||
|
||||
gap: 16px 20px;
|
||||
|
||||
margin: 40px 0 0;
|
||||
}
|
||||
|
||||
.login-stat {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.login-stat dt {
|
||||
color: rgba(244, 247, 255, 0.64);
|
||||
|
||||
font-size: var(--font-size-caption);
|
||||
}
|
||||
|
||||
.login-stat dd {
|
||||
margin: 4px 0 0;
|
||||
|
||||
font-size: 20px;
|
||||
|
||||
font-weight: var(--font-weight-semibold);
|
||||
}
|
||||
|
||||
.login-stat-tag {
|
||||
margin-left: 6px;
|
||||
|
||||
font-size: var(--font-size-caption);
|
||||
|
||||
font-weight: var(--font-weight-regular);
|
||||
}
|
||||
|
||||
.login-stage {
|
||||
flex: 1 1 auto;
|
||||
|
||||
display: grid;
|
||||
|
||||
place-items: center;
|
||||
|
||||
padding: 48px 24px;
|
||||
}
|
||||
|
||||
.login-card {
|
||||
width: 400px;
|
||||
|
||||
max-width: calc(100vw - 48px);
|
||||
|
||||
padding: 32px;
|
||||
|
||||
border: 1px solid var(--border-strong);
|
||||
|
||||
border-radius: var(--size-radius-dialog);
|
||||
|
||||
background: var(--surface);
|
||||
|
||||
box-shadow: var(--shadow-raised);
|
||||
}
|
||||
|
||||
.login-card.is-loading .login-form {
|
||||
pointer-events: none;
|
||||
|
||||
opacity: 0.72;
|
||||
}
|
||||
|
||||
.login-card-title {
|
||||
margin: 0;
|
||||
|
||||
font-size: 22px;
|
||||
|
||||
font-weight: var(--font-weight-semibold);
|
||||
}
|
||||
|
||||
.login-card-lead {
|
||||
margin: 8px 0 0;
|
||||
|
||||
color: var(--text-secondary);
|
||||
|
||||
font-size: var(--font-size-label);
|
||||
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.login-tabs {
|
||||
display: grid;
|
||||
|
||||
grid-template-columns: 1fr 1fr;
|
||||
|
||||
margin-top: 24px;
|
||||
|
||||
border-bottom: 1px solid var(--line);
|
||||
}
|
||||
|
||||
.login-tab {
|
||||
min-height: 40px;
|
||||
|
||||
border: 0;
|
||||
|
||||
border-bottom: 2px solid transparent;
|
||||
|
||||
background: transparent;
|
||||
|
||||
color: var(--text-secondary);
|
||||
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.login-tab.is-active {
|
||||
border-bottom-color: var(--action);
|
||||
|
||||
color: var(--action);
|
||||
|
||||
font-weight: var(--font-weight-medium);
|
||||
}
|
||||
|
||||
.login-form {
|
||||
display: grid;
|
||||
|
||||
gap: 14px;
|
||||
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.login-portal .form-field input {
|
||||
height: 38px;
|
||||
}
|
||||
|
||||
.login-submit {
|
||||
width: 100%;
|
||||
|
||||
height: 40px;
|
||||
|
||||
min-height: 40px;
|
||||
}
|
||||
|
||||
.login-spinner {
|
||||
width: 14px;
|
||||
|
||||
height: 14px;
|
||||
|
||||
border: 2px solid currentColor;
|
||||
|
||||
border-right-color: transparent;
|
||||
|
||||
border-radius: 50%;
|
||||
|
||||
animation: login-spin 0.7s linear infinite;
|
||||
}
|
||||
|
||||
@keyframes login-spin {
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
.login-error {
|
||||
margin: 0;
|
||||
|
||||
color: var(--danger);
|
||||
|
||||
font-size: var(--font-size-caption);
|
||||
}
|
||||
|
||||
.login-error[hidden] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.login-hint,
|
||||
.login-privacy {
|
||||
margin: 16px 0 0;
|
||||
|
||||
color: var(--text-tertiary);
|
||||
|
||||
font-size: var(--font-size-caption);
|
||||
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.login-portal .login-privacy {
|
||||
display: flex;
|
||||
|
||||
align-items: center;
|
||||
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.login-lock {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.login-back,
|
||||
.login-add,
|
||||
.login-manage,
|
||||
.login-account-enter,
|
||||
.login-account-remove {
|
||||
border: 0;
|
||||
|
||||
background: transparent;
|
||||
|
||||
color: var(--action);
|
||||
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.login-portal .login-back {
|
||||
margin-bottom: 12px;
|
||||
|
||||
padding: 0;
|
||||
|
||||
font-size: var(--font-size-label);
|
||||
}
|
||||
|
||||
.login-portal .login-add {
|
||||
display: block;
|
||||
|
||||
width: 100%;
|
||||
|
||||
min-height: 40px;
|
||||
|
||||
margin-top: 8px;
|
||||
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.login-portal .login-manage {
|
||||
display: block;
|
||||
|
||||
width: 100%;
|
||||
|
||||
min-height: 40px;
|
||||
|
||||
margin-top: 8px;
|
||||
|
||||
text-align: left;
|
||||
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.login-account-list {
|
||||
display: grid;
|
||||
|
||||
gap: 8px;
|
||||
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.login-account-row {
|
||||
display: flex;
|
||||
|
||||
align-items: center;
|
||||
|
||||
justify-content: space-between;
|
||||
|
||||
min-height: 58px;
|
||||
|
||||
padding: 0 14px;
|
||||
|
||||
border: 1px solid var(--border);
|
||||
|
||||
border-radius: var(--size-radius-md);
|
||||
|
||||
background: var(--surface);
|
||||
}
|
||||
|
||||
.login-account-row.is-current {
|
||||
border-color: var(--action);
|
||||
}
|
||||
|
||||
.login-account-row.is-confirming {
|
||||
display: grid;
|
||||
|
||||
gap: 10px;
|
||||
|
||||
padding: 12px 14px;
|
||||
}
|
||||
|
||||
.login-account-meta {
|
||||
display: grid;
|
||||
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.login-account-meta strong {
|
||||
font-weight: var(--font-weight-medium);
|
||||
}
|
||||
|
||||
.login-account-meta span {
|
||||
color: var(--text-tertiary);
|
||||
|
||||
font-size: var(--font-size-caption);
|
||||
}
|
||||
|
||||
.login-account-check {
|
||||
color: var(--action);
|
||||
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.login-confirm-copy {
|
||||
margin: 0;
|
||||
|
||||
font-size: var(--font-size-label);
|
||||
}
|
||||
|
||||
.login-confirm-actions {
|
||||
display: flex;
|
||||
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.login-portal {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.login-brand {
|
||||
width: 100%;
|
||||
|
||||
padding: 20px 20px 16px;
|
||||
}
|
||||
|
||||
.login-brand-lead,
|
||||
.login-brand-stats {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.login-brand-title {
|
||||
font-size: 22px;
|
||||
}
|
||||
|
||||
.login-brand-kicker {
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
.login-stage {
|
||||
padding: 28px 16px 40px;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,12 +53,10 @@ async function applyAuthenticatedSession(session) {
|
||||
function showAuthGate(message = "") {
|
||||
state.user = null;
|
||||
state.csrfToken = "";
|
||||
const gate = document.querySelector("#authGate");
|
||||
gate.hidden = false;
|
||||
const errorElement = document.querySelector("#authError");
|
||||
errorElement.textContent = message;
|
||||
errorElement.hidden = !message;
|
||||
document.querySelector("#authUsername").focus();
|
||||
const params = new URLSearchParams();
|
||||
if (message) params.set("notice", message);
|
||||
const query = params.toString();
|
||||
window.location.replace("/login/" + (query ? `?${query}` : ""));
|
||||
}
|
||||
|
||||
async function logoutAccount() {
|
||||
@@ -197,16 +195,8 @@ async function changeAccountPassword(event) {
|
||||
}
|
||||
|
||||
async function switchAccount() {
|
||||
const button = document.querySelector("#switchAccountMenuButton");
|
||||
button.disabled = true;
|
||||
toggleAccountDropdown(false);
|
||||
try {
|
||||
await apiRequest("/api/auth/logout", "POST", {});
|
||||
window.location.reload();
|
||||
} catch (error) {
|
||||
showToast(error.message || "切换账号失败");
|
||||
button.disabled = false;
|
||||
}
|
||||
window.location.assign("/login/");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -146,6 +146,7 @@
|
||||
--shadow-float: var(--elevation-float);
|
||||
--duration-fast: 150ms;
|
||||
--duration-normal: 220ms;
|
||||
--login-brand-gradient: linear-gradient(165deg, #0c1e4a, #16307c, #2153cc);
|
||||
|
||||
--font-size-aux: 11.5px;
|
||||
--font-size-caption: 12.5px;
|
||||
@@ -509,6 +510,7 @@
|
||||
--warning-line: #6d5a38;
|
||||
--warning-line-strong: #66502d;
|
||||
--control-shadow: 0 1px 3px rgba(0, 0, 0, .3);
|
||||
--login-brand-gradient: linear-gradient(165deg, #080c18, #0e1730, #14224a);
|
||||
--dialog-backdrop: var(--backdrop);
|
||||
--ladder-level-1: #2d2426;
|
||||
--ladder-level-2: #2b2822;
|
||||
|
||||
Reference in New Issue
Block a user