mirror of
https://github.com/langgenius/webapp-conversation.git
synced 2025-12-20 04:46:39 +08:00
feat: lint code
This commit is contained in:
@ -8,20 +8,22 @@ export enum MediaType {
|
||||
}
|
||||
|
||||
const useBreakpoints = () => {
|
||||
const [width, setWidth] = React.useState(globalThis.innerWidth);
|
||||
const [width, setWidth] = React.useState(globalThis.innerWidth)
|
||||
const media = (() => {
|
||||
if (width <= 640) return MediaType.mobile;
|
||||
if (width <= 768) return MediaType.tablet;
|
||||
return MediaType.pc;
|
||||
})();
|
||||
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);
|
||||
}, []);
|
||||
const handleWindowResize = () => setWidth(window.innerWidth)
|
||||
window.addEventListener('resize', handleWindowResize)
|
||||
return () => window.removeEventListener('resize', handleWindowResize)
|
||||
}, [])
|
||||
|
||||
return media;
|
||||
return media
|
||||
}
|
||||
|
||||
export default useBreakpoints
|
||||
export default useBreakpoints
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { useState } from 'react'
|
||||
import type { ConversationItem } from '@/types/app'
|
||||
import produce from 'immer'
|
||||
import type { ConversationItem } from '@/types/app'
|
||||
|
||||
const storageConversationIdKey = 'conversationIdInfo'
|
||||
|
||||
@ -29,9 +29,10 @@ function useConversation() {
|
||||
// input can be updated by user
|
||||
const [newConversationInputs, setNewConversationInputs] = useState<Record<string, any> | null>(null)
|
||||
const resetNewConversationInputs = () => {
|
||||
if (!newConversationInputs) return
|
||||
setNewConversationInputs(produce(newConversationInputs, draft => {
|
||||
Object.keys(draft).forEach(key => {
|
||||
if (!newConversationInputs)
|
||||
return
|
||||
setNewConversationInputs(produce(newConversationInputs, (draft) => {
|
||||
Object.keys(draft).forEach((key) => {
|
||||
draft[key] = ''
|
||||
})
|
||||
}))
|
||||
@ -59,8 +60,8 @@ function useConversation() {
|
||||
setCurrInputs,
|
||||
currConversationInfo,
|
||||
setNewConversationInfo,
|
||||
setExistConversationInfo
|
||||
setExistConversationInfo,
|
||||
}
|
||||
}
|
||||
|
||||
export default useConversation;
|
||||
export default useConversation
|
||||
|
||||
Reference in New Issue
Block a user