feat: align Bell prototype with go-admin-ui (#31)

This commit is contained in:
QiuSW
2026-08-12 10:56:07 +08:00
parent 1da77fe0b1
commit 0bdd88ba9c
8 changed files with 350 additions and 245 deletions
-43
View File
@@ -1,43 +0,0 @@
(function () {
"use strict";
const shell = document.querySelector("[data-go-admin-shell]");
const collapse = document.querySelector("[data-collapse-sidebar]");
const queryForm = document.querySelector("[data-device-query]");
const queryInput = document.querySelector("#device-filter");
function syncTags(viewName) {
document.querySelectorAll(".tags-view-item").forEach((tag) => {
const active = tag.dataset.viewTarget === viewName;
tag.classList.toggle("active", active);
if (active) tag.setAttribute("aria-current", "page");
else tag.removeAttribute("aria-current");
});
}
document.querySelectorAll("[data-view-target]").forEach((trigger) => {
trigger.addEventListener("click", () => syncTags(trigger.dataset.viewTarget));
});
if (collapse && shell) {
collapse.addEventListener("click", () => {
const compact = shell.classList.toggle("compact");
collapse.setAttribute("aria-expanded", String(!compact));
collapse.setAttribute("aria-label", compact ? "展开主导航" : "折叠主导航");
});
}
if (queryForm) {
queryForm.addEventListener("submit", (event) => {
event.preventDefault();
if (queryInput) queryInput.dispatchEvent(new Event("input", { bubbles: true }));
});
queryForm.addEventListener("reset", () => {
window.setTimeout(() => {
if (queryInput) queryInput.dispatchEvent(new Event("input", { bubbles: true }));
}, 0);
});
}
syncTags("overview");
})();