From ac263b4cecda40d7e1f6639bbd81cd8d925e830f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=87=E9=98=B3?= <3311118881@qq.com> Date: Wed, 25 Sep 2024 14:25:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=AE=A1=E6=A0=B8=E4=B8=8E?= =?UTF-8?q?=E6=8B=92=E5=AE=A1=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/Web.ts | 3 ++ src/pages/Comment/index.tsx | 2 +- src/pages/Work/index.tsx | 77 +++++++++++++++++++++++++++++++++---- src/types/app/web.d.ts | 3 +- 4 files changed, 76 insertions(+), 9 deletions(-) diff --git a/src/api/Web.ts b/src/api/Web.ts index 3119b29..9447cc5 100644 --- a/src/api/Web.ts +++ b/src/api/Web.ts @@ -21,3 +21,6 @@ export const getLinkListAPI = (data?: QueryData) => getListAPI("/link", dat export const getLinkTypeListAPI = () => { return Request("GET", `/link/type`); }; + +// 审核网站 +export const auditWebDataAPI = (id: number) => Request("PATCH", `/link/audit/${id}`) diff --git a/src/pages/Comment/index.tsx b/src/pages/Comment/index.tsx index 20fd444..9993227 100644 --- a/src/pages/Comment/index.tsx +++ b/src/pages/Comment/index.tsx @@ -1,5 +1,5 @@ import { useState, useEffect } from 'react'; -import { Spin, Card, message, Table, Popconfirm, Button, Tag, Modal, Form, Input, DatePicker } from 'antd'; +import { Card, message, Table, Popconfirm, Button, Tag, Modal, Form, Input, DatePicker } from 'antd'; import { getCommentListAPI } from '@/api/Comment'; import { auditCommentDataAPI, delCommentDataAPI } from '@/api/Comment'; import { ColumnsType } from 'antd/es/table'; diff --git a/src/pages/Work/index.tsx b/src/pages/Work/index.tsx index a1aff9f..c97556d 100644 --- a/src/pages/Work/index.tsx +++ b/src/pages/Work/index.tsx @@ -1,23 +1,58 @@ -import { Card } from "antd" +import { useEffect, useState } from "react" +import { Card, Dropdown, message } from "antd" +import { getLinkListAPI, delLinkDataAPI, auditWebDataAPI } from '@/api/Web' + import Title from "@/components/Title" import comment from './image/comment.svg' -import message from './image/message.svg' +import info from './image/message.svg' import link from './image/link.svg' -import { useState } from "react" +import { Web } from "@/types/app/web" +import dayjs from 'dayjs'; export default () => { const activeSty = "bg-[#f9f9ff] text-primary" const [active, setActive] = useState(0) + const [linkList, setLinkList] = useState([]) + + const getLinkList = async () => { + const { data } = await getLinkListAPI() + setLinkList((data as Web[]).filter(item => item.auditStatus === 0)) + } + useEffect(() => { + getLinkList() + }, []) + + // 操作 + const getMenuItems = (item: Web) => [ + { + key: 'ok', + label: "通过", + onClick: async () => { + await auditWebDataAPI(item.id) + message.success('🎉 审核成功'); + getLinkList(); + } + }, + { + key: 'no', + label: "拒审", + onClick: async () => { + await delLinkDataAPI(item.id) + message.success('🎉 拒审成功'); + getLinkList(); + } + } + ]; return ( <> <Card className="mt-2"> - <div className="w-full"> + <div className="flex w-full"> <div className="w-2/12 min-h-96 pr-4 border-r border-[#eee]"> - <ul className=""> + <ul className="space-y-1"> <li className={`flex items-center w-full py-3 px-4 hover:bg-[#f9f9ff] hover:text-primary ${active === 0 ? activeSty : ''} rounded-md text-base cursor-pointer transition-colors`} onClick={() => setActive(0)} @@ -38,14 +73,42 @@ export default () => { className={`flex items-center w-full py-3 px-4 hover:bg-[#f9f9ff] hover:text-primary ${active === 2 ? activeSty : ''} rounded-md text-base cursor-pointer transition-colors`} onClick={() => setActive(2)} > - <img src={message} alt="" className="w-8 mr-4" /> + <img src={info} alt="" className="w-8 mr-4" /> <span>留言</span> </li> </ul> </div> - <div className="w-10/12"> + <div className="w-10/12 pl-6 py-4 space-y-10"> + { + linkList.map(item => ( + <div key={item.id}> + <div className="text-center text-xs text-[#e0e0e0] mb-4">{dayjs(+item.createTime!).format('YYYY-MM-DD HH:mm:ss')}</div> + <div className="flex justify-between p-7 rounded-md hover:bg-[#F9F9FD] transition-colors"> + <div className="flex"> + <img src={item.image} alt="" className="w-13 h-13 border border-[#eee] rounded-full" /> + <div className="flex flex-col justify-center ml-4 px-4 py-2 bg-[#F9F9FD] rounded-md"> + <div>网站名称:{item.title}</div> + <div>网站介绍:{item.description}</div> + <div>网站地址:{item.url}</div> + <div>网站类型:{item.type.name}</div> + <div>作者邮箱:{item.email ? item.email : '暂无'}</div> + </div> + </div> + + <div className="flex items-end"> + <Dropdown menu={{ items: getMenuItems(item) }}> + <div className="flex justify-evenly items-center bg-[#F9F9FD] w-11 h-5 rounded-md cursor-pointer"> + <span className="inline-block w-2 h-2 bg-[#b5c2d3] rounded-full"></span> + <span className="inline-block w-2 h-2 bg-[#b5c2d3] rounded-full"></span> + </div> + </Dropdown> + </div> + </div> + </div> + )) + } </div> </div> </Card > diff --git a/src/types/app/web.d.ts b/src/types/app/web.d.ts index d0d9bba..e8a08aa 100644 --- a/src/types/app/web.d.ts +++ b/src/types/app/web.d.ts @@ -4,7 +4,7 @@ export interface LinkType { } export interface Web { - id?: number; + id: number; title: string; description: string; email: string; @@ -13,5 +13,6 @@ export interface Web { rss: string; typeId: number; type: LinkType; + auditStatus: number; createTime?: string; }