mirror of
https://github.com/koreanbots/core.git
synced 2025-12-16 22:30:23 +00:00
This commit is contained in:
parent
a3b1305150
commit
8737ec9a74
@ -1,6 +1,7 @@
|
|||||||
import { useEffect, useRef, useState } from 'react'
|
import { useEffect, useRef, useState } from 'react'
|
||||||
import { useRouter } from 'next/router'
|
import { useRouter } from 'next/router'
|
||||||
import Link from 'next/link'
|
import Link from 'next/link'
|
||||||
|
import AbortController from 'abort-controller'
|
||||||
|
|
||||||
import { makeBotURL, redirectTo } from '@utils/Tools'
|
import { makeBotURL, redirectTo } from '@utils/Tools'
|
||||||
import Fetch from '@utils/Fetch'
|
import Fetch from '@utils/Fetch'
|
||||||
@ -39,7 +40,7 @@ const Search = (): JSX.Element => {
|
|||||||
}
|
}
|
||||||
const controller = new AbortController()
|
const controller = new AbortController()
|
||||||
setAbortControl(controller)
|
setAbortControl(controller)
|
||||||
if (value.length > 2) setLoading(true)
|
if (value.length > 1) setLoading(true)
|
||||||
const res = await Fetch<BotList>(`/search/bots?q=${encodeURIComponent(value)}`, {
|
const res = await Fetch<BotList>(`/search/bots?q=${encodeURIComponent(value)}`, {
|
||||||
signal: controller.signal,
|
signal: controller.signal,
|
||||||
})
|
})
|
||||||
@ -48,7 +49,7 @@ const Search = (): JSX.Element => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const onSubmit = () => {
|
const onSubmit = () => {
|
||||||
if(query.length < 3) return
|
if(query.length < 2) return
|
||||||
if(!localStorage.recentSearch) localStorage.recentSearch = '[]'
|
if(!localStorage.recentSearch) localStorage.recentSearch = '[]'
|
||||||
try {
|
try {
|
||||||
const d = JSON.parse(localStorage.recentSearch).reverse()
|
const d = JSON.parse(localStorage.recentSearch).reverse()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user