609f7d06cf
- pets-fe: 微信原生小程序(首页/计划/记录/报告/社区/引导), 服务端驱动、无假数据;弹层改用 scroll-view,打开时隐藏自定义 tabBar - pets-be: Gin + GORM(MySQL, sundynix_ 前缀) + MinIO,统一响应/分页, 微信 code2session 登录,provider-neutral AI(DeepSeek),go:embed React 后台 - 修复:分段选择类型不匹配(字符串 vs 数字)导致选不中 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
60 lines
2.2 KiB
TypeScript
60 lines
2.2 KiB
TypeScript
import { api } from '@/lib/api'
|
|
import { usePaged } from '@/lib/usePaged'
|
|
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@/components/ui/table'
|
|
import { Button } from '@/components/ui/button'
|
|
import { Badge } from '@/components/ui/badge'
|
|
import { Card, CardContent } from '@/components/ui/card'
|
|
import { Pager } from '@/components/Pager'
|
|
|
|
export default function Comments() {
|
|
const { page, setPage, data, totalPages, reload } = usePaged<any>(api.comments)
|
|
|
|
async function del(id: number) {
|
|
await api.deleteComment(id)
|
|
reload()
|
|
}
|
|
|
|
return (
|
|
<div>
|
|
<h1 className="text-2xl font-bold mb-6">评论管理</h1>
|
|
<Card>
|
|
<CardContent className="pt-6">
|
|
<Table>
|
|
<TableHeader>
|
|
<TableRow>
|
|
<TableHead>ID</TableHead>
|
|
<TableHead>帖子ID</TableHead>
|
|
<TableHead>作者</TableHead>
|
|
<TableHead>内容</TableHead>
|
|
<TableHead>状态</TableHead>
|
|
<TableHead className="text-right">操作</TableHead>
|
|
</TableRow>
|
|
</TableHeader>
|
|
<TableBody>
|
|
{data?.list?.map((c) => (
|
|
<TableRow key={c.id}>
|
|
<TableCell>{c.id}</TableCell>
|
|
<TableCell>{c.post_id}</TableCell>
|
|
<TableCell className="whitespace-nowrap">{c.author_name}</TableCell>
|
|
<TableCell className="max-w-sm truncate">{c.content}</TableCell>
|
|
<TableCell>
|
|
{c.status === 'deleted' ? <Badge variant="destructive">已删除</Badge> : <Badge variant="success">正常</Badge>}
|
|
</TableCell>
|
|
<TableCell className="text-right">
|
|
{c.status !== 'deleted' && (
|
|
<Button variant="destructive" size="sm" onClick={() => del(c.id)}>
|
|
删除
|
|
</Button>
|
|
)}
|
|
</TableCell>
|
|
</TableRow>
|
|
))}
|
|
</TableBody>
|
|
</Table>
|
|
<Pager page={page} totalPages={totalPages} total={data?.total ?? 0} onChange={setPage} />
|
|
</CardContent>
|
|
</Card>
|
|
</div>
|
|
)
|
|
}
|