From 115dc19e3db1b57d718f5f1252ae8221dec7e820 Mon Sep 17 00:00:00 2001 From: expdsn <18111002318@163.com> Date: Tue, 21 Jan 2025 20:34:06 +0800 Subject: [PATCH] save --- app/_lib/types.ts | 9 ---- app/admin/(default)/dashboard/page.tsx | 70 ++++++++++++++++++++++++-- app/api/link/route.ts | 11 +++- 3 files changed, 76 insertions(+), 14 deletions(-) diff --git a/app/_lib/types.ts b/app/_lib/types.ts index 8533929..fa21fe3 100644 --- a/app/_lib/types.ts +++ b/app/_lib/types.ts @@ -1,15 +1,6 @@ import { ReactNode } from "react"; -export type LinkItem = { - title: string; - url?: string; - description: string; - id: number; - type: string; - priority: number; - logoLink: string; -} export type LinkTypeItem = { label: string; icon: ReactNode; diff --git a/app/admin/(default)/dashboard/page.tsx b/app/admin/(default)/dashboard/page.tsx index 73f23d6..19bfb4d 100644 --- a/app/admin/(default)/dashboard/page.tsx +++ b/app/admin/(default)/dashboard/page.tsx @@ -1,5 +1,5 @@ "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 '@ant-design/v5-patch-for-react-19'; import tableConfig from "./config" @@ -61,9 +61,71 @@ export default function Page() { dataSource={data} /> - { - setOpen(false) - }} /> + { + setOpen(false) + }} + footer={ + + + + + + } + > +
{ + mRequest('POST', "/api/link").then(res => { + setOpen(false) + }) + }} + > + + + + + + + + + + + + + {/* + + */} + + + + + + +
+ +
diff --git a/app/api/link/route.ts b/app/api/link/route.ts index 29afddb..7210eb3 100644 --- a/app/api/link/route.ts +++ b/app/api/link/route.ts @@ -4,7 +4,16 @@ import { getCollection, getDb } from "@/app/_lib/mongodb"; import { message } from "antd"; import bcrypt from 'bcrypt'; 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) { try { const collection = await getCollection('link'); @@ -22,7 +31,7 @@ export async function GET(req: NextRequest) { const startIndex = (page - 1) * pageSize; // 查询数据 - const cursor = collection.find({}).skip(startIndex).limit(pageSize); + const cursor = collection.find({}).skip(startIndex).limit(pageSize); const data = await cursor.toArray(); // 计算总数量