feat: 链接批量操作(删除/移动分类)

- 后端 batch-delete + batch-move 接口
- 前端多选checkbox + 批量操作栏
- 支持批量删除(确认弹窗)
- 支持批量移动分类
- 选中后自动显示操作栏,取消选择收起
This commit is contained in:
Agent
2026-07-15 00:00:44 +08:00
parent 5ef10ddecb
commit d1cbecfe98
3 changed files with 70 additions and 1 deletions
+25
View File
@@ -196,6 +196,31 @@ const router = (app) => {
}
});
// 批量删除链接
app.post('/api/admin/links/batch-delete', authenticate, async (req, res) => {
try {
const ids = (req.body.ids || []).map(Number).filter(Boolean);
if (ids.length === 0) return res.json({ status: 400, message: '请选择链接' });
await pool.query(`DELETE FROM links WHERE id IN (${ids.map(() => '?').join(',')})`, ids);
res.json({ status: 200, message: `已删除 ${ids.length} 条链接` });
} catch {
res.json({ status: 500, message: '删除失败' });
}
});
// 批量移动分类
app.post('/api/admin/links/batch-move', authenticate, async (req, res) => {
try {
const ids = (req.body.ids || []).map(Number).filter(Boolean);
const categoryId = Number(req.body.categoryId);
if (ids.length === 0 || !categoryId) return res.json({ status: 400, message: '参数不完整' });
await pool.query(`UPDATE links SET category_id = ? WHERE id IN (${ids.map(() => '?').join(',')})`, [categoryId, ...ids]);
res.json({ status: 200, message: `已移动 ${ids.length} 条链接` });
} catch {
res.json({ status: 500, message: '移动失败' });
}
});
app.get('/api/admin/settings', authenticate, async (req, res) => {
try {
const [sets] = await pool.query('SELECT * FROM settings');