generated from dellevin/template
添加历史足迹
This commit is contained in:
60
static/js/tabchange.js.bak
Normal file
60
static/js/tabchange.js.bak
Normal file
@@ -0,0 +1,60 @@
|
||||
// ==================== 标签切换功能 ====================
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
const tabs = document.querySelectorAll(".nav-tab");
|
||||
const contents = document.querySelectorAll(".tab-content");
|
||||
tabs.forEach((tab) => {
|
||||
tab.addEventListener("click", function () {
|
||||
const tabId = this.getAttribute("data-tab");
|
||||
// 移除所有激活状态
|
||||
tabs.forEach((t) => t.classList.remove("active"));
|
||||
contents.forEach((c) => c.classList.remove("active"));
|
||||
// 添加当前激活状态
|
||||
this.classList.add("active");
|
||||
document.getElementById(`${tabId}-content`).classList.add("active");
|
||||
});
|
||||
});
|
||||
|
||||
const websiteTab = document.querySelector('.nav-tab[data-tab="website"]');
|
||||
const websiteContent = document.getElementById("website-content");
|
||||
if (websiteTab && websiteContent) {
|
||||
websiteTab.addEventListener("click", function () {
|
||||
const hasRendered =
|
||||
websiteContent.querySelector(".category-links") !== null;
|
||||
if (!hasRendered) {
|
||||
const savedLang = localStorage.getItem(LANG_KEY) || "zh";
|
||||
renderWebsites(websitesData, translations, savedLang);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
console.warn("未找到“我的网站”标签或内容区域。");
|
||||
}
|
||||
|
||||
// 点击我的工具函数
|
||||
const toolsTab = document.querySelector('.nav-tab[data-tab="tools"]');
|
||||
const toolsContent = document.getElementById("tools-content");
|
||||
if (toolsTab && toolsContent) {
|
||||
toolsTab.addEventListener("click", function () {
|
||||
const hasRendered = toolsContent.querySelector(".tool-item") !== null;
|
||||
if (!hasRendered) {
|
||||
renderTools(toolsData);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
console.warn("未找到“我的工具”标签或内容区域,将在页面加载时尝试渲染。");
|
||||
renderTools(toolsData);
|
||||
}
|
||||
// 点击常玩游戏函数
|
||||
const gamesTab = document.querySelector('.nav-tab[data-tab="games"]');
|
||||
const gamesContent = document.getElementById("games-content");
|
||||
if (gamesTab && gamesContent) {
|
||||
gamesTab.addEventListener("click", function () {
|
||||
const hasRendered = gamesContent.querySelector(".game-item") !== null;
|
||||
if (!hasRendered) {
|
||||
renderGames(gamesData);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
console.warn("未找到“常玩游戏”标签或内容区域。");
|
||||
renderGames(gamesData);
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user