Update admin.js

This commit is contained in:
Furrium Network authored and GitHub committed 2026-08-10 12:44:56 +08:00
1 parent d87f1b2ab9
commit 0953234bc9
1 file changed
+24 -15
+24 -15
View File
@@ -597,23 +597,32 @@ function loadCustomCSS() {
} }
// ============================================================ // ============================================================
// 管理后台Tab切换 // 管理后台Tab切换(侧边栏适配)
// ============================================================ // ============================================================
document.querySelectorAll('.admin-tab').forEach(tab => { // 使用事件委托监听 .admin-nav 下的点击
tab.addEventListener('click', function() { document.querySelector('.admin-nav')?.addEventListener('click', function(e) {
document.querySelectorAll('.admin-tab').forEach(t => t.classList.remove('active')); const tabLink = e.target.closest('.admin-nav-item');
this.classList.add('active'); if (!tabLink) return;
const tabMap = {
reports: renderAdminReports, e.preventDefault();
users: renderAdminUsers, const tab = tabLink.dataset.tab;
logs: renderAdminLogs, if (!tab) return;
links: renderAdminLinks,
settings: renderAdminSettings, // 切换高亮
custom: renderAdminCustomPages document.querySelectorAll('.admin-nav-item').forEach(el => el.classList.remove('active'));
}; tabLink.classList.add('active');
if (tabMap[this.dataset.tab]) tabMap[this.dataset.tab]();
}); // 渲染对应内容
const tabMap = {
reports: renderAdminReports,
users: renderAdminUsers,
logs: renderAdminLogs,
links: renderAdminLinks,
settings: renderAdminSettings,
custom: renderAdminCustomPages
};
if (tabMap[tab]) tabMap[tab]();
}); });
// 页面加载时尝试加载自定义 CSS // 页面加载时尝试加载自定义 CSS