const Upload = (() => { // 使用localStorage保存上传记录 const STORAGE_KEY = 'mac_upload_history'; // 事件监听器清理 const eventListeners = []; const addListener = (element, event, handler) => { if(element){ element.addEventListener(event, handler); eventListeners.push({element, event, handler}); } }; const cleanupListeners = () => { eventListeners.forEach(({element, event, handler}) => { element.removeEventListener(event, handler); }); eventListeners.length = 0; }; let currentUploadPath = null; Router.onBeforeEach((path) => { if(path.startsWith('/upload')){ if(currentUploadPath && currentUploadPath !== path){ cleanupListeners(); } currentUploadPath = path; return; } cleanupListeners(); currentUploadPath = null; }); function getHistory() { try { return JSON.parse(localStorage.getItem(STORAGE_KEY) || '[]'); } catch { return []; } } function saveToHistory(records) { try { const history = getHistory(); const newRecords = records.map(r => ({ ...r, timestamp: new Date().toISOString() })); const updated = [...newRecords, ...history].slice(0, 100); // 保留最近100条 localStorage.setItem(STORAGE_KEY, JSON.stringify(updated)); } catch (e) { console.error('保存历史记录失败:', e); } } function clearHistory() { localStorage.removeItem(STORAGE_KEY); } function section(title, inner) { return `