feat(badges): medal info remote modal + grant notification

Add zibll-like badge list/single AJAX modals, Message notify on grant,
author-home/user-center entry points, and front wear handler.
This commit is contained in:
kate522 committed 2026-07-19 02:17:53 +08:00
1 parent 5fa902304b
commit 9f90d54821
5 files changed
+273 -1

No files matched your search

+32
View File
@@ -139,6 +139,38 @@
});
}
// Global wear handler (remote modal + UC modal).
document.addEventListener("click", function (e) {
var wearBtn = e.target.closest("[data-aksrt-badge-wear]");
if (!wearBtn) return;
// UC modal has its own handler when canWear on modal root.
var modalRoot = wearBtn.closest("[data-aksrt-badges-modal]");
if (modalRoot) return;
e.preventDefault();
var slug = wearBtn.getAttribute("data-aksrt-badge-wear") || "";
if (!slug) return;
wearBtn.disabled = true;
api("/users/me/badges/wear", {
method: "POST",
body: JSON.stringify({ slug: slug }),
}).then(function (r) {
if (!r.ok) {
toast((r.json && (r.json.message || (r.json.data && r.json.data.message))) || "佩戴失败", "error");
wearBtn.disabled = false;
return;
}
toast((r.json && r.json.message) || "已佩戴徽章", "success");
// Soft refresh modal content if remote host present.
try {
document.dispatchEvent(new CustomEvent("aksrt:remote-modal:close"));
} catch (_) {}
}).catch(function () {
toast("网络错误", "error");
wearBtn.disabled = false;
});
});
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', init);
} else {