feat: 优化项目目录结构
This commit is contained in:
30
apps/frontend/hooks/admin/web/resource/use-resource-list.ts
Normal file
30
apps/frontend/hooks/admin/web/resource/use-resource-list.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
"use client"
|
||||
|
||||
import { AdminApi } from "@/lib/api";
|
||||
import { useCallback } from "react";
|
||||
import { toast } from "sonner";
|
||||
import useSWR from "swr";
|
||||
|
||||
export function useResourceList() {
|
||||
const { data, error, isLoading, mutate } = useSWR(
|
||||
['/admin/web/resource'],
|
||||
() => AdminApi.web.resource.list(),
|
||||
{
|
||||
onError: (e) => {
|
||||
toast.error(`${e.message || e}`)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
const refresh = useCallback(() => {
|
||||
return mutate()
|
||||
}, [mutate])
|
||||
|
||||
return {
|
||||
resources: data,
|
||||
error,
|
||||
isLoading,
|
||||
mutate,
|
||||
refresh,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user