/** Android 平板 PWA 安装后默认锁定横屏 */ export function initTabletLandscape() { if (typeof window === 'undefined') return function tryLockLandscape() { const isStandalone = window.matchMedia('(display-mode: standalone)').matches || (window.navigator as Navigator & { standalone?: boolean }).standalone if (!isStandalone || !/Android/i.test(navigator.userAgent)) return const shortestSide = Math.min(window.screen.width, window.screen.height) if (shortestSide < 600) return const lock = screen.orientation?.lock?.bind(screen.orientation) if (!lock) return lock('landscape-primary').catch(() => { lock('landscape').catch(() => {}) }) } tryLockLandscape() window.addEventListener('orientationchange', tryLockLandscape) }