mirror of
https://github.com/langgenius/webapp-conversation.git
synced 2025-12-08 17:32:27 +08:00
- Replace .eslintrc.json with eslint.config.mjs - Simplify configuration using @antfu/eslint-config - Add necessary ESLint plugin dependencies - Disable overly strict style rules - Set package.json type to module for ESM support - Fix ESLint disable comment format 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
28 lines
657 B
TypeScript
28 lines
657 B
TypeScript
'use client'
|
|
import React from 'react'
|
|
|
|
export enum MediaType {
|
|
mobile = 'mobile',
|
|
tablet = 'tablet',
|
|
pc = 'pc',
|
|
}
|
|
|
|
const useBreakpoints = () => {
|
|
const [width, setWidth] = React.useState(globalThis.innerWidth)
|
|
const media = (() => {
|
|
if (width <= 640) { return MediaType.mobile }
|
|
if (width <= 768) { return MediaType.tablet }
|
|
return MediaType.pc
|
|
})()
|
|
|
|
React.useEffect(() => {
|
|
const handleWindowResize = () => setWidth(window.innerWidth)
|
|
window.addEventListener('resize', handleWindowResize)
|
|
return () => window.removeEventListener('resize', handleWindowResize)
|
|
}, [])
|
|
|
|
return media
|
|
}
|
|
|
|
export default useBreakpoints
|