// 仅在插件安装时设置默认 popup 页面,不再在 startup 中干扰当前 UI chrome.runtime.onInstalled.addListener(() => { chrome.storage.local.get(["token", "loginAt"], (res) => { const maxAge = 24 * 60 * 60 * 1000; // 1天有效期 const now = Date.now(); if (!res.token || !res.loginAt || (now - res.loginAt > maxAge)) { chrome.action.setPopup({ popup: "./pages/login.html" }); } else { chrome.action.setPopup({ popup: "./pages/popup.html" }); } }); });