diff --git a/src/api/Comment.ts b/src/api/Comment.ts index 707c107..71e5ba1 100644 --- a/src/api/Comment.ts +++ b/src/api/Comment.ts @@ -1,4 +1,5 @@ import Request from '@/utils/request' +import { Comment } from '@/types/comment' // 新增评论 export const addCommentDataAPI = (data: Comment) => Request("POST", "/comment", data) diff --git a/src/pages/Comment/index.tsx b/src/pages/Comment/index.tsx index 164326c..b38d85b 100644 --- a/src/pages/Comment/index.tsx +++ b/src/pages/Comment/index.tsx @@ -1,21 +1,22 @@ import { useState, useEffect } from 'react'; -import { Tabs, Spin, Card, message, Table, Popconfirm, Button, Tag } from 'antd'; +import { Tabs, Spin, Card, message, Table, Popconfirm, Button, Tag, Modal } from 'antd'; import { getCommentListAPI } from '@/api/Comment'; import { auditCommentDataAPI, delCommentDataAPI } from '@/api/Comment'; import dayjs from 'dayjs'; import { ColumnsType } from 'antd/es/table'; import { titleSty } from '@/styles/sty'; import Title from '@/components/Title'; -import { Comment as ArticleComment } from '@/types/comment' +import { Comment } from '@/types/comment' const { TabPane } = Tabs; -const Comment = () => { +const CommentPage = () => { const [loading, setLoading] = useState(false); - const [model, setModel] = useState(false); const [comment, setComment] = useState(); const [list, setList] = useState([]); + const [isModalOpen, setIsModalOpen] = useState(false); + // const loadingFn = async (callback: () => void) => { // setLoading(true) // await callback() @@ -78,6 +79,10 @@ const Comment = () => { title: '内容', dataIndex: 'content', key: 'content', + render: (text: string, record) => { + setComment(record) + setIsModalOpen(true) + }}>{text} }, { title: '网站', @@ -101,10 +106,15 @@ const Comment = () => { key: 'action', fixed: 'right', align: 'center', - render: (text: string, record: ArticleComment) => ( + render: (text: string, record: Comment) => (
{!record.auditStatus && } - + + + delCommentData(record.id)}> @@ -131,8 +141,25 @@ const Comment = () => { /> + + setIsModalOpen(false)} footer={null}> +
+
所属文章: {comment?.articleTitle}
+
评论时间: {dayjs(comment?.createTime).format("YYYY-MM-DD HH:mm:ss")}
+
评论用户: {comment?.name}
+
邮箱: {comment?.email}
+
网站: {comment?.url ? {comment?.url} : '无网站'}
+
内容: {comment?.content}
+
状态: {comment?.auditStatus + ? 通过 + : 待审核} +
+ + {!comment?.auditStatus ? : null} +
+
); }; -export default Comment; +export default CommentPage;