feat(extension): 初始化Chrome扩展项目结构与基础功能

This commit is contained in:
雨霖铃
2025-11-11 01:07:43 +08:00
commit 3ab976b930
14 changed files with 697 additions and 0 deletions
+37
View File
@@ -0,0 +1,37 @@
document.getElementById('close').addEventListener('click', () => {
window.parent.postMessage({ action: 'indexind' }, '*');
});
// sidepanel/index.js
// 页面切换逻辑
document.getElementById("nav-timestamp").addEventListener("click", () => {
switchPage("timestamp");
});
document.getElementById("nav-other").addEventListener("click", () => {
switchPage("other");
});
function switchPage(pageName) {
// 隐藏所有页面
document.querySelectorAll(".page").forEach(page => {
page.classList.remove("active");
});
// 移除所有导航按钮的 active 状态
document.querySelectorAll(".nav-button").forEach(button => {
button.classList.remove("active");
});
// 显示目标页面
document.getElementById(`page-${pageName}`).classList.add("active");
// 激活对应的导航按钮
document.getElementById(`nav-${pageName}`).classList.add("active");
}
// 关闭按钮逻辑 (使用消息传递)
document.getElementById("close").addEventListener("click", () => {
// 向父页面发送消息请求关闭
window.parent.postMessage({ action: "closeSidebar" }, "*");
});