初步优化手机端ui

This commit is contained in:
yml2213
2026-08-16 10:33:45 +08:00
parent ad84388450
commit 10ae3d01ee
6 changed files with 1316 additions and 338 deletions
+24
View File
@@ -0,0 +1,24 @@
import { useEffect, useState } from 'react'
export function useIsMobile(breakpoint = 768): boolean {
const [isMobile, setIsMobile] = useState<boolean>(() => {
if (typeof window === 'undefined') return false
return window.innerWidth <= breakpoint
})
useEffect(() => {
if (typeof window === 'undefined') return
function checkMobile() {
setIsMobile(window.innerWidth <= breakpoint)
}
// Initialize state
checkMobile()
window.addEventListener('resize', checkMobile)
return () => window.removeEventListener('resize', checkMobile)
}, [breakpoint])
return isMobile
}