实现添加博客
This commit is contained in:
24
tone-page-web/hooks/admin/web/blog/use-blog-list.ts
Normal file
24
tone-page-web/hooks/admin/web/blog/use-blog-list.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
"use client"
|
||||
|
||||
import { AdminApi } from "@/lib/api";
|
||||
import { useCallback } from "react";
|
||||
import useSWR from "swr";
|
||||
|
||||
export function useBlogList() {
|
||||
const { data, error, isLoading, mutate } = useSWR(
|
||||
['/admin/web/blog'],
|
||||
() => AdminApi.web.blog.list()
|
||||
)
|
||||
|
||||
const refresh = useCallback(() => {
|
||||
return mutate()
|
||||
}, [mutate])
|
||||
|
||||
return {
|
||||
blogs: data,
|
||||
error,
|
||||
isLoading,
|
||||
mutate,
|
||||
refresh,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user