Skip to content

Commit

Permalink
chore: use isTouchDevice judge
Browse files Browse the repository at this point in the history
  • Loading branch information
ddiu8081 committed May 24, 2023
1 parent cbb2994 commit a935b33
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions src/components/Generator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,17 +159,11 @@ export default () => {
setLoading(false)
setController(null)
// Determines whether to focus the cursor based on the user agent
if (!isMobileDevice())
if (!('ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0))
inputRef.focus()
}
}

const isMobileDevice = () => {
const currentUserAgent = navigator.userAgent
const userAgents = ['Android', 'Windows Phone', 'iPhone', 'iPad', 'iPod']
return !!userAgents.filter(ua => currentUserAgent.includes(ua)).length
}

const clear = () => {
inputRef.value = ''
inputRef.style.height = 'auto'
Expand Down

0 comments on commit a935b33

Please sign in to comment.