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;
}
.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 {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
+58
View File
@@ -1,6 +1,14 @@
const form = document.querySelector("#login-form");
const nextInput = document.querySelector("#next-url");
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 requestedNext = params.get("next") || "/software.html";
@@ -12,6 +20,55 @@ function safeNext(value) {
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 = "") {
statusEl.textContent = message;
statusEl.classList.toggle("is-error", type === "error");
@@ -31,6 +88,7 @@ async function checkExistingLogin() {
}
nextInput.value = safeNext(requestedNext);
applyLoginContext();
form.addEventListener("submit", async (event) => {
event.preventDefault();