Use SVN-specific login context

This commit is contained in:
lwt
2026-06-18 11:09:35 +08:00
parent 5d6944c710
commit 72153127b6
3 changed files with 85 additions and 10 deletions
+17
View File
@@ -612,6 +612,23 @@ main,
border-radius: 8px; border-radius: 8px;
} }
.login-context-svn {
--blue: #6a5cff;
--blue-dark: #5545ea;
--blue-soft: #f0f1ff;
}
.login-context-svn .login-panel {
background:
linear-gradient(135deg, rgba(240, 241, 255, 0.92), rgba(255, 255, 255, 0.9)),
#fff;
border-color: rgba(106, 92, 255, 0.22);
}
.login-context-svn .login-form {
border-color: rgba(106, 92, 255, 0.14);
}
.topic-grid { .topic-grid {
display: grid; display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-columns: repeat(3, minmax(0, 1fr));
+58
View File
@@ -1,6 +1,14 @@
const form = document.querySelector("#login-form"); const form = document.querySelector("#login-form");
const nextInput = document.querySelector("#next-url"); const nextInput = document.querySelector("#next-url");
const statusEl = document.querySelector("#login-status"); const statusEl = document.querySelector("#login-status");
const brand = document.querySelector("#login-brand");
const brandIcon = document.querySelector("#login-brand-icon");
const brandText = document.querySelector("#login-brand-text");
const sectionLink = document.querySelector("#login-section-link");
const currentNav = document.querySelector("#login-nav-current");
const kickerEl = document.querySelector("#login-kicker");
const titleEl = document.querySelector("#login-title");
const copyEl = document.querySelector("#login-copy");
const params = new URLSearchParams(window.location.search); const params = new URLSearchParams(window.location.search);
const requestedNext = params.get("next") || "/software.html"; const requestedNext = params.get("next") || "/software.html";
@@ -12,6 +20,55 @@ function safeNext(value) {
return "/software.html"; return "/software.html";
} }
function loginContext(nextUrl) {
const cleanNext = safeNext(nextUrl);
if (/^\/?admin\/svn(?:\.html)?(?:$|[/?#])/.test(cleanNext)) {
return {
bodyClass: "login-context-svn",
title: "SVN 管理登录",
pageTitle: "sumi.work - SVN 管理登录",
kicker: "SVN Admin Access",
copy: "登录后即可进入 SVN 控制台,管理仓库、工作副本和版本操作。",
brandText: "sumi.work SVN 管理",
brandHref: "/admin/svn.html",
brandLabel: "返回 SVN 管理",
brandIcon: "assets/icons/svn.svg",
sectionText: "SVN 管理",
sectionHref: "/admin/svn.html",
};
}
return {
bodyClass: "login-context-player",
title: "玩家登录",
pageTitle: "sumi.work - 玩家登录",
kicker: "Player Access",
copy: "登录后即可下载软件中心里的安装包。",
brandText: "sumi.work 软件中心",
brandHref: "software.html",
brandLabel: "返回软件下载",
brandIcon: "assets/icons/software.svg",
sectionText: "软件下载",
sectionHref: "software.html",
};
}
function applyLoginContext() {
const context = loginContext(requestedNext);
document.body.classList.add(context.bodyClass);
document.title = context.pageTitle;
brand.href = context.brandHref;
brand.setAttribute("aria-label", context.brandLabel);
brandIcon.src = context.brandIcon;
brandText.textContent = context.brandText;
sectionLink.href = context.sectionHref;
sectionLink.textContent = context.sectionText;
currentNav.href = `login.html?next=${encodeURIComponent(safeNext(requestedNext))}`;
currentNav.textContent = context.title;
kickerEl.textContent = context.kicker;
titleEl.textContent = context.title;
copyEl.textContent = context.copy;
}
function setStatus(message, type = "") { function setStatus(message, type = "") {
statusEl.textContent = message; statusEl.textContent = message;
statusEl.classList.toggle("is-error", type === "error"); statusEl.classList.toggle("is-error", type === "error");
@@ -31,6 +88,7 @@ async function checkExistingLogin() {
} }
nextInput.value = safeNext(requestedNext); nextInput.value = safeNext(requestedNext);
applyLoginContext();
form.addEventListener("submit", async (event) => { form.addEventListener("submit", async (event) => {
event.preventDefault(); event.preventDefault();
+10 -10
View File
@@ -5,20 +5,20 @@
<meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="robots" content="noindex" /> <meta name="robots" content="noindex" />
<meta name="theme-color" content="#edf5ff" /> <meta name="theme-color" content="#edf5ff" />
<title>sumi.work - 玩家登录</title> <title>sumi.work - 登录</title>
<link rel="stylesheet" href="assets/css/software.css?v=20260608-2" /> <link rel="stylesheet" href="assets/css/software.css?v=20260618-2" />
</head> </head>
<body> <body>
<header class="soft-topbar"> <header class="soft-topbar">
<div class="soft-topbar-inner login-topbar-inner"> <div class="soft-topbar-inner login-topbar-inner">
<a class="soft-brand" href="software.html" aria-label="返回软件下载"> <a class="soft-brand" id="login-brand" href="software.html" aria-label="返回软件下载">
<img src="assets/icons/software.svg" alt="" aria-hidden="true" /> <img id="login-brand-icon" src="assets/icons/software.svg" alt="" aria-hidden="true" />
<span>sumi.work 软件中心</span> <span id="login-brand-text">sumi.work 软件中心</span>
</a> </a>
<nav class="soft-nav" aria-label="登录页导航"> <nav class="soft-nav" aria-label="登录页导航">
<a href="index.html">首页</a> <a href="index.html">首页</a>
<a href="software.html">软件下载</a> <a id="login-section-link" href="software.html">软件下载</a>
<a class="is-active" href="login.html">玩家登录</a> <a class="is-active" id="login-nav-current" href="login.html">玩家登录</a>
</nav> </nav>
</div> </div>
</header> </header>
@@ -26,9 +26,9 @@
<main class="login-main"> <main class="login-main">
<section class="login-panel" aria-labelledby="login-title"> <section class="login-panel" aria-labelledby="login-title">
<div> <div>
<p class="hero-kicker">Player Access</p> <p class="hero-kicker" id="login-kicker">Player Access</p>
<h1 id="login-title">玩家登录</h1> <h1 id="login-title">玩家登录</h1>
<p class="login-copy">登录后即可下载软件中心里的安装包。</p> <p class="login-copy" id="login-copy">登录后即可下载软件中心里的安装包。</p>
</div> </div>
<form class="login-form" id="login-form"> <form class="login-form" id="login-form">
<input type="hidden" name="next" id="next-url" /> <input type="hidden" name="next" id="next-url" />
@@ -46,6 +46,6 @@
</section> </section>
</main> </main>
<script src="assets/js/login.js?v=20260608-1"></script> <script src="assets/js/login.js?v=20260618-2"></script>
</body> </body>
</html> </html>