HEL-342: 全站切换霜曜日间与黑金夜间主题

按定稿把运行时 token 换成霜曜/黑金双主题,登录与壳层接入官方 Logo 与主题记忆,不改业务接口与金额计算。

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
总工
2026-09-01 17:44:35 +08:00
co-authored by Cursor multica-agent
parent 2d0ae4d7d1
commit b905cba52c
15 changed files with 944 additions and 258 deletions
+55
View File
@@ -0,0 +1,55 @@
/* 霜曜 / 黑金主题:仅记忆主题偏好,不写任何业务数据。 */
(function (global) {
var KEY = "jinniu-theme";
function read() {
try {
return localStorage.getItem(KEY) === "night" ? "night" : "day";
} catch (err) {
return "day";
}
}
function syncButtons(theme) {
document.querySelectorAll("[data-theme-set]").forEach(function (btn) {
var on = btn.getAttribute("data-theme-set") === theme;
btn.classList.toggle("is-active", on);
btn.setAttribute("aria-pressed", on ? "true" : "false");
});
}
function apply(theme, animate) {
var next = theme === "night" ? "night" : "day";
var root = document.documentElement;
root.classList.add("v-fusion");
if (animate) {
root.setAttribute("data-theme-anim", "");
window.setTimeout(function () {
root.removeAttribute("data-theme-anim");
}, 220);
}
root.setAttribute("data-theme", next);
if (document.body) document.body.setAttribute("data-theme", next);
syncButtons(next);
}
function set(theme) {
var next = theme === "night" ? "night" : "day";
try {
localStorage.setItem(KEY, next);
} catch (err) {
/* 无本地存储时仍切换当次会话 */
}
apply(next, true);
}
apply(read(), false);
document.addEventListener("click", function (event) {
var btn = event.target.closest("[data-theme-set]");
if (!btn) return;
event.preventDefault();
set(btn.getAttribute("data-theme-set"));
});
global.JinniuTheme = { apply: apply, set: set, read: read };
})(window);