diff --git a/backend/src/routes/api.js b/backend/src/routes/api.js
index 98b6c1e..a077d34 100644
--- a/backend/src/routes/api.js
+++ b/backend/src/routes/api.js
@@ -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');
diff --git a/frontend/src/api/index.ts b/frontend/src/api/index.ts
index 18a05c0..083ffcb 100644
--- a/frontend/src/api/index.ts
+++ b/frontend/src/api/index.ts
@@ -48,6 +48,8 @@ export const adminApi = {
updateLink: (id: number, data: any) => request.put(`/admin/links/${id}`, data),
deleteLink: (id: number) => request.delete(`/admin/links/${id}`),
updateSorts: (sorts: any[]) => request.put('/admin/links/sort', { sorts }),
+ batchDelete: (ids: number[]) => request.post('/admin/links/batch-delete', { ids }),
+ batchMove: (ids: number[], categoryId: number) => request.post('/admin/links/batch-move', { ids, categoryId }),
getSettings: () => request.get('/admin/settings'),
updateSettings: (data: any) => request.put('/admin/settings', data),
}
diff --git a/frontend/src/views/admin/Links.vue b/frontend/src/views/admin/Links.vue
index 1496cd5..5b1d42a 100644
--- a/frontend/src/views/admin/Links.vue
+++ b/frontend/src/views/admin/Links.vue
@@ -23,7 +23,17 @@