feat: 前端资源、博客采用新的API实现
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
import { BlogApi } from "@/lib/api";
|
|
||||||
import { useCallback } from "react"
|
import { useCallback } from "react"
|
||||||
import {
|
import {
|
||||||
Alert,
|
Alert,
|
||||||
@@ -7,6 +6,7 @@ import {
|
|||||||
} from "@/components/ui/alert";
|
} from "@/components/ui/alert";
|
||||||
import { AlertCircle } from "lucide-react";
|
import { AlertCircle } from "lucide-react";
|
||||||
import { base62 } from "@/lib/utils";
|
import { base62 } from "@/lib/utils";
|
||||||
|
import { BlogAPI } from "@/lib/api/server";
|
||||||
|
|
||||||
export default async function Blog() {
|
export default async function Blog() {
|
||||||
const formatNumber = useCallback((num: number) => {
|
const formatNumber = useCallback((num: number) => {
|
||||||
@@ -19,7 +19,7 @@ export default async function Blog() {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
let errorMsg = '';
|
let errorMsg = '';
|
||||||
const blogs = await BlogApi.list().catch(e => { errorMsg = `${e}`; return null });
|
const blogs = await BlogAPI.list().catch(e => { errorMsg = `${e}`; return null });
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="max-w-120 w-auto mx-auto my-10 flex flex-col gap-8">
|
<div className="max-w-120 w-auto mx-auto my-10 flex flex-col gap-8">
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
import { ResourceCard } from "./components/ResourceCard";
|
import { ResourceCard } from "./components/ResourceCard";
|
||||||
import { ResourceApi } from "@/lib/api";
|
|
||||||
import {
|
import {
|
||||||
Alert,
|
Alert,
|
||||||
AlertDescription,
|
AlertDescription,
|
||||||
AlertTitle,
|
AlertTitle,
|
||||||
} from "@/components/ui/alert"
|
} from "@/components/ui/alert"
|
||||||
|
import { ResourceAPI } from "@/lib/api/server";
|
||||||
import { AlertCircle } from "lucide-react";
|
import { AlertCircle } from "lucide-react";
|
||||||
|
|
||||||
export default async function Resources() {
|
export default async function Resources() {
|
||||||
let errorMsg = '';
|
let errorMsg = '';
|
||||||
const data = await ResourceApi.list().catch(e => { errorMsg = `${e}`; return null; });
|
const data = await ResourceAPI.list().catch(e => { errorMsg = `${e}`; return null; });
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex-1 flex flex-col items-center">
|
<div className="flex-1 flex flex-col items-center">
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
|
import { Blog } from "@/lib/types/blog";
|
||||||
import { serverFetch } from "../server";
|
import { serverFetch } from "../server";
|
||||||
|
|
||||||
export async function list() {
|
export async function list() {
|
||||||
return serverFetch('/api/blog')
|
return serverFetch<Blog[]>('/api/blog')
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user