Add tablet landscape layout and allow PWA horizontal orientation.

Split mobile and tablet breakpoints, restore desktop-style reading on landscape tablets, and lock Android tablet apps to landscape.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-16 14:47:50 +08:00
parent 1eb5264d4d
commit bb4f0c265d
5 changed files with 82 additions and 4 deletions
+25
View File
@@ -0,0 +1,25 @@
/** 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)
}