2025-02-07 19:02:22 +08:00
|
|
|
"use client"
|
2025-02-10 19:20:12 +08:00
|
|
|
import { Button, Card, Image, Space, Table } from "antd";
|
2025-02-07 19:02:22 +08:00
|
|
|
import '@ant-design/v5-patch-for-react-19';
|
2025-02-10 19:20:12 +08:00
|
|
|
import { useRouter } from "next/navigation";
|
|
|
|
import { useAntdTable } from "ahooks";
|
|
|
|
import { mRequest } from "@/app/_lib/request";
|
|
|
|
import { ArticleType } from "@/app/_lib/data/article";
|
2025-02-07 19:02:22 +08:00
|
|
|
|
2025-01-22 17:37:56 +08:00
|
|
|
export default function Page() {
|
2025-02-07 19:02:22 +08:00
|
|
|
const router = useRouter()
|
2025-02-10 19:20:12 +08:00
|
|
|
const { tableProps, refresh } = useAntdTable(async ({ current, pageSize }) => mRequest<{
|
|
|
|
total: number;
|
|
|
|
list: ArticleType[]
|
|
|
|
}>('GET', `/api/article?page=${current}&pageSize=${pageSize}`))
|
2025-01-22 17:37:56 +08:00
|
|
|
return (
|
2025-02-10 19:20:12 +08:00
|
|
|
<Card title="文章管理" extra={
|
|
|
|
<Space>
|
|
|
|
<Button onClick={() => refresh()}>刷新</Button>
|
|
|
|
<Button type="primary" onClick={() => {
|
|
|
|
router.push("/admin/dashboard/article/detail")
|
|
|
|
}} >
|
|
|
|
新增文章
|
|
|
|
</Button>
|
|
|
|
</Space>
|
|
|
|
}>
|
2025-02-07 19:02:22 +08:00
|
|
|
<Table
|
2025-02-10 19:20:12 +08:00
|
|
|
{...tableProps}
|
|
|
|
rowKey="_id"
|
2025-02-07 19:02:22 +08:00
|
|
|
columns={[
|
|
|
|
{
|
|
|
|
title: '标题',
|
|
|
|
dataIndex: 'title',
|
|
|
|
},
|
|
|
|
{
|
2025-02-10 19:20:12 +08:00
|
|
|
title: '副标题',
|
|
|
|
dataIndex: 'description',
|
2025-02-07 19:02:22 +08:00
|
|
|
},
|
2025-02-10 19:20:12 +08:00
|
|
|
|
2025-02-07 19:02:22 +08:00
|
|
|
{
|
2025-02-10 19:20:12 +08:00
|
|
|
title: "封面",
|
|
|
|
dataIndex: "content",
|
|
|
|
render: (_, item) => (
|
|
|
|
<>
|
|
|
|
<Image src={item.content} width={70} ></Image>
|
|
|
|
</>
|
|
|
|
)
|
2025-02-07 19:02:22 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
title: '操作',
|
|
|
|
render: (_, row) => (
|
|
|
|
<Space>
|
2025-02-10 19:20:12 +08:00
|
|
|
<Button type="primary" onClick={() => {
|
|
|
|
router.push(`/admin/dashboard/article/detail/${row._id}`)
|
|
|
|
}} >修改</Button>
|
|
|
|
<Button type="primary" danger>删除</Button>
|
2025-02-07 19:02:22 +08:00
|
|
|
</Space>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
]}
|
|
|
|
|
|
|
|
></Table>
|
|
|
|
</Card>
|
2025-01-22 17:37:56 +08:00
|
|
|
)
|
|
|
|
}
|