import { Template } from "interface/template"; import { Container, Heading, Text, Box, Flex, Table, Button, TextField, DropdownMenu, ScrollArea, DataList, Avatar, Badge } from "@radix-ui/themes"; import { MagnifyingGlassIcon, CheckIcon, Cross2Icon, ChatBubbleIcon, TrashIcon, } from "@radix-ui/react-icons"; import { useState } from "react"; // 模拟评论数据 const mockComments = [ { id: 1, content: "这篇文章写得很好,对我帮助很大!", author: "张三", postTitle: "构建现代化的前端开发工作流", createdAt: new Date("2024-03-15"), status: "pending", // pending, approved, rejected avatar: "https://api.dicebear.com/7.x/avataaars/svg?seed=1" }, { id: 2, content: "文章内容很专业,讲解得很清楚。", author: "李四", postTitle: "React 18 新特性详解", createdAt: new Date("2024-03-14"), status: "approved", avatar: "https://api.dicebear.com/7.x/avataaars/svg?seed=2" }, // 可以添加更多模拟数据 ]; export default new Template({}, ({ http, args }) => { const [searchTerm, setSearchTerm] = useState(""); const [selectedStatus, setSelectedStatus] = useState("all"); const getStatusStyle = (status: string) => { switch(status) { case 'approved': return 'bg-[--green-3] text-[--green-11]'; case 'rejected': return 'bg-[--red-3] text-[--red-11]'; default: return 'bg-[--yellow-3] text-[--yellow-11]'; } }; const getStatusText = (status: string) => { switch(status) { case 'approved': return '已通过'; case 'rejected': return '已拒绝'; default: return '待审核'; } }; return ( {/* 页面标题和统计 */} 评论管理 共 {mockComments.length} 条评论 {/* 搜索和筛选栏 */} ) => setSearchTerm(e.target.value)} > setSelectedStatus('all')}> 全部 setSelectedStatus('pending')}> 待审核 setSelectedStatus('approved')}> 已通过 setSelectedStatus('rejected')}> 已拒绝 {/* 评论列表 */} {/* 桌面端表格视图 */}
评论者 评论内容 文章 状态 时间 操作 {mockComments.map((comment) => ( {comment.author} {comment.content} {comment.postTitle} {comment.status === 'approved' && 已通过} {comment.status === 'pending' && 待审核} {comment.status === 'rejected' && 已拒绝} {comment.createdAt.toLocaleDateString()} ))}
{/* 移动端列表视图 */}
{mockComments.map((comment) => ( 评论者 {comment.author} 评论内容 {comment.content} 文章 {comment.postTitle} 状态 {comment.status === 'approved' && 已通过} {comment.status === 'pending' && 待审核} {comment.status === 'rejected' && 已拒绝} 时间 {comment.createdAt.toLocaleDateString()} 操作 ))}
); });