ai-bot/app/admin/(default)/dashboard/article/page.tsx

64 lines
2.2 KiB
TypeScript
Raw Normal View History

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
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}`))
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>
)
}