feat: 链接批量操作(删除/移动分类)
- 后端 batch-delete + batch-move 接口 - 前端多选checkbox + 批量操作栏 - 支持批量删除(确认弹窗) - 支持批量移动分类 - 选中后自动显示操作栏,取消选择收起
This commit is contained in:
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user