// 桌面路由:侧边栏 5 页 + 页面切换 + 顶部时间 // Launcher router: 5 sidebar pages + page switching + top clock // 侧边栏图标:内联 SVG(stroke=currentColor,跟随主题色),替代 emoji // Sidebar icons: inline SVG (stroke=currentColor, follows theme color), replacing emoji const SVG_ICONS = { home: '', immersive: '', webapp: '', app: '', settings: '', }; const PAGES = [ { id: 'home', label: '首页', icon: SVG_ICONS.home }, { id: 'immersive', label: '沉浸首页', icon: SVG_ICONS.immersive }, { id: 'webapplist', label: 'H5 应用', icon: SVG_ICONS.webapp }, { id: 'applist', label: '安卓 APP', icon: SVG_ICONS.app }, { id: 'settings', label: '设置', icon: SVG_ICONS.settings }, ]; const router = { current: 'home', navigate(id) { this.current = id; document.querySelectorAll('[data-page]').forEach(el => el.classList.toggle('active', el.dataset.page === id)); // 非首页时侧边栏顶部显示小时间(容器始终占位,仅切换可见性避免撑动图标) // Show the small clock at the sidebar top when not on home (the container // always occupies space; only toggle visibility to avoid shifting icons) const clock = document.getElementById('rail-clock'); if (clock) clock.style.visibility = (id === 'home') ? 'hidden' : 'visible'; // 延迟内容加载到下一帧:让切换动画先流畅播放,避免加载重活(查应用/拉清单) // 在动画帧内阻塞导致卡顿 // Defer content loading to the next frame: let the switch animation play // smoothly first, avoiding jank from heavy loads (app query / manifest fetch) // blocking within the animation frame requestAnimationFrame(() => { if (id === 'home') window.updateHomeCards && window.updateHomeCards(); if (id === 'applist') window.loadAppList && window.loadAppList(); if (id === 'webapplist') window.loadWebAppList && window.loadWebAppList(); if (id === 'settings') window.loadSettings && window.loadSettings(); }); } };