新增自动刷新

This commit is contained in:
2025-05-12 13:52:38 +08:00
parent 11d503ab49
commit 26142f9a71
3 changed files with 12 additions and 4 deletions

View File

@@ -2,6 +2,7 @@
import { list, UserListParams, UserListResponse } from '@/lib/api/admin/user'
import { ApiError } from '@/lib/api/fetcher'
import { useCallback } from 'react'
import { toast } from 'sonner'
import useSWR from 'swr'
@@ -11,6 +12,10 @@ export function useUserList(params?: UserListParams) {
() => list(params),
)
const refresh = useCallback(() => {
return mutate()
}, [mutate])
return {
users: data?.items ?? [],
total: data?.total ?? 0,
@@ -19,5 +24,6 @@ export function useUserList(params?: UserListParams) {
isLoading,
error,
mutate,
refresh,
}
}