Files
web_huangguo_web/app/static/js/pages/setting.js
T
fish03andClaude Opus 5.5 bef9f8b4ed Initial commit
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-23 14:43:16 +07:00

35 lines
1.0 KiB
JavaScript

(function () {
document.querySelectorAll(".setting-switch").forEach(function (btn) {
btn.addEventListener("click", function () {
var on = btn.classList.toggle("setting-switch--on");
btn.setAttribute("aria-pressed", on ? "true" : "false");
});
});
var logoutBtn = document.querySelector("[data-auth-logout]");
if (logoutBtn) {
logoutBtn.addEventListener("click", function () {
function done() {
if (window.AuthAPI && typeof AuthAPI.markGuestLogout === "function") {
AuthAPI.markGuestLogout();
}
if (window.CookieUtil && typeof CookieUtil.clearAuth === "function") {
CookieUtil.clearAuth();
}
try {
document.dispatchEvent(new CustomEvent("auth:logout"));
} catch (e) {}
window.location.href = "/";
}
if (window.HttpRequest) {
HttpRequest.post("/api/auth/logout", {})
.catch(function () {})
.then(done);
} else {
done();
}
});
}
})();