feat(admin): 添加评论按域名筛选功能并调整统计页面布局

- 在评论管理页面添加域名筛选功能
- 调整统计页面中卡片顺序,将图表移至概览下方
- 更新文档添加版本更新警告提示
- 修改评论列表API支持域名参数查询
This commit is contained in:
anghunk
2026-01-21 13:37:55 +08:00
parent bbe2bdd820
commit 8fa8748949
5 changed files with 72 additions and 18 deletions

View File

@@ -9,14 +9,27 @@ export const listComments = async (c: Context<{ Bindings: Bindings }>) => {
const limit = 10;
const offset = (page - 1) * limit;
const rawDomain = c.req.query('domain') || '';
const domain = rawDomain.trim();
let whereSql = '';
const params: (string | number)[] = [];
if (domain) {
const pattern = `%://${domain}/%`;
whereSql = 'WHERE post_slug LIKE ? OR url LIKE ?';
params.push(pattern, pattern);
}
const totalCount = await c.env.CWD_DB.prepare(
'SELECT COUNT(*) as count FROM Comment'
).first<{ count: number }>();
`SELECT COUNT(*) as count FROM Comment ${whereSql}`
)
.bind(...params)
.first<{ count: number }>();
const { results } = await c.env.CWD_DB.prepare(
'SELECT * FROM Comment ORDER BY created DESC LIMIT ? OFFSET ?'
`SELECT * FROM Comment ${whereSql} ORDER BY created DESC LIMIT ? OFFSET ?`
)
.bind(limit, offset)
.bind(...params, limit, offset)
.all();
await c.env.CWD_DB.prepare(