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

133 lines
3.7 KiB
TypeScript
Raw Normal View History

"use client";
2025-01-21 20:34:06 +08:00
import { Button, Card, Drawer, Form, Input, Space, Table } from "antd";
import { useState } from "react";
import '@ant-design/v5-patch-for-react-19';
import tableConfig from "./config"
import { useAntdTable } from "ahooks";
import { User } from "@/app/_lib/data/user";
import { mRequest } from "@/app/_lib/request";
interface DataType {
key: string;
name: string;
age: number;
address: string;
tags: string[];
}
const data: DataType[] = [
{
key: '1',
name: 'John Brown',
age: 32,
address: 'New York No. 1 Lake Park',
tags: ['nice', 'developer'],
},
{
key: '2',
name: 'Jim Green',
age: 42,
address: 'London No. 1 Lake Park',
tags: ['loser'],
},
{
key: '3',
name: 'Joe Black',
age: 32,
address: 'Sydney No. 1 Lake Park',
tags: ['cool', 'teacher'],
},
];
export default function Page() {
const [open, setOpen] = useState(false)
const { tableProps, loading, error } = useAntdTable(({ current, pageSize }) => mRequest<{
total: number;
list: User[];
}>('GET', `/api/links?page=${current}&pageSize=${pageSize}}`),
{
defaultPageSize: 10,
}
);
return (
<>
<Card
title="链接管理"
extra={
<Button type="primary" onClick={() => {
setOpen(true)
}}></Button>
}>
<Table
columns={tableConfig}
dataSource={data}
/>
</Card>
2025-01-21 20:34:06 +08:00
<Drawer
title={'添加图标'}
open={open}
width={500}
onClose={() => {
setOpen(false)
}}
footer={
<Space>
<Button></Button>
<Button type="primary"></Button>
</Space>
}
>
<Form
labelCol={{ span: 4 }}
onFinish={(res) => {
mRequest('POST', "/api/link").then(res => {
setOpen(false)
})
}}
>
<Form.Item
name="name"
label="名称"
rules={[{ required: true, message: "请输入名称" }]}
>
<Input />
</Form.Item>
<Form.Item
name="desc"
label="关键词"
rules={[{ required: true, message: "请输入名称" }]}
>
<Input />
</Form.Item>
<Form.Item
name="url"
label="链接"
rules={[{ required: true, message: "请输入链接" }]}
>
<Input />
</Form.Item>
{/* <Form.Item
name="icon"
label="图标"
rules={[{ required: true, message: "请上传图标" }]}
>
<ResourceUpload></ResourceUpload>
</Form.Item> */}
<Form.Item className="flex justify-end">
<Button type="primary" htmlType="submit">
</Button>
</Form.Item>
</Form>
</Drawer>
</>
)
}