console.log('👋 This message is being logged by "index.ts", included via Vite'); // In this file you can include the rest of your app's specific main process // code. You can also put them in separate files and import them here. // 检查登录状态 function checkLoginStatus() { const auth = document.cookie.split('; ').find(row => row.startsWith('EACToken=') || row.startsWith('MssSsoToken=')); if (!auth) { window.location.href = 'login.html'; return; } // 显示用户信息 const userInfo = document.getElementById('userInfo'); if (userInfo) { userInfo.textContent = '欢迎使用'; } } // 处理退出登录 function handleLogout() { document.cookie = 'expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;'; window.location.href = 'login.html'; } // 处理菜单切换 function handleMenuClick(event: Event) { const target = event.target as HTMLElement; const menuItem = target.closest('.menu-item'); if (menuItem) { // 移除所有菜单项的active类 document.querySelectorAll('.menu-item').forEach(item => { item.classList.remove('active'); }); // 添加active类到当前点击的菜单项 menuItem.classList.add('active'); // 获取页面标识 const page = menuItem.getAttribute('data-page'); if (page) { loadPageContent(page); } } } // 加载页面内容 async function loadPageContent(page: string) { const contentArea = document.getElementById('pageContent'); if (!contentArea) return; try { // 这里可以根据不同的页面加载不同的内容 switch (page) { case 'dashboard': contentArea.innerHTML = '
欢迎使用中国电信桌面应用
'; break; case 'tasks': contentArea.innerHTML = '任务管理功能开发中...
'; break; case 'reports': contentArea.innerHTML = '报表统计功能开发中...
'; break; case 'settings': contentArea.innerHTML = '系统设置功能开发中...
'; break; default: contentArea.innerHTML = '请稍后重试
'; } } // 初始化 function initialize() { // 检查登录状态 checkLoginStatus(); // 绑定退出登录事件 const logoutBtn = document.getElementById('btnLogout'); if (logoutBtn) { logoutBtn.addEventListener('click', handleLogout); } // 绑定菜单点击事件 const menuList = document.querySelector('.menu-list'); if (menuList) { menuList.addEventListener('click', handleMenuClick); } // 加载默认页面(仪表盘) loadPageContent('dashboard'); } // 当DOM加载完成后初始化 document.addEventListener('DOMContentLoaded', initialize);