a) { var newIcon = isActive ? menuData.activeIcon : menuData.icon; // 如果是选中状态且图标发生变化,添加抖动动画 if (isActive && newIcon !== menuData.icon) { // 先添加抖动动画 iconEl.classList.add('shake'); // 延迟更新图标,让抖动动画先开始 setTimeout(function() { updateIconContent(iconEl, newIcon, menuData.name); // 动画完成后移除抖动类 setTimeout(function() { iconEl.classList.remove('shake'); // 添加脉冲效果 iconEl.classList.add('pulse'); setTimeout(function() { iconEl.classList.remove('pulse'); }, 400); }, 600); }, 100); } else { // 非选中状态或图标未变化,直接更新 updateIconContent(iconEl, newIcon, menuData.name); } } } } } // 更新图标内容的辅助函数 function updateIconContent(iconEl, newIcon, itemName) { // 判断图标类型并更新(只支持SVG和外部链接) if (newIcon && newIcon.startsWith(''; } } else { // 不支持的图标类型 iconEl.className = 'btm-nav-icon btm-nav-default'; iconEl.innerHTML = '?'; } } // 检测是否为移动设备 function isMobileDevice() { return window.innerWidth <= 760; } // 获取菜单栏的实际高度 function getMenuBarHeight() { var menuBar = document.getElementById('btmNavMenu'); if (menuBar && menuBar.style.display !== 'none') { // 强制重新计算布局 menuBar.offsetHeight; var height = menuBar.getBoundingClientRect().height; if (height > 0) { return Math.ceil(height); // 向上取整避免小数问题 } } // 使用更保守的估算值 return isMobileDevice() ? 55 : 65; } // 显示iframe function showIframe(url, title, menuItem) { var iframe = document.getElementById('btmNavIframe'); var titleEl = document.getElementById('btmNavIframeTitle'); var contentEl = document.getElementById('btmNavIframeContent'); var headerEl = iframe.querySelector('.btm-nav-iframe-header'); var menuBar = document.getElementById('btmNavMenu'); if (iframe && titleEl && contentEl) { closeIframe(); setTimeout(function() { titleEl.textContent = title; contentEl.src = url; // 根据配置决定是否显示关闭栏 var shouldShowCloseBar = getShouldShowCloseBar(menuItem); // 根据配置决定是否显示菜单栏 var shouldShowMenuBar = getShouldShowMenuBar(menuItem); if (shouldShowCloseBar) { headerEl.style.display = 'flex'; iframe.style.top = '0'; contentEl.style.height = 'calc(100% - 35px)'; } else { headerEl.style.display = 'none'; iframe.style.top = '0'; contentEl.style.height = '100%'; } // 控制底部菜单栏显示/隐藏 if (shouldShowMenuBar) { if (menuBar) menuBar.style.display = 'block'; iframe.classList.remove('btm-nav-fullscreen'); // 移除全屏类 // 动态获取菜单栏高度 var menuHeight = getMenuBarHeight(); // 设置CSS变量供CSS使用 document.documentElement.style.setProperty('--btm-nav-menu-height', menuHeight + 'px'); // 简化定位:使用top和bottom,让CSS处理高度 iframe.style.top = '0'; iframe.style.bottom = '0'; // 贴底显示,菜单栏会在上面 if (!shouldShowCloseBar) { iframe.style.height = ''; // 清除内联样式,使用CSS类 iframe.classList.add('btm-nav-with-menu'); contentEl.style.height = '100%'; } else { iframe.style.height = ''; // 清除内联样式,使用CSS类 iframe.classList.add('btm-nav-with-menu'); contentEl.style.height = 'calc(100% - 35px)'; } } else { if (menuBar) menuBar.style.display = 'none'; // 完全占满屏幕,但在移动端考虑安全区域 iframe.style.top = '0'; iframe.classList.remove('btm-nav-with-menu'); // 移除菜单栏类 iframe.classList.add('btm-nav-fullscreen'); // 添加全屏类用于CSS安全区域适配 if (isMobileDevice()) { // 移动端:让CSS的env()处理安全区域,JavaScript只设置基本样式 iframe.style.bottom = '0'; iframe.style.left = '0'; iframe.style.right = '0'; iframe.style.width = '100%'; iframe.style.maxWidth = 'none'; iframe.style.height = '100vh'; iframe.style.transform = 'none'; } else { // 桌面端:保持居中显示 iframe.style.bottom = '0'; iframe.style.left = '50%'; iframe.style.right = 'auto'; iframe.style.width = '100%'; iframe.style.maxWidth = '760px'; iframe.style.height = '100vh'; iframe.style.transform = 'translateX(-50%)'; } if (!shouldShowCloseBar) { contentEl.style.height = '100%'; // iframe内容占满 } else { contentEl.style.height = 'calc(100% - 35px)'; // 减去关闭栏高度 } } iframe.style.display = 'block'; // 显示加载动画 var loadingEl = document.getElementById('btmNavLoading'); var loadingTip = document.getElementById('btmNavLoadingTip'); if (loadingEl) { loadingEl.style.display = 'flex'; // 根据是否显示关闭栏来设置提示内容 if (loadingTip) { loadingTip.className = 'btm-nav-loading-tip'; if (shouldShowCloseBar) {