This commit is contained in:
expdsn 2025-01-21 20:34:06 +08:00
parent 0ec61b5ad4
commit 115dc19e3d
3 changed files with 76 additions and 14 deletions

View File

@ -1,15 +1,6 @@
import { ReactNode } from "react"; import { ReactNode } from "react";
export type LinkItem = {
title: string;
url?: string;
description: string;
id: number;
type: string;
priority: number;
logoLink: string;
}
export type LinkTypeItem = { export type LinkTypeItem = {
label: string; label: string;
icon: ReactNode; icon: ReactNode;

View File

@ -1,5 +1,5 @@
"use client"; "use client";
import { Button, Card, Drawer, Space, Table } from "antd"; import { Button, Card, Drawer, Form, Input, Space, Table } from "antd";
import { useState } from "react"; import { useState } from "react";
import '@ant-design/v5-patch-for-react-19'; import '@ant-design/v5-patch-for-react-19';
import tableConfig from "./config" import tableConfig from "./config"
@ -61,9 +61,71 @@ export default function Page() {
dataSource={data} dataSource={data}
/> />
</Card> </Card>
<Drawer open={open} onClose={() => { <Drawer
setOpen(false) 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>
</> </>

View File

@ -4,7 +4,16 @@ import { getCollection, getDb } from "@/app/_lib/mongodb";
import { message } from "antd"; import { message } from "antd";
import bcrypt from 'bcrypt'; import bcrypt from 'bcrypt';
import { NextRequest } from "next/server"; import { NextRequest } from "next/server";
export type Link = {
title: string;
url?: string;
description: string;
id: number;
type: string;
priority: number;
logoLink: string;
}
export async function GET(req: NextRequest) { export async function GET(req: NextRequest) {
try { try {
const collection = await getCollection('link'); const collection = await getCollection('link');
@ -22,7 +31,7 @@ export async function GET(req: NextRequest) {
const startIndex = (page - 1) * pageSize; const startIndex = (page - 1) * pageSize;
// 查询数据 // 查询数据
const cursor = collection.find<User>({}).skip(startIndex).limit(pageSize); const cursor = collection.find<Link>({}).skip(startIndex).limit(pageSize);
const data = await cursor.toArray(); const data = await cursor.toArray();
// 计算总数量 // 计算总数量