// 导航组件 - 统一管理所有页面的导航栏 (function() { // 检测当前页面路径,自动调整链接 const currentPath = window.location.pathname; const isInPagesFolder = currentPath.includes('/pages/'); const currentPage = currentPath.split('/').pop() || 'index.html'; // 导航项配置 const navItems = [ { href: 'index.html', icon: 'fa-home', text: '首页', id: 'index' }, { href: 'overview.html', icon: 'fa-info-circle', text: '展会概览', id: 'overview' }, { href: 'exhibition.html', icon: 'fa-th-large', text: '展览内容', id: 'exhibition' }, { href: 'marketing.html', icon: 'fa-bullhorn', text: '营销推广', id: 'marketing' }, { href: 'operation.html', icon: 'fa-cogs', text: '运营服务', id: 'operation' }, { href: 'budget.html', icon: 'fa-chart-pie', text: '预算分析', id: 'budget' }, { href: 'risk.html', icon: 'fa-shield-alt', text: '风险评估', id: 'risk' } ]; // 根据当前页面位置调整路径 function getCorrectPath(href) { if (href === 'index.html') { return isInPagesFolder ? '../index.html' : 'index.html'; } else { return isInPagesFolder ? href : `pages/${href}`; } } // 判断是否为当前激活页面 function isActive(href) { return currentPage === href || (currentPage === '' && href === 'index.html'); } // 生成导航HTML function generateNavHTML() { return `
新能源汽车产业博览会