Feat/use searchparams as state (#2554)

Co-authored-by: crazywoola <427733928@qq.com>
This commit is contained in:
Rozstone 2024-02-26 12:52:59 +08:00 • committed by GitHub
commit d93288f711
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 58 additions and 9 deletions

View file

@ -16,6 +16,7 @@ import EditCustomToolModal from './edit-custom-collection-modal'
import NoCustomTool from './info/no-custom-tool'
import NoSearchRes from './info/no-search-res'
import NoCustomToolPlaceholder from './no-custom-tool-placeholder'
import { useTabSearchParams } from '@/hooks/use-tab-searchparams'
import TabSlider from '@/app/components/base/tab-slider'
import { createCustomCollection, fetchCollectionList as doFetchCollectionList, fetchBuiltInToolList, fetchCustomToolList } from '@/service/tools'
import type { AgentTool } from '@/types/app'
@ -68,7 +69,9 @@ const Tools: FC<Props> = ({
})()
const [query, setQuery] = useState('')
const [collectionType, setCollectionType] = useState<CollectionType>(collectionTypeOptions[0].value)
const [collectionType, setCollectionType] = useTabSearchParams({
defaultTab: collectionTypeOptions[0].value,
})
const showCollectionList = (() => {
let typeFilteredList: Collection[] = []